Xlassix Xx
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Paycrest Off-ramp API Documentation Welcome to the comprehensive guide for the Paycrest Off-ramp API. This documentation serves as a detailed reference for developers integrating Paycrest's services into their applications. Whether you're looking to initiate orders, fetch order details, manage webhooks, or handle user authentication, this documentation covers all the necessary aspects to get started and ensure a smooth integration process. If you encounter issues, find bugs, or have suggestions for improvements, just send use an email at support@paycrest.io. Thank you for choosing Paycrest as your off-ramp partner. We're excited to see the innovative solutions you build with our API and look forward to supporting your success. ## Getting Started ### Get API keys Visit [your sender dashboard](https://app.paycrest.io/sender/overview) to retrieve your `Client ID` and `Client Secret`. If you're a new user, [signup here](https://app.paycrest.io/signup) as a "sender" and complete our Know-Your-Business (KYB) process. Your `Client Secret` should always be kept secret. If you accidentally expose it via version control or other means, you should immediately reach out to support@paycrest.io to generate a new API key. ### Configure tokens Head over to the [settings page](https://app.paycrest.io/sender/settings) of your Sender Dashboard to configure the `feePercent`, `feeAddress`, and `refundAddress` across the tokens and blockchain networks you intend to use. ### Interacting with an endpoint Include your `Client ID` in the "API-Key" header of every request you make to Paycrest Offramp API. e.g ```typescript const headers = { "API-Key": "208a4aef-1320-4222-82b4-e3bca8781b4b", } ``` Any request without a valid API key will fail with status code `401: Unauthorized`. All API calls must be made over HTTPS. Body of requests and responses are formatted as JSON with Content-type always as `application/json` --- ## Initiate Payment Order Endpoint: `/v1/sender/orders` Method: `POST` ### Payload A JSON object containing the details of the payment order and the recipient information. | Field name | Type | Required | Comment | |------------|------|----------|---------| | `amount` | `number` | Yes | The amount of the token to be off-ramped. | | `rate` | `number` | Yes | The exchange rate from the token to the local currency. [Fetch current rate](#Fetch-Token-Rate) | | `network` | `string` | Yes | The blockchain network on which the token operates. <br/> <strong>Supported networks</strong>: `tron`, `base`, `bnb-smart-chain`, `polygon`, `arbitrum-one` | `token` | `string` | Yes | The symbol of the cryptocurrency token. <br/> <strong>Supported tokens</strong>: `USDT`, `USDC` <br/>* *USDC is not supported on Tron* <br/> * *USDT is not supported on Base* | `recipient` | `object` | Yes | [see more](#Recipient-object) | | `returnAddress` | `string` | No | The wallet address to refund the fund too if there is a failue | | `feePercent` | `number` | No | The percentage of the token amount charged for creating the order. | | `feeAddress` | `string` | No | The address to which the fees for the transaction should be sent. | #### Recipient object | Field name | Type | Required | Comment | |------------|------|----------|---------| | `institution` | `string` | Yes | The name of the financial institution receving the local currency. [Fetch supported institutions](#Fetch-Supported-Institutions) | | `accountIdentifier` | `string` | Yes | The recipient's bank or mobile money account number | | `accountName` | `string` | Yes | The name associated with the recipient's account. | | `memo` | `string` | Yes | An arbitrary narration for the fiat transfer, could be the name of the sender. | | `providerId` | `string` | No | An optional identifier for the liquidity provider. Set this to off-ramp with a specific provider | ```json { "amount": "100.00", "token": "unique-token-id", "rate": "1500", "network": "polygon", "recipient": { "institution": "GTBINGLA", "accountIdentifier": "123456789", "accountName": "John Doe", "memo": "Payment from John Doe", "providerId": "" }, "returnAddress": "0x123...", "feePercent": "2", "feeAddress": "0x123..." } ``` ### Response Format A JSON object containing the receive address to accept the cryptocurrency token. ```json { "message": "Payment order initiated successfully", "status": "success", "data": { "id": "uuid-string", "amount": "100.00", "token": "USDT", "network": "polygon", "receiveAddress": "0x1234...", "validUntil": "2024-07-01T12:34:56Z", "senderFee": "0.50", "transactionFee": "0.10" } } ``` --- ## Fetch Payment Order by ID Endpoint: `/v1/sender/orders/:id` Method: `GET` ### Path Parameters - `id`: The unique identifier for the order ### Response Format A JSON object containing detailed information about the fetched payment order. ```json { "message": "The order has been successfully retrieved", "status":"success", "data": { "id": "uuid-string", "amount": "100.00", "amountPaid": "80.00", "amountReturned": "0.00", "token": "USDT", "senderFee": "0.50", "transactionFee": "0.10", "rate": "1500", "network": "polygon", "gatewayId": "gw-123", "recipient": { "institution": "GTBINGLA", "accountIdentifier": "123456789", "accountName": "John Doe", "memo": "Payment from John Doe" }, "fromAddress": "0x123...", "returnAddress": "0x123...", "receiveAddress": "0x123...", "feeAddress": "0x123...", "createdAt": "2024-06-26T12:34:56Z", "updatedAt": "2024-06-27T12:34:56Z", "txHash": "abc123", "status": "initiated", "transactions": [ { "id": "uuid-string", "gatewayId": "gw-123", "status": "crypto_deposited", "txHash": "abc123", "createdAt": "2024-06-26T12:34:56Z" } ] } } ``` ## Fetch All Payment Orders Endpoint: `/v1/sender/orders` Method: `GET` ### Query Parameters - `ordering`: Sorts the results based on the specified field. - `status`: Filters orders by their status. - `token`: Filters orders by their token. - `network`: Filters orders by their network. - `page`: Specifies the page number for pagination. - `pageSize`: Specifies the number of items per page for pagination. ### Response Format A JSON array containing detailed information about each fetched payment order. ```json { "message":"Payment orders retrieved successfully", "status":"success", "data": { "total": 100, "page": 1, "pageSize": 20, "orders": [ { "id": "uuid-string", "amount": "100.00", "amountPaid": "80.00", "amountReturned": "0.00", "token": "unique-token-id", "senderFee": "0.50", "transactionFee": "0.10", "rate": "1500", "network": "polygon", "gatewayId": "0x123...", "recipient": { "institution": "GTBINGLA", "accountIdentifier": "123456789", "accountName": "John Doe", "memo": "Payment from John Doe" }, "fromAddress": "0x123...", "returnAddress": "0x123...", "receiveAddress": "0x123...", "feeAddress": "0x123...", "createdAt": "2024-06-26T12:34:56Z", "updatedAt": "2024-06-27T12:34:56Z", "txHash": "abc123...", "status": "settled", } ... ] } } ``` --- ## Fetch Supported Institutions Endpoint: `/v1/institutions/:currency_code` Method: `GET` ### Response Format A successful response from the `GET /institutions/:currency_code` endpoint will contain a JSON object with the following structure: ```json { "message": "OK", "status": "success", "data": [ { "name": "GT Bank Plc", "code": "GTBINGLA", "type": "bank" // bank or mobile_money }, { "name": "First Bank of Nigeria", "code": "FBNINGLA", "type": "bank" // bank or mobile_money }, ] } ``` ## Fetch Token Rate Endpoint: `/v1/rates/:token/:amount/:fiat` Method: `GET` ### Path Parameters - **`token`**: The cryptocurrency token for which you wish to fetch the rate. - **`amount`**: The amount of the cryptocurrency token for which you want to know the equivalent fiat amount. This parameter is mandatory. - **`fiat`**: The local currency to which you want to convert the cryptocurrency token amount. ### Query Parameters - **`provider_id`**: The ID of a provider. Use this to get the rate of a specific liquidity provider ### Response Format A successful response from the `GET /v1/rates/:token/:amount/:fiat` endpoint will contain a JSON object with the following structure: ```json { "message": "OK", "status": "success", "data": "1500" } ``` --- ## Webhooks Listen to payment order events by configuring a Webhook URL in your [dashboard settings](https://app.paycrest.io/sender/settings). We trigger various events based on the status of the payment order. Our webhook events are sent exponientially until 24 hours from when the first one is sent. ### Payload Structure The webhook payload contains the event type and the associated data. ```json { "event": "payment_order.settled", "data": { "id": "uuid-string", "amount": "100.00", "amountPaid": "80.00", "amountReturned": "0.00", "percentSettled": "90.00", "senderFee": "0.50", "networkFee": "0.05", "rate": "1500", "network": "polygon", "gatewayId": "gw-123", "senderId": "uuid-string", "recipient": { "institution": "FBNINGLA", "accountIdentifier": "123456789", "accountName": "John Doe", "memo": "Payment from John Doe" }, "fromAddress": "0x123...", "returnAddress": "0x123...", "updatedAt": "2024-06-26T12:34:56Z", "createdAt": "2024-06-26T12:34:56Z", "txHash": "abc123", "status": "settled" } ``` ### Event Types The webhook can trigger various events based on the status of the payment order. - `payment_order.pending` - `payment_order.reverted` - `payment_order.expired` - `payment_order.settled` - `payment_order.refunded` ### Verifying events Each event must include a signature in its header (`"X-Paycrest-Signature"`) to ensure the message originates from Paycrest. Upon receiving a request, the receiver should verify this signature to authenticate the request. 1. **Extract the Signature**: Retrieve the `"X-Paycrest-Signature"` header from the incoming request. 2. **Calculate the Signature**: Compute the HMAC signature of the request body using your `Client Secret` key. 3. **Compare Signatures**: Compare the extracted signature with the calculated signature. If they match, the request is authenticated. ##### TypeScript sample implementation ```typescript import crypto from 'crypto'; function verifyPaycrestSignature(requestBody: string, signatureHeader: string, secretKey: string): boolean { const calculatedSignature = calculateHmacSignature(requestBody, secretKey); return signatureHeader === calculatedSignature; } function calculateHmacSignature(data: string, secretKey: string): string { const key = Buffer.from(secretKey); const hash = crypto.createHmac('sha256', key); hash.update(data); return hash.digest('hex'); } ``` ---

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully