Adding a gift to the cart (Part one)

  1. Customer goes to the SailPlay Loyalty Page and redeems their points for a gift. 
  2. We process the transaction, deduct points, etc.
  3. We send a JSONP request to an address of your choice, containing the following: 
    1. gift_public_key: a unique hash;
    2. gift_sku: Gift ID in your system;
    3. user_email OR origin_user_id OR user_phone;

The request the Example:  http://amazon.com/sailplay-listener/?gift_public_key=09kdhhn72idgh785920kfa&gift_sku=4829&user_phone=79146003334

(Part two)

  1. Upon receipt of our query your site should make a request back to us to check the status of the transaction. You'll need to send the following parameters:
    1. gift_public_key: a unique hash;
    2. the token: the auth your the token (see  http://docs.sailplay.net/en/page/api-back-login/ );
    3. store_department_id: your store_department_id (see  https://sailplay.net/spanel/#/departments/ );
      The request the Example:  http://sailplay.ru/api/v1/ecommerce/gifts/commit-transaction/?token=7ce324861c4a5de5bfe931c04d96073f9b72bfec&store_department_id=122&gift_public_key=09kdhh472idgh785920kfa 
       
      You should receive a response like this:

      "status": "ok",  
      "purchase_gift": { 
      "id": 166, // the transaction id 
      "already_completed": to false, // Whether or not the the transaction has already been completed
      "gift_id": 20, // gift in SailPlay id 
      "gift_sku": "123", // product product SKU in your system 
      "PURCHASE_DATE": "2013-03-26T10: 18: 41",        
      "complete_date": "2013-03-26T10: 19: 04,118" 
      "points_delta": 800, 
      "is_completed": to true,  
      "the user": " john@example.com " 

      }
  2. If the request is successful, and already_completed is false, then you can add the customer's free gift to their cart. 
  3. Customer completes checkout as normal. You physically deliver the gift along with the rest of their order.