Skip to content

Commit 81ef8d5

Browse files
authored
[ECP-9723] Fix failing recurring payments in the absence of stateData and add missing command executors for vault authorization (#3127)
* [ECP-9723] Add missing command executors for vault payments * [ECP-9723] Remove unused commandPool definitions in vault facade declarations * [ECP-9723] Add missing paymentMethod details in the absence of stateData * [ECP-9723] Sort the executors in alphabetical order
1 parent 7bf66ca commit 81ef8d5

File tree

2 files changed

+42
-63
lines changed

2 files changed

+42
-63
lines changed

Gateway/Request/RecurringVaultDataBuilder.php

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,11 @@ public function build(array $buildSubject): array
5252
$paymentToken = $extensionAttributes->getVaultPaymentToken();
5353
$details = json_decode((string) ($paymentToken->getTokenDetails() ?: '{}'), true);
5454

55-
if ($paymentToken->getType() === PaymentTokenFactoryInterface::TOKEN_TYPE_CREDIT_CARD) {
56-
// Build base request for card token payments (including card wallets)
57-
58-
$isInstantPurchase = (bool) $payment->getAdditionalInformation('instant-purchase');
59-
60-
if ($isInstantPurchase) {
61-
// `Instant Purchase` doesn't have the component and state data. Build the `paymentMethod` object.
62-
$requestBody['paymentMethod']['type'] = 'scheme';
63-
$requestBody['paymentMethod']['storedPaymentMethodId'] = $paymentToken->getGatewayToken();
64-
} else {
65-
// Initialize the request body with the current state data if it's not `Instant Purchase`.
66-
$requestBody = $this->stateData->getStateData($order->getQuoteId());
67-
}
55+
// Initialize the request body with the current state data
56+
$requestBody = $this->stateData->getStateData($order->getQuoteId());
6857

58+
// Build base request for card token payments (including card wallets)
59+
if ($paymentToken->getType() === PaymentTokenFactoryInterface::TOKEN_TYPE_CREDIT_CARD) {
6960
/*
7061
* `allow3DS: true` flag is required to trigger the native 3DS challenge.
7162
* Otherwise, shopper will be redirected to the issuer for challenge.
@@ -78,13 +69,21 @@ public function build(array $buildSubject): array
7869

7970
// Due to new VISA compliance requirements, holderName is added to the payments call
8071
$requestBody['paymentMethod']['holderName'] = $details['cardHolderName'] ?? null;
81-
} else {
82-
// Build base request for alternative payment methods for regular checkout and Instant Purchase
72+
}
8373

84-
$requestBody['paymentMethod'] = [
85-
'type' => $details['type'],
86-
'storedPaymentMethodId' => $paymentToken->getGatewayToken()
87-
];
74+
/*
75+
* `paymentMethod.type` and `paymentMethod.storedPaymentMethodId` need to be manually populated
76+
* for all recurring alternative payment methods, recurring card payments where state data is missing and
77+
* `Instant Purchase` payments.
78+
*/
79+
if (empty($requestBody['paymentMethod']['type'])) {
80+
$requestBody['paymentMethod']['type'] =
81+
$paymentToken->getType() === PaymentTokenFactoryInterface::TOKEN_TYPE_CREDIT_CARD
82+
? 'scheme'
83+
: $details['type'];
84+
}
85+
if (empty($requestBody['paymentMethod']['storedPaymentMethodId'])) {
86+
$requestBody['paymentMethod']['storedPaymentMethodId'] = $paymentToken->getGatewayToken();
8887
}
8988

9089
// Check the `stateData` if `recurringProcessingModel` is added through a headless request.

0 commit comments

Comments
 (0)