diff --git a/spec/Payum/Action/Assert/SuccessfulResponseHandlerSpec.php b/spec/Payum/Action/Assert/SuccessfulResponseHandlerSpec.php index 5be85da..94e3254 100644 --- a/spec/Payum/Action/Assert/SuccessfulResponseHandlerSpec.php +++ b/spec/Payum/Action/Assert/SuccessfulResponseHandlerSpec.php @@ -5,6 +5,7 @@ namespace spec\CommerceWeavers\SyliusSaferpayPlugin\Payum\Action\Assert; use CommerceWeavers\SyliusSaferpayPlugin\Client\ValueObject\AssertResponse; +use CommerceWeavers\SyliusSaferpayPlugin\Client\ValueObject\Body\PaymentMeans; use CommerceWeavers\SyliusSaferpayPlugin\Client\ValueObject\Body\Transaction; use PhpSpec\ObjectBehavior; use Sylius\Component\Core\Model\PaymentInterface; @@ -24,11 +25,41 @@ function it_handles_the_successful_payment( 'some_key' => 'some_value', 'transaction_id' => 'some_transaction_id', 'status' => 'some_status', + 'payment_means' => [ + 'Brand' => [ + 'Name' => 'VISA', + 'PaymentMethod' => 'VISA', + ], + 'DisplayText' => 'VISA XXXX-XXXX-XXXX-1111', + 'Card' => [ + 'MaskedNumber' => 'XXXX-XXXX-XXXX-1111', + 'ExpYear' => 2025, + 'ExpMonth' => 12, + 'HolderName' => 'John Doe', + 'CountryCode' => 'CH', + ], + 'BankAccount' => null, + 'PayPal' => null, + ], ]) ->shouldBeCalled() ; $response->getTransaction()->willReturn($transaction); + $response->getPaymentMeans()->willReturn(PaymentMeans::fromArray([ + 'Brand' => [ + 'PaymentMethod' => 'VISA', + 'Name' => 'VISA', + ], + 'DisplayText' => 'VISA XXXX-XXXX-XXXX-1111', + 'Card' => [ + 'MaskedNumber' => 'XXXX-XXXX-XXXX-1111', + 'ExpYear' => 2025, + 'ExpMonth' => 12, + 'HolderName' => 'John Doe', + 'CountryCode' => 'CH', + ], + ])); $transaction->getStatus()->willReturn('some_status'); $transaction->getId()->willReturn('some_transaction_id'); diff --git a/src/Payum/Action/Assert/SuccessfulResponseHandler.php b/src/Payum/Action/Assert/SuccessfulResponseHandler.php index 3356ed4..776a438 100644 --- a/src/Payum/Action/Assert/SuccessfulResponseHandler.php +++ b/src/Payum/Action/Assert/SuccessfulResponseHandler.php @@ -16,6 +16,7 @@ public function handle(PaymentInterface $payment, AssertResponse $response): voi $paymentDetails['status'] = $transaction->getStatus(); $paymentDetails['transaction_id'] = $transaction->getId(); + $paymentDetails['payment_means'] = $response->getPaymentMeans()->toArray(); $payment->setDetails($paymentDetails); }