Payment card authorization
Last updated
Was this helpful?
Last updated
Was this helpful?
Whenever a user creates a reservation, there is an option to let them add a payment card, which will then be stored in Mews. You can read more about how to support payment cards in your booking engine application in the use case.
With the PSD2 directive (Revised Payment Services Directive - a European Union Directive), it might be convenient for the enterprise to authorize the card for smooth payments in the future. This can minimize the risk of a future payment being rejected.
The first step of the workflow is to create a reservation group via the API, using and supplying payment card data with the request - see . The next step is to check whether the card needs authorization by getting the card details using and checking if the card is Authorizable
. If it is, then you can try to authorize the card immediately, using .
Check the card in the response to . If the state is a finite state, such as Authorized
or Declined
, then no further action is needed. If the state is a non-finite state, such as Pending
or Requested
, then you can redirect the user to the Mews application, which will take care of the whole authorization process. Simply navigate the user to URL:
https://[MewsApplicationsBaseUrl]/navigator/card-authorization/detail/[PaymentCardId]?returnUrl=[ReturnUrl]
.
A returnUrl
query parameter is optional and is used by the application to return the user into your booking engine after successful payment card authorization, or in case the user decides to abandon the process. The returnUrl
value should be a Base64
encoded absolute URL e.g. in JavaScript via the btoa
function.
After the user returns to your booking engine, you can verify the card authorization state again using and checking that the of the card is Authorized
.
Call with , and get PaymentCardId
from the response.
Validate that the card is Authorizable
via the operation. If not, the workflow ends here.
Try to authorize the card via and check that the in the response is either Pending
or Requested
. If not, the workflow ends here.
Create a ReturnUrl
by encoding your URL using Base64
, e.g. the JavaScript example would be btoa(urlWhereUserShouldReturn)
.
Re-direct the user to the gateway at URL https://[MewsApplicationsBaseUrl]/navigator/card-authorization/detail/[PaymentCardId]?returnUrl=[ReturnUrl]
(you can find the value of MewsApplicationBaseUrl
in the section).
After the user returns to the ReturnUrl
in your booking engine, you can verify the authorization state by again using and checking that the is Authorized
.