Instructions
- Go to Merchant
- Click on Blue Gears button (where type is ‘Express’. If you do not find gears icon please wait until admin approve the merchant account.)
- Click on "Client ID" and "Client Secret" to copy
Payer
If payer wants to fund payments using UPayz, set payer to UPayz.
(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 :
Go to php-sdk/src/UPayz/Rest/Connection.php then change BASE_URL
value to your hostname
(ex: If localhost then define( 'BASE_URL' , 'http://localhost' ) )
require 'vendor/autoload.php'; use UPayz\Api\Payer; use UPayz\Api\Amount; use UPayz\Api\Transaction; use UPayz\Api\RedirectUrls; use UPayz\Api\Payment; $payer = new Payer(); $payer->setPaymentMethod('mts'); $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; }