Webhooks allow you to set up integrations which subscribe to certain events from your Payhip store.
Currently, the only event available is the successful transaction event. Whenever a successful transaction occurs we send you a HTTP POST payload to the webhook’s configured URL. Webhooks can be used to tweet a new sale, add a line to a Google spreadsheet or add a buyer to an email subscriber list.
Please make sure the webhook’s configured URL returns a 200 HTTP status code. If your endpoint does not return a 200 HTTP status code, the POST is retried once an hour for up to 3 hours.
This is an example of the JSON response you will find in the body of the HTTP POST payload:
{ "id":"2GZqVkJkBp", "email":"abs@payhip.com", "currency":"USD", "price":923, "vat_applied":true, "vat_amount":173, "vat_country":"Ireland", "ip_address":"62.40.63.255", "items":[ { "product_id":"29129", "product_name":"Book Title", "product_key":"k9Ew", "product_permalink":"https:\/\/payhip.com\/b\/k9Ew", "license_key":"WTKP4-66NL5-HMKQW-GFSCZ" } ], "coupons":[ { "code":"26FDEC7CDV", "percentage":25, "amount":250 } ], "date":"1661789457", "signature":"59e178bd522471f152be2d629be31f0860a60146f090906184397c4977d83442" }
Key notes
1) Please note, all prices are in cents or pennies. For example, 10 dollars or euros will be represented as 1000.
2) The "date" property is a timestamp at which the transaction was completed. Measured in seconds since the Unix epoch.
3) To ensure that the webhook comes from us for security reasons you can use the "signature" property. The signature can be matched by comparing with
hash('sha256', $apiKey)
The above is a PHP snippet, you can sha256 hashing in any language. Your API key can be found from your Settings > Developer page.