Skip to content

Commit 98a14db

Browse files
Release/2.5.2 new (#127)
* OSF-22 Change default value of enhanced data mode to false. * OSF-21 Added reason code mapping. * OSF-21 Added reason code mapping. * OSF-56 Made changes for compatibility with adyen v9. * OSF-56 Made changes for compatibility with adyen v9. * OSF-59 Cron Config fix * OSF-60 Added 3DS mapping for Adyen * OSF-60 Added 3DS mapping for Adyen * OSF-60 Added 3DS mapping for Adyen * Bump up version * OSF-64 added ECI and mapping from OSF-60 * OSF-64 added ECI and mapping from OSF-60 (for failed 3ds) * OSF-64 fixed array merging. * Bump up version * OSF-66 resultCode mapping in case of 3DS failure * OSF-67 more adyen CC mapping * OSF-67 more adyen CC mapping * Bump up version * OSF-48 Cron Refactor * OSF-48 Cron Refactor * OSF-48 Cron Refactor * OSF-48 Cron Refactor * OSF-48 Cron Refactor * OSF-48 Cron Refactor * OSF-48 Cron Refactor * OSF-48 Cron Refactor * OSF-68 added Applepay method for Adyen. * OSF-68 added Applepay method for Adyen. * OSF-48 Cron Refactor * backwards compatibility with order forter tab * handling error in decline action. * if statement for phtml template * error handlings * order holding in Cron class * optimization * Improvement * more mapping * more fixing * more fixing * more fixing * Improvement * Improvement * Improvements * OSF-48 more fixings * OSF-48 more fixing * OSF-48 more fixing * Bump up version * restricted to at least adyen 8.22.6 * OSF-76 Removed payment action failure order validation call * OSF-76 Removed payment action failure order validation call * OSF-77 -removed orderFLow endpoint requests * small fix * small fix * OSF-75 mappings * OSF-79 Stripe integration * OSF-79 Stripe integration * OSF-79 Stripe integration * OSF-79 Stripe integration * OSF-79 Stripe integration * OSF-79 Stripe integration * OSF-79 Stripe integration * OSF-79 Stripe integration * OSF-79 Stripe integration * OSF-79 Stripe integration * OSF-79 Stripe integration * OSF-79 Stripe integration * OSF-79 Stripe integration * OSF-79 Stripe integration * OSF-79 Stripe integration * OSF-82 fix * OSF-82 more fixes on recommendations * OSF-82 more fixes on recommendations * Bump up version 2.5.2 --------- Co-authored-by: ioancatanoaiaosf <57447552+ioancatanoaiaosf@users.noreply.github.com> Co-authored-by: Ioan Catanoaia <ioan.catanoaia@osf-global.com>
1 parent 89c508d commit 98a14db

File tree

16 files changed

+379
-69
lines changed

16 files changed

+379
-69
lines changed

Cron/ForterQueue.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ public function execute()
139139
continue;
140140
}
141141
$payment = $order->getPayment();
142+
143+
if (!$payment) {
144+
continue;
145+
}
146+
142147
$method = $payment->getMethod();
143148

144149
// let bind the relevent store in case of multi store settings
@@ -157,7 +162,7 @@ public function execute()
157162
continue;
158163
}
159164

160-
if ($this->forterConfig->getIsPaymentMethodAccepted($payment->getMethod()) && !$payment->getCcTransId()) {
165+
if ($this->forterConfig->getIsPaymentMethodAccepted($payment->getMethod()) && !$this->forterConfig->getIsReadyForForter($payment)) {
161166
if ($this->forterConfig->isHoldingOrdersEnabled()) {
162167
$order->canHold() ?? $order->hold()->save();
163168
}
@@ -298,4 +303,4 @@ private function handleForterResponse($order, $response, $item = null)
298303
}
299304
}
300305
}
301-
}
306+
}

Model/Config.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,11 @@ public function acceptedPaymentMethods($scope = null, $scopeId = null)
889889
return explode(',', $this->getConfigValue('general/accepted_payment_methods', $scope, $scopeId));
890890
}
891891

892+
public function noPreAuthPaymentMethods($scope = null, $scopeId = null)
893+
{
894+
return explode(',', $this->getConfigValue('general/no_preauth_payment_methods', $scope, $scopeId));
895+
}
896+
892897
/**
893898
* @param $scope
894899
* @param $scopeId
@@ -904,4 +909,23 @@ public function getIsPaymentMethodAccepted($paymentMethod)
904909
}
905910
return false;
906911
}
907-
}
912+
913+
public function getIsReadyForForter($payment)
914+
{
915+
if (strpos($payment->getMethod(), 'stripe') !== false) {
916+
return $payment->getLastTransId();
917+
}
918+
919+
return $payment->getCcTransId();
920+
}
921+
922+
public function getNoPreAuthPaymentMethod($paymentMethod)
923+
{
924+
foreach ($this->noPreAuthPaymentMethods() as $noPreAuthPaymentMethod) {
925+
if (strpos($paymentMethod, $noPreAuthPaymentMethod) !== false) {
926+
return true;
927+
}
928+
}
929+
return false;
930+
}
931+
}

Model/ForterLogger.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ public function __construct(ForterConfig $forterConfig) {
2929
public function SendLog(ForterLoggerMessage $data) {
3030
try {
3131
$json = $data->ToJson();
32-
$requestOps = [];
33-
$requestOps['x-forter-siteid'] = $this->forterConfig->getSiteId();
34-
$requestOps['api-version'] = $this->forterConfig->getApiVersion();
35-
$requestOps['x-forter-extver'] = $this->forterConfig->getModuleVersion();
36-
$requestOps['x-forter-client'] = $this->forterConfig->getMagentoFullVersion();
37-
$requestOps['Content-Type'] = 'application/json';
38-
$requestOps['Accept'] = 'application/json';
39-
$requestOps['Authorization'] =['Basic '.$this->forterConfig->getSecretKey().':'];
40-
$requestOps['json'] = $json;
32+
// $requestOps = [];
33+
// $requestOps['x-forter-siteid'] = $this->forterConfig->getSiteId();
34+
// $requestOps['api-version'] = $this->forterConfig->getApiVersion();
35+
// $requestOps['x-forter-extver'] = $this->forterConfig->getModuleVersion();
36+
// $requestOps['x-forter-client'] = $this->forterConfig->getMagentoFullVersion();
37+
// $requestOps['Content-Type'] = 'application/json';
38+
// $requestOps['Accept'] = 'application/json';
39+
// $requestOps['Authorization'] =['Basic '.$this->forterConfig->getSecretKey().':'];
40+
// $requestOps['json'] = $json;
4141
$this->forterConfig->log('send log request: ' .$this->BASE_URL.'/magento/orderFlow/'.$this->forterConfig->getSiteId().'/'.$data->orderId);
42-
$response = $this->httpClient->request('post','/magento/orderFlow/'.$this->forterConfig->getSiteId().'/'.$data->orderId, $requestOps);
43-
$this->forterConfig->log(sprintf('send log status: %s', $response->getStatusCode()));
42+
// $response = $this->httpClient->request('post','/magento/orderFlow/'.$this->forterConfig->getSiteId().'/'.$data->orderId, $requestOps);
43+
// $this->forterConfig->log(sprintf('send log status: %s', $response->getStatusCode()));
4444
} catch (\Exception $e) {
4545
$this->forterConfig->log('Error:' . $e->getMessage());
4646
}

Model/RequestBuilder/Cart.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class Cart
2929
*/
3030
private $giftCardPrepere;
3131

32-
3332
/**
3433
* Cart constructor.
3534
* @param CategoryFactory $categoryFactory
@@ -49,9 +48,13 @@ public function __construct(
4948
*/
5049
public function getTotalAmount($order)
5150
{
51+
$amountUSD = null;
52+
if ($order->getOrderCurrency()->getCurrencyCode() === 'USD') {
53+
$amountUSD = number_format($order->getGrandTotal(), 2, '.');
54+
}
5255
return [
53-
"amountUSD" => null,
54-
"amountLocalCurrency" => strval($order->getGrandTotal()),
56+
"amountUSD" => $amountUSD,
57+
"amountLocalCurrency" => strval(number_format($order->getGrandTotal(), 2,'.')),
5558
"currency" => $order->getOrderCurrency()->getCurrencyCode() . ""
5659
];
5760
}
@@ -81,11 +84,11 @@ public function generateCartItems($order)
8184
$singleCartItem = [
8285
"basicItemData" => [
8386
"price" => [
84-
"amountLocalCurrency" => strval($item->getPrice()),
87+
"amountLocalCurrency" => strval(number_format($item->getPrice(), 2, '.', '')),
8588
"currency" => $order->getOrderCurrency()->getCurrencyCode() . ""
8689
],
8790
"value" => [
88-
"amountLocalCurrency" => strval($item->getPrice()),
91+
"amountLocalCurrency" => strval(number_format($item->getPrice(), 2, '.', '')),
8992
"currency" => $order->getOrderCurrency()->getCurrencyCode() . ""
9093
],
9194
"productId" => $item->getProductId(),

Model/RequestBuilder/Payment.php

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
use Forter\Forter\Model\RequestBuilder\Customer as CustomerPreper;
1414
use Forter\Forter\Model\RequestBuilder\Payment\PaymentMethods;
15+
use Forter\Forter\Model\ThirdParty\Stripe\StripePayment;
1516

1617
/**
1718
* Class Payment
@@ -29,17 +30,21 @@ class Payment
2930
*/
3031
protected $customerPreper;
3132

33+
protected $stripePayment;
34+
3235
/**
3336
* Payment constructor.
3437
* @param PaymentMethods $paymentMethods
3538
* @param CustomerPreper $customerPreper
3639
*/
3740
public function __construct(
3841
PaymentMethods $paymentMethods,
39-
CustomerPreper $customerPreper
42+
CustomerPreper $customerPreper,
43+
StripePayment $stripePayment
4044
) {
4145
$this->paymentMethods = $paymentMethods;
4246
$this->customerPreper = $customerPreper;
47+
$this->stripePayment = $stripePayment;
4348
}
4449

4550
/**
@@ -77,11 +82,13 @@ public function generatePaymentInfo($order)
7782
$cardDetails = $this->paymentMethods->getBraintreeDetails($payment);
7883
} elseif (strpos($payment_method, 'mercadopago') !== false) {
7984
$cardDetails = $this->paymentMethods->getMercadopagoDetails($payment);
85+
} elseif (strpos($payment_method, 'stripe') !== false) {
86+
$cardDetails = $this->paymentMethods->getStripePaymentDetails($payment, $this->stripePayment->getPaymentData($order));
8087
} else {
8188
$cardDetails = $this->paymentMethods->preferCcDetails($payment);
8289
}
8390

84-
if (array_key_exists("expirationMonth", $cardDetails) || array_key_exists("expirationYear", $cardDetails) || array_key_exists("lastFourDigits", $cardDetails)) {
91+
if (array_key_exists("expirationMonth", $cardDetails ?? []) || array_key_exists("expirationYear", $cardDetails ?? []) || array_key_exists("lastFourDigits", $cardDetails ?? [])) {
8592
$paymentData["creditCard"] = $cardDetails;
8693
}
8794

@@ -94,13 +101,42 @@ public function generatePaymentInfo($order)
94101
$paymentData['applePay'] = $cardDetails;
95102
unset($paymentData["creditCard"]);
96103
}
104+
if (strpos($payment->getMethod(), 'stripe_payments') !== false) {
105+
$stripeData = json_decode($payment->getAdditionalInformation('stripeChargeData') ?? '');
106+
if ($stripeData && isset($stripeData->payment_method)) {
107+
$paymentData['tokenizedCard'] = $cardDetails;
108+
unset($paymentData["creditCard"]);
109+
}
110+
111+
if ($stripeData && isset($stripeData->payment_method_details)
112+
&& isset($stripeData->payment_method_details->card)
113+
&& isset($stripeData->payment_method_details->card->wallet)
114+
&& isset($stripeData->payment_method_details->card->wallet->type)
115+
&& $stripeData->payment_method_details->card->wallet->type === 'google_pay') {
116+
117+
$paymentData['androidPay'] = $cardDetails;
118+
unset($paymentData["tokenizedCard"]);
119+
unset($paymentData["creditCard"]);
120+
}
121+
122+
if ($stripeData && isset($stripeData->payment_method_details)
123+
&& isset($stripeData->payment_method_details->card)
124+
&& isset($stripeData->payment_method_details->card->wallet)
125+
&& isset($stripeData->payment_method_details->card->wallet->type)
126+
&& $stripeData->payment_method_details->card->wallet->type === 'apple_pay') {
127+
128+
$paymentData['applePay'] = $cardDetails;
129+
unset($paymentData["tokenizedCard"]);
130+
unset($paymentData["creditCard"]);
131+
}
132+
}
97133

98134
// Attempt to set tokenized card information if available
99-
if ( !isset($paymentData["creditCard"]) && $payment->getAdditionalInformation('forter_cc_token') && $payment->getAdditionalInformation('forter_cc_bin') ) {
100-
$paymentData["tokenizedCard"] = array(
135+
if (!isset($paymentData["creditCard"]) && $payment->getAdditionalInformation('forter_cc_token') && $payment->getAdditionalInformation('forter_cc_bin')) {
136+
$paymentData["tokenizedCard"] = [
101137
'bin' => $payment->getAdditionalInformation('forter_cc_bin'),
102138
'token' => $payment->getAdditionalInformation('forter_cc_token')
103-
);
139+
];
104140
}
105141
}
106142

@@ -113,4 +149,4 @@ public function generatePaymentInfo($order)
113149

114150
return [$paymentData];
115151
}
116-
}
152+
}

Model/RequestBuilder/Payment/PaymentMethods.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
use Forter\Forter\Model\Config as ForterConfig;
1414
use Magento\Customer\Model\Session;
15+
use Forter\Forter\Model\ThirdParty\Stripe;
1516

1617
/**
1718
* Class Payment
@@ -35,17 +36,21 @@ class PaymentMethods
3536
'authorizationProcessedWith3DS' => 'boolean'
3637
];
3738

39+
protected $stripePaymentDataMapper;
40+
3841
/**
3942
* @method __construct
4043
* @param Session $customerSession
4144
* @param ForterConfig $forterConfig
4245
*/
4346
public function __construct(
4447
Session $customerSession,
45-
ForterConfig $forterConfig
48+
ForterConfig $forterConfig,
49+
Stripe\PaymentDataMapper $stripePaymentDataMapper
4650
) {
4751
$this->customerSession = $customerSession;
4852
$this->forterConfig = $forterConfig;
53+
$this->stripePaymentDataMapper = $stripePaymentDataMapper;
4954
}
5055

5156
public function getPaypalDetails($payment)
@@ -252,6 +257,7 @@ public function getAdyenDetails($payment)
252257
}
253258
if (isset($additonal_data['refusalReasonRaw'])) {
254259
$detailsArray['verificationResults']['processorResponseText'] = $additonal_data['refusalReasonRaw'];
260+
$detailsArray['verificationResults']['processorResponseCode'] = $additonal_data['refusalReasonRaw'];
255261
}
256262
if (isset($additonal_data['eci'])) {
257263
$detailsArray['verificationResults']['eciValue']= $additonal_data['eci'] === 'N/A' ? '' : $additonal_data['eci'];
@@ -327,6 +333,7 @@ public function getAdyenDetails($payment)
327333
$processorResponseText = $payment->getAdditionalInformation('adyen_refusal_reason_raw');
328334
if ($processorResponseText) {
329335
$detailsArray['verificationResults']['processorResponseText'] = $processorResponseText;
336+
$detailsArray['verificationResults']['processorResponseCode'] = $processorResponseText;
330337
}
331338

332339
$preferCcDetailsArray = $this->preferCcDetails($payment, $detailsArray);
@@ -409,6 +416,7 @@ public function getAdyenGooglePayDetails($payment, $order)
409416

410417
if (isset($additonal_data['refusalReasonRaw'])) {
411418
$detailsArray['verificationResults']['processorResponseText']= $additonal_data['refusalReasonRaw'];
419+
$detailsArray['verificationResults']['processorResponseCode']= $additonal_data['refusalReasonRaw'];
412420
}
413421

414422
if (isset($additonal_data['merchantReference'])) {
@@ -422,6 +430,21 @@ public function getAdyenGooglePayDetails($payment, $order)
422430
return $mergedArray;
423431
}
424432

433+
public function getStripePaymentDetails($payment, $stripePayment)
434+
{
435+
$detailsArray = [];
436+
437+
$detailsArray = $this->stripePaymentDataMapper->dataMapper($payment, $detailsArray, $stripePayment);
438+
439+
if (isset($stripePayment)) {
440+
$payment->setAdditionalInformation('stripeChargeData',json_encode($stripePayment));
441+
}
442+
$preferCcDetailsArray = $this->preferCcDetails($payment, $detailsArray);
443+
$mergedArray = $this->mergeArrays($preferCcDetailsArray, $detailsArray);
444+
445+
return $mergedArray;
446+
}
447+
425448
/**
426449
* Get mapped forter field
427450
* @return mixed

Model/ThirdParty/Adyen/Gateway/Request/RecommendationsDataBuilder.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class RecommendationsDataBuilder implements BuilderInterface
1414
protected const REQUEST_SCA_EXEMPTION_TRA = "REQUEST_SCA_EXEMPTION_TRA";
1515
protected const REQUEST_SCA_EXCLUSION_MOTO = "REQUEST_SCA_EXCLUSION_MOTO";
1616
protected const REQUEST_SCA_EXEMPTION_CORP = "REQUEST_SCA_EXEMPTION_CORP";
17+
protected const CANCELED_ORDER_PAYMENT_MESSAGE = "Canceled order online";
1718

1819
/**
1920
* @var ScopeConfigInterface
@@ -55,15 +56,20 @@ public function build(array $buildSubject): ?array
5556
$payment = $paymentDataObject->getPayment();
5657

5758
// Ensuring payment method is adyen_cc before proceeding
58-
if ($payment && $payment->getMethod() === "adyen_cc") {
59+
if ($payment && ($payment->getMethod() === "adyen_cc" || $payment->getMethod() === "adyen_cc_vault") && !$payment->getLastTransId() && !$payment->getOrder()->getState()) {
60+
61+
$message = $payment->getMessage() ? $payment->getMessage()->getText() : null;
62+
if ($message === self::CANCELED_ORDER_PAYMENT_MESSAGE) {
63+
return $request;
64+
}
65+
5966
$order = $payment->getOrder();
6067

6168
$forterEntity = $this->entityHelper->getForterEntityByIncrementId($order->getIncrementId());
6269
if (!$forterEntity) {
63-
return null;
70+
return $request;
6471
}
6572

66-
$forterResponse = $payment->getOrder()->getForterResponse();
6773
$forterResponse = $forterEntity->getForterResponse();
6874
//de facut
6975
if ($forterResponse !== null) {
@@ -101,4 +107,4 @@ protected function isForterPreAuth()
101107
{
102108
return $this->scopeConfig->getValue('forter/immediate_post_pre_decision/pre_post_select', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
103109
}
104-
}
110+
}

0 commit comments

Comments
 (0)