As the interaction is directly on-chain, this is not an endpoint. Steps to create a BNPL plan are detailed below!

📘

For the best experience, please refer to the SDK documentation. You'll be able to install our library and get started in not only creating BNPL plans but interacting with the Cyan Protocol as well.

In order to create a BNPL plan, call the createBNPL function from the smart contract with data retrieved from the endpoint BNPL Pricer Step 2.

📘

  • The PaymentPlanV2 contract is available on Contracts
  • Cyan ABI is available on: Github

createBNPL function accepts the following parameters:

FieldsDescription
itemItem object
planPlan object
planIdPlan ID generated from the Cyan pricer
signedBlockNumThe last block number
signatureSignature created and provided by Cyan

Item object:

Example:

const signer = this.provider.getSigner();
const item = {...}; // Item object
const plan = {...}; // Plan object
const planId = 123; // Plan ID from the pricer
const blockNum = 1000; // Latest block number of the chain
const signature = '0x123abc' // Signature from the pricer

const contract = new Contract(
      paymentContractAddress, // Cyan payment contract address
      abi // Cyan ABI
      signer // signer from Web3
);

const transaction = await contract.createBNPL(
      item,
  		plan,
  		planId,
  		blockNum,
  		signature,
      { value: calculatedData.downpaymentAmount } // The value may be zero if it is not a native currency.
);