Documentation You are here: start » v » 2.0 » webhooks

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
v:2.0:webhooks [2019/11/05 13:48]
marija [Sending Webhooks & Automatic Retries]
v:2.0:webhooks [2019/11/06 05:29] (current)
Line 14: Line 14:
 ===== Sending Webhooks & Automatic Retries ===== ===== Sending Webhooks & Automatic Retries =====
  
-When a new transaction is placed and your webhooks are triggered, Foxy will wait for 1 minute for a response from your webhook endpoint. If a webhook fails to respond successfully (that is, if we don't receive a //​200// ​HTTP Response Code, or in the case of the Legacy XML Webhook, //foxy//) in that time for any reason, Foxy will automatically reattempt to connect to your endpoint 11 more times within the following hour after it was initially attempted. The retries will get progressively further apart over the hour: ranging from around 1 minute apart up to around 10 minutes apart. If any of the retries are successful, no further attempts will be made.+When a new transaction is placed and your webhooks are triggered, Foxy will wait for 1 minute for a response from your webhook endpoint. If a webhook fails to respond successfully (that is, if we don't receive a HTTP response code of ''​200''​, or in the case of the Legacy XML Webhook ​a response body of just ''​foxy''​) in that time for any reason, Foxy will automatically reattempt to connect to your endpoint 11 more times within the following hour after it was initially attempted. The retries will get progressively further apart over the hour: ranging from around 1 minute apart up to around 10 minutes apart. If any of the retries are successful, no further attempts will be made.
  
 ===== PayPal, Amazon Pay, and other Hosted Gateways ===== ===== PayPal, Amazon Pay, and other Hosted Gateways =====
Line 136: Line 136:
 ==== Example Payload ==== ==== Example Payload ====
  
-The JSON payload will follow much the same structure as our Hypermedia API. Most of the objects will include the API's ''​_links''​ array. These contain helpful URI's that could be used to access the specific resources in the API if you're also making use of that. If not, these can be safely ignored. ​+The JSON payload will follow much the same structure as our Hypermedia API. Most of the objects will include the API's ''​_links''​ array. These contain helpful URI's that could be used to access the specific resources in the API if you're also making use of that. If not, these can be safely ignored.
  
 The source of the payload data is our Hypermedia API, so you can use [[https://​api.foxycart.com/​docs/​reference|the documentation]] for the different resources for further information on the data it contains. The source of the payload data is our Hypermedia API, so you can use [[https://​api.foxycart.com/​docs/​reference|the documentation]] for the different resources for further information on the data it contains.
Line 657: Line 657:
 if (is_array($parsedData)) { if (is_array($parsedData)) {
     // Handle the payload     // Handle the payload
-    ​+
     if ($event == "​transaction/​created"​) {     if ($event == "​transaction/​created"​) {
         // The following is an example of working with the transaction/​created payload         // The following is an example of working with the transaction/​created payload
Line 685: Line 685:
         }         }
     }     }
-    ​+
 } else { } else {
     // JSON data not found     // JSON data not found
Line 706: Line 706:
     return halt 500, "​Signature verification failed - data corrupted"​ unless Rack::​Utils.secure_compare(signature,​ request.env['​HTTP_FOXY_WEBHOOK_SIGNATURE'​])     return halt 500, "​Signature verification failed - data corrupted"​ unless Rack::​Utils.secure_compare(signature,​ request.env['​HTTP_FOXY_WEBHOOK_SIGNATURE'​])
 end end
- +
 post '/​webhook'​ do post '/​webhook'​ do
     request.body.rewind     request.body.rewind
Line 714: Line 714:
  
     parsedData = JSON.parse(data)     parsedData = JSON.parse(data)
-    ​+
     # Handle the payload     # Handle the payload
     puts parsedData['​id'​]     puts parsedData['​id'​]

Site Tools