Deposit Flow
Last updated
Last updated
With deposit flow, you can let your users deposit money into their accounts, keep track of user balances, and charge them for your services later.
Note that repaya is not at any time in control or has any possession of your or your customer's funds. You are fully responsible and in control of your users' funds handling and custody.
The algorithm of user deposits generally consists of two steps
At this step, you set up a payment request integration with repaya to let your customer make a payment to their balance.
After you have successfully received payment, you can request user balances from repaya. From now on, repaya is only tracking the number of funds deposited, so you will need to set up some further billing processes to deduct from the user balance when the user performs a purchase or pays for a service in your app.
Set up a Payment Request form and fill in the necessary details:
Title (for example, "Deposit to App")
Coins that you accept for payment
Your receiving blockchain address
Your return URL. This is the address on your website to redirect customers after they complete the payment.
To build the deposit flow on your site, you will need to make three things happen from your server:
Create a payment session and redirect users by the URL you get from repaya API
Check payment status
Request user balance and display it to the user
Perform a request to repaya's Rest API to create a payment session. Set the id
of the customer
field to the corresponding user ID in your own database to be able to match them after the payment is complete. Use the checkoutUrl
field from the response to redirect your user.
When the payment is completed, the customer will be redirected to your website on the return URL you provided during the payment form setup. Verify the payment status at this step by requesting it via the API. The sessionId
for the request will be provided to you in the query parameter of the return URL.
Save the resulting payment in your DB if you want to enumerate all the customer payments later or use them another way.
After the payment, you can finally request the user balance from repaya.
To let your users purchase products in your app or pay for services, you need to establish some billing process and keep track of the number of funds you deducted from user balances. Then the final user balance will be the sum of balances from repaya and the ones from your backend or database.
Check out the full Rest API Reference and Client libraries section to find out more.
You can also find the complete working example for this flow on Github.
List of customer balances
Customer ID for this balance record. The record represents a total balance if this field is an empty string
"user_123141"
Product ID for this balance record. The record represents a total balance if this field is an empty string
"product_123141"
Balance value
"123.08"
A payment associated with a given session, null if missing
"pid_3251"
"0x0000000000000000000000000000000000000000"
"0x0000000000000000000000000000000000000000"
"15.0"
"5.0"
"pending"
Create a payment session to initiate the checkout flow
"jAY7k"
"key_1432"
Payment session created
Redirect customer to this url to complete the payment
"https://repaya.io/checkout/id_124124"
Payment session ID
"id_124124"
"jAY7k"
"0x0000000000000000000000000000000000000000"
"key_1432"