Skip to content

Commit

Permalink
4.1.7
Browse files Browse the repository at this point in the history
- Added "Use Base Currency" which allows end-users to initiate payments using selected currency instead of base shop currency
  • Loading branch information
andys2p committed Jun 25, 2021
1 parent 519d486 commit 75efe3f
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 17 deletions.
13 changes: 8 additions & 5 deletions Block/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,14 @@ protected function _prepareSpecificInformation($transport = null)
$method_arr = [];
}

$this->setDataToTransfer(
$transport,
__('Payment Method'),
$method_arr['display_name'].(!$is_in_frontend?' (#'.$method_arr['method_id'].')':'')
);
if (!empty($method_arr)) {
$this->setDataToTransfer(
$transport,
__('Payment Method'),
$method_arr['display_name'].
(!$is_in_frontend?' (#'.$method_arr['method_id'].')':'')
);
}

if (!$is_in_frontend) {
$this->setDataToTransfer(
Expand Down
25 changes: 18 additions & 7 deletions Controller/Payment/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,24 @@ public function execute()

case \S2P_SDK\S2P_SDK_Meth_Payments::STATUS_SUCCESS:
case \S2P_SDK\S2P_SDK_Meth_Payments::STATUS_CAPTURED:
$orderAmount = number_format(
$order->getBaseGrandTotal(),
2,
'.',
''
) * 100;
$orderCurrency = $order->getBaseCurrency()->getCurrencyCode();

if (!empty($config_arr['use_base_currency'])) {
$orderAmount = number_format(
$order->getBaseGrandTotal(),
2,
'.',
''
) * 100;
$orderCurrency = $order->getBaseCurrency()->getCurrencyCode();
} else {
$orderAmount = number_format(
$order->getGrandTotal(),
2,
'.',
''
) * 100;
$orderCurrency = $order->getOrderCurrency()->getCurrencyCode();
}

if ((string)$orderAmount !== (string)$payment_arr['amount']
|| (string)$orderCurrency !== (string)$payment_arr['currency']) {
Expand Down
18 changes: 15 additions & 3 deletions Gateway/Request/CaptureRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,18 @@ public function build(array $buildSubject)

$total_surcharge_amount = $surcharge_amount + $surcharge_fixed_amount;

$order_original_amount = $amount_to_pay = $quote->getBaseGrandTotal();
if (!empty($config_arr['use_base_currency'])) {
$order_original_amount = $amount_to_pay = $quote->getBaseGrandTotal();
} else {
$order_original_amount = $amount_to_pay = $quote->getGrandTotal();
}

$articles_params = [];
$articles_params['transport_amount'] = $quote->getShippingAddress()->getBaseShippingAmount();
if (!empty($config_arr['use_base_currency'])) {
$articles_params['transport_amount'] = $quote->getShippingAddress()->getBaseShippingAmount();
} else {
$articles_params['transport_amount'] = $quote->getShippingAddress()->getShippingAmount();
}
$articles_params['total_surcharge'] = $total_surcharge_amount;
$articles_params['amount_to_pay'] = $amount_to_pay;

Expand Down Expand Up @@ -173,7 +181,11 @@ public function build(array $buildSubject)
}
}

$currency = $quote->getCurrency()->getBaseCurrencyCode();
if (!empty($config_arr['use_base_currency'])) {
$currency = $quote->getCurrency()->getBaseCurrencyCode();
} else {
$currency = $quote->getCurrency()->getQuoteCurrencyCode();
}

//
// SDK functionality
Expand Down
1 change: 1 addition & 0 deletions Helper/S2pHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ public function getFullConfigArray($force = false, $storeId = null)
'auto_invoice' => 0,
'auto_ship' => 0,
'use_3dsecure' => 0,
'use_base_currency' => 1,
'order_status' => 'pending',
'order_status_on_2' => 'processing',
'order_status_on_3' => 'canceled',
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "smart2pay/magento2",
"description": "Use Smart2Pay module to have access to 200+ payment methods.",
"type": "magento2-module",
"version": "4.1.6",
"version": "4.1.7",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
6 changes: 6 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@
<config_path>payment/smart2pay/auto_ship</config_path>
</field>
-->
<field id="use_base_currency" translate="label" type="select" sortOrder="12" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Use Base Currency</label>
<comment><![CDATA[Yes: Initiate payments in base currency. No: Initiate payments in current selected currency.]]></comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/smart2pay/use_base_currency</config_path>
</field>
<field id="use_3dsecure" translate="label" type="select" sortOrder="15" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Use 3DSecure</label>
<comment><![CDATA[Use 3DSecure for SmartCards payment method.]]></comment>
Expand Down
1 change: 1 addition & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@

<auto_invoice>0</auto_invoice>
<auto_ship>0</auto_ship>
<use_base_currency>1</use_base_currency>
<use_3dsecure>0</use_3dsecure>
<order_status>pending</order_status>
<order_status_on_2>processing</order_status_on_2>
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Smart2Pay_GlobalPay" setup_version="4.1.6">
<module name="Smart2Pay_GlobalPay" setup_version="4.1.7">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Quote"/>
Expand Down

0 comments on commit 75efe3f

Please sign in to comment.