This is not an endpoint, but a way to retrieve the next payment due on a plan, and make a payment.

📘

For the best experience, please refer to the SDK documentation. You'll be able to install our library and get started in not only retrieving the next payment on plans but also interacting with the Cyan Protocol.

In order to retrieve the next payment data, use the getNextPayment function from the smart contract which uses returned data from the Retrieve Plan data, or from the Retrieve user's Activated, Funded and Pending Plans data.

📘

  • The Payment plan contract is available on: Etherscan
    • Cyan ABI is available on: Github

getNextPayment function accepts following inputs:

FieldsDescription
addressCyan Wrapper address of the collection.
tokenIdNFT id

This function returns the following data:

FieldsDescription
payAmountForCollateralPayment amount for collateral as BigNumber
payAmountForInterestPayment amount for interest as BigNumber
payAmountForServicePlatform Fee as BigNumber as BigNumber
currentPaymentPayment amount to be made as BigNumber
nextPaymentDateNext due date of the payment

After usinggetNextPayment function from the smart contract and getting some of the data in the table.
We can use currentPayment to make a payment using pay function from the smart contract.

pay function accepts following inputs:

FieldsDescription
addressCyan Wrapper address of the collection.
tokenIdNFT id
valuePayment amount to be made as BigNumber

Example:

const provider = ... // your Web3 provider
const contract = new Contract( // Contract from ether.js
       plan.paymentPlanContractAddress, // returned from Plan API
       abi, // Cyan ABI
       provider // Web3 provider
)

// Retrieve the next payment due on a plan
const [
      payAmountForCollateral,
      payAmountForInterest,
      payAmountForService,
      currentPayment,
      nextPaymentDate,
    ] = await contract.getNextPayment(plan.wNFTContract, plan.wNFTTokenId);

// Make a payment
const res = await contract.pay(plan.wNFTContract, plan.wNFTTokenId, {
      value: currentPayment
})