eGiftify Developers

eGiftify provides a series of REST APIs, which enables reseller's third party applications to offer their own end-to-end virtual gift card programs with minimal effort.

Quick Start

  1. Contact us for an eGiftify Partner API account here
  2. Continue reading the "eGiftify Partner API" documentation

Reseller

Third party resellers of eGiftify's cards are provided with the ability to buy a prepaid USD currency float. Once they have set up their USD currency account, they are provided with a series of API (and administrative) tools to redeem their prepaid float for real gift cards that are distributed across the eGiftify mobile gift card wallet.

Web service request & response formats

To keep things simple and portable, a web service call is either a GET request or a POST request, and all web service calls return a HTTP 200 response code except in extreme cases. If there is an error, details of the error are in the response body. For GET requests, the parameters can be query or path parameters. For POST requests with more than one parameter, the parameters are in the form of a JSON object in the post body (the content-type must be application/json). All responses are in JSON.

Authentication & Security

URL = [ENDPOINT][API_CALL]?api_key=[API_KEY]&hash=[HEX(SHA-256([API_KEY] + [API_SECRET] + [x-timestamp]))]
ENDPOINT = http://www.eGiftify.com/API/ (Sandbox)
API_CALL = The api call you want to make eg: /merchant/account
API_KEY = Your eGiftify API key
API_SECRET = eGiftify API secret key
x-timestamp - The current time() in format "yyyy:MM:dd-HH:mm:ss". This would be set in the request header.
Each request includes an "api_key" parameter which will be your eGiftify API key and a "hash" parameter, which is built up from "api_key" + "secret" + "timestamp" and sha-256 encrypted and then hex encoded.
*x-timestamp in request header and while creating hash should be same.

Example Java Code of Request signing

A Java example of doing an eGiftify api call and printing the JSON response.

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.MessageDigest;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class CallRestApi {
private static String hexEncode(final byte[] bytes) 
{
  StringBuilder hexEncode = new StringBuilder();
	for (int i = 0; i< bytes.length; i++) {
	  String hex = Integer.toHexString(0xFF & bytes[i]);
	  if (hex.length() == 1) hexEncode.append('0');
	  hexEncode.append(hex);
	}
	return hexEncode.toString();
}

public  String getSHA2Hash(String original) throws IllegalArgumentException 
{
  MessageDigest digest = null;
   try
	{ 
	 digest = MessageDigest.getInstance("SHA-256");
	 byte[] hash = digest.digest(original.getBytes("UTF-8"));
	return  hexEncode(hash);
	}
  catch ( Exception e ) {}
  return null;
}

public String getCurrentDateInProperFormat()
{
	DateFormat formatter= new SimpleDateFormat("yyyy:MM:dd-HH:mm:ss");
	return formatter.format( new Date());
}
public static void main(String[] args) 
{
  CallRestApi test=new CallRestApi();
  String apiKey = "apiKeytest1234567890"; //your apiKey
  String apiSecret = "hash1234567890"; //your SecretKey
  String timestamp =test.getCurrentDateInProperFormat(); // current date in proper format
  String stringToSign = apiKey + apiSecret + timestamp;
  //get Hash
  String hash= test.getSHA2Hash(stringToSign);
try {
String fullURLString = String.format("https://www.eGiftify.com/API/merchant/account?api_key=%s&hash=%s",apiKey,hash);
URL url = new URL(fullURLString);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("x-timestamp", timestamp);
BufferedReader br = new BufferedReader(	new InputStreamReader((conn.getInputStream())));
String output;
while ((output = br.readLine()) != null) {
	System.out.println(output);
}
conn.disconnect();
  } catch (Exception e) {
		e.printStackTrace();
    }
 }
}
Example PHP Code of Request signing

A PHP example of doing an eGiftify API call and printing the JSON response.

<?php
$apiKey = "apiKeytest1234567890"; //your apiKey
$apiSecret = "hash1234567890"; //your SecretKey
$timestamp = date("Y-m-d,h:m:s");

$stringToSign = $apiKey . $apiSecret . $timestamp;
$hash = hash('sha256', $stringToSign, true);
$signature = bin2hex($hash);
$fullURLString = sprintf(
  'https://www.egiftify.com/API/merchant/account?api_key=%s&hash=%s',
$apiKey,
$signature
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $fullURLString);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('x-timestamp: '.$timestamp));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
echo curl_exec($curl)."\n";
?>

Redeem Gift Cards

POST /giftcard/redeem

This is a private signed API that takes giftcode and amount which needs to be redeemed.
Input parameters:
[giftcode] - This unique code you want to redeem.
[amount] - The amount you want to redeem.
[staffName] - The name of person who did redeem.

Sample API Response
{
"totalAmount": "1.0",
"redeemAmount": "0.1",
"balanceRemaining":".9",
"mGiftcode": "1o70m6",
"name": "test",
"fundTransferStatus": "12345",
"redeemedAt": "1233 te...........",
"currencyName": "USD",
  }

View Transactions

POST /transaction/all

This is a private signed API that takes start date and end date and show all redemptions done during this period.
Input parameters:
[startDate] - redemption history start date
[endDate] - redemption history end date

Sample API Response
[
  {
         "totalAmount": "1.0",
         "redeemAmount": "0.1",
         "balanceRemaining":".9",
         "mGiftcode": "1o7036",
         "name": "test",
         "fundTransferStatus": "12345",
         "redeemedAt": "1233 te...........",
         "currencyName": "USD",
         "redeemTime":"2015-02-11T05:54:58Z"
    
  },
 {
         "totalAmount": "1.0",
         "redeemAmount": "0.1",
         "balanceRemaining":".9",
         "mGiftcode": "1o7036",
         "name": "test",
         "fundTransferStatus": "12345",
         "redeemedAt": "1233 te...........",
         "currencyName": "USD",
         "redeemTime":"2015-02-11T05:54:58Z"
    
  },
]

Check Balance

POST /giftcard/info

This is a private signed API that takes giftcode to check balance status.
Input parameters:
[giftcode] - The unique code you want to check balance .

Sample API Response
{
"totalAmount": "1.0",
"recipientName"":"test name",
"recipientEmail":"rec@t...com",
"senderEmail":"sender@t..com",
"createdOn":"2015-02-11T05:54:58Z",
"currencyName": "USD",
}                 

Please enter your username

An error occurred during upload. Please check your file and retry again. If you continue to experience this error, please contact us at support@egiftify.com.