Skip to content

Commit

Permalink
Merge pull request #70 from payfort/Release-Feature
Browse files Browse the repository at this point in the history
v2.6.0 release
  • Loading branch information
cetozgen authored Dec 14, 2023
2 parents 6c7c46c + dfd8e4b commit d98d69f
Show file tree
Hide file tree
Showing 42 changed files with 795 additions and 116 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <br/> * 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 <br/> * Fix - Cron check status to consider Success scenarios <br/> * Fix - Response handling to consider order cancellation only if order state is in list of failure or pending to avoid cancelling success cases. <br/> * Fix - ApplePay discount values fix|
| 2.5.0 | * New - Tabby is added as a new payment option |
| 2.4.9 | * Fix - SameSite cookie handling <br/> * Fix - ApplePay is now enabled with Magento payment option checkbox <br/> * Fix - Refund considers Base/Front currencies <br/> * Fix - STCPay to use order id which is enabled via configuration <br/> * 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 <br/> * Fix - ApplePay url validation is added <br/> * Fix - item id is considered during subscription product cancellation|
Expand Down
Binary file removed magento2-aps-2.4.9.zip
Binary file not shown.
Binary file renamed magento2-aps-2.5.0.zip → magento2-aps-2.6.0.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function __construct(
$this->_orderConfig = $orderConfig;
$this->httpContext = $httpContext;
$this->_helper = $helperFort;
$this->_isScopePrivate = true;
}

/**
Expand Down Expand Up @@ -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();
Expand Down
29 changes: 28 additions & 1 deletion magento2-aps/Amazonpaymentservices/Fort/Block/Success.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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";
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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');
Expand All @@ -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']);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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'],
Expand All @@ -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'],
Expand All @@ -230,6 +233,7 @@ public function execute()
],
false
);

$data['data']['total'] = str_replace(",", "", $data['data']['total']);

$data['status'] = 'success';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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'],
Expand All @@ -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'],
Expand Down
21 changes: 15 additions & 6 deletions magento2-aps/Amazonpaymentservices/Fort/Cron/Paymentstatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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.');
}
}
}
Loading

0 comments on commit d98d69f

Please sign in to comment.