Working with webhooks and tokenization
Since the tokenization workflows are asynchronous we recommend that you subscribe to at least these webhooks:
Track successes​
By subscribing to the walley:order:created
you can receive the OrderId of the order created from the success of this authorization. You will need this OrderId if you want to utilize the Order Management api.
Track failures​
By subscribing to walley:authorization:retrying
and walley:authorization:failed
webhooks you can follow all the reasons why we are at the moment not able to a fulfill the authorization.
The Reason
property in the webhook payload will give you a hint on what went wrong. The possible reasons are:
For the retrying webhook:
Reason | Description |
---|---|
SERVICE_UNAVAILABLE | There was a temporary issue with the payment provider, and we will retry the authorization. |
PAYMENT_METHOD_NO_FUNDS | The payment method used for the authorization has insufficient funds, and we will retry the authorization. |
PAYMENT_METHOD_DECLINED | The payment method used for the authorization was declined by the payment provider or bank, and we will retry the authorization. |
For the failed webhook:
Reason | Description |
---|---|
PAYMENT_METHOD_EXPIRED | The payment method used for the authorization has expired. |
PAYMENT_METHOD_REFUSED | The payment method used for the authorization was refused by the payment provider or bank, for example due to lost or stolen card. |
CANCELLED_BY_CUSTOMER | The customer token has been cancelled using the Cancel endpoint. |
Testing webhooks​
If you want to test the different outcomes for the webhooks for an authorization, you can simulate an error by modifying the customer token. This is only available in the test environment.
- Request
- Response
- Error
PUT /purchase/customer-tokens/916f7730-8d24-4dd9-9778-92b75b747382 HTTP/1.1
Host: api.uat.walleydev.com // (Please note! Different hostname in production)
Authorization: Bearer bXlVc2VybmFtZTpmN2E1ODA4MGQzZTk0M2VmNWYyMTZlMDE...
Content-Type: application/json
{
"AuthorizationFailure":
{
"Reason": "Expired"
}
}
HttpStatusCode: 200 Ok
{
"id": "17635160-e66f-46b9-84fc-db939005050c"
}
/*
Example error. More errors available below.
*/
HttpStatusCode: 404 Not Found
{
"id": "fe8a21bb-6cb5-4d7d-b7f6-c0c335fc4593",
"error":
{
"code": 404,
"message": "The resource requested was not found.",
"errors": []
}
}
Request Properties​
Request headers
Header | Required | Explanation |
---|---|---|
Authorization | Yes | Instructions on how to generate the authorization header value can be found here. |
Request body
Property | Required | Explanation |
---|---|---|
AuthorizationFailure | No | Provide null to remove the error, or an object describing the reason |
AuthorizationFailure object
Property | Required | Explanation |
---|---|---|
Reason | No | The reason can be one of the following: Expired, Refused, ServiceUnavailable, NoFunds, Declined. Set to null to remove the error |
Important error responses​
Error code | Cause |
---|---|
401 | Incorrect, missing or expired bearer token |
404 | The customer token was not found for the authenticated bearer token |
503 | There was some internal error. Please try again |