PHP code example of gopay-libs / gopay-ui

1. Go to this page and download the library: Download gopay-libs/gopay-ui 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/ */

    

gopay-libs / gopay-ui example snippets


use App\Models\Order;
use Gopay\GopayUi\DTO\PaymentFormData;
use Gopay\GopayUi\DTO\PaymentInsertAction;
use Gopay\GopayUi\DTO\PaymentUpdateAction;
use Gopay\GopayUi\Enums\PaymentSuccessAction;
use Gopay\GopayUi\GopayUI;

$form = new PaymentFormData(

    amount: 10,

    currency: 'USD',

    phone: '991234567',

    onSuccess: PaymentSuccessAction::GO_TO_URL,

    redirectUrl: '/payment/success?reference={reference}&amount={amount}&currency={currency}',

    formColor: '#262626',

    payBtnLabel: 'Payer maintenant',

    insertActions: [

        new PaymentInsertAction(
            model: Order::class,
            data: [
                'reference' => '{reference}',
                'amount' => '{amount}',
                'currency' => '{currency}',
                'name' => 'Paiement GoPay'
            ]
        )

    ],

    updateActions: [

        new PaymentUpdateAction(
            model: Order::class,
            where: [
                'reference' => '{reference}'
            ],
            data: [
                'status' => 'PAID'
            ]
        )

    ]

);

echo GoPayUI::renderForm($form);

redirectUrl: '/success?ref={reference}&amount={amount}'

Schedule::command('gopay:process-pending')
    ->everyMinute();
bash
php artisan gopay:install
text
{reference}
{amount}
{currency}
bash
php artisan gopay:process-pending
bash
php artisan gopay:uninstall
bash
php artisan pest:install
bash
php artisan test
text
tests/
├── PaymentFormDataTest.php