API Quickstart

Overview

Through this guide, you will be able to enable users to purchase cryptocurrency using fiat currency and have it deposited into their wallets.

Prerequisites

Before you can get started, ensure:

  1. Register as a Saber merchant: If you haven’t registered yet, get started by reaching out to our team Merchant User Flow
  2. Set up your keys: Keep your keys handy. Each API call requires an authentication signature. Learn how to create it using the guide Authentication
  3. Create a user: Users form the foundation of all operations. Create a user using the Guide
  4. Configure your webhooks: Saber sends webhooks for various milestones in the on-ramp flow. Set up your webhooks using the guide Webhook Configuration and IP

Implementation

Step 1:Resgister the user, complete KYC and Verify KYC Status

Ensure the user’s KYC status is complete before proceeding.

To do so, the user's KYC information can:

  1. Be shared with Saber using the KYC sharing API. Read more KYC Sharing
  2. Or, the SDK can be used to complete the user's KYC. Read more KYC SDK. This however needed additional integration with the Saber team.

Once done, the user's KYC status can be checked using the fetch KYC status endpoint.

API Call:

curl --location 'https://saber.money/api/v1/users/kyc-status' \
--header 'X-Timestamp: {{timestamp}}' \
--header 'X-Client-Id: {{client_id}}' \
--header 'X-Request-Id: {{request_id}}' \
--header 'X-Secret-Key: {{secret_key}}' \
--header 'X-User-Id: {{user_id}}'

Sample Response:

{
  "status": "success",
  "kyc_status": "complete"
}

Find more info about the API here.


Step 2: Fetch a buy price for crypto

  • Get a real-time quote for the fiat-to-crypto conversion.
  • Use the fetch quote API. This can be used to show the quote information to the user.

📘

How long does the quote remain before updating?

As of now the quote can change between calls. This is not a sequential call and is only intended to show the quotes. It currently has no influence on order creation

API Call:

curl --location 'https://mudrex.com/api/v2/wallet/s/quote?from_currency=INR&to_currency=USDT&network=BSC&to_amount=55.38' \
--header 'X-Timestamp: {{timestamp}}' \
--header 'X-Client-Id: •••••••' \
--header 'X-Request-Id: 3456' \
--header 'X-User-Id: •••••••' \
--header 'X-Secret-Key: •••••••'

Sample Response:

{
  "success": true,
  "data": {
    "from_currency": "INR",
    "to_currency": "USDT",
    "from_amount": 5036.81,
    "pre_fee_to_amount": 55.49,
    "to_amount": 55.38,
    "base_price": 90.77,
    "final_price": 90.95,
    "total_fee": 0.11,
    "fee_currency": "USDT",
    "fee_breakup": {
      "platform_fee": 0.111,
      "network_fee": 0,
      "client_fee": 0,
      "discount": 0,
      "tax_on_fee": 0,
      "tds": 0
    }
  }
}

Find more info about the API here.


Step 3: Fetch the payment methods available

  • Fetch the payment methods available for the user to make a fiat payment

API Call:

curl --location 'https://mudrex.com/api/v1/wallet/conversion/fiat/methods?fiat=INR&crypto=USDT&type=buy' \
--header 'X-Timestamp: {{timestamp}}' \
--header 'X-Client-Id: •••••••' \
--header 'X-Request-Id: 2' \
--header 'X-Secret-Key: •••••••'

Sample Response:

{
  "success": true,
  "data": {
    "UPI": {
      "enabled": true,
      "options": {
        "gpay_intent": {
          "id": 1,
          "conversion_type": "BUY",
          "name": "gpay_intent",
          "display_name": "Google Pay",
          "description": null,
          "icon": null,
          "mode": "INTENT",
          "type": "INSTANT",
          "priority": 1
        },
        "paytm_intent": {
          "id": 2,
          "conversion_type": "BUY",
          "name": "paytm_intent",
          "display_name": "Paytm",
          "description": null,
          "icon": null,
          "mode": "INTENT",
          "type": "INSTANT",
          "priority": 3
        },
        "phonepe_intent": {
          "id": 3,
          "conversion_type": "BUY",
          "name": "phonepe_intent",
          "display_name": "PhonePe",
          "description": null,
          "icon": null,
          "mode": "INTENT",
          "type": "INSTANT",
          "priority": 2
        },
        "other_upi_intent": {
          "id": 4,
          "conversion_type": "BUY",
          "name": "other_upi_intent",
          "display_name": "Other UPI Apps",
          "description": null,
          "icon": null,
          "mode": "INTENT",
          "type": "INSTANT",
          "priority": 4
        }
      },
      "category_name": "UPI",
      "category_display_name": "UPI Options"
    },
    "BANK_TRANSFER": {
      "enabled": true,
      "options": {
        "imps_transfer": {
          "id": 6,
          "conversion_type": "BUY",
          "name": "imps_transfer",
          "display_name": "IMPS/NEFT Bank Transfer",
          "description": null,
          "icon": null,
          "mode": "IMPS",
          "type": "MANUAL",
          "priority": 1
        }
      },
      "category_name": "BANK_TRANSFER",
      "category_display_name": "Bank Transfer"
    }
  }
}

Find more info about the API here.


Step 4: Fetch beneficiary details

Once the preferred method is selected from the previous step, the beneficiary details for that payment method are to be fetched

Note:

  • If the payment method is set to "upi_transfer," the API will provide the UPI details of the beneficiary. Additionally, a unique verification code will be included, which the user needs to add while making the payment. This verification code is important for reconciling the payment on the system's end, ensuring accurate tracking and processing.
  • If the payment method is set to "bank_transfer," the API will return the bank details of the beneficiary. These details can be used to initiate a bank transfer payment.

Sample Call:

curl --location 'https://mudrex.com/api/v1/wallet/conversion/fiat/methods/upi_transfer/beneficiary?type=buy&fiat=INR&crypto=USDT' \
--header 'X-Timestamp: {{timestamp}}' \
--header 'X-Client-Id: •••••••' \
--header 'X-Request-Id: s' \
--header 'X-Secret-Key: •••••••'

Sample Response:

{
  "success": true,
  "data": {
    "id": "15adbb9b-3593-45d8-964e-debbc3474b22",
    "aggregator_id": "b4427086-4940-4c8f-a800-98319f3277e8",
    "bank_name": "RPFAS TECHNOLOGIES PRIVATE LIMITED",
    "ifsc_code": null,
    "account_number": null,
    "upi": "paytmqr28100505010114pimg61rdg6@paytm",
    "account_name": "RPFAS TECHNOLOGIES PRIVATE LIMITED",
    "account_type": null
  }
}

Find more info about API here.


Step 5: Create a transaction

Using the information retrieved from the previous steps, create a buy transaction using the buy API.

Sample Call:

curl --location 'https://mudrex.com/api/v1/wallet/crypto/buy/' \
--header 'X-Timestamp: {{timestamp}}' \
--header 'X-Client-Id: •••••••' \
--header 'X-Request-Id: qsfe' \
--header 'X-User-Id: •••••••' \
--header 'X-Secret-Key: •••••••' \
--data '{
    "from_currency": "INR",
    "to_currency": "USDT",
    "to_amount": 10,
    "source_id": "c41f7d27-781c-41da-b74c-278fe7202af5",
    "payment_method": "bank_transfer",
    "crypto_wallet_address": "0xb84b44140b9c9d2a32707ba35332969c65bc918d",
    "network": "BSC"
}'

Sample Response:

{
  "success": true,
  "data": {
    "fiat_symbol": "INR",
    "crypto_amount": 10,
    "source_id": "c41f7d27-781c-41da-b74c-278fe7202af5",
    "id": "74cbe2f9-4e2a-4bd2-92d2-1a139e7cdcf9",
    "crypto_symbol": "USDT",
    "crypto_wallet_address": "0xb84b44140b9c9d2a32707ba35332969c65bc918d",
    "network": "BSC",
    "failure_desc": null,
    "created_at": 1684394172000,
    "bank_transaction_id": null,
    "fiat_amount": 976.11,
    "status": "PROCESSING",
    "payment_method": "bank_transfer",
    "failure_code": null,
    "exchange_rate": 97.61,
    "tag": null
  }
}

Find more info about the API here.

Step 6 Wait for a Success Callback

Once the user completes the payment, Saber sends a webhook to your configured endpoint.

Sample Webhook:

curl --location -g '{{configured_webhook}}' \
--data '{
  "event" : "BUY",
  "user_id": "77c4562e-ce47-4054-9d4e-4df69ca11a11", 
  "client_id": "3a309275-5936-4c79-8375-0ebb897502f0",
  "transaction_status": "COMPLETED", 
  "invested_at": "2022-11-16T09:30:13", 
  "transaction_id": "4f4d9561-b12f-4cdd-9726-d29333892fc9", 
  "transfer_type": "bank_transfer", 
  "bank_reference_id": "1176073620125", 
  "usd_amount": "1.21000000", 
  "fiat_amount": "100.00000000"
}'

Once this webhook is received, the transaction will be visible on the Saber dashboard.


Conclusion

Congratulations! 🥳 You have successfully integrated Saber Money’s On-Ramp solution.