Skip to content

Commit 1fe0e3e

Browse files
committed
Merge branch 'release/v6.4.0' into 'master'
release/v6.4.0 into master See merge request agence-dnd/marketplace/magento-2/external/module-checkout-magento2-plugin!244
2 parents 36368a1 + ce1fa3c commit 1fe0e3e

File tree

8 files changed

+77
-9
lines changed

8 files changed

+77
-9
lines changed

Model/Api/V3.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,9 @@ private function processPayment(): array
336336

337337
// Get the payment
338338
$response = $this->getPaymentResponse($amount, $currency, $reference);
339+
$isValidResponse = $this->api->isValidResponse($response);
339340

340-
if ($this->api->isValidResponse($response)) {
341+
if ($isValidResponse) {
341342
// Process the payment response
342343
$is3ds = property_exists($response, '_links')
343344
&& isset($response->_links['redirect'])
@@ -357,7 +358,7 @@ private function processPayment(): array
357358
}
358359

359360
// Update the result
360-
$this->result['success'] = $response->isSuccessful();
361+
$this->result['success'] = $isValidResponse;
361362
} else {
362363
// Payment failed
363364
if (isset($response->response_code)) {
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
/**
4+
* Checkout.com
5+
* Authorized and regulated as an electronic money institution
6+
* by the UK Financial Conduct Authority (FCA) under number 900816.
7+
*
8+
* PHP version 7
9+
*
10+
* @category Magento2
11+
* @package Checkout.com
12+
* @author Platforms Development Team <[email protected]>
13+
* @copyright 2010-present Checkout.com
14+
* @license https://opensource.org/licenses/mit-license.html MIT License
15+
* @link https://docs.checkout.com/
16+
*/
17+
18+
declare(strict_types=1);
19+
20+
namespace CheckoutCom\Magento2\Model\Config\Backend\Source;
21+
22+
use Magento\Framework\Data\OptionSourceInterface;
23+
24+
class ConfigRegion implements OptionSourceInterface
25+
{
26+
public const REGION_GLOBAL = 'global';
27+
public const REGION_KSA = 'ksa';
28+
29+
/**
30+
* Options getter
31+
*
32+
* @return string[][]
33+
*/
34+
public function toOptionArray(): array
35+
{
36+
return [
37+
[
38+
'value' => self::REGION_GLOBAL,
39+
'label' => __('--')
40+
],
41+
[
42+
'value' => self::REGION_KSA,
43+
'label' => __('KSA')
44+
]
45+
];
46+
}
47+
}

Model/Service/ApiHandlerService.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
use CheckoutCom\Magento2\Gateway\Config\Config;
3838
use CheckoutCom\Magento2\Helper\Logger;
3939
use CheckoutCom\Magento2\Helper\Utilities;
40+
use CheckoutCom\Magento2\Model\Config\Backend\Source\ConfigRegion;
4041
use CheckoutCom\Magento2\Model\Config\Backend\Source\ConfigService;
4142
use Magento\Framework\App\Config\ScopeConfigInterface;
4243
use Magento\Framework\App\ProductMetadataInterface;
@@ -172,6 +173,8 @@ public function init(
172173
string $secretKey = null,
173174
string $publicKey = null
174175
): ApiHandlerService {
176+
$region = $this->config->getValue('region', null, $storeCode, $scope);
177+
175178
if (!$secretKey) {
176179
$secretKey = $this->config->getValue('secret_key', null, $storeCode, $scope);
177180
}
@@ -181,7 +184,7 @@ public function init(
181184
}
182185

183186
$service = $this->scopeConfig->getValue(ConfigService::SERVICE_CONFIG_PATH, $scope, $storeCode);
184-
$environment = $this->config->getEnvironment($storeCode, $scope);
187+
$environment = $this->config->getEnvironment((string)$storeCode, $scope);
185188
$api = CheckoutSdk::builder();
186189

187190
if ($service === ConfigService::SERVICE_ABC) {
@@ -190,11 +193,17 @@ public function init(
190193
$api = $api->staticKeys();
191194
}
192195

193-
$this->checkoutApi = $api
196+
$sdkBuilder = $api
194197
->publicKey($publicKey)
195198
->secretKey($secretKey)
196-
->environment($environment)
197-
->build();
199+
->environment($environment);
200+
201+
// Do not set subdomain when global region is used
202+
if ($region !== ConfigRegion::REGION_GLOBAL) {
203+
$sdkBuilder->environmentSubdomain($region);
204+
}
205+
206+
$this->checkoutApi = $sdkBuilder->build();
198207

199208
return $this;
200209
}
@@ -208,7 +217,7 @@ public function initAbcForRefund(
208217
$publicKey = $this->config->getValue('abc_refund_public_key', null, $storeCode, $scope);
209218

210219
$api = CheckoutSdk::builder();
211-
$environment = $this->config->getEnvironment($storeCode, $scope);
220+
$environment = $this->config->getEnvironment((string)$storeCode, $scope);
212221

213222
$this->checkoutApi = $api
214223
->previous()->staticKeys()

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
"name": "checkoutcom/magento2",
33
"description": "Checkout.com Payment Gateway for Magento 2",
44
"require": {
5-
"checkout/checkout-sdk-php": "3.2.0",
5+
"checkout/checkout-sdk-php": "3.2.4",
66
"php": "~7.4.0||~8.1.0||~8.2.0||~8.3.0",
77
"magento/framework": ">=100.0.1"
88
},
99
"type": "magento2-module",
10-
"version": "6.3.2",
10+
"version": "6.4.0",
1111
"autoload": {
1212
"files": [
1313
"registration.php"

etc/adminhtml/system.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@
176176
</group>
177177
<group id="account_settings" type="text" showInDefault="1" showInWebsite="1" showInStore="0">
178178
<label>Account Settings</label>
179+
<field id="region" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
180+
<label>Region</label>
181+
<source_model>CheckoutCom\Magento2\Model\Config\Backend\Source\ConfigRegion</source_model>
182+
<config_path>settings/checkoutcom_configuration/region</config_path>
183+
<validate>required-entry</validate>
184+
</field>
179185
<field id="service" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
180186
<label>Service</label>
181187
<source_model>CheckoutCom\Magento2\Model\Config\Backend\Source\ConfigService</source_model>

etc/config.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<gateway_responses>0</gateway_responses>
2828
<additional_logging></additional_logging>
2929
<environment>1</environment>
30+
<region>global</region>
3031
<service>ABC</service>
3132
<secret_key backend_model="Magento\Config\Model\Config\Backend\Encrypted"/>
3233
<public_key/>

i18n/en_GB.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"--","Others"
12
" for an amount of %1. Action ID: %2. Event ID: %3. Payment ID: %4. Error: %5 %6"," for an amount of %1. Action ID: %2. Event ID: %3. Payment ID: %4. Error: %5 %6"
23
"3DS authorization code","3DS authorization code"
34
"3DS has expired or authentication failed, please try again","3DS has expired or authentication failed, please try again"
@@ -63,6 +64,7 @@
6364
"Invalid request. No session ID found.","Invalid request. No session ID found."
6465
"It looks like this transaction has been blocked due to account holder action, please contact your bank or use another card or payment method","It looks like this transaction has been blocked due to account holder action, please contact your bank or use another card or payment method"
6566
"It looks like your card is invalid or blocked, please try with another card","It looks like your card is invalid or blocked, please try with another card"
67+
"KSA","KSA"
6668
"Learn More","Learn More"
6769
"Match Not Capable","Match Not Capable"
6870
"Mismatched Address (fraud check)","Mismatched Address (fraud check)"

i18n/en_US.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"--","Others"
12
" for an amount of %1. Action ID: %2. Event ID: %3. Payment ID: %4. Error: %5 %6"," for an amount of %1. Action ID: %2. Event ID: %3. Payment ID: %4. Error: %5 %6"
23
"3DS authorization code","3DS authorization code"
34
"3DS has expired or authentication failed, please try again","3DS has expired or authentication failed, please try again"
@@ -63,6 +64,7 @@
6364
"Invalid request. No session ID found.","Invalid request. No session ID found."
6465
"It looks like this transaction has been blocked due to account holder action, please contact your bank or use another card or payment method","It looks like this transaction has been blocked due to account holder action, please contact your bank or use another card or payment method"
6566
"It looks like your card is invalid or blocked, please try with another card","It looks like your card is invalid or blocked, please try with another card"
67+
"KSA","KSA"
6668
"Learn More","Learn More"
6769
"Match Not Capable","Match Not Capable"
6870
"Mismatched Address (fraud check)","Mismatched Address (fraud check)"

0 commit comments

Comments
 (0)