Saber: Onramp SDK Docs

User Flow

The user needs to follow a series of steps on the client platform to purchase crypto as given below:

Onramp Hosted SDK

Saber’s Hostel SDK can be integrated by following the below mentioned steps. The integration is done in two steps:

Note:
  • You can obtain the Sandbox and Production Credentials from Mudrex Team
  • In Sandbox Testing:
    • real money testing is not allowed
    • dummy account is not present, testing should be done by creating a real account

The steps to integrate are SDK are highlighted below:

The overall integration includes two major areas:

  1. User Registration: Creation of user on Mudrex’s system and generate a UUID for the user for payment processing
  1. Payment Initiation: Generation of URL for payment where the user needs to be redirected for Onramp

User Registration

The user registration part contains the following steps:

Steps to Register a User

To be able to make payments a user has to be first registered with Mudrex. To register a user on Mudrex you need to follow the steps:

  1. Generate a secret key for user registration using the following script
var timestamp = Math.floor(Date.now() / 1000).toString();
var sigString = clientId + timeInSeconds;
var secret = CryptoJS.HmacSHA256(sigString, clientSecrect).toString().toUpperCase();
💡
The clientId and clientSecrect will be shared by the Mudrex team
  1. Use this API endpoint to register a user
MethodURL
POST{base_url}/api/v1/user/client_user
🌐
Base URL (Staging): https://sandbox.mudrex.com

Base URL (Production): https://mudrex.com

HeadersDescriptionValues
X-TimestampTimestamp used to generate the secretstring
X-Client-IdClient ID provided by Mudrexstring
X-Secret-KeyThe secret key generated in the first stepstring
X-Request-IdFor client reference (can be anything)string
💡
The User UUID is generated as a response to the request. The client can also furnish a User UUID and other user data if present already
Sample Request and Response
curl --location 'https://mudrex.com/api/v1/user/client_user' \
--header 'X-Timestamp: {{timestamp}}' \
--header 'X-Client-Id: •••••••' \
--header 'X-Secret-Key: •••••••' \
--header 'X-Request-Id: 123456789876' \
--data-raw '{
    "user_uuid": "77c4562e-ce47-4054-9d4e-4df69ca61ac2",
    "client_user_id": "Abhishek-TestAcc",
    "email": "kk@mail1.com",
    "phone":"8734567891"
}'
⚠️
data-raw parameters are optional
{
    "success": true,
    "data": {
        "client_user_id": "",
        "user_id": "d57626e7-d6f3-44e0-bc82-12c5f42843af"
    }
}

Payment Initiation

Post user registration, URL needs to be generated for payment where the user will be redirected

💡
KYC Sharing

If the user has already completed KYC with the client, the existing KYC can be shared with Mudrex. The steps can be found here under KYC Sharing tab.
Quote API

Steps to Initiate Payment

To generate a payment URL for the user where he must be redirected, follow these steps:

  1. Generate a secret key for payment using the following script. Please note that this script is slightly different from the one used at the time of user registration
var timestamp = Math.floor(Date.now() / 1000).toString();
var sigString = clientId + timeInSeconds + "sdk" + user_id;
var secret = CryptoJS.HmacSHA256(sigString, clientSecrect).toString().toUpperCase();
  1. Pass the following parameters as URL params to the base payment URL
🌐
Base URL (Sandbox): https://app.sandbox.saber.money/onramp

Base URL (Production):https://app.saber.money/onramp

ParametersDescriptionSample Value
client_idClient ID provided by Mudrexd951b040-ecb0-432b-ae3c-2ae7d2d19987
user_idA UUIDv4 unique identifier for the user-generated by the client during user registrationd951b040-ecb0-432b-ae3c-2ae7d2d19987
timestampThe timestamp of the payment request (used at the time of creating the secret)1687276964
secretThe secret generated by the client in previous step to authenticate the requestCE1B5BD087BA408C2AFF01B00595007858DF496D3468CE3307CB1A7966DDC265
⚠️
Note: The generated payment URL expires after 10 minutes
Sample URL
Payment URL Customization

If you wish to customize the integration with Mudrex Onramp, you can add query parameters to the URL. This allows you to set specific options according to your requirements. Check sample URL for example.

ParametersDescriptionSample Value
crypto_symbolThis is the unique identifier of the cryptocurrency. Currently, we support USDTUSDT
networkThis is the network on which you want to withdraw the cryptocurrency. Currently supported networks include:

BSC, BNB, ETH, MATIC TRX, ARB
MATIC
wallet_addressThis is the on-chain wallet address to which the cryptocurrency will be withdrawn.0x5ccff9cf986079c6d6f2187c3dc4bd9ba9834a9k
crypto_amountThis is the amount denoted in the native coin/token. Please note that either crypto_amount or fiat_amount can be passed, and if both are provided, fiat_amount takes precedence.100
fiat_amountThis is the amount denoted in fiat currency (currently only INR is supported).10000
payment_methodThe type of method the user would choose to pay with.
Supported payment methods:
- bank_transfer
- upi_transfer
bank_transfer
transaction_idA UUID16 identifier passed by the client (optional). The client will receive webhooks with same transaction_id
fiat_currencyThis is the fiat currency the user wants to pay (currently only INR is supported).INR
redirect_urlThis is the URL to which the user will be redirected after a successful transaction. This parameter is applicable only in hosted mode.
Webhooks

The following webhooks can be received by the client for obtaining status of the order as given below:

StatusDescriptionSample Value
‘CREATED’Triggered when the user confirms to have made the payment (click on ‘I have transferred’ CTA){'failure_code': None, 'crypto_symbol': 'USDT', 'exchange_rate': '85.00000000', 'status': 'CREATED', 'id': '146b37f1-26b5-411d-ae49-a4b6d3aa17f3', 'network': 'BSC', 'fiat_amount': '850.00000000', 'crypto_wallet_address': '0xe7cdF59Db5202f970607E19dd9921A711D377Afc', 'tag': None, 'failure_desc': None, 'payment_method': 'upi_transfer', 'crypto_amount': '10.00000000', 'fiat_symbol': 'INR', 'created_at': 1702540033000, 'source_id': '37f7cfcb-4890-471d-9f37-aa762db3eba9', 'event': 'CRYPTO_BUY', 'user_id': '7970d2d2-401b-4322-9672-c03f051dedc0'}
'ONRAMP_INITIATED'Triggered immediately once the payment reconciliation process is triggered.{'payment_method': 'upi_transfer', 'source_id': None, 'tag': None, 'exchange_rate': '84.99000000', 'failure_code': None, 'fiat_amount': '2299.00000000', 'created_at': 1694714157000, 'id': 'e4606ddb-8e63-4822-8be9-4698bb14174c', 'fiat_symbol': 'INR', 'failure_desc': None, 'crypto_symbol': 'USDT', 'network': 'MATIC', 'crypto_wallet_address': '0x466fA637cEB624F9d14fC470c509a818410768FD', 'crypto_amount': '27.05000000', 'status': 'ONRAMP_INITIATED', 'event': 'CRYPTO_BUY', 'user_id': '11030590-8f27-4325-8db6-c3bb38ba4bf3'}
'ONRAMP_COMPLETED'Triggered when the user’s payment is successfully reconciled.{'payment_method': 'upi_transfer', 'source_id': None, 'tag': None, 'exchange_rate': '84.99000000', 'failure_code': None, 'fiat_amount': '2299.00000000', 'created_at': 1694714157000, 'id': 'e4606ddb-8e63-4822-8be9-4698bb14174c', 'bank_transaction_id': '325795572402', 'fiat_symbol': 'INR', 'failure_desc': None, 'crypto_symbol': 'USDT', 'network': 'MATIC', 'crypto_wallet_address': '0x466fA637cEB624F9d14fC470c509a818410768FD', 'crypto_amount': '27.05000000', 'status': 'ONRAMP_COMPLETED', 'event': 'CRYPTO_BUY', 'user_id': '11030590-8f27-4325-8db6-c3bb38ba4bf3'}
'COMPLETED'Triggered when the crypto withdrawal to client’s specified wallet address in completed{'payment_method': 'upi_transfer', 'source_id': None, 'tag': None, 'exchange_rate': '84.99000000', 'failure_code': None, 'fiat_amount': '2299.00000000', 'created_at': 1694714157000, 'id': 'e4606ddb-8e63-4822-8be9-4698bb14174c', 'bank_transaction_id': '325795572402', 'fiat_symbol': 'INR', 'failure_desc': None, 'crypto_symbol': 'USDT', 'network': 'MATIC', 'crypto_wallet_address': '0x466fA637cEB624F9d14fC470c509a818410768FD', 'crypto_amount': '27.05000000', 'status': 'COMPLETED', 'event': 'CRYPTO_BUY', 'user_id': '11030590-8f27-4325-8db6-c3bb38ba4bf3', ‘txn_hash’: ‘0x8bc46443e1bca3f32163d193466f216d2cc774093b8280483529b8c39957e53b’}
'FAILED'Triggered when user’s payment could not be found{'failure_code': 'ONRAMP_FAILED', 'created_at': 1694631289000, 'exchange_rate': '84.99000000', 'fiat_amount': '300.00000000', 'tag': None, 'crypto_symbol': 'USDT', 'network': 'MATIC', 'source_id': None, 'failure_desc': 'Payment not received from the user', 'status': 'FAILED', 'fiat_symbol': 'INR', 'crypto_wallet_address': '0x9e706548D4443E0EdEa9a1B47AF251Ec0FF09B36', 'payment_method': 'upi_transfer', 'crypto_amount': '3.53000000', 'id': '1b824d4e-f5e5-4313-aa27-9ed67ed3d937', 'event': 'CRYPTO_BUY', 'user_id': '4924280a-c703-47f2-a82d-78567b57cedc'}
'ONRAMP_INCONSISTENT'Triggered when a payment with different amount is found for the user.{'crypto_amount': '0.57647100', 'fiat_symbol': 'INR', 'created_at': 1702202538000, 'crypto_wallet_address': '0x7ba0FF36f3bB47A0Bffd79D322CC71cFC5ddec92', 'fiat_amount': '49.00000000', 'status': 'ONRAMP_INCONSISTENT', 'crypto_symbol': 'USDT', 'failure_code': None, 'failure_desc': None, 'payment_method': 'upi_transfer', 'tag': None, 'bank_transaction_id': '334463178476', 'source_id': None, 'network': 'MATIC', 'exchange_rate': '85.00000000', 'id': 'adedaad8-ed8d-4f9d-9241-3e0eef33f704', 'event': 'CRYPTO_BUY', 'user_id': '603da946-508a-412d-961a-393cbc65714b'}
'REFUND_COMPLETED'Triggered when user’s deposited amount is refunded.{'bank_transaction_id': '334463178476', 'status': 'REFUND_COMPLETED', 'created_at': 1702202538000, 'failure_desc': None, 'crypto_amount': '0.57647100', 'payment_method': 'upi_transfer', 'crypto_wallet_address': '0x7ba0FF36f3bB47A0Bffd79D322CC71cFC5ddec92', 'source_id': None, 'id': 'adedaad8-ed8d-4f9d-9241-3e0eef33f704', 'fiat_amount': '49.00000000', 'exchange_rate': '85.00000000', 'tag': None, 'failure_code': None, 'crypto_symbol': 'USDT', 'network': 'MATIC', 'fiat_symbol': 'INR', 'event': 'CRYPTO_BUY', 'user_id': '603da946-508a-412d-961a-393cbc65714b'}
The webhooks needs to be manually added by the client using their API endpoints
SDK Events

The client can received by the client from the SDK to get status of user actions as given below:

EventDescriptionSample Value
KYC_STATUSTriggered when user completes their KYC{
  event: "KYC_STATUS",
  level: "INFO",
  params: { status: "COMPLETED" }
}
ORDER_CREATEDTriggered when an order is created{
  event: "ORDER_CREATED",
  level: "INFO",
  params: { order_id : "order_id" }
}
ORDER_UPDATEDTriggered when an order is updated, generally when a user updates their UTR manually.{
  event: "ORDER_UPDATED",
  level: "INFO",
  params: { order_id : "order_id" }
}
UPI_INTENTTriggered when user attempts to pay via upi intent. url in payment can be used to trigger the intent url in cases where it doesn’t automatically get triggered.

{
  event: "UPI_INTENT",
  level: "INFO",
  params: { url : "intent_url" }
}
BACKWhen user clicks back button in saber{
  event: "BACK",
  level: "INFO",
}
SUCCESSCalled when transaction is completed{
  event: "SUCCESS",
  level: "INFO",
  params: {
    crypto_amount: cryptoAmount,
    transaction_id: transactionID,
    status: status,
  },
}
KYC Sharing

If the user has already completed KYC on client’s platform, the same data can be shared without the need for re-KYC. The steps are as follows:

The existing KYC data of user can be shared with Mudrex using this API Endpoint

MethodURL
POSThttps://mudrex.com/api/v1/user/client_user/kyc
HeadersDescriptionValues
X-TimestampTimestamp used to generate the secretstring
X-Client-IdClient ID provided by Mudrexstring
X-Secret-KeyThe secret key generated in the first stepstring
X-Request-IdFor client reference
X-User-IdUUID of the userstring
⚠️
In the above endpoint,
  1. legal_name, poi (PAN number), poa (Aadhar number) is required (the rest are optional)
  1. dob should be in dd-mm-yyyy format
  1. gender must be either M or F
Example
curl --location 'https://mudrex.com/api/v1/user/client_user/kyc' \
--header 'X-Timestamp: 1709120158' \
--header 'X-Client-Id: 18e963ea-39fd-4a1b-b1e6-decbfe791d31' \
--header 'X-Secret-Key: <key>' \
--header 'X-Request-Id: 123456789876' \
--header 'X-User-Id: cbbb71b2-0dea-40d1-a7df-3bcdd62d1caa' \
--header 'Content-Type: application/json' \
--data-raw '{
   "legal_name":"KARTIKEY AGARWAL", 
   "poi":"AWSPP1410L",    
   "poa":"500100111232", 
   "dob":"31-01-2000",   
   "gender":"M",      
   "income":"1,00,000-5,00,000",  
   "email":"kartikey@mudrex.com", 
   "phone":"8553383091", 
   "occupation":"professional", 
   "address":"my address is a addreess" 
}'
🌐
Link to our Postman collection can also be found here: Postman