Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PAYSHIP-3125] Added new 3DS status in admin order page #1309

Merged
merged 11 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>ps_checkout</name>
<displayName><![CDATA[PrestaShop Checkout]]></displayName>
<version><![CDATA[8.4.3.0]]></version>
<version><![CDATA[8.4.3.1]]></version>
<description><![CDATA[Provide the most commonly used payment methods to your customers in this all-in-one module, and manage all your sales in a centralized interface.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[payments_gateways]]></tab>
Expand Down
2 changes: 2 additions & 0 deletions config/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ services:
public: true
arguments:
- "@ps_checkout.logger"
- '@PrestaShop\Module\PrestashopCheckout\Repository\PayPalOrderRepository'
- '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration'

PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\PaymentMethodTokenService:
class: 'PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\PaymentMethodTokenService'
Expand Down
9 changes: 9 additions & 0 deletions controllers/front/payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetPayPalOrderForCheckoutCompletedQuery;
use PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetPayPalOrderForCheckoutCompletedQueryResult;
use PrestaShop\Module\PrestashopCheckout\PayPal\Order\ValueObject\PayPalOrderId;
use PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration;
use PrestaShop\Module\PrestashopCheckout\Repository\PaymentTokenRepository;
use PrestaShop\Module\PrestashopCheckout\Repository\PayPalOrderRepository;

Expand Down Expand Up @@ -87,6 +88,8 @@ public function postProcess()

$this->commandBus = $this->module->getService('ps_checkout.bus.command');

/** @var PayPalConfiguration $payPalConfiguration */
$payPalConfiguration = $this->module->getService(PayPalConfiguration::class);
/** @var PayPalOrderRepository $payPalOrderRepository */
$payPalOrderRepository = $this->module->getService(PayPalOrderRepository::class);
/** @var Psr\SimpleCache\CacheInterface $payPalOrderCache */
Expand Down Expand Up @@ -136,6 +139,12 @@ public function postProcess()
$this->createOrder($payPalOrderFromCache, $payPalOrder);
break;
case Card3DSecure::NO_DECISION:
if ($payPalConfiguration->getHostedFieldsContingencies() === 'SCA_WHEN_REQUIRED') {
$this->commandBus->handle(new CapturePayPalOrderCommand($orderId, array_keys($payPalOrderFromCache['payment_source'])[0]));
$payPalOrderFromCache = $payPalOrderCache->get($orderId);
$this->createOrder($payPalOrderFromCache, $payPalOrder);
}
// no break
default:
break;
}
Expand Down
6 changes: 3 additions & 3 deletions ps_checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class Ps_checkout extends PaymentModule

// Needed in order to retrieve the module version easier (in api call headers) than instanciate
// the module each time to get the version
const VERSION = '8.4.3.0';
const VERSION = '8.4.3.1';

const INTEGRATION_DATE = '2024-04-01';

Expand All @@ -137,7 +137,7 @@ public function __construct()

// We cannot use the const VERSION because the const is not computed by addons marketplace
// when the zip is uploaded
$this->version = '8.4.3.0';
$this->version = '8.4.3.1';
$this->author = 'PrestaShop';
$this->currencies = true;
$this->currencies_mode = 'checkbox';
Expand Down Expand Up @@ -1123,7 +1123,7 @@ public function hookActionFrontControllerSetMedia()
'checkout.payment.token.delete.modal.confirm-button' => $this->l('Delete payment method'),
'checkout.payment.loader.processing-request' => $this->l('Please wait, we are processing your request'),
'APPLE_PAY_MERCHANT_SESSION_VALIDATION_ERROR' => $this->l('We’re unable to process your Apple Pay payment at the moment. This could be due to an issue verifying the payment setup for this website. Please try again later or choose a different payment method.'),
'APPROVE_APPLE_PAY_VALIDATION_ERROR' => $this->l('We encountered an issue while processing your Apple Pay payment. Please verify your order details and try again, or use a different payment method.')
'APPROVE_APPLE_PAY_VALIDATION_ERROR' => $this->l('We encountered an issue while processing your Apple Pay payment. Please verify your order details and try again, or use a different payment method.'),
],
]);

Expand Down
35 changes: 30 additions & 5 deletions src/Checkout/CheckoutChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
namespace PrestaShop\Module\PrestashopCheckout\Checkout;

use Cart;
use Configuration;
use Customer;
use PrestaShop\Module\PrestashopCheckout\Exception\PsCheckoutException;
use PrestaShop\Module\PrestashopCheckout\PayPal\Card3DSecure;
use PrestaShop\Module\PrestashopCheckout\PayPal\Order\Entity\PayPalOrder;
use PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration;
use PrestaShop\Module\PrestashopCheckout\Repository\PayPalOrderRepository;
use Psr\Log\LoggerInterface;
use Validate;

Expand All @@ -34,13 +36,26 @@ class CheckoutChecker
* @var LoggerInterface
*/
private $logger;
/**
* @var PayPalOrderRepository
*/
private $payPalOrderRepository;
/**
* @var PayPalConfiguration
*/
private $payPalConfiguration;

/**
* @param LoggerInterface $logger
*/
public function __construct(LoggerInterface $logger)
{
public function __construct(
LoggerInterface $logger,
PayPalOrderRepository $payPalOrderRepository,
PayPalConfiguration $payPalConfiguration
) {
$this->logger = $logger;
$this->payPalOrderRepository = $payPalOrderRepository;
$this->payPalConfiguration = $payPalConfiguration;
}

/**
Expand All @@ -57,6 +72,8 @@ public function continueWithAuthorization($cartId, $orderPayPal)
throw new PsCheckoutException(sprintf('PayPal Order %s is already captured', $orderPayPal['id']), PsCheckoutException::PAYPAL_ORDER_ALREADY_CAPTURED);
}

$contingencies = $this->payPalConfiguration->getHostedFieldsContingencies();

$paymentSource = isset($orderPayPal['payment_source']) ? key($orderPayPal['payment_source']) : '';

if (in_array($paymentSource, ['google_pay', 'card'], true)) {
Expand All @@ -74,7 +91,7 @@ public function continueWithAuthorization($cartId, $orderPayPal)
(string) Card3DSecure::RETRY,
],
[
Configuration::get('PS_CHECKOUT_LIABILITY_SHIFT_REQ') ? 'Rejected, no liability shift' : 'Proceed, without liability shift',
$contingencies === 'SCA_ALWAYS' ? 'Rejected, no liability shift' : 'Proceed, without liability shift',
'Proceed, liability shift is possible',
'Rejected',
'Retry, ask customer to retry',
Expand All @@ -90,9 +107,17 @@ public function continueWithAuthorization($cartId, $orderPayPal)
case Card3DSecure::RETRY:
throw new PsCheckoutException('Card Strong Customer Authentication must be retried.', PsCheckoutException::PAYPAL_PAYMENT_CARD_SCA_UNKNOWN);
case Card3DSecure::NO_DECISION:
if (Configuration::get('PS_CHECKOUT_LIABILITY_SHIFT_REQ')) {
if ($contingencies === 'SCA_ALWAYS') {
throw new PsCheckoutException('No liability shift to card issuer', PsCheckoutException::PAYPAL_PAYMENT_CARD_SCA_UNKNOWN);
}
if ($contingencies === 'SCA_WHEN_REQUIRED') {
$payPalOrder = $this->payPalOrderRepository->getPayPalOrderByCartId($cartId);
try {
$payPalOrder->addTag(PayPalOrder::THREE_D_SECURE_NOT_REQUIRED);
$this->payPalOrderRepository->savePayPalOrder($payPalOrder);
} catch (PsCheckoutException $e) {
}
}
break;
}
}
Expand Down
Loading
Loading