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

[ECP-9518] Handle payment response collection of recurring alternative payment methods #2772

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
25 changes: 16 additions & 9 deletions Gateway/Response/PaymentAuthorisationDetailsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@

namespace Adyen\Payment\Gateway\Response;

use Magento\Payment\Gateway\Helper\SubjectReader;
use Magento\Payment\Gateway\Response\HandlerInterface;
use Magento\Sales\Api\Data\OrderPaymentInterface;

class PaymentAuthorisationDetailsHandler implements HandlerInterface
{
/**
* @param array $handlingSubject
* @param array $response
* @param array $responseCollection
*/
public function handle(array $handlingSubject, array $response)
public function handle(array $handlingSubject, array $responseCollection): void
{
$payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
$payment = SubjectReader::readPayment($handlingSubject);

/** @var OrderPaymentInterface $payment */
$payment = $payment->getPayment();
Expand All @@ -32,12 +34,17 @@ public function handle(array $handlingSubject, array $response)
// no not send order confirmation mail
$payment->getOrder()->setCanSendNewEmailFlag(false);

// set pspReference as transactionId
$payment->setCcTransId($response['pspReference']);
$payment->setLastTransId($response['pspReference']);

// set transaction
$payment->setTransactionId($response['pspReference']);
// for partial payments, non-giftcard payments will always be the last element in the collection
// for non-partial, there is only one response in the collection
$response = end($responseCollection);
if (!empty($response['pspReference'])) {
// set pspReference as transactionId
$payment->setCcTransId($response['pspReference']);
$payment->setLastTransId($response['pspReference']);

// set transaction
$payment->setTransactionId($response['pspReference']);
}

// do not close transaction so you can do a cancel() and void
$payment->setIsTransactionClosed(false);
Expand Down
Loading