Webhooks
General
SMARTy Pay can notify an external e-commerce system of different events occurring in the system via webhooks.
You can configure the notification URL in your BackOffice UI.
The following rules apply to webhook notifications:
Webhook is fired using HTTP POST.
Payload/body is in JSON format (see table below for attributes).
Payload is signed by SMARTy Pay using API Secret.
Webhook is considered successfully delivered when the remote endpoint returns HTTP 200.
Webhook is delivered with at least-once semantics.
SMARTy Pay retries webhook delivery several times with exponential backoff.
To ensure the authenticity of the webhook signature is placed inside the x-sp-digest HTTP header and is calculated using HMAC-SHA256 from the whole request body using ApiSecret as a secret.
It's important to ensure that the receiving system can handle events coming in out of order. This can happen due to network delays or other issues. If the order of events is critical, you can use an eventTs
attribute to restore order.
In some cases, the same event might be sent more than once. You can use eventId
attribute for deduplication purposes.
Invoicing
When the status of the invoice changes to Paid
or SimplePaid
SMARTy Pay notifies the external e-commerce system via webhook.
Payload attributes:
Attribute | Required | Description |
---|---|---|
eventId | Yes | Unique Id of the event |
eventType | Yes | Type of the event |
eventTs | Yes | Timestamp (iso8601) of the event |
invoiceId | Yes | Identifier of this invoice |
amount | Yes | Amount with token code |
status | Yes | Invoice new status |
createdAt | Yes | Invoice creation date/time |
expiresAt | Yes | Expiration date/time |
paidAt | No | Paid date/time |
paidAmount | No | Paid amount |
errorCode | No | Error code |
metadata | No | External metadata |
Example payload:
Recharge Payments
When a new recharge payment is detected SMARTy Pay notifies the external e-commerce system via webhook.
Payload attributes:
Attribute | Required | Description |
---|---|---|
eventId | Yes | Unique Id of the event |
eventType | Yes | Type of the event |
eventTs | Yes | Timestamp (iso8601) of the event |
cid | Yes | Customer (external) id |
hash | Yes | Payment transaction hash |
fromAddress | Yes | Source address |
pushAddress | Yes | Destination push/recharge address |
amount | Yes | Funds amount |
ingestedAt | Yes | Data/Time when this payments was detected |
Example payload:
Subscriptions
When a subscription state change is detected SMARTy Pay notifies the external e-commerce system via webhook.
Payload attributes:
Attribute | Required | Description |
---|---|---|
eventId | Yes | Unique Id of the event |
eventType | Yes | Type of event |
eventTs | Yes | Timestamp (iso8601) of the event |
contractAddress or sid | Yes | ID of subscription, contract address |
planId | Yes | ID of the plan |
asset | Yes | Token code |
blockchain | Yes | Blockchain mnemonic code |
customerId | Yes | Customer correlation ID |
payer | Yes | Payer address |
metadata | Yes | Additional correlation data |
newStatus | Yes | New subscription status |
oldStatus | Yes | Old subscription status |
Examples.
On new subscription creation:
On subscription status change:
Subscription Charges
When a subscription charge is scheduled (created) and later processed the following events are dispatched via webhook.
On subscription charge created:
On subscription charge status changed:
All possible charge statuses can be found here.
Last updated