You can indicate to use APM for payment authorization. This will require customers to complete an authorization step with chosen APM provider.
We return a link, generated by APM provider that you can redirect your customer to for authorization process. An authorization screen will be presented to customers where they login and approve the payment.
You need to provide apmRedirectUrl
in the authorisePayment API so we can notify you about successful payment authorization by your client. After that you can trigger capture payment with payment ID returned in callback to provided apmRedirectUrl
.
Currently available APM types :
Configure APM authorization
Open your payment flow in the Web Application and check your authorize payment action has payment-method-type
and apm-redirect-url
set to receive parameters from authorize API call.
As mentioned above, always pass apmRedirectUrl
in the API call, and replace APM_METHOD_TYPE
with the APM value value.
curl
-X POST
-H "Content-Type: application/json"
-H "Authorization: Bearer xxxxxxx"
-d '{
"query": "mutation authorizePayment($authorisePayment: AuthorisedPaymentInput!) {
authorizePayment(authorisePayment: $authorisePayment) {
id
status
}
}",
"variables": {
"authorisePayment": {
"orderId": "5113e019-9316-4498-a16d-4343fda403eb",
"flowId": "0c6d975e-f586-4fa6-8caf-863e69ac78d6",
"amount": 1200,
"currencyCode": "USD",
"apmRedirectUrl": "http://valid-url-to-merchant-callback-endpoint.io",
"paymentMethod":{
"type": "APM_METHOD_TYPE"
}
}
}
}'
https://api.whenthen.com/api/graphql
Handle Valid Error Response
We use an error pattern to handle next steps required. When an error is returned with error codeerror.authorize.requiresApmAuthorization
then you must redirect your web application to the url
.
The customer will be redirected to their APM account to confirm the payment authorization by logging into their APM account.
{
"data": {
"authorizePayment": null
},
"errors": [
{
"message": "Alternative payment method needs authorization: https://www.apm-payment-confirmation.com",
"extensions": {
"noTrace": true,
"code": "error.authorize.requiresApmAuthorization",
"url": "https://www.apm-payment-confirmation.com"
}
}
]
}
Handle Authorization Callback Response
When your customer has completed APM payment authorization, success/fail will be returned to theapmRedirectUrl
with id
of the payment as a query parameter.
http://valid-url-to-merchant-callback-endpoint.io?id=payments:d5ad8b04-7d77-11ec-90d6-0242ac120003
In case there was and error during the client authorization or callback back to whenthen application from APM provider, we reply to the provided apmRedirectUrl
but witherror
query parameter.
http://valid-url-to-merchant-callback-endpoint.io?error=failed.apm.authorization
It is recommended you use the id
to call the getPayment
API and verify the status of the payment.
Don't forget the power of WhenThen as a no-code payment logic platform. You can build automations based on the outcome of a payment