Skip to content

Commit

Permalink
Merge pull request #9 from BitBagCommerce/feature/add-convert-payment…
Browse files Browse the repository at this point in the history
…-action

[FEATURE]Add convert payment action
  • Loading branch information
liszkapawel authored Feb 21, 2024
2 parents 98683ef + a1394f8 commit 01e87b5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/services/action.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@
<argument type="service" id="bitbag.imoje_plugin.resolver.signature_resolver"/>
<tag name="payum.action" factory="imoje" alias="payum.action.notify"/>
</service>

<service id="bitbag.payu_plugin.action.convert_payment" class="BitBag\SyliusImojePlugin\Action\ConvertPaymentAction">
<tag name="payum.action" factory="imoje" alias="payum.action.convert_payment"/>
</service>
</services>
</container>
29 changes: 29 additions & 0 deletions src/ConvertPaymentAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace BitBag\SyliusImojePlugin\Action;

use Payum\Core\Action\ActionInterface;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Model\PaymentInterface;
use Payum\Core\Request\Convert;

final class ConvertPaymentAction implements ActionInterface
{
public function execute($request): void
{
$payment = $request->getSource();
$details = ArrayObject::ensureArrayObject($payment->getDetails());

$request->setResult((array) $details);
}

public function supports($request)
{
return
$request instanceof Convert &&
$request->getSource() instanceof PaymentInterface &&
$request->getTo() === 'array';
}
}

0 comments on commit 01e87b5

Please sign in to comment.