Skip to content

Commit

Permalink
Add enabled payment methods field to extension settings page (#2)
Browse files Browse the repository at this point in the history
onurpolattimur authored Mar 27, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent d058732 commit bf2aba4
Showing 5 changed files with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ class ControllerExtensionPaymentCraftgatePaymentGateway extends Controller
array('name' => 'payment_craftgate_payment_gateway_sandbox_api_key', 'rules' => 'required'),
array('name' => 'payment_craftgate_payment_gateway_sandbox_secret_key', 'rules' => 'required'),
array('name' => 'payment_craftgate_payment_gateway_sandbox_mode', 'rules' => ''),
array('name' => 'payment_craftgate_payment_gateway_enabled_payment_methods', 'rules' => ''),
array('name' => 'payment_craftgate_payment_gateway_order_status_id', 'rules' => ''),
array('name' => 'payment_craftgate_payment_gateway_sort_order', 'rules' => ''),
);
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
// Heading
$_['heading_title'] = 'Craftgate Payment Gateway';

// Text
// Text
$_['text_success'] = 'Craftgate Gateway Settings Updated';
$_['text_payment'] = 'Payment';
$_['text_craftgate_payment_gateway'] = '<a href="https://craftgate.io/" target="_blank"><img src="view/image/payment/craftgate.png" alt="Craftgate Gateway" title="Craftgate Gateway"/></a>';
@@ -19,6 +19,7 @@
$_['text_sandbox_api_key_help'] = 'Enter your Sandbox API Key.';
$_['text_sandbox_secret_key_help'] = 'Enter your Sandbox Secret Key.';
$_['text_sandbox_mode_help'] = 'Enable test mode using sandbox API keys.';
$_['text_enabled_payment_methods_help'] = 'Payment methods to be displayed on the Payment Form. All available payment methods are shown when this field is empty.</br>Example: CARD, SODEXO</br>For details: <a target="_blank" href="https://developer.craftgate.io">Craftgate Developer Portal</a>';
$_['text_order_status_help'] = 'Status of order after payment completed ';
$_['text_order_help'] = 'Method order in checkout page.';

@@ -30,6 +31,7 @@
$_['entry_sandbox_api_key'] = 'Sandbox API Key';
$_['entry_sandbox_secret_key'] = 'Sandbox Secret Key';
$_['entry_sandbox_mode'] = 'Sandbox Mode';
$_['entry_enabled_payment_methods'] = 'Enabled Payment Methods';
$_['error_required'] = 'This field is required.';
$_['entry_order_status'] = 'Order Status';
$_['entry_cancel_order_status'] = "Cancel Order Status";
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
$_['text_sandbox_api_key_help'] = 'Sandbox API Key’inizi giriniz.';
$_['text_sandbox_secret_key_help'] = 'Sandbox Secret Key’inizi giriniz.';
$_['text_sandbox_mode_help'] = 'Sandbox API bilgilerinizi kullanarak test modunu aktif edebilirsiniz.';
$_['text_enabled_payment_methods_help'] = 'Ortak ödeme sayfasında görünmesi istenen ödeme yöntemleri. Hiç gönderilmediğinde mevcuttaki tüm ödeme yöntemleri listelenir. <br> Örnek: CARD, SODEXO</br>Detaylar için <a target="_blank" href="https://developer.craftgate.io">Craftgate Developer Portal</a> ';
$_['text_order_status_help'] = 'Ödeme tamamlandıktan sonra siparişin durumu.';
$_['text_order_help'] = 'Ödeme sayfasındaki sıralaması.';

@@ -30,6 +31,7 @@
$_['entry_sandbox_api_key'] = 'Sandbox API Key';
$_['entry_sandbox_secret_key'] = 'Sandbox Secret Key';
$_['entry_sandbox_mode'] = 'Sandbox Modu';
$_['entry_enabled_payment_methods'] = 'Kullanılabilir Ödeme Yöntemleri';
$_['error_required'] = 'Bu alanın doldurulması zorunludur.';
$_['entry_order_status'] = 'Sipariş Durumu';
$_['entry_sort_order'] = 'Sıra No';
Original file line number Diff line number Diff line change
@@ -124,6 +124,20 @@
</div>
</div>

<div class="form-group">
<label class="col-sm-2 control-label"
for="payment_craftgate_payment_gateway_enabled_payment_methods"> {{ entry_enabled_payment_methods }}</label>
<div class="col-sm-10">
<input type="text" name="payment_craftgate_payment_gateway_enabled_payment_methods"
value="{{ payment_craftgate_payment_gateway_enabled_payment_methods }}"
class="form-control"/>
{% if error_payment_craftgate_payment_gateway_enabled_payment_methods %}
<span class="text-danger">{{ error_payment_craftgate_payment_gateway_enabled_payment_methods }}</span>
{% endif %}
<p class="description">{{text_enabled_payment_methods_help}}</p>
</div>
</div>

<div class="form-group">
<label class="col-sm-2 control-label" for="payment_craftgate_payment_gateway_order_status_id">
{{ entry_order_status }}
Original file line number Diff line number Diff line change
@@ -78,6 +78,17 @@ private function initCraftgateClient()

}

private function retrieveEnabledPaymentMethods()
{
$this->load->model('extension/payment/craftgate_payment_gateway');
$enabledPaymentMethods = $this->config->get('payment_craftgate_payment_gateway_enabled_payment_methods');
if (empty($enabledPaymentMethods)) {
return null;
}
return array_map('trim', explode(',', $enabledPaymentMethods));

}

private function validateCallbackParams()
{
$order_id = $this->request->get["order_id"];
@@ -122,6 +133,7 @@ private function buildInitCheckoutFormRequest()
'paymentGroup' => 'LISTING_OR_SUBSCRIPTION',
'conversationId' => $order_id,
'callbackUrl' => $this->getSiteUrl() . 'index.php?route=extension/payment/craftgate_payment_gateway/callback&order_id=' . $order_id,
'enabledPaymentMethods' => $this->retrieveEnabledPaymentMethods(),
'items' => $items,
);
}
@@ -174,7 +186,7 @@ private function calculateTotalProductPrice($items)

private function formatPrice($number)
{
return round((float) $number, 2);
return round((float)$number, 2);
}

private function getShippingInfo()
@@ -252,10 +264,10 @@ private static function isHttps()
{
static $ret;

isset($ret) || $ret =@ (
isset($ret) || $ret = @ (
$_SERVER['REQUEST_SCHEME'] == 'https' ||
$_SERVER['SERVER_PORT'] == '443' ||
$_SERVER['HTTPS'] == 'on'
$_SERVER['SERVER_PORT'] == '443' ||
$_SERVER['HTTPS'] == 'on'
);

return $ret;

0 comments on commit bf2aba4

Please sign in to comment.