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 + * @license GNU / GPL v3 + * @version GIT: @1.0.0@ + * @link Amazonpaymentservices + **/ +class Benefit extends \Amazonpaymentservices\Fort\Model\Payment +{ + const CODE = 'aps_benefit'; + + protected $_code = self::CODE; + protected $_helper; + + public function __construct( + \Magento\Framework\Model\Context $context, + \Magento\Framework\Registry $registry, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, + \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, + \Amazonpaymentservices\Fort\Helper\Data $paymentData, + \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, + \Magento\Payment\Model\Method\Logger $logger, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, + \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, + array $data = [] + ) { + parent::__construct( + $context, + $registry, + $extensionFactory, + $customAttributeFactory, + $paymentData, + $scopeConfig, + $logger, + $resource, + $resourceCollection, + $data + ); + + $this->_code = self::CODE; + $this->_helper = $paymentData; + } + + /** + * Determine method availability based on quote amount and config data + * + * @param \Magento\Quote\Api\Data\CartInterface|null $quote + * @return bool + */ + public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) + { + $baseCurrency = $this->_helper->getBaseCurrency(); + $frontCurrency = $this->_helper->getFrontCurrency(); + $currency = $this->_helper->getFortCurrency($baseCurrency, $frontCurrency); + if ($currency != 'BHD') { + return false; + } + + if (!$this->_helper->checkSubscriptionItemInCart()) { + return false; + } + + return parent::isAvailable($quote); + } +} diff --git a/magento2-aps/Amazonpaymentservices/Fort/Model/Method/OmanNet.php b/magento2-aps/Amazonpaymentservices/Fort/Model/Method/OmanNet.php new file mode 100644 index 0000000..4a19740 --- /dev/null +++ b/magento2-aps/Amazonpaymentservices/Fort/Model/Method/OmanNet.php @@ -0,0 +1,82 @@ + + * @license GNU / GPL v3 + * @version GIT: @1.0.0@ + * @link Amazonpaymentservices + **/ +namespace Amazonpaymentservices\Fort\Model\Method; + +/** + * Amazonpaymentservices Payment OmanNet Model + * php version 7.3.* + * + * @author Amazonpaymentservices + * @license GNU / GPL v3 + * @version GIT: @1.0.0@ + * @link Amazonpaymentservices + **/ +class OmanNet extends \Amazonpaymentservices\Fort\Model\Payment +{ + const CODE = 'aps_omannet'; + + protected $_code = self::CODE; + protected $_helper; + + public function __construct( + \Magento\Framework\Model\Context $context, + \Magento\Framework\Registry $registry, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, + \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, + \Amazonpaymentservices\Fort\Helper\Data $paymentData, + \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, + \Magento\Payment\Model\Method\Logger $logger, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, + \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, + array $data = [] + ) { + parent::__construct( + $context, + $registry, + $extensionFactory, + $customAttributeFactory, + $paymentData, + $scopeConfig, + $logger, + $resource, + $resourceCollection, + $data + ); + + $this->_code = self::CODE; + $this->_helper = $paymentData; + } + + /** + * Determine method availability based on quote amount and config data + * + * @param \Magento\Quote\Api\Data\CartInterface|null $quote + * @return bool + */ + public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) + { + $baseCurrency = $this->_helper->getBaseCurrency(); + $frontCurrency = $this->_helper->getFrontCurrency(); + $currency = $this->_helper->getFortCurrency($baseCurrency, $frontCurrency); + + if ($currency != 'OMR') { + return false; + } + + if (!$this->_helper->checkSubscriptionItemInCart()) { + return false; + } + + return parent::isAvailable($quote); + } +} diff --git a/magento2-aps/Amazonpaymentservices/Fort/Model/PaymentConfigProvider.php b/magento2-aps/Amazonpaymentservices/Fort/Model/PaymentConfigProvider.php index 0a11711..9048e3b 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Model/PaymentConfigProvider.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Model/PaymentConfigProvider.php @@ -56,6 +56,8 @@ class PaymentConfigProvider implements ConfigProviderInterface \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 ]; @@ -232,6 +234,12 @@ public function getConfig() if ($code == \Amazonpaymentservices\Fort\Model\Method\VisaCheckout::CODE) { $this->visaConfig($code); } + if ($code == \Amazonpaymentservices\Fort\Model\Method\Benefit::CODE) { + $this->config['payment']['apsFort'][$code]['benefitLogo'] = $this->getBenefitLogo(); + } + if ($code == \Amazonpaymentservices\Fort\Model\Method\OmanNet::CODE) { + $this->config['payment']['apsFort'][$code]['omanNetLogo'] = $this->getOmanNetLogo(); + } if ($code == \Amazonpaymentservices\Fort\Model\Method\Valu::CODE) { $this->config['payment']['apsFort'][$code]['valuLogo'] = $this->getValuConfig(); $this->config['payment']['apsFort'][$code]['ajaxOtpUrl'] = $this->apsHelper->getReturnUrl('amazonpaymentservicesfort/payment/GetUserData'); @@ -489,6 +497,18 @@ protected function getValuConfig() return $output; } + protected function getBenefitLogo() + { + $output = $this->getViewFileUrl('Amazonpaymentservices_Fort::images/benefit-logo.png'); + return $output; + } + + protected function getOmanNetLogo() + { + $output = $this->getViewFileUrl('Amazonpaymentservices_Fort::images/omannet-logo.png'); + return $output; + } + public function getViewFileUrl($fileId, array $params = []) { return $this->_assetRepository->getUrlWithParams($fileId, $params); diff --git a/magento2-aps/Amazonpaymentservices/Fort/Model/Plugin/CreditmemoAddData.php b/magento2-aps/Amazonpaymentservices/Fort/Model/Plugin/CreditmemoAddData.php index 5ec6dcf..64832ff 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Model/Plugin/CreditmemoAddData.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Model/Plugin/CreditmemoAddData.php @@ -120,6 +120,12 @@ public function beforeSave( throw new \Exception('Payment Method not allow for refund.'); } + //Need to check for omannet and benefit. + if (\Amazonpaymentservices\Fort\Model\Method\Benefit::CODE == $paymentMethod or \Amazonpaymentservices\Fort\Model\Method\OmanNet::CODE == $paymentMethod) { + $this->_helper->log("\n\n Payment Method (".$paymentMethod.") not allow for refund for order id ".$postParams['order_id']." \n\n"); + throw new \Exception('Payment Method not allow for refund.'); + } + $orderId = $order->getId(); $orderTotal = $order->getGrandTotal(); $orderIncrementId = $order->getIncrementId(); @@ -158,7 +164,7 @@ public function beforeSave( } $this->_helper->log("Creditmemo with Shipping Tax amount : ".$taxAmount); - $amount += $shipAmount + $adjustAmount - $adjustNegative + $taxAmount; + $amount += ($shipAmount - $order->getShippingDiscountAmount()) + $adjustAmount - $adjustNegative + $taxAmount; if (( \Amazonpaymentservices\Fort\Model\Method\Naps::CODE == $paymentMethod) && $amount != $orderTotal) { $this->_helper->log("\n\n Partial Refund is not allowed for this payment method(".$paymentMethod."). (order id: ".$postParams['order_id'].") \n\n"); diff --git a/magento2-aps/Amazonpaymentservices/Fort/Observer/AdminSystemConfigChangedPaymentObserver.php b/magento2-aps/Amazonpaymentservices/Fort/Observer/AdminSystemConfigChangedPaymentObserver.php index 777749a..906f729 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Observer/AdminSystemConfigChangedPaymentObserver.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Observer/AdminSystemConfigChangedPaymentObserver.php @@ -103,8 +103,10 @@ protected function saveCommonConfig($configKey, $configValue, $scope, $scopeId) $this->resourceConfig->saveConfig('payment/aps_knet/'.$configKey, $configValue, $scope, $scopeId); $this->resourceConfig->saveConfig('payment/aps_apple/'.$configKey, $configValue, $scope, $scopeId); $this->resourceConfig->saveConfig('payment/aps_fort_valu/'.$configKey, $configValue, $scope, $scopeId); + $this->resourceConfig->saveConfig('payment/aps_omannet/'.$configKey, $configValue, $scope, $scopeId); $this->resourceConfig->saveConfig('payment/aps_fort_visaco/'.$configKey, $configValue, $scope, $scopeId); $this->resourceConfig->saveConfig('payment/aps_fort_stc/'.$configKey, $configValue, $scope, $scopeId); + $this->resourceConfig->saveConfig('payment/aps_benefit/'.$configKey, $configValue, $scope, $scopeId); $this->resourceConfig->saveConfig('payment/aps_fort_tabby/'.$configKey, $configValue, $scope, $scopeId); } } diff --git a/magento2-aps/Amazonpaymentservices/Fort/composer.json b/magento2-aps/Amazonpaymentservices/Fort/composer.json index 4c82b55..06fc642 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/composer.json +++ b/magento2-aps/Amazonpaymentservices/Fort/composer.json @@ -1,7 +1,7 @@ { "name": "amazonpaymentservices/module-fort", "description": "APS integration with payment gateway", - "version": "2.5.0", + "version": "2.6.0", "type": "magento2-module", "license": [ "MIT" diff --git a/magento2-aps/Amazonpaymentservices/Fort/etc/adminhtml/system.xml b/magento2-aps/Amazonpaymentservices/Fort/etc/adminhtml/system.xml index 7d9e446..309d5b0 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/etc/adminhtml/system.xml +++ b/magento2-aps/Amazonpaymentservices/Fort/etc/adminhtml/system.xml @@ -369,6 +369,23 @@ payment/aps_fort_valu/sort_order + + + + + Magento\Config\Model\Config\Source\Yesno + payment/aps_omannet/active + + + + payment/aps_omannet/title + + + + validate-number + payment/aps_omannet/sort_order + + @@ -440,6 +457,23 @@ payment/aps_fort_tabby/active + + + + + Magento\Config\Model\Config\Source\Yesno + payment/aps_benefit/active + + + + payment/aps_benefit/title + + + + validate-number + payment/aps_benefit/sort_order + + diff --git a/magento2-aps/Amazonpaymentservices/Fort/etc/config.xml b/magento2-aps/Amazonpaymentservices/Fort/etc/config.xml index 72f4a11..09872e2 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/etc/config.xml +++ b/magento2-aps/Amazonpaymentservices/Fort/etc/config.xml @@ -24,7 +24,7 @@ base aps_fort AE,VI,MC,MZ,MD - 440647|440795|446404|457865|968208|457997|474491|636120|417633|468540|468541|468542|468543|968201|446393|409201|458456|484783|462220|455708|410621|455036|486094|486095|486096|504300|440533|489318|489319|445564|968211|410685|406996|432328|428671|428672|428673|968206|446672|543357|434107|407197|407395|412565|431361|604906|521076|529415|535825|543085|524130|554180|549760|968209|524514|529741|537767|535989|536023|513213|520058|558563|588982|589005|531095|530906|532013|968204|422817|422818|422819|428331|483010|483011|483012|589206|968207|419593|439954|530060|531196|420132|421141|588845|403024|968205|42689700|406136 + |22331122|440647|440795|446404|457865|968208|457997|474491|636120|417633|468540|468541|468542|468543|968201|446393|409201|458456|484783|462220|455708|410621|455036|486094|486095|486096|504300|440533|489318|489319|445564|968211|410685|406996|432328|428671|428672|428673|968206|446672|543357|434107|407197|407395|412565|431361|604906|521076|529415|535825|543085|524130|554180|549760|968209|524514|529741|537767|535989|536023|513213|520058|558563|588982|589005|531095|530906|532013|968204|422817|422818|422819|428331|483010|483011|483012|589206|968207|419593|439954|530060|531196|420132|421141|588845|403024|968205|42689700|406136 507803[0-6][0-9]|507808[3-9][0-9]|507809[0-9][0-9]|507810[0-2][0-9] @@ -86,6 +86,14 @@ aps_fort 60 + + Amazonpaymentservices\Fort\Model\Method\OmanNet + 0 + OmanNet + aps_fort + 40 + + Amazonpaymentservices\Fort\Model\Method\VisaCheckout 0 @@ -110,6 +118,14 @@ aps_fort 90 + + Amazonpaymentservices\Fort\Model\Method\Benefit + 0 + Benefit + aps_fort + 100 + + diff --git a/magento2-aps/Amazonpaymentservices/Fort/etc/module.xml b/magento2-aps/Amazonpaymentservices/Fort/etc/module.xml index 9a5fe45..3529936 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/etc/module.xml +++ b/magento2-aps/Amazonpaymentservices/Fort/etc/module.xml @@ -10,7 +10,7 @@ **/ --> - + diff --git a/magento2-aps/Amazonpaymentservices/Fort/etc/payment.xml b/magento2-aps/Amazonpaymentservices/Fort/etc/payment.xml index b5c8652..135ddd3 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/etc/payment.xml +++ b/magento2-aps/Amazonpaymentservices/Fort/etc/payment.xml @@ -32,9 +32,15 @@ 0 + + 0 + 0 + + 0 + diff --git a/magento2-aps/Amazonpaymentservices/Fort/view/adminhtml/templates/order/view/view.phtml b/magento2-aps/Amazonpaymentservices/Fort/view/adminhtml/templates/order/view/view.phtml index 2a89408..eaf9f7c 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/view/adminhtml/templates/order/view/view.phtml +++ b/magento2-aps/Amazonpaymentservices/Fort/view/adminhtml/templates/order/view/view.phtml @@ -192,25 +192,23 @@ if ($isAvailable) { - - escapeHtml(__('KNET third party transaction number')); ?> - - + + + escapeHtml(__($data['additionalData']['payment_option'] . ' third party transaction number')); ?> + - - - - - escapeHtml(__('KNET Reference Number')); ?> - - + + + + + + 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 @@ false + + false + + + false + diff --git a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/layout/onestepcheckout_index_index.xml b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/layout/onestepcheckout_index_index.xml index edebde8..74eda22 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/layout/onestepcheckout_index_index.xml +++ b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/layout/onestepcheckout_index_index.xml @@ -40,6 +40,12 @@ false + + false + + + false + diff --git a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/templates/express/cart_button.phtml b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/templates/express/cart_button.phtml index 0dbd763..4bfd448 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/templates/express/cart_button.phtml +++ b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/templates/express/cart_button.phtml @@ -150,18 +150,18 @@ var tempData = data; var storeName = ''; var supportedNetworks = ''; - var runningAmount = data.totalPrice; - var runningShipping = data.shippingAmount; - var totalTax = data.totalTax; - var discountAmount = data.discountAmount; - var appleTotal = data.total; + var runningAmount = data.totalPriceUnformatted ? data.totalPriceUnformatted : data.totalPrice; + var runningShipping = data.shippingAmountUnformatted ? data.shippingAmountUnformatted : data.shippingAmount; + var totalTax = data.totalTaxUnformatted ? data.totalTaxUnformatted : data.totalTax; + var discountAmount = data.discountAmountUnformatted ? data.discountAmountUnformatted : data.discountAmount; + var appleTotal = data.totalUnformatted ? data.totalUnformatted : data.total; var newItemArray = []; var runningTotal = function(data) { - runningAmount = parseFloat(data.totalPrice); - runningShipping = parseFloat(data.shippingAmount); - totalTax = parseFloat(data.totalTax); - discountAmount = parseFloat(data.discountAmount); + runningAmount = parseFloat(data.totalPriceUnformatted ? data.totalPriceUnformatted : data.totalPrice); + runningShipping = parseFloat(data.shippingAmountUnformatted ? data.shippingAmountUnformatted : data.shippingAmount); + totalTax = parseFloat(data.totalTaxUnformatted ? data.totalTaxUnformatted : data.totalTax); + discountAmount = parseFloat(data.discountAmountUnformatted ? data.discountAmountUnformatted : data.discountAmount); newItemArray[0] = {type: 'final',label: 'Subtotal', amount: runningAmount}; @@ -241,8 +241,10 @@ if(dataShip.data.hasOwnProperty(0)) { shipData = dataShip.data; data.shippingAmount = parseFloat(dataShip.data[0].amount); + data.shippingAmountUnformatted = parseFloat(dataShip.data[0].amount); } data.totalTax = parseFloat(dataShip.taxes); + data.totalTaxUnformatted = parseFloat(dataShip.taxes); var finalTotal = { label: storeName, diff --git a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/templates/express/product_button.phtml b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/templates/express/product_button.phtml index c1b3729..7a2044d 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/templates/express/product_button.phtml +++ b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/templates/express/product_button.phtml @@ -163,18 +163,18 @@ if ($checkActive) { var shipData = {}; var storeName = ''; var supportedNetworks = ''; - var runningAmount = data.totalPrice; - var runningShipping = data.shippingAmount; - var totalTax = data.totalTax; - var discountAmount = data.discountAmount; - var appleTotal = data.total; + var runningAmount = data.totalPriceUnformatted ? data.totalPriceUnformatted : data.totalPrice; + var runningShipping = data.shippingAmountUnformatted ? data.shippingAmountUnformatted : data.shippingAmount; + var totalTax = data.totalTaxUnformatted ? data.totalTaxUnformatted : data.totalTax; + var discountAmount = data.discountAmountUnformatted ? data.discountAmountUnformatted : data.discountAmount; + var appleTotal = data.totalUnformatted ? data.totalUnformatted : data.total; var newItemArray = []; var runningTotal = function(data) { - runningAmount = parseFloat(data.totalPrice); - runningShipping = parseFloat(data.shippingAmount); - totalTax = parseFloat(data.totalTax); - discountAmount = parseFloat(data.discountAmount); + runningAmount = parseFloat(data.totalPriceUnformatted ? data.totalPriceUnformatted : data.totalPrice); + runningShipping = parseFloat(data.shippingAmountUnformatted ? data.shippingAmountUnformatted : data.shippingAmount); + totalTax = parseFloat(data.totalTaxUnformatted ? data.totalTaxUnformatted : data.totalTax); + discountAmount = parseFloat(data.discountAmountUnformatted ? data.discountAmountUnformatted : data.discountAmount); newItemArray[0] = {type: 'final',label: 'Subtotal', amount: runningAmount}; var x= 1; @@ -252,8 +252,10 @@ if ($checkActive) { if(dataShip.data.hasOwnProperty(0)) { shipData = dataShip.data; data.shippingAmount = parseFloat(dataShip.data[0].amount); + data.shippingAmountUnformatted = parseFloat(dataShip.data[0].amount); } data.totalTax = parseFloat(dataShip.taxes); + data.totalTaxUnformatted = parseFloat(dataShip.taxes); var finalTotal = { label: storeName, diff --git a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/templates/order/success.phtml b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/templates/order/success.phtml index 3ff6ea1..87eb0b0 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/templates/order/success.phtml +++ b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/templates/order/success.phtml @@ -30,4 +30,26 @@

+ + + + +isOmanNetPaymentMethod()): ?> + + getOmanNetParmeters(); + $thirdRefNo = isset($OmanNetData['third_party_transaction_number']) ? $OmanNetData['third_party_transaction_number'] : ''; + ?> + +
+
OmanNet third party transaction number : escapeHtml(__($thirdRefNo)); ?>
+ + + +isBenefitPaymentMethod()): ?> + getBenefitParmeters(); + $thirdRefNo = isset($benefitData['third_party_transaction_number']) ? $benefitData['third_party_transaction_number'] : ''; + ?> +
+

BENEFIT third party transaction number : escapeHtml(__($thirdRefNo)); ?>

+
\ No newline at end of file diff --git a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/images/benefit-logo.png b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/images/benefit-logo.png new file mode 100644 index 0000000..c5c4f32 Binary files /dev/null and b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/images/benefit-logo.png differ diff --git a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/images/benefit_logo.png b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/images/benefit_logo.png new file mode 100644 index 0000000..7f849ce Binary files /dev/null and b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/images/benefit_logo.png differ diff --git a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/images/omannet-logo.png b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/images/omannet-logo.png new file mode 100644 index 0000000..0b03b54 Binary files /dev/null and b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/images/omannet-logo.png differ diff --git a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/aps-payments.js b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/aps-payments.js index 802a1d9..a4dce4e 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/aps-payments.js +++ b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/aps-payments.js @@ -55,6 +55,14 @@ define( type: 'aps_fort_stc', component: window.checkoutConfig.payment.apsFort.aps_fort_stc.integrationType == 'hosted' ? 'Amazonpaymentservices_Fort/js/view/payment/method-renderer/aps_fort_stc-merchant' : 'Amazonpaymentservices_Fort/js/view/payment/method-renderer/aps_fort_stc' }, + { + type: 'aps_omannet', + component: 'Amazonpaymentservices_Fort/js/view/payment/method-renderer/aps_omannet-method' + }, + { + type: 'aps_benefit', + component: 'Amazonpaymentservices_Fort/js/view/payment/method-renderer/aps_benefit-method' + }, { type: 'aps_fort_tabby', component: 'Amazonpaymentservices_Fort/js/view/payment/method-renderer/aps_fort_tabby' diff --git a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/method-renderer/aps_apple-method.js b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/method-renderer/aps_apple-method.js index 8352ca2..8d66e6a 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/method-renderer/aps_apple-method.js +++ b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/method-renderer/aps_apple-method.js @@ -96,20 +96,20 @@ define( } this.placeOrder(); var totals = quote.totals(); - var runningAmount = (totals ? totals : quote)['subtotal']; + var runningAmount = (totals ? totals : quote)['subtotal'], runningAmountFormatted = ''; var priceFormat = quote.getPriceFormat(); priceFormat.pattern = "%s"; - runningAmount = priceUtils.formatPrice(runningAmount, priceFormat, false); - runningAmount = runningAmount.replace(/,/g, ''); + runningAmountFormatted = priceUtils.formatPrice(runningAmount, priceFormat, false); + // runningAmount = runningAmount.replace(/,/g, ''); runningAmount = parseFloat(runningAmount); - var totalTax = (totals ? totals : quote)['tax_amount']; - totalTax = priceUtils.formatPrice(totalTax, priceFormat, false); - totalTax = totalTax.replace(/,/g, ''); + var totalTax = (totals ? totals : quote)['tax_amount'], totalTaxFormatted = ''; + totalTaxFormatted = priceUtils.formatPrice(totalTax, priceFormat, false); + // totalTax = totalTax.replace(/,/g, ''); totalTax = parseFloat(totalTax); - var runningPP = 0; - var displayPP = 0; + var runningPP = 0, runningPPFormatted = ''; + var displayPP = 0, displayPPFormatted = ''; if (window.checkoutConfig.payment.apsFort.aps_apple.shippingconfig == 0) { if (window.checkoutConfig.payment.apsFort.aps_apple.shippingdisplayconfig == 1) { @@ -131,23 +131,21 @@ define( } runningPP = (totals ? totals : quote)['shipping_amount']; - runningPP = priceUtils.formatPrice(runningPP, priceFormat, false); - runningPP = runningPP.replace(/,/g, ''); + runningPPFormatted = priceUtils.formatPrice(runningPP, priceFormat, false); + // runningPP = runningPP.replace(/,/g, ''); runningPP = parseFloat(runningPP); - displayPP = priceUtils.formatPrice(displayPP, priceFormat, false); - displayPP = displayPP.replace(/,/g, ''); + displayPPFormatted = priceUtils.formatPrice(displayPP, priceFormat, false); + // displayPP = displayPP.replace(/,/g, ''); displayPP = parseFloat(displayPP); - - var runningShipDiscount = (totals ? totals : quote)['shipping_discount_amount']; - runningShipDiscount = priceUtils.formatPrice(runningShipDiscount, priceFormat, false); - runningShipDiscount = runningShipDiscount.replace(/,/g, ''); + var runningShipDiscount = Math.abs( (totals ? totals : quote)['shipping_discount_amount']), runningShipDiscountFormatted = ''; + runningShipDiscountFormatted = priceUtils.formatPrice(runningShipDiscount, priceFormat, false); + // runningShipDiscount = runningShipDiscount.replace(/,/g, ''); runningShipDiscount = parseFloat(runningShipDiscount); - runningPP = runningPP - runningShipDiscount; - var discountAmount = (totals ? totals : quote)['discount_amount']; - discountAmount = priceUtils.formatPrice(discountAmount, priceFormat, false); - discountAmount = discountAmount.replace(/,/g, ''); + var discountAmount = Math.abs( (totals ? totals : quote)['discount_amount']), discountAmountFormatted = '' ; + discountAmountFormatted = priceUtils.formatPrice(discountAmount, priceFormat, false); + // discountAmount = discountAmount.replace(/,/g, ''); discountAmount = parseFloat(discountAmount); var currencyCode = (totals ? totals : quote)['quote_currency_code']; @@ -157,9 +155,9 @@ define( var runningPP1 = parseFloat(runningPP); var totalTax1 = parseFloat(totalTax); var discountAmount1 = parseFloat(discountAmount); - var tempTotals = (runningAmount1 + runningPP1 + totalTax1 - discountAmount1); - tempTotals = priceUtils.formatPrice(tempTotals, priceFormat, false); - tempTotals = tempTotals.replace(/,/g, ''); + var tempTotals = (runningAmount1 + runningPP1 + totalTax1 - discountAmount1), tempTotalsFormatted = ''; + tempTotalsFormatted = priceUtils.formatPrice(tempTotals, priceFormat, false); + // tempTotals = tempTotals.replace(/,/g, ''); tempTotals = parseFloat(tempTotals); return tempTotals; } @@ -184,13 +182,12 @@ define( newItemArray[x++] = {type: 'final',label: 'Discount', amount: discountAmount }; } newItemArray[x++] = {type: 'final',label: 'Shipping Fees', amount: displayPP }; - totalTax = totalTax; newItemArray[x++] = {type: 'final',label: 'Taxes', amount: totalTax }; function getShippingOptions() { - return [{label: 'Standard Shipping', amount: runningPP, detail: '3-5 days', identifier: 'domestic_std'}]; + return [{label: 'Standard Shipping', amount: runningPPFormatted, detail: '3-5 days', identifier: 'domestic_std'}]; } var storeName = window.checkoutConfig.payment.apsFort.aps_apple.storeName; var paymentRequest = { diff --git a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/method-renderer/aps_benefit-method.js b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/method-renderer/aps_benefit-method.js new file mode 100644 index 0000000..a3064b4 --- /dev/null +++ b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/method-renderer/aps_benefit-method.js @@ -0,0 +1,60 @@ +/** + * Aps_Fort Magento JS component + * + * @category Aps + * @package Aps_Fort + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'ko', + 'jquery', + 'Magento_Checkout/js/view/payment/default', + 'Magento_Checkout/js/model/quote', + 'Magento_Checkout/js/model/full-screen-loader', + 'Magento_Checkout/js/action/set-payment-information', + 'Magento_Checkout/js/action/place-order', + ], + function (ko, $, Component, quote, fullScreenLoader, setPaymentInformationAction, placeOrder) { + 'use strict'; + return Component.extend({ + defaults: { + template: 'Amazonpaymentservices_Fort/payment/aps-payment-benefit' + }, + getCode: function () { + return 'aps_benefit'; + }, + getTitle: function () { + return $.mage.__('Pay With BENEFIT'); + }, + isActive: function () { + return true; + }, + context: function () { + return this; + }, + getInstructions: function () { + return window.checkoutConfig.payment.apsFort.aps_benefit.instructions; + }, + setLogo: function () { + $('[data-action="setLogo"]').attr('src',window.checkoutConfig.payment.apsFort.aps_benefit.benefitLogo); + }, + // Overwrite properties / functions + redirectAfterPlaceOrder: false, + + afterPlaceOrder : function () { + $.mage.redirect(window.checkoutConfig.payment.apsFort.aps_benefit.redirectUrl); + }, + isChecked: ko.computed(function () { + var checked = quote.paymentMethod() ? quote.paymentMethod().method : null; + if (window.checkoutConfig.payment.apsFort.configParams.gatewayCurrency == 'front') { + if (checked) { + $('.totals.charge').hide(); + } + } + return checked; + }), + }); + } +); diff --git a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/method-renderer/aps_fort_cc_merchant_page2-method.js b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/method-renderer/aps_fort_cc_merchant_page2-method.js index 04e84b0..e96ceaa 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/method-renderer/aps_fort_cc_merchant_page2-method.js +++ b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/method-renderer/aps_fort_cc_merchant_page2-method.js @@ -405,7 +405,7 @@ define( var getCode = this.getCode(); var cardId = "#" + getCode + "_cc_number"; var cardNumber = $(cardId).val(); - cardNumber = cardNumber.substring(0, 6); + cardNumber = cardNumber.substring(0, 8); if ($(cardId).val().length >= 15) { $('[data-action="widget-cc-insta-grid"]').html(sliderText); $.ajax({ diff --git a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/method-renderer/aps_installment_hosted-method.js b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/method-renderer/aps_installment_hosted-method.js index 76b22ff..86a98c9 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/method-renderer/aps_installment_hosted-method.js +++ b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/method-renderer/aps_installment_hosted-method.js @@ -321,7 +321,7 @@ define( var getCode = this.getCode(); var cardId = "#" + getCode + "_cc_number"; var cardNumber = $(cardId).val(); - cardNumber = cardNumber.substring(0, 6); + cardNumber = cardNumber.substring(0, 8); if ($(cardId).val().length >= 15) { $('[data-action="widget-insta-grid"]').html(sliderText); $.ajax({ diff --git a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/method-renderer/aps_omannet-method.js b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/method-renderer/aps_omannet-method.js new file mode 100644 index 0000000..bfc73da --- /dev/null +++ b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/js/view/payment/method-renderer/aps_omannet-method.js @@ -0,0 +1,60 @@ +/** + * Aps_Fort Magento JS component + * + * @category Aps + * @package Aps_Fort + */ +/*browser:true*/ +/*global define*/ +define( + [ + 'ko', + 'jquery', + 'Magento_Checkout/js/view/payment/default', + 'Magento_Checkout/js/model/quote', + 'Magento_Checkout/js/model/full-screen-loader', + 'Magento_Checkout/js/action/set-payment-information', + 'Magento_Checkout/js/action/place-order', + ], + function (ko, $, Component, quote, fullScreenLoader, setPaymentInformationAction, placeOrder) { + 'use strict'; + return Component.extend({ + defaults: { + template: 'Amazonpaymentservices_Fort/payment/aps-payment-omannet' + }, + getCode: function () { + return 'aps_omannet'; + }, + getTitle: function () { + return $.mage.__(window.checkoutConfig.payment.apsFort.aps_omannet.title); + }, + isActive: function () { + return true; + }, + context: function () { + return this; + }, + getInstructions: function () { + return window.checkoutConfig.payment.apsFort.aps_omannet.instructions; + }, + setLogo: function () { + $('[data-action="setLogo"]').attr('src',window.checkoutConfig.payment.apsFort.aps_omannet.omanNetLogo); + }, + // Overwrite properties / functions + redirectAfterPlaceOrder: false, + + afterPlaceOrder : function () { + $.mage.redirect(window.checkoutConfig.payment.apsFort.aps_omannet.redirectUrl); + }, + isChecked: ko.computed(function () { + var checked = quote.paymentMethod() ? quote.paymentMethod().method : null; + if (window.checkoutConfig.payment.apsFort.configParams.gatewayCurrency == 'front') { + if (checked) { + $('.totals.charge').hide(); + } + } + return checked; + }), + }); + } +); diff --git a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/template/payment/aps-form-merchant-page2.html b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/template/payment/aps-form-merchant-page2.html index 7a4dd34..ad485a6 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/template/payment/aps-form-merchant-page2.html +++ b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/template/payment/aps-form-merchant-page2.html @@ -57,14 +57,14 @@ afterRender: afterVaultRender ">
diff --git a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/template/payment/aps-payment-benefit.html b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/template/payment/aps-payment-benefit.html new file mode 100644 index 0000000..2ac3ef3 --- /dev/null +++ b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/template/payment/aps-payment-benefit.html @@ -0,0 +1,58 @@ + +
+
+
+ + + +
+
+
+ + + + +
+ + + + +
+
+ +
+
+
+ + + + +
+
+
+ +
+
+
+
\ No newline at end of file diff --git a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/template/payment/aps-payment-omannet.html b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/template/payment/aps-payment-omannet.html new file mode 100644 index 0000000..983c91c --- /dev/null +++ b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/template/payment/aps-payment-omannet.html @@ -0,0 +1,58 @@ + +
+
+
+ + + +
+
+
+ + + + +
+ + + + +
+
+ +
+
+
+ + + + +
+
+
+ +
+
+
+
\ No newline at end of file