Skip to main content

How users can purchase Payment Plans?

With the Payments Library, users/subscribers can order Payment Plans by paying. 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).

When the Payment Plan requires a payment in Fiat, the payment can be initiated with the libraries, but the final step needs to be done in the Nevermined App. The App will handle the payment in Fiat (Stripe integration) and will return the user to the application with the Payment Plan ordered.

Ordering a Plan

# Here we are ordering the Plan created in the previous steps
order_result = payments.order_plan(plan_DID)
# OUTPUT: orderResult:
# { success: True, agreementId: '0xaabbcc' }

Checking the Balance of a Payment Plan

After a user orders a plan, they can check their balance for that plan. The balance represents the number of credits the user has available to use within the plan.

note

Time-based plans provide a balance of 1 credit for subscribers. When the plan expires, this balance will be zero.

balance_result = payments.get_plan_balance(plan_DID)
# OUTPUT: balanceResult:
# {
# "planType": "credits",
# "isSubscriptor": True,
# "isOwner": False,
# "balance": 10000000
# }