GiftPay API Documentation

If you are Wordpress user please click here.
If you are woocommerce user click here
Client Code
include the following script on your checkout / payment method page.
(function (d) {
var h = d.getElementsByTagName('head')[0];
var c = d.createElement('script');
c.type = 'text/javascript';
c.charset = 'utf-8';
c.src = ''+ (new Date()).getTime();
We recommend putting a button with "Pay with Gift Cards" label you can download and use one of our pre build buttons here.
When user clicks on the button, call "giftpayOpenPopup" javascript function with the following parameters:
var params = {};
params.apikey = "your api key"; // required
params.userid = "unique id of your customer that you can track / use email for simplicity"; // required
params.amount = 123.45; // required, put an exact amount that user needs to pay
//params.uniqueid = ''; // optional, you can send unique identification of the order / cart that you can track, this cannot be repeated
//params.description = ''; // optional, item or subscription description to show on payment screen
//params.ipnurl = ''; // optional, you can specify different IPN URL for each transaction, see IPN URL section below for details

// optional callback function to be called after the payment is completed, you can simply reload the page if you have configured an IPN page
params.callback = function (data) {
// data.paidamount: amount that was paid by the user, note that in some cases this can be different from the amount that you have requested
// data.orderid: giftpay order id that you need to verify with the server side code, this is NOT uniqueid that you have sent, but order id that was assigned by giftpay
// alert("paid: $"+data.paidamount + " / orderid: " + data.orderid);
// call function to open the popup
Download Sample Page HTML
Server Side Code
Even if you had a positive response on client side, you need to verify the status of the payment with the server side API.s:
POST: JSON object
"apikey": "your api key",
"orderid": "order id returned on client side or on IPN page"
API-SECRET: your api secret
Response: JSON - "Order" OBJECT
"orderid": "order id"
"userid": "userid that you have sent",
"amount": "amount that requested to pay",
"paidamount": "paid amount by the user (after deducting customer fee if applied), note that in some cases this can be different from the amount that you have requested",
"uniqueid": "unique identification that you have sent or empty if not applied",
"description": "description that you have sent or empty if not applied",
"txnid": "transaction id, better readable for users",
"cardtype": "card type ex: walmart, applestore, target, amazon",
"cardlastfour": "last four digits/symbols of the card number",
"cardvalue": "total card value submitted",
"customerfee": "fee deducted from the card value for card types with lower market rates or complex selling methods if applied",
"fixedfee": "Fixed Fee that you decided to pay instead of the Customer if applied",
"merchantfee": "paid amount after deducting customer fee if applied",
"amountpaidtoyou": "paid to you after fees deducted",
"status": "new|good|completed|cancelled"
New - the user has opened a transaction but has not submitted a gift card for payment.
Good - the payment was successfully processed and you can release the credits to the user or complete checkout if you wish
Completed - paid and available for withdrawal
Cancelled - cancelled due to bad card
This is an alternative to "Get Order Status", here you can query all orders that where created with your "uniqueid".
POST: JSON object
"apikey": "your api key",
"uniqueid": "uniqueid that you have sent"
API-SECRET: your api secret
Response: JSON - list of "Order" OBJECTs, can be an empty list
"orderid": "order id"
// ...
// every thing that "Order" OBJECT has
"orderid": "order id"
// ...
// every thing that "Order" OBJECT has
When a new payment is received and each time the status of the payment is changed, we will send a notification to the configured url with a single query string parameter "orderid"
You should use this order id to get the Order Status as described above and apply appropriate changes on your backend depending on the status.
Sample IPN call: