Here you'll be able to get existing BNPL or Pawn Plans, fetch the next payment due, and make a payment on an existing Plan.

Get user plans

Call the getUserPlans method to get the pending, funded, active plans of the given address.

const userWallet = '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d';
const plans = await cyan.getUserPlans(userWallet);

Make a single payment on a Plan

To make a payment for an existing BNPL or Pawn Plan, call the pay method with the result from the getUserPlans method.

const plan = await cyan.pay({
	planId: 1234,
	paymentPlanContractAddress: '0xE803684B9E391D01Dc1cdF76baC9aE3A596B2ae0',
}); // You can pass single IPlan object returned from `getUserPlans`

Make all remaining payments on a Plan

const plan = await cyan.payEarly({
	planId: 1234,
	paymentPlanContractAddress: '0xE803684B9E391D01Dc1cdF76baC9aE3A596B2ae0',
}); // You can pass single IPlan object returned from `getUserPlans`

Make a single payment for all given Plans

To make multiple payments for an existing BNPL or Pawn Plans, call the payBulk method with the result from the getUserPlans method.

const plans = await cyan.payBulk(plans, false); // You can pass multiple IPlan object returned from `getUserPlans`

Make all remaining payments for all given Plans

const plans = await cyan.payBulk(plans, true); // You can pass multiple IPlan object returned from `getUserPlans`

Get the next payment due in a Plan

If you want to get payment information for the plan, call the getPaymentInfo method to get the next payment information with the returned result of getUserPlans method.

const plan = await cyan.getPaymentInfo(
  {
    planId: 1234,
    paymentPlanContractAddress: '0xE803684B9E391D01Dc1cdF76baC9aE3A596B2ae0',
  }, // You can pass single IPlan object returned from `getUserPlans`
  false, // Optional boolean representing is early repayment or not
);