Payment Tokens
Payment tokens can be used to make the payment for an order using a saved payment token at payment service provider. These are used in saved credit cards and recurring payments.
Pre-requisites
To save a credit card, payment service provider should usually enable the recurring payment / subscription payments feature for the payment account.
Also, the payment app implimentation in Litium should support the feature.
Saving a payment token
To save a payment token, when creating the order, initialize the checkout flow with setting CheckoutFlowInfo.InitializePaymentToken property to true.
Example:
Following is a code snippet from Litium Accelerator that switches on the above property.
private CheckoutFlowInfo GetCheckoutFlowInfo()
{
//Other code...
return new CheckoutFlowInfo
{
//Other code...
//Initialize to save a paymen token
InitializePaymentToken = true,
};
}
The payment token is saved in the payment app.
The payment token is associated with the Payment.SystemId of the payment of the order that is used initialize the payment token. Create the order after setting InitializePaymentToken to true in checkout flow info, and get the Payment.SystemId to pay for a order using payment token as shown below.
Using Payment Token
To pay for an order using a saved payment token, use a payment method with PaymentIntegrationType.PaymentToken.
Following method should be called to initialize the payment with the saved token. Use the Payment.SystemId of the payment of the order that is used initialize the payment token for this.
var cartContext = await HttpContext.GetCartContextAsync();
await cartContext.SetPaymentTokenAsync(new SetPaymentTokenArgs() { PaymentToken = token });
After that, create the order as usual.
There is a detailed example of how to use payment tokens here >>