On this page, you can find additional configuration for adding gift card to your Components integration.
Before you begin
This page assumes you've already:
API reference
You don't need to send additional fields for gift card. To see optional fields that you can send for all payment methods, choose the endpoint you integrated:
- /sessions: This is the default with Components v5.0.0 or later.
- /payments: If you implemented an advanced use case, or integrated Components before v5.0.0.
Component configuration
Step 1: Create a DOM element
Create a DOM element on your checkout page, placing it where you want the payment method form to be rendered:
<div id="giftcard-container"></div>
Step 2: Create an instance of the Component
Required
Add the following event to your gift card configuration object:
Event name | Description |
---|---|
onBalanceCheck(resolve, reject, data) |
Called when the shopper pays with gift card. Make a /paymentMethods/balance request and check if the balance amount is greater than or equal to the total transaction amount. |
(Optional) Accepting partial payments
If you want to accept partial payments, you can configure the gift card Component to create an order or cancel an order. After an order is created, you must make partial payments outside of the Component.
To configure the Component to create and cancel orders, add the following events to your gift card configuration object:
Event name | Description |
---|---|
onOrderRequest(resolve, reject, data) |
Called when the gift card balance is less than the transaction amount. Make an /orders request with the amount of the total transaction amount. |
onOrderCancel(order) |
Called when the shopper cancels the gift card transaction. Make an orders/cancel request. |
The following example shows how to configure the gift card Component:
const giftcardConfiguration = {
onBalanceCheck: function (resolve, reject, data) {
// Make a POST /paymentMethods/balance request
// Check if the balance is greater than or equal to the transaction amount
resolve(BalanceResponse);
};
onOrderRequest: function (resolve, reject, data) {
// Make a POST /orders request
// Create an order for the total transaction amount
resolve(OrderResponse);
};
onOrderCancel: function(Order) {
// Make a POST /orders/cancel request
};
};
Use the create
method of your AdyenCheckout
instance, in this case checkout
, to create the Component. Pass the configuration object if you created one:
const giftcardComponent = checkout.create('giftcard', giftcardConfiguration);
Step 3: Mount the Component
Mount the Component only after checking that gift card is available to the shopper:
giftcardComponent
.isAvailable()
.then(() => {
giftcardComponent.mount("#giftcard-container");
})
.catch(e => {
//gift card is not available
});
(Optional) Making partial payments
When balance of the shopper's gift card is less than the payment amount, no payment is made. Instead, the
onOrderRequest
event creates an order for the full payment amount. After the order is created, you can start making partial payments:
-
The response to the
onOrderRequest
event includes the following fields that you need for payment:Field Description pspReference
The unique reference for the order. orderData
The details needed to make payments for the order. remainingAmount
The full payment amount. - Use the values from the Component and the /payments endpoint to make partial payments and complete the order outside of the Component.
Test and go live
Before making live gift card payments, simulate transactions:
-
Test your integration using our test card numbers depending on your gift card provider.
To simulate a scenario, send one of the following amounts in the test payment request:
For example, send a payment amount with 100 as the last three digits, such as 1.00 or 11.00. This will result in an Authorised transaction.Amount (last three digits) resultCode
refusalReason
100 Authorised 123 Refused Refused 124 Refused Not enough balance 125 Refused Blocked Card 126 Refused Expired Card 130 Error Acquirer Error 134 Refused Invalid Pin 135 Refused Pin tries exceeded You can check the status of test payments in your test Customer Area > Transactions > Payments.You can test other scenarios in your live environment using real gift card details and small amounts. - Contact our Support Team to add the gift card to your live Customer Area.