Skip to content

Commit

Permalink
Merge branch 'release/v6.4.0' into 'master'
Browse files Browse the repository at this point in the history
release/v6.4.0 into master

See merge request agence-dnd/marketplace/magento-2/external/module-checkout-magento2-plugin!244
  • Loading branch information
DnD-Behou committed Nov 28, 2024
2 parents 36368a1 + ce1fa3c commit 1fe0e3e
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 9 deletions.
5 changes: 3 additions & 2 deletions Model/Api/V3.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,9 @@ private function processPayment(): array

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

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

// Update the result
$this->result['success'] = $response->isSuccessful();
$this->result['success'] = $isValidResponse;
} else {
// Payment failed
if (isset($response->response_code)) {
Expand Down
47 changes: 47 additions & 0 deletions Model/Config/Backend/Source/ConfigRegion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

/**
* Checkout.com
* Authorized and regulated as an electronic money institution
* by the UK Financial Conduct Authority (FCA) under number 900816.
*
* PHP version 7
*
* @category Magento2
* @package Checkout.com
* @author Platforms Development Team <[email protected]>
* @copyright 2010-present Checkout.com
* @license https://opensource.org/licenses/mit-license.html MIT License
* @link https://docs.checkout.com/
*/

declare(strict_types=1);

namespace CheckoutCom\Magento2\Model\Config\Backend\Source;

use Magento\Framework\Data\OptionSourceInterface;

class ConfigRegion implements OptionSourceInterface
{
public const REGION_GLOBAL = 'global';
public const REGION_KSA = 'ksa';

/**
* Options getter
*
* @return string[][]
*/
public function toOptionArray(): array
{
return [
[
'value' => self::REGION_GLOBAL,
'label' => __('--')
],
[
'value' => self::REGION_KSA,
'label' => __('KSA')
]
];
}
}
19 changes: 14 additions & 5 deletions Model/Service/ApiHandlerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use CheckoutCom\Magento2\Gateway\Config\Config;
use CheckoutCom\Magento2\Helper\Logger;
use CheckoutCom\Magento2\Helper\Utilities;
use CheckoutCom\Magento2\Model\Config\Backend\Source\ConfigRegion;
use CheckoutCom\Magento2\Model\Config\Backend\Source\ConfigService;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\ProductMetadataInterface;
Expand Down Expand Up @@ -172,6 +173,8 @@ public function init(
string $secretKey = null,
string $publicKey = null
): ApiHandlerService {
$region = $this->config->getValue('region', null, $storeCode, $scope);

if (!$secretKey) {
$secretKey = $this->config->getValue('secret_key', null, $storeCode, $scope);
}
Expand All @@ -181,7 +184,7 @@ public function init(
}

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

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

$this->checkoutApi = $api
$sdkBuilder = $api
->publicKey($publicKey)
->secretKey($secretKey)
->environment($environment)
->build();
->environment($environment);

// Do not set subdomain when global region is used
if ($region !== ConfigRegion::REGION_GLOBAL) {
$sdkBuilder->environmentSubdomain($region);
}

$this->checkoutApi = $sdkBuilder->build();

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

$api = CheckoutSdk::builder();
$environment = $this->config->getEnvironment($storeCode, $scope);
$environment = $this->config->getEnvironment((string)$storeCode, $scope);

$this->checkoutApi = $api
->previous()->staticKeys()
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"name": "checkoutcom/magento2",
"description": "Checkout.com Payment Gateway for Magento 2",
"require": {
"checkout/checkout-sdk-php": "3.2.0",
"checkout/checkout-sdk-php": "3.2.4",
"php": "~7.4.0||~8.1.0||~8.2.0||~8.3.0",
"magento/framework": ">=100.0.1"
},
"type": "magento2-module",
"version": "6.3.2",
"version": "6.4.0",
"autoload": {
"files": [
"registration.php"
Expand Down
6 changes: 6 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@
</group>
<group id="account_settings" type="text" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Account Settings</label>
<field id="region" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Region</label>
<source_model>CheckoutCom\Magento2\Model\Config\Backend\Source\ConfigRegion</source_model>
<config_path>settings/checkoutcom_configuration/region</config_path>
<validate>required-entry</validate>
</field>
<field id="service" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Service</label>
<source_model>CheckoutCom\Magento2\Model\Config\Backend\Source\ConfigService</source_model>
Expand Down
1 change: 1 addition & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<gateway_responses>0</gateway_responses>
<additional_logging></additional_logging>
<environment>1</environment>
<region>global</region>
<service>ABC</service>
<secret_key backend_model="Magento\Config\Model\Config\Backend\Encrypted"/>
<public_key/>
Expand Down
2 changes: 2 additions & 0 deletions i18n/en_GB.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"--","Others"
" 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"
"3DS authorization code","3DS authorization code"
"3DS has expired or authentication failed, please try again","3DS has expired or authentication failed, please try again"
Expand Down Expand Up @@ -63,6 +64,7 @@
"Invalid request. No session ID found.","Invalid request. No session ID found."
"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"
"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"
"KSA","KSA"
"Learn More","Learn More"
"Match Not Capable","Match Not Capable"
"Mismatched Address (fraud check)","Mismatched Address (fraud check)"
Expand Down
2 changes: 2 additions & 0 deletions i18n/en_US.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"--","Others"
" 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"
"3DS authorization code","3DS authorization code"
"3DS has expired or authentication failed, please try again","3DS has expired or authentication failed, please try again"
Expand Down Expand Up @@ -63,6 +64,7 @@
"Invalid request. No session ID found.","Invalid request. No session ID found."
"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"
"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"
"KSA","KSA"
"Learn More","Learn More"
"Match Not Capable","Match Not Capable"
"Mismatched Address (fraud check)","Mismatched Address (fraud check)"
Expand Down

0 comments on commit 1fe0e3e

Please sign in to comment.