Skip to content

Commit

Permalink
[Payum] Bring back saving payment means during assert action
Browse files Browse the repository at this point in the history
  • Loading branch information
coldic3 committed Dec 13, 2023
1 parent fff987d commit a52cbb0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions spec/Payum/Action/Assert/SuccessfulResponseHandlerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
Expand Down
1 change: 1 addition & 0 deletions src/Payum/Action/Assert/SuccessfulResponseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit a52cbb0

Please sign in to comment.