How to Configure Gift Card Payment
This document provides a step-by-step guide on how to configure and integrate the Gift Card Payment Flow in Commerce. The Gift Card Payment Flow connects Commerce to an external gift card provider through a standardised extension interface, allowing customers to redeem gift cards during checkout — with optional OTP verification support.
This integration is particularly useful for providers that manage their own card balance logic, require OTP-based identity verification, or need idempotent refund handling.
1. Overview
When a customer applies a gift card during checkout, Commerce communicates with the configured provider through a standardised interface. The provider handles card balance queries, optional OTP verification, and payment transactions. Commerce orchestrates the flow and applies the result to the basket.
Key characteristics of this flow:
Provider abstraction: Each provider implements its own gift card logic; Commerce communicates through a fixed interface without provider-specific changes.
OTP support: Providers that require OTP verification are fully supported. The user must verify their identity before the card can be charged.
Multi-card support: Multiple gift cards can be applied to a single order when enabled.
Idempotent refunds: Refund operations are safe to retry; the provider is expected to handle duplicate requests gracefully.
Automatic void on failure: If an order cannot be created after a successful gift card charge, Commerce schedules an automatic void to clean up the orphaned transaction.
2. Setup
Configuring the gift card feature requires two steps: setting the behavioural parameters via the GIFT_CARD_CONFIG dynamic setting, and registering the gift card provider through the Omnitron provider management screen.
2.1. Configuring GIFT_CARD_CONFIG
Log in to Omnitron using your own credentials.

Navigate to Sales Channels → Sales Channel Settings → Dynamic Settings.

Search for GIFT_CARD_CONFIG in the search box and click on it in the list.

Update the configuration on the edit screen with the following fields.

multi_card_enabled
Set to true to allow more than one gift card per order. When false, a second card is rejected if one is already applied.
max_amount_per_order
Maximum total gift card amount per order (in the order's currency). 0 means unlimited.
balance_cache_ttl
Duration in seconds that a queried card balance is kept in cache. Should be long enough to cover the full application flow including OTP verification.
otp_resend_cooldown
Minimum seconds a user must wait before requesting a new OTP.
void_task_countdown
Delay in seconds before Commerce automatically voids an orphaned gift card charge when order creation fails.
Example configuration:
2.2. Registering the Gift Card Provider
The gift card provider connection details (service URL and authentication credentials) are managed through the Gift Card Providers screen in Omnitron. This is separate from Dynamic Settings.
Navigate to Gift Card Providers in Omnitron.
Click Add Provider and fill in the following fields.
resource_url
Base URL of the gift card provider's extension service.
username
Username for HTTP Basic Authentication.
password
Password for HTTP Basic Authentication.
Example provider configuration:
3. How the Flow Works
3.1. Applying a Gift Card (Non-OTP)
When a customer enters a gift card number, Commerce calls the provider's check-balance endpoint. If the provider does not require OTP, the response includes the card balance and a purchaseToken directly. The card is reserved in the basket and the customer can proceed to payment.
3.2. Applying a Gift Card (OTP Flow)
If the provider requires OTP verification, check-balance returns otpRequired: true and an otpRef. Commerce prompts the user to enter the OTP sent to their masked phone number. The user may request the OTP to be resent; Commerce enforces the otp_resend_cooldown between consecutive resend requests. Once the user submits the correct OTP, verify-otp returns the purchaseToken and the card is reserved.
3.3. Purchase
When the order is placed, Commerce charges each applied gift card by calling the purchase endpoint with the corresponding purchaseToken. If multiple gift cards are applied, a separate purchase request is sent per card. If any charge fails, all previously successful charges for that order are automatically voided.
3.4. Void
The void endpoint is used to reverse a purchase transaction. If the order has not yet been created at the time of the void, orderNumber is sent as null.
Commerce does not halt the flow on void errors — the void is best-effort. However, the provider is still expected to return a successful response.
If order creation fails after a successful gift card charge (e.g. due to a server error or timeout), Commerce schedules a background void task after void_task_countdown seconds to clean up the orphaned transaction automatically.
3.5. Refund
Partial and full refunds are supported. Commerce calls the refund endpoint with the original transactionId, the refund amount, and the order number. The provider is expected to handle duplicate refund requests idempotently.
4. Payment & Balance Behavior
This section describes how gift cards behave during checkout, payment, and post-order — partial payment, insufficient balance, cancellation/refund, multiple cards, and the errors a customer may see.
4.1. Partial Payment (Gift Card + Another Method)
A gift card is not a payment step that hands off to the credit card page in sequence. When a card is applied, Commerce reserves it on the basket and lowers the amount left to pay. The remaining amount is then charged on the customer's regular payment method (e.g. credit card) in the same payment step.
The amount still owed after gift cards is:
where gift_card_amount is the sum of all applied gift card reservations.
Partial coverage: The gift card is charged as a pre-payment alongside the regular payment method. The customer selects a payment option as usual, and only
amount_to_payis charged to that method. There is no separate request to "move" the remainder — Commerce computes it and charges the regular method for that figure.Full coverage: When the applied gift cards cover the entire total (
amount_to_pay = 0), the order is completed directly on the gift card payment page, with no credit card involved.
4.2. Insufficient Balance
A gift card whose balance is lower than the requested amount (or lower than the order total) is not rejected. The requested amount is automatically capped and the card is partially applied. The applied amount is the smallest of:
the requested amount,
the card's available balance,
the amount still left to pay on the order, and
the remaining headroom under
max_amount_per_order(when a per-order limit is configured).
The remaining order total is then paid by the regular payment method, as described in the partial payment behavior above. The customer is shown the maximum applicable amount for the card before confirming.
The only case in which a low balance leads to a rejection is when the capped amount comes out as zero — for example, when the order is already fully paid or the per-order limit is already reached. In that case the card is refused with the gift_card_108 error.
4.3. Cancellation & Refund
Gift card charges are reversed through two distinct provider operations — void and refund — both of which are invoked by the Omnitron backend through the corresponding methods under omnicore (the GiftCardExtensionClient).
Void (automatic cleanup): If a gift card is charged but the order cannot be created afterwards (for example, a server error or timeout during order creation), Commerce reverses the charge by calling the provider's
voidendpoint. This runs automatically as a background safety-net after the configuredvoid_task_countdownseconds (code default1800; the example configuration in section 2 sets it to3600). If the order is created successfully in the meantime, the charge is linked to the order and the scheduled void becomes a no-op.Refund: Partial and full refunds are issued through the provider's
refundendpoint. The provider is expected to handle duplicate refund requests idempotently.
4.4. Multiple Gift Cards on One Order
Whether more than one gift card can be applied to a single order is controlled by multi_card_enabled in GIFT_CARD_CONFIG:
When
multi_card_enabledisfalse(the default), applying a second card is rejected withgift_card_110once one card is already applied.The same card cannot be added twice regardless of the setting; a duplicate is rejected with
gift_card_101.max_amount_per_orderlimits the combined total of all applied gift cards. Each additional card can only reserve up to the remaining headroom under this limit;0means unlimited.
At payment time, each applied card is charged with a separate purchase request. If any card's charge fails, all previously successful charges for that order are automatically voided and the payment fails with gift_card_106.
4.5. Common Errors
The following errors may be returned during the gift card flow. The message shown to the customer is the user-facing text; the cause column explains when each one occurs.
gift_card_100
Gift card not found.
The referenced gift card reservation no longer exists (e.g. removed before an update).
gift_card_101
This gift card has already been added.
The same card is applied a second time on the same order.
gift_card_102
Gift card currency does not match the order currency.
The card currency returned by the provider differs from the order currency.
gift_card_103
Gift card balance session has expired. Please re-enter your card.
The cached card balance expired (balance_cache_ttl) before the amount was confirmed. The card must be re-added.
gift_card_104
OTP verification failed.
The submitted OTP is wrong or expired, or the provider reports verified=false.
gift_card_105
Please wait before requesting a new OTP code.
An OTP resend was requested during the otp_resend_cooldown window. The response includes the retry-after delay.
gift_card_106
Gift card payment failed.
The provider did not return a successful (RESOLVED) purchase. Any prior successful charges on the order are voided.
gift_card_107
Transaction failed. Please try again.
A generic provider failure: balance check unsuccessful, otpRequired=true without an otpRef, or resend failed.
gift_card_108
Gift card cannot be applied: the applicable amount is zero.
The capped applicable amount is zero (order already paid, or per-order limit reached).
gift_card_109
OTP has already been verified.
Re-verifying an OTP that was already verified for the card.
gift_card_110
Adding multiple gift cards is not allowed.
A second card is applied while multi_card_enabled is false.
5. Implementing the Extension Service
To integrate a gift card provider, you need to implement an HTTP service that Commerce will call during checkout, cancellation, and refund flows. Once the service is deployed, register its URL and credentials through the Gift Card Providers screen in Omnitron. For the full API specification — including endpoint definitions, request/response field descriptions, OTP flow details, and error handling — refer to the Extension Gift Card Gateway Flows documentation.
Last updated
Was this helpful?

