How Subscribers can order Plans?
With the Payments Library, Subscribers can order Plans paying in Crypto. The process is simple and secure. The Subscriber needs to have enough funds in their wallet to pay for the Plan in the token selected by the creator of the Plan. In Nevermined the Payment Plan creators can request the payments in any valid ERC20 or Native token (depending on the network where the Plan is created).
Ordering a Plan
- Python
- Typescript
# Here we are ordering the Plan created in the previous steps
order_result = payments.order_plan(plan_DID)
# OUTPUT: orderResult:
# { success: True, agreementId: '0xaabbcc' }
// Here we are ordering the Plan created in the previous steps
const orderResult = await payments.orderPlan(planDID)
// OUTPUT: orderResult:
// { success: true, agreementId: '0xaabbcc' }
Get balance in credits of the Payment Plan
Once a user orders a Plan, they can check the balance of the Plan. The balance is the amount of credits that the user has available to use in the Plan.
note
Time-based Plans have a balance of 1 credit for subscribers. When the plan expires this balance will be zero.
- Python
- Typescript
balance_result = payments.get_plan_balance(plan_DID)
# OUTPUT: balanceResult:
# {
# "planType": 'credits",
# "isSubscriptor": True,
# "isOwner": False,
# "balance": 10000000
#}
const balanceResult = await payments.getPlanBalance(planDID)
// OUTPUT: balanceResult:
// {
// subscriptionType: 'credits',
// isSubscriptor: true,
// isOwner: false,
// balance: 100n
//}