PHP code example of descom / payment-gateway

1. Go to this page and download the library: Download descom/payment-gateway 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/ */

    

descom / payment-gateway example snippets




use Descom\Payment\Payment;
use Omnipay\OfflineDummy\Gateway as OfflineDummyGateway;

Payment::for(new OfflineDummyGateway())
            ->name('Method Name')
            ->config([
                'return_url' => 'http:/www.localhost/checkout/success',
                'cancel_url' => 'http:/www.localhost/checkout/cancel',
                'request' => [
                    'notify_url' => 'http:/api.localhost/payment/paymentdemo/notify',
                    'return_url' => 'http:/api.localhost/payment/{parameterId}/redirect',
                ],
            ]))
            ->transformer() // Optional, you can use your own transformer with interface Descom\Payment\Transformers\Transformer
            ->create('paymentdemo');


use Descom\Payment\Payment;

$payment = Payment::find('paymentdemo');


use Descom\Payment\Payment;
use Descom\Payment\Transaction;

$payment = Payment::find('paymentdemo');

$transaction = Transaction::for($payment)->create([
    'amount' => '10.00',
    'merchant_id' => 'order_1',
]);


use Descom\Payment\Payment;
use Descom\Payment\Transaction;

$payment = Payment::find('paymentdemo');

$transaction = Transaction::for($payment)
    ->model(Order::find(1))
    ->create([
        'amount' => '10.00',
        'merchant_id' => 'order_1',
    ]);