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}¤cy={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);