In this tutorial you can learn how to save and charge your customer's payment methods using the Revolut Checkout Widget. To do that, you have to:
Familiarizing yourself with this process can be helpful to take advantage of saved payment methods. There are two types of payments:
To save a customer's payment details using any of the available payment methods, you need to meet one of the following requirements:
email
and assign it to the order by providing customer.id
customer.email
during order creationThere are two approaches to save the payment details of a customer:
Use this approach when your customer already has an account on your site at checkout. The payment method is attached to the customer after the payment is made.
Use this approach when your customer starts the checkout as a guest user on your site. The payment method is attached to the customer after the payment is made.
Once the customer is created and their payment method is saved, you can charge the payment method even when the customer is not on the checkout page. This can be useful for taking recurring payments.
You can also use this approach to provide a faster checkout experience for customers, for example, a 1-click buy flow.
To charge a customer's saved payment method, follow these steps:
Create an order with the amount
, currency
and customer.id
parameters in the body of the request. Where the customer.id
corresponds to a customer with a saved payment method.
Pay for the order using the Merchant API: Pay for an order endpoint to initiate the payment using a customer's saved payment method.
Use the following JSON object as the payload of the request:
{
"saved_payment_method": {
"type": "<type of the saved payment method>",
"id": "<ID of the saved payment method>",
"initiator": "<initiator of the payment>"
}
}
To retrieve the required information, use the order paid initially in Step 1. Retrieve the payment method ID and type from the order response using payments.payment_method.id
and payments.payment_method.type
.
The following table shows who can initiate payments on saved payment methods (initiator
parameter in payment request), depending on if the payment method was saved for the customer or the merchant (savedPaymentMethodFor
parameter in the widget configuration):
savePaymentMethodFor: customer | savePaymentMethodFor: merchant | |
---|---|---|
initiator: customer | Allowed | Allowed |
initiator: merchant | Not allowed | Allowed |
Only merchant initiated transactions are supported with Revolut Pay on the Pay for an order endpoint.
If the payment is successfully captured, the following JSON is returned:
{
"id": "6407402d-cf34-ac35-9be4-f1448708811b",
"order_id": "64073e7b-41af-a715-8a37-9d73cd01fa9f",
"payment_method": {
"type": "card",
"id": "6513122e-877b-aa8d-9d26-4d1a805c7841",
"brand": "mastercard_credit",
"last_four": "1234"
},
"state": "captured"
}
You can handle captured payments as completed, it takes around 24 hours to settle payments on your Merchant Account.
Congratulations! You've successfully charged one of your customer's saved payment methods.