PHP code example of korozcolt / payments-symfony

1. Go to this page and download the library: Download korozcolt/payments-symfony library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

korozcolt / payments-symfony example snippets


Korbytes\Payments\Symfony\PaymentsBundle::class => ['all' => true],

use Korbytes\Payments\Core\Standalone;
use Korbytes\Payments\DTOs\PaymentData;

public function checkout(Standalone $payments): JsonResponse
{
    $charge = $payments->driver('wompi')->charge(new PaymentData(referenceId: 'ORDER-1001', amount: 5000000));

    return $this->json(['reference' => $charge->reference, 'signature' => $charge->signature, 'widget' => $charge->widgetUrl]);
}

use Korbytes\Payments\Core\Events\PaymentApproved;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;

#[AsEventListener]
final class MarkOrderPaid
{
    public function __invoke(PaymentApproved $event): void
    {
        // $event->transaction->reference_id ...
    }
}
yaml
# config/routes/payments.yaml
payments:
    resource: '@PaymentsBundle/config/routes.php'