Avec GlofPay Standard et Express, vous pouvez facilement et en toute sécurité recevoir des paiements en ligne de vos clients.
If payer wants to fund payments using GlofPay, set payer to GlofPay. Other payment methods (paypal, stripe, coin payments) are not available yet.
// Payer Object
$payer = new Payer();
$payer->setPaymentMethod('GlofPay'); //preferably, your system name
Spécifiez un montant de paiement et la devise.
// Amount Object
$amountIns = new Amount();
$amountIns->setTotal(20)->setCurrency('USD'); //must give a valid currency code and must exist in merchant wallet list
It’s a Transaction resource where amount object has to be set.
// Transaction Object
$trans = new Transaction();
$trans->setAmount($amountIns);
Set the URLs where buyer should redirect after transaction is completed or cancelled.
// RedirectUrls Object
$urls = new RedirectUrls();
$urls->setSuccessUrl('http://your-merchant-domain.com/example-success.php')
->setCancelUrl('http://your-merchant-domain.com/');
It’s a payment resource where all Payer, Amount, RedirectUrls, and merchant Credentials (Client ID and Client Secret) have to be set. After initializing the payment object, call create() to generate a redirect URL. Users must be redirected to this URL to complete the transaction.
// Payment Object
$payment = new Payment();
$payment->setCredentials([
'client_id' => 'place your client id here',
'client_secret' => 'place your client secret here'
])
->setRedirectUrls($urls)
->setPayer($payer)
->setTransaction($trans);
try {
$payment->create(); // create payment
header("Location: ".$payment->getApprovedUrl()); // checkout URL
} catch (Exception $ex) {
print $ex;
exit;
}
Cliquez sur télécharger pour le package
Now, go to php-sdk/src/GlofPay/Rest/Connections.php, then change BASE_URL value to your domain name
Exemple de code
require 'vendor/autoload.php';
use GlofPay\Api\Payer;
use GlofPay\Api\Amount;
use GlofPay\Api\Transaction;
use GlofPay\Api\RedirectUrls;
use GlofPay\Api\Payment;
$payer = new Payer();
$payer->setPaymentMethod('GlofPay');
$amountIns = new Amount();
$amountIns->setTotal(20)->setCurrency('USD');
$trans = new Transaction();
$trans->setAmount($amountIns);
If you don't see changes after configuring and extracting SDK, go to your SDK root and run the commands below: