Open a payment pop-up window, which is available on the Instance.
Use the Options object to specify the pages where the customer should be redirected, and any additional information related to the payment of the customer:
type InstancePayWithPopup = (
options: Options
) => {
destroy: () => void;
};
type RevolutCheckoutError = {
type: string;
message: string;
code?: number;
}
type Options = {
onSuccess?: () => void;
onError?: (error: RevolutCheckoutError) => void;
onCancel?: () => void;
name?: string;
email?: string;
phone?: string;
locale?: string;
upsellBanner?: boolean;
savePaymentMethodFor?: string;
billingAddress?: {
countryCode: string;
region?: string;
city?: string;
postcode: string;
streetLine1?: string;
streetLine2?: string;
};
shippingAddress?: {
countryCode: string;
region?: string;
city?: string;
postcode: string;
streetLine1?: string;
streetLine2?: string;
};
};
| Option | Description | Format |
|---|---|---|
onSuccess | Callback when the payment is successfully completed. | Function |
onError | Callback if the transaction fails to complete. The reason for the failure is available in the message parameter. | Function |
onCancel | Callback if a user did not complete the transaction and cancelled the authorisation or closed the payment pop-up window. | Function |
locale | Controls the language of the text in the widget.Possible values
| String |
upsellBanner | Controls if the upsell banner is displayed on the pop-up window. | Boolean |
name | Cardholder's name in the format of FirstName LastName. This value is optional. If not sent, it will be dynamically asked in the popup. | String |
email | Customer's email. This is optional. If not sent, it will be dynamically asked in the pop-up (if it wasn't already set on the order via API). | String |
phone | Customer's phone number if available | String |
savePaymentMethodFor | Controls if and how the payment method should be saved after a successful payment. A customer.id must be associated with the order to save a payment method. If not provided during initialisation, then the SDK will create a new customer and link it to the order associated with the payment session.Possible values:
| Enum |
billingAddress | Customer's billing address, which is required if not set on order via API. | Object |
billingAddress.countryCode | Country code (e.g. GB). If sending the billingAddress, this is required. | String |
billingAddress.region | State, county or region. For US states, the 2-digit abbreviation should be used (e.g. AL for Alabama) | String |
billingAddress.city | Name of the city (e.g. London) | String |
billingAddress.postcode | Postal code (e.g. EC2V 6DN). If sending the billingAddress, this is required. | String |
billingAddress.streetLine1 | Address line 1 (e.g. 1 Canada Square) | String |
billingAddress.streetLine2 | Address line 2 (optional) | String |
shippingAddress | The same object as the billingAddress object. However, it is displayed only in the order details on the Merchant Dashboard. | Object |
Methods object:
| Field | Description | Format |
|---|---|---|
methods.destroy | Manually destroy payment pop-up if needed | Function |
RevolutCheckout("<token>").then(function (instance) {
instance.payWithPopup({
onSuccess() {
window.alert("Thank you!");
},
onError(message) {
window.alert("Oh no :(");
},
});
});
RevolutCheckout("<token>").then(function (instance) {
instance.payWithPopup({
onSuccess() {
window.alert("Thank you!");
},
onError(message) {
window.alert("Oh no :(");
},
locale: "es",
billingAddress: {
countryCode: "GB",
region: "Greater London",
city: "London",
streetLine1: "Revolut",
streetLine2: "1 Canada Square",
postcode: "EC2V 6DN"
},
});
});
RevolutCheckout("<token>").then(function (instance) {
var popup = instance.payWithPopup({
name: "John Smith",
email: "customer@example.com",
phone: "+447950630319",
locale: "es",
upsellBanner: true,
billingAddress: {
countryCode: "GB",
region: "Greater London",
city: "London",
streetLine1: "Revolut",
streetLine2: "1 Canada Square",
postcode: "EC2V 6DN"
},
shippingAddress: {
countryCode: "GB",
region: "Greater London",
city: "London",
streetLine1: "Revolut",
streetLine2: "1 Canada Square",
postcode: "EC2V 6DN"
},
onSuccess() {
window.alert("Thank you!");
},
onError(message) {
window.alert("Oh no :(");
}
});
// ...
popup.destroy();
});
For a more in-depth example, see the pay with pop-up example.