diff --git a/README.md b/README.md
index 313178a..199b57c 100755
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ execute below command in your magento installation directory
`composer require amazonpaymentservices/module-fort`
## Configuration and User Guide
-You can download the archive [file](/magento2-aps-2.5.0.zip) of the plugin and install it to Magento. Detailed guide is included in the repository [here](/Magento%20Extension%20User%20Guide_v1.1.pdf).
+You can download the archive [file](/magento2-aps-2.6.0.zip) of the plugin and install it to Magento. Detailed guide is included in the repository [here](/Magento%20Extension%20User%20Guide_v1.1.pdf).
## Payment Options
@@ -35,13 +35,19 @@ You can download the archive [file](/magento2-aps-2.5.0.zip) of the plugin and i
* KNET
* NAPS
* Apple Pay
+ * STCPay
+ * Tabby
+ * OmanNet
+ * Benefit
## Changelog
| Plugin Version | Release Notes |
| :---: | :--- |
-| 2.5.0 | * New - Tabby is added as a new payment option
* Fix - StcPay reference field index is added |
+| 2.6.0 | * New - Benefit and OmanNet are added as a new payment options |
+| 2.5.1 | * Fix - Webhook Handling
* Fix - Cron check status to consider Success scenarios
* Fix - Response handling to consider order cancellation only if order state is in list of failure or pending to avoid cancelling success cases.
* Fix - ApplePay discount values fix|
+| 2.5.0 | * New - Tabby is added as a new payment option |
| 2.4.9 | * Fix - SameSite cookie handling
* Fix - ApplePay is now enabled with Magento payment option checkbox
* Fix - Refund considers Base/Front currencies
* Fix - STCPay to use order id which is enabled via configuration
* Fix - PHP8.2 Compatibility changes|
| 2.4.8 | * Fix - jQuery deprecated size() function is replaced with length |
| 2.4.7 | * Fix - Shipping tax is considered for the refund calculation
* Fix - ApplePay url validation is added
* Fix - item id is considered during subscription product cancellation|
diff --git a/magento2-aps-2.4.9.zip b/magento2-aps-2.4.9.zip
deleted file mode 100644
index 087bfa3..0000000
Binary files a/magento2-aps-2.4.9.zip and /dev/null differ
diff --git a/magento2-aps-2.5.0.zip b/magento2-aps-2.6.0.zip
similarity index 64%
rename from magento2-aps-2.5.0.zip
rename to magento2-aps-2.6.0.zip
index daa24e2..e17ffb8 100644
Binary files a/magento2-aps-2.5.0.zip and b/magento2-aps-2.6.0.zip differ
diff --git a/magento2-aps/Amazonpaymentservices/Fort/Block/Adminhtml/Order/View/View.php b/magento2-aps/Amazonpaymentservices/Fort/Block/Adminhtml/Order/View/View.php
index 6c0f1b6..74c1187 100755
--- a/magento2-aps/Amazonpaymentservices/Fort/Block/Adminhtml/Order/View/View.php
+++ b/magento2-aps/Amazonpaymentservices/Fort/Block/Adminhtml/Order/View/View.php
@@ -15,8 +15,10 @@ class View extends \Magento\Backend\Block\Template
\Amazonpaymentservices\Fort\Model\Method\Apple::CODE,
\Amazonpaymentservices\Fort\Model\Method\Installment::CODE,
\Amazonpaymentservices\Fort\Model\Method\Valu::CODE,
+ \Amazonpaymentservices\Fort\Model\Method\OmanNet::CODE,
\Amazonpaymentservices\Fort\Model\Method\VisaCheckout::CODE,
\Amazonpaymentservices\Fort\Model\Method\Stc::CODE,
+ \Amazonpaymentservices\Fort\Model\Method\Benefit::CODE,
\Amazonpaymentservices\Fort\Model\Method\Tabby::CODE
];
diff --git a/magento2-aps/Amazonpaymentservices/Fort/Block/Payment/Redirect.php b/magento2-aps/Amazonpaymentservices/Fort/Block/Payment/Redirect.php
index 442f5c1..b263e77 100755
--- a/magento2-aps/Amazonpaymentservices/Fort/Block/Payment/Redirect.php
+++ b/magento2-aps/Amazonpaymentservices/Fort/Block/Payment/Redirect.php
@@ -59,6 +59,7 @@ public function __construct(
$this->_orderConfig = $orderConfig;
$this->httpContext = $httpContext;
$this->_helper = $helperFort;
+ $this->_isScopePrivate = true;
}
/**
@@ -96,6 +97,11 @@ protected function prepareBlockData()
$form_data = '';
$form_url = '';
$arrPaymentPageData = [];
+ $this->_helper->log('Redirect 2');
+ $this->_helper->log(json_encode($order));
+ $this->_helper->log($order_is_ok);
+ $this->_helper->log($order->getState());
+ $this->_helper->log($order_error_message);
if ($order_is_ok) {
$helper = $this->_helper;
$paymentMethod= $order->getPayment()->getMethod();
diff --git a/magento2-aps/Amazonpaymentservices/Fort/Block/Success.php b/magento2-aps/Amazonpaymentservices/Fort/Block/Success.php
index 14e6436..515a2c1 100755
--- a/magento2-aps/Amazonpaymentservices/Fort/Block/Success.php
+++ b/magento2-aps/Amazonpaymentservices/Fort/Block/Success.php
@@ -22,12 +22,13 @@ public function __construct(
$this->_checkoutSession = $checkoutSession;
$this->_orderConfig = $orderConfig;
$this->httpContext = $httpContext;
-
+ $this->_isScopePrivate = true;
parent::__construct($context, $checkoutSession, $orderConfig, $httpContext, $data);
$this->pricingHelper = $pricingHelper;
$this->checkoutHelper = $checkoutHelper;
$this->order = $this->_checkoutSession->getLastRealOrder();
+ $this->_isScopePrivate = true;
}
public function getBaseGrandTotal()
@@ -49,6 +50,11 @@ public function isKnetPaymentMethod()
return $this->getMethod() == "aps_knet";
}
+ public function isOmanNetPaymentMethod()
+ {
+ return $this->getMethod() == "aps_omannet";
+ }
+
public function isValuPaymentMethod()
{
return $this->getMethod() == "aps_fort_valu";
@@ -70,10 +76,31 @@ public function getValuParmeters()
return $valuData;
}
+ public function getOmanNetParmeters()
+ {
+ $payment = $this->order->getPayment();
+ $data = $payment->getAdditionalData();
+ $OmanNetData = json_decode($data, true);
+ return $OmanNetData;
+ }
+
public function getOrderNumber()
{
return $this->order->getIncrementId();
}
+
+ public function isBenefitPaymentMethod()
+ {
+ return $this->getMethod() == "aps_benefit";
+ }
+
+ public function getBenefitParmeters()
+ {
+ $payment = $this->order->getPayment();
+ $data = $payment->getAdditionalData();
+ $benefitData = json_decode($data, true);
+ return $benefitData;
+ }
public function getCacheLifetime()
{
return null;
diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/AppleValidateAddress.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/AppleValidateAddress.php
index 63163dd..b43179b 100755
--- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/AppleValidateAddress.php
+++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/AppleValidateAddress.php
@@ -142,6 +142,7 @@ public function execute()
{
$responseParams = $this->getRequest()->getParams();
$addressData = $responseParams['addressObject'];
+ $countryCode = null;
$this->_helper->log('Apple Address:'.json_encode($addressData));
$result = [];
@@ -150,6 +151,7 @@ public function execute()
$countryCode = explode(',', $countryCode);
$this->_helper->log('Apple Config: Country');
if (in_array($addressData['countryCode'], $countryCode)) {
+ $countryCode = $addressData['countryCode'];
$result = $this->getShippingRates($addressData);
} else {
$dataArr['error_msg'] = __('Country not allowed for shipping');
@@ -159,11 +161,25 @@ public function execute()
}
$quote = $this->_cart->getQuote();
+ if($countryCode) {
+ $quote->getShippingAddress()->setRegionCode($countryCode);
+ }
+ if(isset($addressData['postalCode'])) {
+ $quote->getShippingAddress()->setPostcode($addressData['postalCode']);
+ }
+
if(!empty($result[0]['id'])) {
$quote->getShippingAddress()->setShippingMethod($result[0]['id']);
$quote->save();
}
$quote = $this->_cart->getQuote();
+
+ $quote->getShippingAddress()->setCountryId($addressData['countryCode']);
+ $quote->save();
+ $quote = $this->_cart->getQuote();
+ $quote->setTotalsCollectedFlag(false);
+ $quote->collectTotals();
+
$dataArr['taxes'] = $quote->getShippingAddress()->getData('tax_amount');
$dataArr['taxes'] = str_replace(",", "", $dataArr['taxes']);
diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetInstallmentPlans.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetInstallmentPlans.php
index 25fda26..c7358f7 100755
--- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetInstallmentPlans.php
+++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetInstallmentPlans.php
@@ -99,10 +99,31 @@ public function validateForCsrf(RequestInterface $request): ?bool
public function execute()
{
$responseParams = $this->getRequest()->getParams();
- $arrPaymentPageData = $this->_helper->getInstallmentPlan();
+ //$arrPaymentPageData = $this->_helper->getInstallmentPlan();
+ $arrPaymentPageData = [];
$installmentData = [];
- $cardNumber = '';
+ $cardNumberOrToken = '';
+
if (!empty($responseParams['cardNumber'])) {
+ $cardNumberOrToken = $responseParams['cardNumber'];
+ $arrPaymentPageData = $this->_helper->getInstallmentPlan($cardNumberOrToken,\Amazonpaymentservices\Fort\Helper\Data::INSTALLMENTS_PLAN_CARD);
+ } elseif (!empty($responseParams['vaultSelected'])) {
+ $customerId = $this->_customerSession->getCustomer()->getId();
+ $tokenData = $this->_paymentToken->getByPublicHash($responseParams['vaultSelected'], $customerId);
+ $tokenName = '';
+ if (!empty($tokenData)) {
+ $details = json_decode($tokenData['details'], 1);
+ $this->_helper->log("Token details");
+ $this->_helper->log($details);
+ $cardNumberOrToken = substr($details['maskedCC'], 0, 6);
+ $arrPaymentPageData = $this->_helper->getInstallmentPlan($cardNumberOrToken,\Amazonpaymentservices\Fort\Helper\Data::INSTALLMENTS_PLAN_TOKEN);
+ }
+ } else{
+ $arrPaymentPageData = $this->_helper->getInstallmentPlan();
+ }
+ $installmentData = $this->installmentData($arrPaymentPageData, $cardNumberOrToken);
+
+ /*if (!empty($responseParams['cardNumber'])) {
$cardNumber = $responseParams['cardNumber'];
$installmentData = $this->installmentData($arrPaymentPageData, $responseParams['cardNumber']);
} elseif (!empty($responseParams['vaultSelected'])) {
@@ -111,10 +132,11 @@ public function execute()
$tokenName = '';
if (!empty($tokenData)) {
$details = json_decode($tokenData['details'], 1);
+
$cardNumber = substr($details['maskedCC'], 0, 6);
$installmentData = $this->installmentData($arrPaymentPageData, $cardNumber);
}
- }
+ }*/
$responseData = [];
if (isset($installmentData['success']) && $installmentData['success'] === true) {
$responseData = $this->getInstallmentHandler($installmentData);
diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/Response.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/Response.php
index 4118397..b903fd1 100755
--- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/Response.php
+++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/Response.php
@@ -50,6 +50,10 @@ public function execute()
$integrationType = $helper->getConfig('payment/aps_apple/integration_type');
} elseif ($paymentMethod == $helper::PAYMENT_METHOD_VISACHECKOUT) {
$integrationType = $helper->getConfig('payment/aps_fort_visaco/integration_type');
+ } elseif ($paymentMethod == $helper::PAYMENT_METHOD_OMANNET) {
+ $integrationType = $helper->getConfig('payment/aps_omannet/integration_type');
+ } elseif ($paymentMethod == $helper::PAYMENT_METHOD_BENEFIT) {
+ $integrationType = $helper->getConfig('payment/aps_benefit/integration_type');
}
$success = $helper->handleFortResponse($responseParams, 'offline', $integrationType);
diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/Webhook.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/Webhook.php
index 7f07b20..404a290 100755
--- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/Webhook.php
+++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/Webhook.php
@@ -92,7 +92,7 @@ public function execute()
$this->_helper->captureAuthorize($responseParams);
} elseif ($responseCode == \Amazonpaymentservices\Fort\Helper\Data::PAYMENT_METHOD_REFUND_STATUS) {
$this->_helper->refundAps($responseParams);
- } elseif ($responseCode == \Amazonpaymentservices\Fort\Helper\Data::PAYMENT_METHOD_AUTH_SUCCESS_STATUS || $responseCode == \Amazonpaymentservices\Fort\Helper\Data::PAYMENT_METHOD_PURCHASE_SUCCESS_STATUS) {
+ } else{
$this->_helper->handleFortResponse($responseParams, 'offline');
}
$result = [];
diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Product/AddProductToCart.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Product/AddProductToCart.php
index 0009d79..209881c 100755
--- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Product/AddProductToCart.php
+++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Product/AddProductToCart.php
@@ -196,9 +196,8 @@ public function execute()
foreach ($quote->getAllItems() as $item) {
$data['data']['totalPrice'] += $item->getRowTotal();
-
}
-
+ $data['data']['totalPriceUnformatted'] = (string)$data['data']['totalPrice'];
$data['data']['totalPrice'] =
$this->modelCurrency->format(
$data['data']['totalPrice'],
@@ -209,8 +208,11 @@ public function execute()
);
$data['data']['totalPrice'] = str_replace(",", "", $data['data']['totalPrice']);
$data['data']['shippingAmount'] = 0;
+ $data['data']['shippingAmountUnformatted'] = (string)$data['data']['shippingAmount'];
$data['data']['totalTax'] = 0;
+ $data['data']['totalTaxUnformatted'] = (string)$data['data']['totalTax'];
$data['data']['discountAmount'] = $quote->getSubtotal() - $quote->getSubtotalWithDiscount();
+ $data['data']['discountAmountUnformatted'] = (string)$data['data']['discountAmount'];
$data['data']['discountAmount'] =
$this->modelCurrency->format(
$data['data']['discountAmount'],
@@ -222,6 +224,7 @@ public function execute()
$data['data']['discountAmount'] = str_replace(",", "", $data['data']['discountAmount']);
$data['data']['total'] = $quote->getGrandTotal();
+ $data['data']['totalUnformatted'] = (string)$data['data']['total'];
$data['data']['total'] =
$this->modelCurrency->format(
$data['data']['total'],
@@ -230,6 +233,7 @@ public function execute()
],
false
);
+
$data['data']['total'] = str_replace(",", "", $data['data']['total']);
$data['status'] = 'success';
diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Product/GetQuoteData.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Product/GetQuoteData.php
index 3cfe4d8..c8b80db 100755
--- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Product/GetQuoteData.php
+++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Product/GetQuoteData.php
@@ -95,8 +95,9 @@ public function execute()
$data['data']['totalPrice'] = 0;
foreach ($quote->getAllItems() as $item) {
$data['data']['totalPrice'] += $item->getRowTotal();
-
}
+
+ $data['data']['totalPriceUnformatted'] = (string)$data['data']['totalPrice'];
$data['data']['totalPrice'] =
$this->modelCurrency->format(
$data['data']['totalPrice'],
@@ -107,8 +108,11 @@ public function execute()
);
$data['data']['totalPrice'] = str_replace(",", "", $data['data']['totalPrice']);
$data['data']['shippingAmount'] = 0;
+ $data['data']['shippingAmountUnformatted'] = (string)$data['data']['shippingAmount'];
$data['data']['totalTax'] = 0;
+ $data['data']['totalTaxUnformatted'] = (string)$data['data']['totalTax'];
$data['data']['discountAmount'] = $quote->getSubtotal() - $quote->getSubtotalWithDiscount();
+ $data['data']['discountAmountUnformatted'] = (string)$data['data']['discountAmount'];
$data['data']['discountAmount'] =
$this->modelCurrency->format(
$data['data']['discountAmount'],
@@ -120,6 +124,7 @@ public function execute()
$data['data']['discountAmount'] = str_replace(",", "", $data['data']['discountAmount']);
$data['data']['total'] = $quote->getGrandTotal();
+ $data['data']['totalUnformatted'] = (string)$data['data']['total'];
$data['data']['total'] =
$this->modelCurrency->format(
$data['data']['total'],
diff --git a/magento2-aps/Amazonpaymentservices/Fort/Cron/Paymentstatus.php b/magento2-aps/Amazonpaymentservices/Fort/Cron/Paymentstatus.php
index 7da9137..cad13a3 100755
--- a/magento2-aps/Amazonpaymentservices/Fort/Cron/Paymentstatus.php
+++ b/magento2-aps/Amazonpaymentservices/Fort/Cron/Paymentstatus.php
@@ -20,7 +20,9 @@ class Paymentstatus
\Amazonpaymentservices\Fort\Model\Method\Apple::CODE,
\Amazonpaymentservices\Fort\Model\Method\Installment::CODE,
\Amazonpaymentservices\Fort\Model\Method\Valu::CODE,
- \Amazonpaymentservices\Fort\Model\Method\VisaCheckout::CODE
+ \Amazonpaymentservices\Fort\Model\Method\VisaCheckout::CODE,
+ \Amazonpaymentservices\Fort\Model\Method\OmanNet::CODE,
+ \Amazonpaymentservices\Fort\Model\Method\Benefit::CODE
];
public function __construct(
@@ -68,20 +70,27 @@ private function Orderupdate($order)
$response = $this->_helper->checkOrderStatus($orderId, $paymentMethod);
$this->_logger->debug('APS CHECK_VERIFY_CARD_STATUS Response : '.json_encode($response));
- if (!empty($response['response_code']) && $response['response_code'] === '12000') {
+ if (
+ ($response['response_code'] ?? '') === '12000'
+ || ($response['transaction_code'] ?? '') === \Amazonpaymentservices\Fort\Helper\Data::PAYMENT_METHOD_AUTH_SUCCESS_STATUS
+ || ($response['transaction_code'] ?? '') === \Amazonpaymentservices\Fort\Helper\Data::PAYMENT_METHOD_PURCHASE_SUCCESS_STATUS
+ ) {
+ $this->_helper->log('process order 2');
+ $this->_helper->handleSendingInvoice($order, $response);
+
$order->setState($order::STATE_PROCESSING)->save();
$order->setStatus($order::STATE_PROCESSING)->save();
$order->addStatusToHistory($order::STATE_PROCESSING, 'APS :: Order status changed.', true);
$order->save();
$this->_logger->debug('APS order status changed '.$order->getId());
- } else {
+ } elseif ($this->_helper->canCancelOrder($order)) {
$order->setState($order::STATE_CANCELED)->save();
$order->setStatus($order::STATE_CANCELED)->save();
-
- $order->addStatusToHistory($order::STATE_CANCELED, 'APS :: Order status changed.', true);
+
+ $order->addStatusToHistory($order::STATE_CANCELED, 'APS :: Order status changed. Cancelled because of unrecognized response code.', true);
$order->save();
- $this->_logger->debug('APS order status changed '.$order->getId());
+ $this->_logger->debug('APS order status changed '.$order->getId() . '. Cancelled because of unrecognized response code.');
}
}
}
diff --git a/magento2-aps/Amazonpaymentservices/Fort/Helper/Data.php b/magento2-aps/Amazonpaymentservices/Fort/Helper/Data.php
index 99c92aa..4c32f1d 100755
--- a/magento2-aps/Amazonpaymentservices/Fort/Helper/Data.php
+++ b/magento2-aps/Amazonpaymentservices/Fort/Helper/Data.php
@@ -209,6 +209,7 @@ class Data extends \Magento\Payment\Helper\Data
const PAYMENT_METHOD_VAULT = 'aps_fort_vault';
const PAYMENT_METHOD_NAPS = 'aps_fort_naps';
const PAYMENT_METHOD_KNET = 'aps_knet';
+ const PAYMENT_METHOD_OMANNET = 'aps_omannet';
const PAYMENT_METHOD_APPLE = 'aps_apple';
const PAYMENT_METHOD_INSTALLMENT = 'aps_installment';
const PAYMENT_METHOD_VALU = 'aps_fort_valu';
@@ -222,6 +223,10 @@ class Data extends \Magento\Payment\Helper\Data
const PAYMENT_METHOD_REFUND_STATUS = '06000';
const PAYMENT_METHOD_PURCHASE_SUCCESS_STATUS = '14000';
const PAYMENT_METHOD_AUTH_SUCCESS_STATUS = '02000';
+ const PAYMENT_TRANSACTION_DECLINED = '13666';
+ const INSTALLMENTS_PLAN_CARD = 'BIN';
+ const INSTALLMENTS_PLAN_TOKEN = 'TOKEN';
+ const PAYMENT_METHOD_BENEFIT = 'aps_benefit';
const PAYMENT_METHOD = [
\Amazonpaymentservices\Fort\Model\Method\Vault::CODE,
@@ -233,6 +238,8 @@ class Data extends \Magento\Payment\Helper\Data
\Amazonpaymentservices\Fort\Model\Method\Valu::CODE,
\Amazonpaymentservices\Fort\Model\Method\VisaCheckout::CODE,
\Amazonpaymentservices\Fort\Model\Method\Stc::CODE,
+ \Amazonpaymentservices\Fort\Model\Method\OmanNet::CODE,
+ \Amazonpaymentservices\Fort\Model\Method\Benefit::CODE,
\Amazonpaymentservices\Fort\Model\Method\Tabby::CODE
];
@@ -506,11 +513,17 @@ private function setPaymentMethodParams($paymentMethod, $orderId)
} elseif ($paymentMethod == self::PAYMENT_METHOD_KNET) {
$this->_gatewayParams['payment_option'] = 'KNET';
$this->_gatewayParams['command'] = \Amazonpaymentservices\Fort\Model\Config\Source\Commandoptions::PURCHASE;
+ } elseif ($paymentMethod == self::PAYMENT_METHOD_OMANNET) {
+ $this->_gatewayParams['payment_option'] = 'OMANNET';
+ $this->_gatewayParams['command'] = \Amazonpaymentservices\Fort\Model\Config\Source\Commandoptions::PURCHASE;
} elseif ($paymentMethod == self::PAYMENT_METHOD_VALU) {
$this->_gatewayParams['payment_option'] = 'VALU';
$this->_gatewayParams['order_description'] = $orderId;
} elseif ($paymentMethod == self::PAYMENT_METHOD_VISACHECKOUT) {
$this->_gatewayParams['digital_wallet'] = 'VISA_CHECKOUT';
+ } elseif ($paymentMethod == self::PAYMENT_METHOD_BENEFIT) {
+ $this->_gatewayParams['payment_option'] = 'BENEFIT';
+ $this->_gatewayParams['command'] = \Amazonpaymentservices\Fort\Model\Config\Source\Commandoptions::PURCHASE;
}
}
@@ -1023,7 +1036,7 @@ public function getInstallmentRequestParams($order, $integrationType)
return ['url' => $gatewayUrl, 'params' => $gatewayParams];
}
- public function getInstallmentPlan()
+ public function getInstallmentPlan($cardNumberOrToken, $binOrTokenFlag)
{
$language = $this->getLanguage();
@@ -1039,6 +1052,16 @@ public function getInstallmentPlan()
$amount = $this->convertFortAmountCart($currency);
$gatewayParams['currency'] = strtoupper($currency);
$gatewayParams['amount'] = $amount;
+ switch ($binOrTokenFlag) {
+ case self::INSTALLMENTS_PLAN_CARD:
+ $gatewayParams['card_bin'] = $cardNumberOrToken;
+ break;
+ case self::INSTALLMENTS_PLAN_CARD:
+ $gatewayParams['token'] = $cardNumberOrToken;
+ break;
+ default:
+ break;
+ }
$signature = $this->calculateSignature($gatewayParams, 'request');
$gatewayParams['signature'] = $signature;
@@ -1818,7 +1841,7 @@ public function cancelOrder($order, $comment)
public function orderFailed($order, $reason, $responseCode = '')
{
- if ($order->getState() != $order::STATE_PROCESSING) {
+ if ($this->canCancelOrder($order)) {
if (in_array($responseCode, self::APS_ONHOLD_RESPONSE_CODES, true)) {
if ($order->getState() != $order::STATE_HOLDED) {
$order->setStatus($order::STATE_HOLDED);
@@ -1844,6 +1867,7 @@ public function orderFailed($order, $reason, $responseCode = '')
public function applePayResponse($responseParams)
{
+ //timestamp here
$order = $this->_checkoutSession->getLastRealOrder();
if (!empty($order->getRealOrderId())) {
$orderId = $order->getRealOrderId();
@@ -1883,9 +1907,12 @@ public function applePayResponse($responseParams)
$data['signature'] = $this->calculateSignature($data, 'request', "apple_pay");
$gatewayUrl = $this->getGatewayUrl('notificationApi');
+ //timestamp here
$result = $this->callApi($data, $gatewayUrl);
+ //timestamp here
$integrationType = \Amazonpaymentservices\Fort\Model\Config\Source\Integrationtypeoptions::HOSTED;
$success = $this->handleFortResponse($result, 'online', $integrationType, 'h2h');
+ //timestamp here
return ['success' => $success, 'order' => $order];
}
@@ -2097,6 +2124,9 @@ public function checkOrderStatus($orderId, $paymentMethod = '')
public function processOrder($order, $responseParams)
{
$this->log('process order');
+ if ($order->getState() == $order::STATE_COMPLETE) {
+ return false;
+ }
if ($order->getState() != $order::STATE_PROCESSING) {
$this->log('process order1');
$payment = $order->getPayment();
@@ -2138,28 +2168,7 @@ public function processOrder($order, $responseParams)
$order->save();
$this->log('process order2');
$paymentMethod = $order->getPayment()->getMethod();
- if ($paymentMethod != \Amazonpaymentservices\Fort\Model\Method\Stc::CODE && !empty($responseParams['token_name']) && !empty($order->getCustomerId()) && $this->getConfig('payment/aps_fort_vault/active') == '1') {
- $this->log('process order3');
- $this->log('process order4');
- $year = substr($responseParams['expiry_date'], 0, 2);
- $month = substr($responseParams['expiry_date'], 2, 4);
- $paymentMethodCode = Payment::CODE;
-
- $hashKey = $responseParams['token_name'];
- if ($order->getCustomerId()) {
- $hashKey = $order->getCustomerId();
- }
- $hashKey .= $paymentMethodCode
- . 'card'
- . '{"type":"'.$responseParams['payment_option'].'","maskedCC":"'.$responseParams['card_number'].'","expirationDate":"'.$year."\/".$month.'","orderId":"'.$responseParams['merchant_reference'].'"}';
-
- $publicHash = $this->_encryptorInterface->getHash($hashKey);
-
- $tokenobjectManagerDuplicate = $this->_paymentToken->getByGatewayToken($responseParams['token_name'], $paymentMethodCode, $order->getCustomerId());
- $this->log('process order5');
- $this->saveTokenisation($tokenobjectManagerDuplicate, $order, $publicHash, $paymentMethodCode, $responseParams, $year, $month);
- }
- if ($paymentMethod != \Amazonpaymentservices\Fort\Model\Method\Tabby::CODE && !empty($responseParams['token_name']) && !empty($order->getCustomerId()) && $this->getConfig('payment/aps_fort_vault/active') == '1') {
+ if (( $paymentMethod != \Amazonpaymentservices\Fort\Model\Method\Tabby::CODE || $paymentMethod != \Amazonpaymentservices\Fort\Model\Method\Stc::CODE ) && !empty($responseParams['token_name']) && !empty($order->getCustomerId()) && $this->getConfig('payment/aps_fort_vault/active') == '1') {
$this->log('process order3');
$this->log('process order4');
$year = substr($responseParams['expiry_date'], 0, 2);
@@ -2379,15 +2388,24 @@ private function getOrderId($responseParams)
$orderId = $collection->getIncrementId();
}
}
- if ((isset($responseParams['payment_option']) && $responseParams['payment_option'] == 'STCPAY') || (isset($responseParams['digital_wallet']) && $responseParams['digital_wallet'] == 'STCPAY')) {
-
+ if (isset($responseParams['payment_option']) && $responseParams['payment_option'] == 'STCPAY') {
+
+ $collections = $this->_salesCollectionFactory->create()
+ ->addAttributeToSelect('*')
+ ->addFieldToFilter('aps_stc_ref', ['eq'=>$responseParams['merchant_reference']]);
+ foreach ($collections as $collection) {
+ $orderId = $collection->getIncrementId();
+ }
+ }
+
+ if (isset($responseParams['digital_wallet']) && $responseParams['digital_wallet'] == 'STCPAY') {
+
$collections = $this->_salesCollectionFactory->create()
->addAttributeToSelect('*')
->addFieldToFilter('aps_stc_ref', ['eq'=>$responseParams['merchant_reference']]);
foreach ($collections as $collection) {
$orderId = $collection->getIncrementId();
}
-
}
if (isset($responseParams['payment_option']) && $responseParams['payment_option'] == 'TABBY') {
@@ -2424,7 +2442,15 @@ private function errorReponse($responseCode, $order, $responseStatusMessage)
$this->_messageManager->addError($responseMessage);
return false;
}
- } else {
+ } elseif ($responseCode == self::PAYMENT_TRANSACTION_DECLINED){
+ $responseMessage = __('Your payment transaction was declined, please try again.');
+ $r = $this->orderFailed($order, $responseMessage, $responseCode);
+ if ($r) {
+ $this->restoreQuote();
+ $this->_messageManager->addError($responseMessage);
+ return false;
+ }
+ }else {
$responseMessage = sprintf(__('An error occurred while making the transaction. Please try again. (Error message: %s)'), $responseStatusMessage);
$r = $this->orderFailed($order, $responseStatusMessage, $responseCode);
if ($r) {
@@ -3227,4 +3253,32 @@ public function getTabbyRequestParams($order, $integrationType)
return ['url' => $gatewayUrl, 'params' => $gatewayParams];
}
+
+ /**
+ * @param $order
+ *
+ * @return bool
+ */
+ public function canCancelOrder($order)
+ {
+ return in_array($order->getStatus(), [
+ $order::STATE_NEW,
+ $order::STATE_PENDING_PAYMENT,
+ $order::STATE_HOLDED,
+ $order::STATE_PAYMENT_REVIEW,
+ ]);
+ }
+ /**
+ * Creates invoice and sends invoice email
+ *
+ * @param $order
+ * @param $response
+ *
+ * @return void
+ */
+ public function handleSendingInvoice(&$order, $response): void
+ {
+ $invoice = $this->createInvoice($order, $response);
+ $this->sendInvoiceEmail($invoice);
+ }
}
diff --git a/magento2-aps/Amazonpaymentservices/Fort/Model/Method/Benefit.php b/magento2-aps/Amazonpaymentservices/Fort/Model/Method/Benefit.php
new file mode 100644
index 0000000..ac60665
--- /dev/null
+++ b/magento2-aps/Amazonpaymentservices/Fort/Model/Method/Benefit.php
@@ -0,0 +1,81 @@
+
+ * @license GNU / GPL v3
+ * @version GIT: @1.0.0@
+ * @link Amazonpaymentservices
+ **/
+namespace Amazonpaymentservices\Fort\Model\Method;
+
+/**
+ * Amazonpaymentservices Payment Benefit Model
+ * php version 7.3.*
+ *
+ * @author Amazonpaymentservices
- = $block->escapeHtml(__('KNET third party transaction number')); ?>
-
-
+
+
+
- = $block->escapeHtml(__($data['additionalData']['payment_option'] . ' third party transaction number')); ?>
+
= /* @noEscape */ ($data['additionalData']['third_party_transaction_number']); ?>
-
-
-
-
+
+
+ = $block->escapeHtml(__('KNET Reference Number')); ?>
-
-
+
+
+
-
+
+
+
+
\ No newline at end of file
diff --git a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/layout/checkout_index_index.xml b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/layout/checkout_index_index.xml
index 4492433..6567c3a 100755
--- a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/layout/checkout_index_index.xml
+++ b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/layout/checkout_index_index.xml
@@ -52,6 +52,12 @@
= $block->escapeHtml(__('KNET Reference Number')); ?>
+
= /* @noEscape */ ($data['additionalData']['knet_ref_number']); ?>
-
-
-
BENEFIT third party transaction number : = $block->escapeHtml(__($thirdRefNo)); ?>
+