Installment Plans
You can retrieve a list of installment plans in two ways:
- As an intent state called
INSTALLMENT_PLANS
, which makes it part of the intent lifecycle. In this case, the plans property will be within stateDetails. - By retrieving the list of plans without creating an intent, using
moneyhash.getInstallmentPlans
, and providing thepublicApiKey
for the relevant account. For this approach, ensure that the default payment provider for the account supports installment plans.
Retrieving Plans as Intent State
During the intent lifecycle, if the user enters an eligible card number for installment plans, the intent state property will appear as INSTALLMENT_PLANS
. The stateDetails
will then contain a list of available plan items.
// intent details sample
{
state: "INSTALLMENT_PLANS",
stateDetails: {
plans: [
{
id: "<plan-id>",
installmentPeriod: 3,
amount: {
value: "value", // amount with currency
formatted: 60.92, // amount as number
currency: "currency",
},
interestRate: "<interest-rate>" | null,
upfrontFees: "<upfront-fees>" | null,
issuerCode?: "<issuer-code>" // optional field
},
],
}
}
Once the plans
are displayed to the user, you can call moneyhash.selectInstallmentPlan
to proceed with the payment. This method will return the updated intent details.
const intentDetails = await moneyhash.selectInstallmentPlan({
intentId: "<intent-id>",
planId: "<plan-id>",
issuerCode?: "<issuer-code>" // optional, pass it if received in plan details
});
Retrieving Plans Without Intent Creation
Alternatively, you can obtain a list of plans directly from the account’s default payment provider. This approach requires the account's publicApiKey
when initializing the MoneyHash
instance. Additionally, you’ll need to provide the first six digits of the card, the installment amount, and the currency.
const plans = moneyhash.getInstallmentPlans({
first6Digits,
amount,
currency,
});
console.log(plans);
The methods moneyhash.submitForm
, moneyhash.cardForm.pay
, and moneyhash.submitCvv
now accept an optional installmentPlanData
parameter. This object should include planId
and issuerCode
to specify the chosen installment plan during payment submission.
const res = await submitCvv({
intentId,
cvv,
installmentPlanData: {
planId: "<plan-id>",
issuerCode: "<issuer-code>" // send it if received in plan item
},
});
Updated about 1 month ago