SHARE
TWEET

Untitled

Ortund Jul 29th, 2016 (edited) 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function()
  2. {
  3.     var APIKey = <?php echo json_encode($store_settings->apiKey); ?>;
  4.     var Password = <?php echo json_encode($store_serttings->apiPassword); ?>;
  5.     var StoreId = <?php echo json_encode($store_settings->storeID); ?>;
  6.     var ReceiptNumber = <?php echo json_encode($inv->reference_no); ?>;
  7.     var ReceiptValue = <?php echo json_encode($inv->total); ?>;
  8.  
  9.     var Receipt = {
  10.             "APIKey": APIKey,
  11.             "Password": Password,
  12.             "StoreId": StoreId,
  13.             "ReceiptNumber": ReceiptNumber,
  14.             "ReceiptValue": ReceiptValue
  15.     };
  16.  
  17.     PostReceipt(Receipt, false);
  18. });
  19.  
  20. function PostReceipt(receipt, isRetry)
  21. {
  22.     $.ajax({
  23.         type: "post",
  24.         url: "http://api.url/api/Receipt",
  25.         data: { receipt },
  26.         success: function(data)
  27.         {
  28.             setTimeout("location.href = 'index.php?module=pos';",2500);
  29.         },
  30.         error: function(xhr, status,data)
  31.         {
  32.             // Only retry the post once.
  33.             // If it errors a second time, the customer will be informed elsewhere
  34.             if (isRetry)
  35.             {
  36.                 return;
  37.             }
  38.             else
  39.             {
  40.                 PostReceipt(receipt, true);
  41.             }                  
  42.         }
  43.     });
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top