Developer

bujapay Express Payment Gateway Documentation

Payer

If payer wants to fund payments using bujapay, set payer to bujapay.
(Other payment method ex: paypal, stripe, coinpayments etc not available yet).

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/bujapay/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 bujapay\Api\Payer;
				 use bujapay\Api\Amount;
				 use bujapay\Api\Transaction;
				 use bujapay\Api\RedirectUrls;
				 use bujapay\Api\Payment;

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

				                                     $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;
                 }