Handling Deposits

Phase 1: Receiving Deposit Request from a User

Step 1

The user should send the deposit request to the server. The deposit request should have the currency and amount being transferred.

Step 2

The server creates a unique key (UUID) for the deposit. This UUID will ensure that this transaction occurs only once.

After creating the UUID, the deposit data (amount, currency, user ID, UUID) should be stored on Redis. We recommend setting the UUID as the key. It's also a good idea to give the data an expiry time.

Step 3

After the deposit is given a UUID and is stored on Redis, the server should then forward the payment request to the payment service. The payment service should receive the amount, currency, and UUID of the requested deposit.

Step 4

Once the request from the server is received, the payment service will prompt the user to complete the payment. This can be handled by the server or by the payment service directly via a redirect.

Phase 2: User completes deposit

Phase 3: Payment service notifies the server of completed deposit

Step 1

Once the user completes the payment, the service will notify the server of the completed payment. The way notifications are handled will depend on the payment service used. This notification should come with the amount and currency of the completed deposit. It should also provide the UUID the server created for this deposit in Phase 1.

Step 2

Once the server receives the notification, it should first check Redis to make sure the UUID is valid.

If data is found with the UUID, that data should be deleted from Redis. After deletion, the server should verify that the amount and currency of the deposit received from the payment service matches the ones found on Redis.

Step 3

Once everything is validated, the server should mint the asset to the user. This completes the deposit flow.

Code Example

Last updated