Onboarding for Remittance Merchants

A React Native SDK for integrating Approvely's credit-based payment system with purchase and redemption capabilities.

Table of Contents

Setup

Prerequisites

Before starting integration, you MUST complete the account setup section:

  1. Register a sandbox merchant account or Login to your sandbox merchant account
  2. Create sandbox API Key
  3. Add Team Members to your sandbox account
  4. Add chargeback protection script to every page of your app (if adding support for credit cards)

Onboarding Checklist

Track your onboarding progress with this shared checklist to stay aligned on status, outstanding tasks, and next steps.

Developer Resources

Authorization Headers

  • Authorization: Your API Key (generate from merchant dashboard)
  • x-coinflow-auth-user-id: Unique customer ID from your system
  • x-coinflow-auth-blockchain: Should always be solana if settlement location is Approvely in-app wallet
  • x-coinflow-auth-session-key: JWT that authorizes the payer (valid for 24 hours)

Flow of Funds

Flow of Funds Diagram

Implementation

Installation

npm i @coinflowlabs/react-native

Enable Payers to Purchase Credits

Step 1: Tokenize Checkout Parameters

Tokenize the checkout parameters to encrypt them and prevent tampering. Use the JWT Token endpoint.

Request:

curl --request POST \
  --url https://api-sandbox.approvely.com/api/checkout/jwt-token \
  --header 'Authorization: YOUR_API_KEY' \
  --header 'accept: application/json' \
  --header 'content-type: application/json' \
  --data '{
    "subtotal": {
      "currency": "USD",
      "cents": 200
    },
    "blockchain": "solana",
    "email": "[email protected]",
    "deviceId": "123456789",
    "settlementType": "Credits",
    "chargebackProtectionData": [
      {
        "productName": "My Item",
        "quantity": 1,
        "rawProductData": {
          "example": "{\"description\": \"asdf\"}"
        },
        "productType": "topUp"
      }
    ],
    "webhookInfo": {
      "example": "{\"someId\":\"123abc\"}"
    }
  }'

Response:

{
  "checkoutJwtToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Step 2: Implement Approvely Purchase Component

<CoinflowPurchase
  wallet={{
    publicKey: PublicKey,
    signMessage: (message: UInt8Array) => Promise,
    sendTransaction: (transaction: Transaction | VersionedTransaction) => Promise
  }}
  env='sandbox' // Change to 'prod' for production
  connection={connection} // Solana RPC connection
  blockchain='solana'
  merchantId='YOUR_MERCHANT_ID'
  origins={['http://localhost:3000/']}
  jwtToken={'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'} // From step 1
/>

Enable Payers to Redeem Credits

Step 1: Tokenize Checkout Parameters for Redemption

curl --request POST \
  --url https://api-sandbox.approvely.com/api/checkout/jwt-token \
  --header 'Authorization: YOUR_API_KEY' \
  --header 'accept: application/json' \
  --header 'content-type: application/json' \
  --data '{
    "subtotal": {
      "currency": "USD",
      "cents": 200
    },
    "blockchain": "solana",
    "email": "[email protected]",
    "webhookInfo": {
      "example": "{\"someId\":\"123abc\"}"
    },
    "settlementType": "Credits"
  }'

Step 2: Implement Credit Redemption

<CoinflowPurchase
  wallet={{
    publicKey: PublicKey,
    signMessage: (message: UInt8Array) => Promise,
    sendTransaction: (transaction: Transaction | VersionedTransaction) => Promise
  }}
  env='sandbox' // Change to 'prod' for production
  connection={connection} // Solana RPC connection
  blockchain='solana'
  merchantId='YOUR_MERCHANT_ID'
  origins={['http://localhost:3000/']}
  jwtToken={'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'} // From step 1
  transaction={tx} // Base58 encoded transaction for redemption
/>

Note: Only pass the transaction parameter when customers are redeeming credits. Do NOT pass it when customers are purchasing credits.

Step 3: Configure Webhooks

Set up checkout webhooks to handle transaction events and updates.

API Reference

CoinflowPurchase Props

PropTypeRequiredDescription
walletWalletInterfaceSolana wallet interface with publicKey, signMessage, and sendTransaction methods
env`'sandbox' \'prod'`
connectionConnectionSolana RPC connection
blockchain'solana'Blockchain network
merchantIdstringYour merchant ID
originsstring[]Allowed origins for the checkout
jwtTokenstringTokenized checkout parameters
transactionstringBase58 encoded transaction (only for redemption)

Wallet Interface

interface WalletInterface {
  publicKey: PublicKey;
  signMessage: (message: UInt8Array) => Promise<Uint8Array>;
  sendTransaction: (transaction: Transaction | VersionedTransaction) => Promise<string>;
}

Support

For additional help and resources:

License

Please refer to Approvely's terms of service and licensing agreement.