diff --git a/README.md b/README.md index bc4b7af..06eb9fb 100755 --- a/README.md +++ b/README.md @@ -11,25 +11,10 @@ or execute below command in your magento installation directory `composer require amazonpaymentservices/module-fort` -# Amazon Payment Services Account: -If you don't have an APS account click here to sign up for Amazon Payment Services account -https://paymentservices.amazon.com/ -Have any questions? Just get in touch -- email the team at integration-ps@amazon.com - -# Installation Steps -1. Connect via SFTP and navigate to [your site root folder] -1. Copy APS extension for Magento folder under app/code folder -1. Compile Magento -1. Follow the configuration steps mentioned in Step 3 - -# Configuration -Follow the below instruction to access configuration page of APS extension for Magento: -1. Navigate to Stores → Configuration -1. At left hand side click on Sales → Payment Methods -1. Under Other Payment Methods section find a payment methods names as “Amazon Payment Services” -1. Click on Configure button - +## Configuration and User Guide +You can download the archive [file](/magento2-aps-2.4.9.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 * Integration Types @@ -50,14 +35,16 @@ Follow the below instruction to access configuration page of APS extension for M * KNET * NAPS * Apple Pay - + ## Configuration and User Guide -You can download the archive [file](/magento2-aps-2.4.8.zip) of the plugin and install it to Magento. Detailed guide is included in the repository [here](https://github.com/payfort/magento2-payfort/wiki). +You can download the archive [file](/magento2-aps-2.4.9.zip) of the plugin and install it to Magento. Detailed guide is included in the repository [here](https://github.com/payfort/magento2-payfort/wiki). + ## Changelog | Plugin Version | Release Notes | | :---: | :--- | +| 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| | 2.4.6 | * Fix - Notification endpoints to consider auth and purchase success status codes | @@ -75,6 +62,7 @@ You can download the archive [file](/magento2-aps-2.4.8.zip) of the plugin and i | 2.1.0 | * New - ApplePay is activated in Product and Cart pages | | 2.0.0 | * New - Integrated payment options: MasterCard, Visa, AMEX, mada, Meeza, KNET, NAPS, Visa Checkout, ApplePay, valU
* New - Tokenization is enabled for Debit/Credit Cards and Installments
* New - Partial/Full Refund, Single/Multiple Capture and Void events are managed in order details | + ## API Documentation This plugin has been implemented by using following [API library](https://paymentservices-reference.payfort.com/docs/api/build/index.html) diff --git a/magento2-aps-2.4.8.zip b/magento2-aps-2.4.9.zip similarity index 60% rename from magento2-aps-2.4.8.zip rename to magento2-aps-2.4.9.zip index a877ba8..087bfa3 100644 Binary files a/magento2-aps-2.4.8.zip and b/magento2-aps-2.4.9.zip differ diff --git a/magento2-aps/Amazonpaymentservices/Fort/Block/Payment/Redirect.php b/magento2-aps/Amazonpaymentservices/Fort/Block/Payment/Redirect.php index 823d384..4631f5c 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Block/Payment/Redirect.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Block/Payment/Redirect.php @@ -57,7 +57,6 @@ public function __construct( parent::__construct($context, $data); $this->_checkoutSession = $checkoutSession; $this->_orderConfig = $orderConfig; - $this->_isScopePrivate = true; $this->httpContext = $httpContext; $this->_helper = $helperFort; } @@ -169,4 +168,8 @@ protected function canViewOrder(Order $order) return $this->httpContext->getValue(Context::CONTEXT_AUTH) && $this->isVisible($order); } + public function getCacheLifetime() + { + return null; + } } diff --git a/magento2-aps/Amazonpaymentservices/Fort/Block/Subscription/SubscriptionList.php b/magento2-aps/Amazonpaymentservices/Fort/Block/Subscription/SubscriptionList.php index 4fd94c2..f5c7d6a 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Block/Subscription/SubscriptionList.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Block/Subscription/SubscriptionList.php @@ -23,7 +23,6 @@ public function __construct( \Magento\Directory\Model\CountryFactory $countryFactory, array $data = [] ) { - $this->_isScopePrivate = true; $this->_orderCollectionFactory = $orderCollectionFactory; $this->_customerSession = $customerSession; $this->_orderConfig = $orderConfig; @@ -226,4 +225,8 @@ public function getCountryName($countryCode) $country = $this->_countryFactory->create()->loadByCode($countryCode); return $country->getName(); } + public function getCacheLifetime() + { + return null; + } } diff --git a/magento2-aps/Amazonpaymentservices/Fort/Block/Success.php b/magento2-aps/Amazonpaymentservices/Fort/Block/Success.php index 13aabe3..14e6436 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Block/Success.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Block/Success.php @@ -21,7 +21,6 @@ public function __construct( ) { $this->_checkoutSession = $checkoutSession; $this->_orderConfig = $orderConfig; - $this->_isScopePrivate = true; $this->httpContext = $httpContext; parent::__construct($context, $checkoutSession, $orderConfig, $httpContext, $data); @@ -75,4 +74,8 @@ public function getOrderNumber() { return $this->order->getIncrementId(); } + 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 29ca106..63163dd 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/AppleValidateAddress.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/AppleValidateAddress.php @@ -113,7 +113,6 @@ public function __construct( parent::__construct($context); $this->_checkoutSession = $checkoutSession; $this->_orderConfig = $orderConfig; - $this->_isScopePrivate = true; $this->_helper = $helperFort; $this->_apsModel = $apsModel; $this->_resultJsonFactory = $resultJsonFactory; @@ -299,4 +298,8 @@ public function getRegionIdBy($countryCode) return null; } + public function getCacheLifetime() + { + return null; + } } diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/CreateToken.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/CreateToken.php index bb2be4b..bb9fc0f 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/CreateToken.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/CreateToken.php @@ -58,7 +58,6 @@ public function __construct( parent::__construct($context); $this->_checkoutSession = $checkoutSession; $this->_orderConfig = $orderConfig; - $this->_isScopePrivate = true; $this->_helper = $helperFort; @@ -144,4 +143,8 @@ public function execute() $jsonResult->setData($result); return $jsonResult; } + public function getCacheLifetime() + { + return null; + } } diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetAppleValidation.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetAppleValidation.php index 956a9cd..6edffd7 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetAppleValidation.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetAppleValidation.php @@ -71,7 +71,6 @@ public function __construct( parent::__construct($context); $this->_checkoutSession = $checkoutSession; $this->_orderConfig = $orderConfig; - $this->_isScopePrivate = true; $this->_helper = $helperFort; $this->_apsModel = $apsModel; $this->_resultJsonFactory = $resultJsonFactory; @@ -133,4 +132,8 @@ private function validateAppleUrl($apple_url) return $apple_url; } + public function getCacheLifetime() + { + return null; + } } diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetInstallmentPlans.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetInstallmentPlans.php index cf60757..25fda26 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetInstallmentPlans.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetInstallmentPlans.php @@ -77,7 +77,6 @@ public function __construct( parent::__construct($context); $this->_checkoutSession = $checkoutSession; $this->_orderConfig = $orderConfig; - $this->_isScopePrivate = true; $this->_helper = $helperFort; $this->_apsModel = $apsModel; $this->_resultJsonFactory = $resultJsonFactory; @@ -252,4 +251,8 @@ public function getInstallmentHandler($response) } return $dataArr; } + public function getCacheLifetime() + { + return null; + } } diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetOtpVerifyData.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetOtpVerifyData.php index 81cff3f..9d3b4cc 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetOtpVerifyData.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetOtpVerifyData.php @@ -7,7 +7,7 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\App\Action\HttpPostActionInterface; -use Magento\Framework\Controller\Result\JsonFactory; +use Magento\Framework\Controller\ResultFactory; use Magento\Sales\Model\Order; class GetOtpVerifyData extends \Magento\Framework\App\Action\Action implements CsrfAwareActionInterface, HttpGetActionInterface, HttpPostActionInterface @@ -23,32 +23,21 @@ class GetOtpVerifyData extends \Magento\Framework\App\Action\Action implements C * @var \Amazonpaymentservices\Fort\Helper\Data */ protected $_helper; - - /** - * JSON Helper - * - * @var \Magento\Framework\Controller\Result\JsonFactory - */ - protected $_jsonHelper; /** * @param \Magento\Framework\App\Action\Context $context, * @param \Magento\Checkout\Model\Session $checkoutSession, * @param \Amazonpaymentservices\Fort\Helper\Data $helperFort, - * @param \Magento\Framework\Controller\Result\JsonFactory */ public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Checkout\Model\Session $checkoutSession, - \Amazonpaymentservices\Fort\Helper\Data $helperFort, - \Magento\Framework\Controller\Result\JsonFactory $jsonFactory + \Amazonpaymentservices\Fort\Helper\Data $helperFort ) { parent::__construct($context); $this->_checkoutSession = $checkoutSession; - $this->_isScopePrivate = true; $this->_helper = $helperFort; - $this->_jsonHelper = $jsonFactory; } public function createCsrfValidationException( @@ -71,7 +60,12 @@ public function execute() $data = $this->_helper->merchantOtpVerifyValuFort($order, $mobileNumber, $otp); - $resultJson = $this->_jsonHelper->create(); - return $resultJson->setData($data); + $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); + $resultJson->setData($data); + return $resultJson; + } + public function getCacheLifetime() + { + return null; } } diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetPaymentData.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetPaymentData.php index e549938..f82719a 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetPaymentData.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetPaymentData.php @@ -58,7 +58,6 @@ public function __construct( parent::__construct($context); $this->_checkoutSession = $checkoutSession; $this->_orderConfig = $orderConfig; - $this->_isScopePrivate = true; $this->_helper = $helperFort; @@ -130,4 +129,8 @@ public function execute() $jsonResult->setData($result); return $jsonResult; } + public function getCacheLifetime() + { + return null; + } } diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetPurchaseData.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetPurchaseData.php index 0137c2f..83019f0 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetPurchaseData.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetPurchaseData.php @@ -7,7 +7,7 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\App\Action\HttpPostActionInterface; -use Magento\Framework\Controller\Result\JsonFactory; +use Magento\Framework\Controller\ResultFactory; use Magento\Sales\Model\Order; class GetPurchaseData extends \Magento\Framework\App\Action\Action implements CsrfAwareActionInterface, HttpGetActionInterface, HttpPostActionInterface @@ -34,21 +34,17 @@ class GetPurchaseData extends \Magento\Framework\App\Action\Action implements Cs /** * @param \Magento\Framework\App\Action\Context $context, * @param \Magento\Checkout\Model\Session $checkoutSession, - * @param \Amazonpaymentservices\Fort\Helper\Data $helperFort, - * @param \Magento\Framework\Controller\Result\JsonFactory + * @param \Amazonpaymentservices\Fort\Helper\Data $helperFort */ public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Checkout\Model\Session $checkoutSession, - \Amazonpaymentservices\Fort\Helper\Data $helperFort, - \Magento\Framework\Controller\Result\JsonFactory $jsonFactory + \Amazonpaymentservices\Fort\Helper\Data $helperFort ) { parent::__construct($context); $this->_checkoutSession = $checkoutSession; - $this->_isScopePrivate = true; $this->_helper = $helperFort; - $this->_jsonHelper = $jsonFactory; } public function createCsrfValidationException( @@ -78,7 +74,12 @@ public function execute() $data = $this->_helper->merchantPurchaseValuFort($order, $mobileNumber, $otp, $tenure, $valuTenureAmount, $valuTenureInterest, $downPayment, $wallet_amount, $cashback_amount); - $resultJson = $this->_jsonHelper->create(); - return $resultJson->setData($data); + $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); + $resultJson->setData($data); + return $resultJson; + } + public function getCacheLifetime() + { + return null; } } diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetStcPaymentData.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetStcPaymentData.php index b5e07b4..52d0448 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetStcPaymentData.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetStcPaymentData.php @@ -58,7 +58,6 @@ public function __construct( parent::__construct($context); $this->_checkoutSession = $checkoutSession; $this->_orderConfig = $orderConfig; - $this->_isScopePrivate = true; $this->_helper = $helperFort; @@ -115,4 +114,8 @@ public function execute() $jsonResult->setData($result); return $jsonResult; } + public function getCacheLifetime() + { + return null; + } } diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetUserData.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetUserData.php index a36ae70..80ea8bb 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetUserData.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetUserData.php @@ -7,7 +7,7 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\App\Action\HttpPostActionInterface; -use Magento\Framework\Controller\Result\JsonFactory; +use Magento\Framework\Controller\ResultFactory; use Magento\Sales\Model\Order; class GetUserData extends \Magento\Framework\App\Action\Action implements CsrfAwareActionInterface, HttpGetActionInterface, HttpPostActionInterface @@ -24,30 +24,20 @@ class GetUserData extends \Magento\Framework\App\Action\Action implements CsrfAw */ protected $_helper; - /** - * JSON Helper - * - * @var \Magento\Framework\Controller\Result\JsonFactory - */ - protected $_jsonFactory; /** * @param \Magento\Framework\App\Action\Context $context, * @param \Magento\Checkout\Model\Session $checkoutSession, - * @param \Amazonpaymentservices\Fort\Helper\Data $helperFort, - * @param \Magento\Framework\Controller\Result\JsonFactory + * @param \Amazonpaymentservices\Fort\Helper\Data $helperFort */ public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Checkout\Model\Session $checkoutSession, - \Amazonpaymentservices\Fort\Helper\Data $helperFort, - \Magento\Framework\Controller\Result\JsonFactory $jsonFactory + \Amazonpaymentservices\Fort\Helper\Data $helperFort ) { parent::__construct($context); $this->_checkoutSession = $checkoutSession; - $this->_isScopePrivate = true; $this->_helper = $helperFort; - $this->_jsonHelper = $jsonFactory; } public function createCsrfValidationException( @@ -76,7 +66,12 @@ public function execute() } elseif ($otpCheck == 'requestOtp') { $data = $this->_helper->execGenOtp($order, $mobileNumber, $downPayment, $wallet_amount, $cashback_amount); } - $resultJson = $this->_jsonHelper->create(); - return $resultJson->setData($data); + $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); + $resultJson->setData($data); + return $resultJson; + } + public function getCacheLifetime() + { + return null; } } diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetVaultData.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetVaultData.php index 66b45b6..0d25949 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetVaultData.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetVaultData.php @@ -58,7 +58,6 @@ public function __construct( parent::__construct($context); $this->_checkoutSession = $checkoutSession; $this->_orderConfig = $orderConfig; - $this->_isScopePrivate = true; $this->_helper = $helperFort; @@ -91,4 +90,8 @@ public function execute() $jsonResult->setData($result); return $jsonResult; } + public function getCacheLifetime() + { + return null; + } } diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetVaultInstallment.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetVaultInstallment.php index 6a378c4..b392178 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetVaultInstallment.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetVaultInstallment.php @@ -72,7 +72,6 @@ public function __construct( parent::__construct($context); $this->_checkoutSession = $checkoutSession; $this->_orderConfig = $orderConfig; - $this->_isScopePrivate = true; $this->_helper = $helperFort; @@ -151,4 +150,8 @@ public function execute() $jsonResult->setData($result); return $jsonResult; } + public function getCacheLifetime() + { + return null; + } } diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetVaultPaymentData.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetVaultPaymentData.php index 1ca7a71..8ee8d87 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetVaultPaymentData.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/GetVaultPaymentData.php @@ -70,7 +70,6 @@ public function __construct( parent::__construct($context); $this->_checkoutSession = $checkoutSession; $this->_orderConfig = $orderConfig; - $this->_isScopePrivate = true; $this->_helper = $helperFort; @@ -158,4 +157,8 @@ public function execute() $jsonResult->setData($result); return $jsonResult; } + public function getCacheLifetime() + { + return null; + } } diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/Stcpayotp.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/Stcpayotp.php index 5bb52cd..5a90c31 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/Stcpayotp.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/Stcpayotp.php @@ -7,7 +7,7 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\App\Action\HttpPostActionInterface; -use Magento\Framework\Controller\Result\JsonFactory; +use Magento\Framework\Controller\ResultFactory; use Magento\Sales\Model\Order; class Stcpayotp extends \Magento\Framework\App\Action\Action implements CsrfAwareActionInterface, HttpGetActionInterface, HttpPostActionInterface @@ -17,6 +17,13 @@ class Stcpayotp extends \Magento\Framework\App\Action\Action implements CsrfAwar */ protected $_checkoutSession; + protected $_cart; + + /** + * @var \Magento\Quote\Model\QuoteManagement + */ + protected $quoteManagement; + /** * Helper * @@ -24,30 +31,25 @@ class Stcpayotp extends \Magento\Framework\App\Action\Action implements CsrfAwar */ protected $_helper; - /** - * JSON Helper - * - * @var \Magento\Framework\Controller\Result\JsonFactory - */ - protected $_jsonFactory; - /** * @param \Magento\Framework\App\Action\Context $context, * @param \Magento\Checkout\Model\Session $checkoutSession, + * @param \Magento\Checkout\Model\Cart $cart, + * @param \Magento\Quote\Model\QuoteManagement $quoteManagement, * @param \Amazonpaymentservices\Fort\Helper\Data $helperFort, - * @param \Magento\Framework\Controller\Result\JsonFactory */ public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Checkout\Model\Session $checkoutSession, - \Amazonpaymentservices\Fort\Helper\Data $helperFort, - \Magento\Framework\Controller\Result\JsonFactory $jsonFactory + \Magento\Checkout\Model\Cart $cart, + \Magento\Quote\Model\QuoteManagement $quoteManagement, + \Amazonpaymentservices\Fort\Helper\Data $helperFort ) { parent::__construct($context); $this->_checkoutSession = $checkoutSession; - $this->_isScopePrivate = true; + $this->_cart = $cart; + $this->quoteManagement = $quoteManagement; $this->_helper = $helperFort; - $this->_jsonHelper = $jsonFactory; } public function createCsrfValidationException( @@ -63,11 +65,21 @@ public function validateForCsrf(RequestInterface $request): ?bool public function execute() { - $order = $this->_checkoutSession->getLastRealOrder(); + + $quote = $this->_cart->getQuote(); + $this->_helper->log(json_encode($quote->getData())); + $quote->reserveOrderId()->save(); + $orderId = $quote->getReservedOrderId(); + $mobileNumber = $this->getRequest()->getParam('mobileNumber'); $data = []; - $data = $this->_helper->stcPayRequestOtp($order, $mobileNumber); - $resultJson = $this->_jsonHelper->create(); - return $resultJson->setData($data); + $data = $this->_helper->stcPayRequestOtp($orderId, $mobileNumber); + $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); + $resultJson->setData($data); + return $resultJson; + } + public function getCacheLifetime() + { + return null; } } diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/Webhook.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/Webhook.php index bb00be1..7f07b20 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/Webhook.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Payment/Webhook.php @@ -56,7 +56,6 @@ public function __construct( parent::__construct($context); $this->_checkoutSession = $checkoutSession; $this->_orderConfig = $orderConfig; - $this->_isScopePrivate = true; $this->_helper = $helperFort; $this->_apsModel = $apsModel; $this->_resultJsonFactory = $resultJsonFactory; @@ -101,4 +100,8 @@ public function execute() $jsonResult->setData($result); return $jsonResult; } + public function getCacheLifetime() + { + return null; + } } diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Product/AddProductToCart.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Product/AddProductToCart.php index 7513b70..0009d79 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Product/AddProductToCart.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Product/AddProductToCart.php @@ -11,7 +11,7 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\App\Action\HttpPostActionInterface; -use Magento\Framework\Controller\Result\JsonFactory; +use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Currency; use Magento\Framework\Event\ManagerInterface; use Magento\Framework\Filter\LocalizedToNormalized; @@ -34,12 +34,6 @@ class AddProductToCart extends \Magento\Framework\App\Action\Action implements C */ protected $_helper; - /** - * JSON Helper - * - * @var \Magento\Framework\Controller\Result\JsonFactory - */ - protected $_jsonFactory; /** * @var \Magento\Checkout\Model\Cart @@ -82,7 +76,6 @@ class AddProductToCart extends \Magento\Framework\App\Action\Action implements C * @param Context $context * @param Session $checkoutSession * @param Data $helperFort - * @param JsonFactory * @param Cart $cart * @param StoreManagerInterface $storeManager * @param ProductRepositoryInterface $productRepository @@ -95,7 +88,6 @@ public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Checkout\Model\Session $checkoutSession, \Amazonpaymentservices\Fort\Helper\Data $helperFort, - \Magento\Framework\Controller\Result\JsonFactory $jsonFactory, \Magento\Checkout\Model\Cart $cart, StoreManagerInterface $storeManager, ProductRepositoryInterface $productRepository, @@ -106,9 +98,7 @@ public function __construct( ) { parent::__construct($context); $this->_checkoutSession = $checkoutSession; - $this->_isScopePrivate = true; $this->_helper = $helperFort; - $this->_jsonHelper = $jsonFactory; $this->cart = $cart; $this->storeManager = $storeManager; $this->productRepository = $productRepository; @@ -244,7 +234,12 @@ public function execute() $data['status'] = 'success'; $this->_helper->log('Apple Json : '.json_encode($data)); - $resultJson = $this->_jsonHelper->create(); - return $resultJson->setData($data); + $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); + $resultJson->setData($data); + return $resultJson;; + } + public function getCacheLifetime() + { + return null; } } diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Product/GetQuoteData.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Product/GetQuoteData.php index 1fc30b0..3cfe4d8 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Product/GetQuoteData.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Product/GetQuoteData.php @@ -7,7 +7,7 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\App\Action\HttpPostActionInterface; -use Magento\Framework\Controller\Result\JsonFactory; +use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Currency; use Magento\Sales\Model\Order; use Magento\Store\Model\StoreManagerInterface; @@ -27,12 +27,6 @@ class GetQuoteData extends \Magento\Framework\App\Action\Action implements CsrfA */ protected $_helper; - /** - * JSON Helper - * - * @var \Magento\Framework\Controller\Result\JsonFactory - */ - protected $_jsonFactory; /** * @var \Magento\Checkout\Model\Cart @@ -62,14 +56,12 @@ class GetQuoteData extends \Magento\Framework\App\Action\Action implements CsrfA /** * @param \Magento\Framework\App\Action\Context $context, * @param \Magento\Checkout\Model\Session $checkoutSession, - * @param \Amazonpaymentservices\Fort\Helper\Data $helperFort, - * @param \Magento\Framework\Controller\Result\JsonFactory + * @param \Amazonpaymentservices\Fort\Helper\Data $helperFort */ public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Checkout\Model\Session $checkoutSession, \Amazonpaymentservices\Fort\Helper\Data $helperFort, - \Magento\Framework\Controller\Result\JsonFactory $jsonFactory, \Magento\Checkout\Model\Cart $cart, StoreManagerInterface $storeManager, ProductRepositoryInterface $productRepository, @@ -78,9 +70,7 @@ public function __construct( ) { parent::__construct($context); $this->_checkoutSession = $checkoutSession; - $this->_isScopePrivate = true; $this->_helper = $helperFort; - $this->_jsonHelper = $jsonFactory; $this->cart = $cart; $this->storeManager = $storeManager; $this->productRepository = $productRepository; @@ -142,7 +132,12 @@ public function execute() $data['status'] = 'success'; $this->_helper->log('Apple Json : '.json_encode($data)); - $resultJson = $this->_jsonHelper->create(); - return $resultJson->setData($data); + $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); + $resultJson->setData($data); + return $resultJson; + } + public function getCacheLifetime() + { + return null; } } diff --git a/magento2-aps/Amazonpaymentservices/Fort/Controller/Vault/VaultDelete.php b/magento2-aps/Amazonpaymentservices/Fort/Controller/Vault/VaultDelete.php index ca2f5e7..4657d7b 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Controller/Vault/VaultDelete.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Controller/Vault/VaultDelete.php @@ -7,7 +7,7 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\App\Action\HttpPostActionInterface; -use Magento\Framework\Controller\Result\JsonFactory; +use Magento\Framework\Controller\ResultFactory; use Magento\Sales\Model\Order; class VaultDelete extends \Magento\Framework\App\Action\Action implements CsrfAwareActionInterface, HttpGetActionInterface, HttpPostActionInterface @@ -24,12 +24,6 @@ class VaultDelete extends \Magento\Framework\App\Action\Action implements CsrfAw */ protected $_helper; - /** - * JSON Helper - * - * @var \Magento\Framework\Controller\Result\JsonFactory - */ - protected $_jsonFactory; /** * @@ -53,15 +47,12 @@ public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Checkout\Model\Session $checkoutSession, \Amazonpaymentservices\Fort\Helper\Data $helperFort, - \Magento\Framework\Controller\Result\JsonFactory $jsonFactory, \Magento\Vault\Model\ResourceModel\PaymentToken $paymentToken, \Magento\Customer\Model\Session $modelSession ) { parent::__construct($context); $this->_checkoutSession = $checkoutSession; - $this->_isScopePrivate = true; $this->_helper = $helperFort; - $this->_jsonHelper = $jsonFactory; $this->paymentToken = $paymentToken; $this->modelSession = $modelSession; } @@ -88,7 +79,12 @@ public function execute() $details = json_decode($tokenData['details']); $data = $this->_helper->tokenChangeStatus($tokenData['gateway_token'], $details->orderId, 'INACTIVE'); } - $resultJson = $this->_jsonHelper->create(); - return $resultJson->setData($data); + $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); + $resultJson->setData($data); + return $resultJson; + } + public function getCacheLifetime() + { + return null; } } diff --git a/magento2-aps/Amazonpaymentservices/Fort/Helper/Data.php b/magento2-aps/Amazonpaymentservices/Fort/Helper/Data.php index 6ee68b5..8aa4bc0 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Helper/Data.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Helper/Data.php @@ -1600,7 +1600,7 @@ public function convertFortAmountCart($currencyCode) $amount = $this->_cart->getQuote()->getBaseGrandTotal(); } $decimal_points = $this->getCurrencyDecimalPoint($currencyCode); - $new_amount = round($amount, $decimal_points); + $new_amount = round((float)$amount, $decimal_points); $new_amount = $new_amount * (pow(10, $decimal_points)); return $new_amount; } @@ -3009,12 +3009,15 @@ public function getStcRequestParams($order, $integrationType) return ['url' => $gatewayUrl, 'params' => $gatewayParams]; } - public function stcPayRequestOtp($order, $mobileNumber) + public function stcPayRequestOtp($orderId, $mobileNumber) { $refId = 'MA'.round(microtime(true) * 1000); - //$refId = '006200334'; + //$refId = $orderId; + if ($this->getConfig('payment/aps_fort_stc/ref_id_as_order_id') == 1) + { + $refId = substr(uniqid($orderId.'APS'), 0, 40); + } $language = $this->getLanguage(); - $orderId = $order->getRealOrderId(); $baseCurrency = $this->getBaseCurrency(); $orderCurrency = $this->_storeManager->getStore()->getCurrentCurrencyCode(); $currency = $this->getFortCurrency($baseCurrency, $orderCurrency); @@ -3056,6 +3059,8 @@ public function getStcPaymentRequestParams($order, $postData = []) 'access_code' => $this->getMainConfigData('access_code'), 'merchant_reference' => $sessionData['refId'], 'language' => $language, + 'order_description' => $orderId, + 'merchant_extra' => $orderId ]; $baseCurrency = $this->getBaseCurrency(); diff --git a/magento2-aps/Amazonpaymentservices/Fort/Model/Plugin/CreditmemoAddData.php b/magento2-aps/Amazonpaymentservices/Fort/Model/Plugin/CreditmemoAddData.php index 174862a..5ec6dcf 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Model/Plugin/CreditmemoAddData.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Model/Plugin/CreditmemoAddData.php @@ -15,6 +15,8 @@ use Magento\Sales\Api\Data\CreditmemoInterface; use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Sales\Api\CreditmemoRepositoryInterface; +use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\App\Config\ScopeConfigInterface; /** * Amazonpaymentservices Payment Apple Model @@ -69,6 +71,16 @@ class CreditmemoAddData * @var ConfigProvider */ private $configProvider; + + /** + * @var StoreManagerInterface + */ + protected $_storeManager; + + /** + * @var ScopeConfigInterface + */ + protected $_scopeConfig; public function __construct( \Amazonpaymentservices\Fort\Helper\Data $apsHelper, @@ -78,7 +90,9 @@ public function __construct( SearchCriteriaBuilder $searchCriteriaBuilder, \Amazonpaymentservices\Fort\Model\PaymentcaptureFactory $paymentCaptureFactory, \Magento\Sales\Model\OrderRepository $order, - \Magento\Tax\Model\Config $configProvider + \Magento\Tax\Model\Config $configProvider, + \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig ) { $this->_helper = $apsHelper; $this->_request = $request; @@ -88,6 +102,8 @@ public function __construct( $this->_paymentCaptureFactory = $paymentCaptureFactory; $this->_order = $order; $this->configProvider = $configProvider; + $this->_storeManager = $storeManager; + $this->_scopeConfig = $scopeConfig; } public function beforeSave( @@ -173,7 +189,15 @@ public function beforeSave( } } - $currencyCode = $order->getOrderCurrencyCode(); + $configCurrency = $this->_scopeConfig->getValue('payment/aps_fort/gateway_currency'); + $baseCurrency = $this->_storeManager->getStore()->getBaseCurrencyCode(); + $this->_helper->log("\n\n 'Config Currency : ".$configCurrency."\n\n"); + $this->_helper->log("\n\n 'Base Currency : ".$baseCurrency."\n\n"); + if ($configCurrency === "base") { + $currencyCode = $baseCurrency; + } else { + $currencyCode = $order->getOrderCurrencyCode(); + } $paymentMethod = $order->getPayment()->getMethod(); if ($paymentMethod == \Amazonpaymentservices\Fort\Model\Method\Valu::CODE) { diff --git a/magento2-aps/Amazonpaymentservices/Fort/Plugin/SwitchSameSite.php b/magento2-aps/Amazonpaymentservices/Fort/Plugin/SwitchSameSite.php index f1d3c9b..602bd31 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/Plugin/SwitchSameSite.php +++ b/magento2-aps/Amazonpaymentservices/Fort/Plugin/SwitchSameSite.php @@ -2,48 +2,14 @@ namespace Amazonpaymentservices\Fort\Plugin; -use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Framework\HTTP\Header; use Magento\Framework\Stdlib\Cookie\PhpCookieManager; use Magento\Framework\Stdlib\Cookie\PublicCookieMetadata; -use Magento\Store\Model\ScopeInterface; -use Amazonpaymentservices\Fort\Validator\SameSite; class SwitchSameSite { - const CONFIG_PATH = 'web/cookie/samesite'; - const CONFIG_AFFECTED_KEYS = 'web/cookie/affected_keys'; - /** - * @var SameSite - */ - private $validator; - /** - * @var Header - */ - private $header; - /** - * @var ScopeConfigInterface - */ - private $scopeConfig; - + const AFFECTED_KEYS = 'PHPSESSID,form_key,private_content_version,X-Magento-Vary'; private $affectedKeys = []; - /** - * SwitchSameSite constructor. - * @param Header $header - * @param ScopeConfigInterface $scopeConfig - * @param SameSite $validator - */ - public function __construct( - Header $header, - ScopeConfigInterface $scopeConfig, - SameSite $validator - ) { - $this->validator = $validator; - $this->header = $header; - $this->scopeConfig = $scopeConfig; - } - /** * @param PhpCookieManager $subject * @param string $name @@ -53,21 +19,13 @@ public function __construct( */ public function beforeSetPublicCookie( PhpCookieManager $subject, - $name, - $value, + $name, + $value, PublicCookieMetadata $metadata = null ) { if ($this->isAffectedKeys($name)) { - $agent = $this->header->getHttpUserAgent(); - $sameSite = $this->validator->shouldSendSameSiteNone($agent); - if ($sameSite === false) { - $metadata - ->setSecure(true) - ->setSameSite('None'); - } else { - $metadata->setSecure(true); - $metadata->setSameSite('None'); - } + $metadata->setSecure(true); + $metadata->setSameSite('None'); } return [$name, $value, $metadata]; @@ -76,10 +34,8 @@ public function beforeSetPublicCookie( private function isAffectedKeys($name) { if (!count($this->affectedKeys)) { - $affectedKeys = $this->scopeConfig->getValue(self::CONFIG_AFFECTED_KEYS, ScopeInterface::SCOPE_STORE); - if (!empty($affectedKeys)) { - $this->affectedKeys = explode(',', strtolower($affectedKeys)); - } + $affectedKeys = self::AFFECTED_KEYS; + $this->affectedKeys = explode(',', strtolower($affectedKeys)); } return in_array(strtolower($name), $this->affectedKeys); diff --git a/magento2-aps/Amazonpaymentservices/Fort/composer.json b/magento2-aps/Amazonpaymentservices/Fort/composer.json index c7734a3..d36f606 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.4.8", + "version": "2.4.9", "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 bee5eeb..0f77b87 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/etc/adminhtml/system.xml +++ b/magento2-aps/Amazonpaymentservices/Fort/etc/adminhtml/system.xml @@ -415,16 +415,21 @@ Magento\Config\Model\Config\Source\Yesno payment/aps_fort_stc/active + + + Magento\Config\Model\Config\Source\Yesno + payment/aps_fort_stc/token + STC Integration Type Amazonpaymentservices\Fort\Model\Config\Source\Stcintegrationtype payment/aps_fort_stc/integration_type - - + + Magento\Config\Model\Config\Source\Yesno - payment/aps_fort_stc/token + payment/aps_fort_stc/ref_id_as_order_id diff --git a/magento2-aps/Amazonpaymentservices/Fort/etc/module.xml b/magento2-aps/Amazonpaymentservices/Fort/etc/module.xml index 2732ad6..3a6654f 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/etc/module.xml +++ b/magento2-aps/Amazonpaymentservices/Fort/etc/module.xml @@ -10,13 +10,14 @@ **/ --> - + + diff --git a/magento2-aps/Amazonpaymentservices/Fort/etc/webapi_rest/di.xml b/magento2-aps/Amazonpaymentservices/Fort/etc/webapi_rest/di.xml new file mode 100644 index 0000000..38b8f2b --- /dev/null +++ b/magento2-aps/Amazonpaymentservices/Fort/etc/webapi_rest/di.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file 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 4b0f1e7..0dbd763 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 @@ -117,7 +117,7 @@ } else { $("#applePayCart").remove(); } - + var cartData; $("#applePayCart").on("click",function(){ $.ajax({ url: 'getQuoteData(); ?>', @@ -126,12 +126,24 @@ dataType: 'json', success:function(data) { if ( data.status === 'success' ) { - iniApplePay(data.data); + //iniApplePay(data.data); + cartData = data.data; } else { console.log( data.error_msg ); } } }); + var delay = (function() { + var timer = 0; + return function(callback, ms) { + clearTimeout(timer); + timer = setTimeout(callback, ms); + }; + })(); + delay(function() { + console.log('Wait for server response'); + }, 1000); + iniApplePay(cartData); }); function iniApplePay (data) { var shipData = {}; @@ -181,6 +193,7 @@ }; var supportedNetworks = supportedNetworks.split(','); + new Promise(resolve => setTimeout(resolve, 1000)); if(supportedNetworks.indexOf('mada') >= 0) { var session = new ApplePaySession(5, paymentRequest); } else { 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 5a522ee..c1b3729 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 @@ -125,7 +125,7 @@ if ($checkActive) { $(".apple-err").text(''); $("#applePayProd").remove(); } - + var cartData; $("#applePayProd").on("click",function(){ var form = $('#product_addtocart_form'); var request = []; @@ -140,12 +140,24 @@ if ($checkActive) { dataType: 'json', success:function(data) { if ( data.status === 'success' ) { - iniApplePay(data.data); + //iniApplePay(data.data); + cartData = data.data; } else { console.log( data.error_msg ); } } }); + var delay = (function() { + var timer = 0; + return function(callback, ms) { + clearTimeout(timer); + timer = setTimeout(callback, ms); + }; + })(); + delay(function() { + console.log('Wait for server response'); + }, 1000); + iniApplePay(cartData); }); function iniApplePay (data) { var shipData = {}; @@ -192,6 +204,7 @@ if ($checkActive) { }; var supportedNetworks = supportedNetworks.split(','); + new Promise(resolve => setTimeout(resolve, 1000)); if(supportedNetworks.indexOf('mada') >= 0) { var session = new ApplePaySession(5, paymentRequest); } else { diff --git a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/css/checkout-page.css b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/css/checkout-page.css index fdbd8a6..289572e 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/css/checkout-page.css +++ b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/css/checkout-page.css @@ -11,6 +11,7 @@ background-size: 60% !important; background-repeat: no-repeat !important; z-index: 999; + display: block !important; } .apple-pay-buy { 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 8859d00..8352ca2 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 @@ -10,6 +10,7 @@ define( [ 'ko', 'jquery', + 'uiRegistry', 'Magento_Checkout/js/view/payment/default', 'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/model/full-screen-loader', @@ -18,7 +19,7 @@ define( 'Magento_Customer/js/customer-data', 'Magento_Catalog/js/price-utils' ], - function (ko, $, Component, quote, fullScreenLoader, setPaymentInformationAction, placeOrder, customerData, priceUtils) { + function (ko, $, registry, Component, quote, fullScreenLoader, setPaymentInformationAction, placeOrder, customerData, priceUtils) { 'use strict'; var promise = ''; $("#applePay").addClass(window.checkoutConfig.payment.apsFort.aps_apple.appleButtonClass); @@ -54,13 +55,23 @@ define( return this; }, redirectAfterPlaceOrder: false, - + + isApplePayChecked: function () { + var applePayRadio = document.getElementById("aps_apple"); + return applePayRadio.checked; + }, beforeApplePay: function () { document.getElementById("applePay").disabled = false; if (window.ApplePaySession) { if (ApplePaySession.canMakePayments) { $("#applePay").addClass(window.checkoutConfig.payment.apsFort.aps_apple.appleButtonClass); - document.getElementById("applePay").style.display = "block"; + if (this.isApplePayChecked()) { + document.getElementById("applePay").style.display = "block"; + } + if($('.bss-onestepcheckout').length && this.isApplePayChecked()){ + var button = document.getElementsByClassName('btn-placeorder')[0]; + button.style = "display:none;"; + } } else { $(".apple-err").text(''); $("#applePay").remove(); @@ -71,9 +82,18 @@ define( $("#applePay").remove(); $(".payment-method.apple-pay").remove(); } - }, afterPlaceOrder : function () { + if(registry) { + var shippingAddressComponent = registry.get('checkout.steps.shipping-step.shippingAddress'); + var validateShippingInfomation; + if ($('.selected-store-pickup').length) { + validateShippingInfomation = true; + } else { + validateShippingInfomation = shippingAddressComponent.validateShippingInformation(); + } + if(!validateShippingInfomation) return false; + } this.placeOrder(); var totals = quote.totals(); var runningAmount = (totals ? totals : quote)['subtotal']; @@ -91,7 +111,7 @@ define( var runningPP = 0; var displayPP = 0; if (window.checkoutConfig.payment.apsFort.aps_apple.shippingconfig == 0) { - + if (window.checkoutConfig.payment.apsFort.aps_apple.shippingdisplayconfig == 1) { displayPP = (totals ? totals : quote)['shipping_amount']; } else if (window.checkoutConfig.payment.apsFort.aps_apple.shippingdisplayconfig == 2) { @@ -118,7 +138,7 @@ define( displayPP = 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, ''); @@ -129,7 +149,7 @@ define( discountAmount = priceUtils.formatPrice(discountAmount, priceFormat, false); discountAmount = discountAmount.replace(/,/g, ''); discountAmount = parseFloat(discountAmount); - + var currencyCode = (totals ? totals : quote)['quote_currency_code']; var runningTotal = function () { @@ -150,7 +170,7 @@ define( var shippingAddress = quote.shippingAddress(); //var countryCode = (shippingAddress ? shippingAddress : quote)['countryId']; var countryCode = window.checkoutConfig.payment.apsFort.aps_apple.storeCountryCode; - + var newItemArray = []; var x = 0; var subTotal = 0.00; @@ -158,7 +178,7 @@ define( subTotal = subTotal + parseFloat(arrayItem.product_price_value * arrayItem.qty); }); - + newItemArray[x++] = {type: 'final',label: 'Subtotal', amount: runningAmount}; if (discountAmount > parseFloat(0)) { newItemArray[x++] = {type: 'final',label: 'Discount', amount: discountAmount }; @@ -167,7 +187,7 @@ define( 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'}]; @@ -221,7 +241,7 @@ define( session.onpaymentmethodselected = function (event) { var newTotal = { type: 'final', label: storeName, amount: runningTotal() }; - + session.completePaymentMethodSelection(newTotal, newItemArray); } var paymentData = {}; @@ -245,7 +265,7 @@ define( session.oncancel = function (event) { window.location.href = window.checkoutConfig.payment.apsFort.aps_apple.cancelUrl; } - + function sendPaymentToken(paymentToken) { return new Promise(function (resolve, reject) { @@ -256,7 +276,7 @@ define( session.abort(); }); } - + function sendPaymentToAps(data) { var formId = 'frm_aps_fort_apple_payment'; @@ -275,15 +295,21 @@ define( value: v }).appendTo($('#'+formId)); }); - + $('#'+formId).attr('action', window.checkoutConfig.payment.apsFort.aps_apple.appleToAps); $('#'+formId).submit(); } - + session.begin(); }, isChecked: ko.computed(function () { var checked = quote.paymentMethod() ? quote.paymentMethod().method : null; + if($('.bss-onestepcheckout').length){ + if(document.getElementById("applePay") && checked == 'aps_apple'){ + var button = document.getElementsByClassName('btn-placeorder')[0]; + button.style = "display:none;"; + } + } if (window.checkoutConfig.payment.apsFort.configParams.gatewayCurrency == 'front') { if (checked) { $('.totals.charge').hide(); 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 a122ec3..04e84b0 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 @@ -273,6 +273,7 @@ define( $('.cc-form-error').remove(); if (customer.isLoggedIn() && window.checkoutConfig.payment.apsFort.aps_fort_vault.hasOwnProperty('data') == true && $("input[name='vaultHash']:checked").val() == undefined) { $('.error-ccform').html($.mage.__('Please select a card.')); + this.removeLoader(); return false; } else if (customer.isLoggedIn() && window.checkoutConfig.payment.apsFort.aps_fort_vault.hasOwnProperty('data') == false) { vault = 'newCard' ; @@ -362,6 +363,7 @@ define( if (vault != 'newCard') { if ($("input[value='"+vault+"']").parent('.vault').find('.input-text').val().length === 0) { $("input[value='"+vault+"']").parent('.vault').find('.input-text').after(''+$.mage.__('CVV is mandatory')+''); + this.removeLoader(); return false; } else { this.placeOrder(); @@ -387,6 +389,12 @@ define( } } }, + removeLoader: function(){ + var loadingMask = document.querySelector('.loading-mask'); + if (loadingMask) { + loadingMask.style.display = 'none'; + } + }, getInstallment: function () { if (window.checkoutConfig.payment.apsFort.aps_installment.integrationType == 'embeded') { $('.cvv-error').remove(); diff --git a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/template/payment/aps-apple.html b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/template/payment/aps-apple.html index 7a002ab..6dc444e 100755 --- a/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/template/payment/aps-apple.html +++ b/magento2-aps/Amazonpaymentservices/Fort/view/frontend/web/template/payment/aps-apple.html @@ -6,7 +6,14 @@ * @package Amazonpaymentservices_Fort */ --> -
+
+
+ +
@@ -24,7 +31,8 @@ type="submit" id="applePay" data-bind=" click: afterPlaceOrder, - attr: {title: $t('Apple Pay')},, + attr: {title: $t('Apple Pay')}, + visible: isApplePayChecked, afterRender: beforeApplePay " disabled>