Loading...

Express API

Gig Pay Express Payment Gateway Documentation

Payer

If payer wants to fund payments using gigpay, set payer to gigpay.
(Other payment method ex:Mobile Money, coinpayments).

Amount

Specify a payment amount and the currency.

Transaction

It’s a Transaction resource where amount object has to set.

RedirectUrls

Set the urls where buyer should redirect after transaction is completed or cancelled.

Payment

It’s a payment resource where all Payer, Amount, RedirectUrls and Credentials of merchant (Client ID and Client Secret) have to set. After initialized into Payment object, need to call create method. It will generate a redirect URL. Users have to redirect into this URL to complete the transaction.


Installation Instruction :

Click download for the package download

Go to php-sdk/src/GigPay/Rest/Connection.php then change BASE_URL value to your hostname
(ex: If localhost then define( 'BASE_URL' , 'http://localhost' ) )

Example :
 require 'vendor/autoload.php';
 use GigPay\Api\Payer;
 use GigPay\Api\Amount;
 use GigPay\Api\Transaction;
 use GigPay\Api\RedirectUrls;
 use GigPay\Api\Payment;

 $payer = new Payer();
 $payer->setPaymentMethod('gigpay');

                                     $amountIns = new Amount();
                                     $amountIns->setTotal(20)
                                     ->setCurrency('USD'); //currency must be in merchant wallet list

                                     $trans = new Transaction();
                                     $trans->setAmount($amountIns);
                                            
                                     $urls = new RedirectUrls();
                                     $urls->setReturnUrl('http://localhost/return-url')
                                     ->setCancelUrl('http://localhost/cancel-url');

                                     $payment = new Payment();
                                     //Client ID & Secret = Merchants->setting(gear icon)
                                     $payment->setCredentials([
                                     'client_id' => 'ID',
                                     'client_secret' => 'secret'
                                     ])

                                     ->setRedirectUrls($urls)
                                     ->setPayer($payer)
                                     ->setTransaction($trans);

                                     try {
                                     $payment->create();
                                     // redirecting to the approved url
                                     header("Location: ".$payment->getApprovedUrl());
                                     } catch (\Exception $ex) {
                                     print $ex;
                                     exit;
                                     }