I Pay Documentation

website·Indexed 30 days ago

https://docs.i-pay.io

Searchable website documentation for I Pay from https://docs.i-pay.io.

Tokens
6.4K
Snippets
16
Records
38
Agent score
49%

What's inside I Pay Documentation

  1. Overview of iPay payment gateway

    iPay is a secure payment gateway designed for high-risk merchants that allows businesses to accept fiat payments and have the funds converted and delivered directly to a crypto wallet. This architecture ensures merchants maintain full control over their assets by bypassing intermediaries.
  2. Overview of iPay Payment Gateway Integration

    iPay is a payment gateway that allows merchants to accept fiat payments and have them converted and delivered directly to a crypto wallet. The integration consists of two primary technical steps: generating a REST API URL to initiate transactions and setting up HTTP POST callbacks to receive instant payment notifications. The iPay dashboard (dash.i-pay.io) is used exclusively for configuration and monitoring and does not control funds, as all funds flow directly to the user's wallet.
  3. Integrate iPay into a business workflow

    Integrating iPay requires a combination of dashboard configuration and technical implementation. The process consists of five primary steps:

    1. Register and Configure: Create an account, set up company details, and link a crypto wallet.
    2. Create an API Key: Generate a key to link the wallet and callback URL. The iPay team must activate this key and register the redirect URL.
    3. Build Payment URLs: Construct REST API URLs using required parameters to create customer transaction links.
    4. Handle Callbacks: Implement listeners to process real-time transaction notifications via HTTP POST callbacks.
    5. Manage Errors: Implement error handling based on iPay's error code table to resolve integration issues.
  4. Handle i-pay.io payment success callbacks (IPN)

    When a payment is successfully completed and funds are delivered to the wallet, i-pay.io sends an HTTP POST request with a JSON payload to the configured IPN URL. Note that there is no status field in the payload; the receipt of the callback itself indicates a completed payment.

    Processing Workflow:

    1. Authentication: Verify the authorization header against your configured secret token.
    2. Identification: Use the customerID (which corresponds to the customId passed in the payment URL) to identify the customer in your records.
    3. Credit: Credit the user based on the transferedAmount (the net amount received in the wallet).
    4. Acknowledgment: Respond with an HTTP 200 OK to confirm receipt.

    Technical Constraints:

    • Request Header: Content-Type: application/json
    • Field Naming: You must match field names literally, including specific spellings: transferedAmount and transactionFeePrecent.
    POST /your-ipn-endpoint HTTP/1.1
    Content-Type: application/json
    authorization: <your secret token>
  5. Access and set up the iPay dashboard

    After account approval, follow these steps to access the dashboard and complete the initial configuration:

    1. First-time Login: Visit dash.i-pay.io, click "Forgot password", and follow the emailed link to set your password.
    2. Company Registration: Enter your business details in the dashboard.
    3. Account Setup: Connect your crypto wallet.
    4. API Key Generation: Generate an API key and provide your callback URL. Note that the iPay team must activate the key and register your redirect URL before it becomes functional.
  6. Handle iPay payment callbacks with Express

    Set up a public POST endpoint to receive JSON callbacks from iPay. Callbacks are only sent for completed payments. To ensure security, you can verify an optional secret token passed in the authorization header. The callback payload contains the customerID (which corresponds to the customId sent in the payment URL) and the transferedAmount (the net USDT delivered to the wallet). Ensure your processing logic is idempotent to avoid duplicate credits for the same transaction ID.
    // Express route to handle iPay JSON callback
    const express = require('express');
    const app = express();
    app.use(express.json()); // Parses JSON body
    
    const SECRET_TOKEN = 'YOUR_SECRET_TOKEN'; // Optional secret token from iPay
    
    app.post('/ipay-callback', (req, res) => {
      // Verify the authorization header (if a secret token is configured)
      if (SECRET_TOKEN && req.get('authorization') !== SECRET_TOKEN) {
        return res.status(401).send('Invalid token');
      }
    
      const data = req.body || {};
      if (data.customerID === undefined || data.transferedAmount === undefined) {
        return res.status(400).send('Bad payload');
      }
    
      // Note the field spellings: transferedAmount (single r), transactionFeePrecent
      const depositId = String(data.customerID);         // your customId, returned as a string
      const amountReceived = Number(data.transferedAmount); // net USDT delivered to your wallet
      const txId = data.blockchainTxId;
    
      // TODO: Update your CRM/database to mark depositId as completed with amountReceived.
      // Make this idempotent: ignore the callback if depositId (or txId) was already credited.
      console.log(`Deposit ${depositId} completed, amount: ${amountReceived} USDT (tx ${txId})`);
    
      // Respond to acknowledge receipt
      res.sendStatus(200);
    });
  7. Add a crypto wallet to receive payments in iPay

    To receive payments, you must link a crypto wallet to your company account. iPay uses a decentralized settlement model where funds from customer purchases are sent directly to the wallet address you provide. Each added wallet is assigned a unique Account ID, which is included in callback data to identify the payment destination.

    Steps to add a wallet:

    1. Navigate to the Companies menu (👤).
    2. Click + Open New Account next to your company's name.
    3. Enter a descriptive name for the account (e.g., "CRM Deposits").
    4. Select Polygon USDT.
    5. Enter your own wallet address (generated from any wallet provider of your choice).

    Warning: Carefully verify the wallet address before saving. iPay forwards funds exactly to the address provided; incorrect addresses will result in lost funds.

  8. Test the iPay payment flow and callback functionality

    To test the iPay integration, you must first have a configured callback URL, a registered redirect URL, an API key, and a constructed REST API URL. The testing process verifies that funds are correctly routed to your wallet and that your server receives the payment callback.

    Testing Steps:

    1. Initiate Request: Trigger the payment request by pasting your constructed REST API URL into a browser or clicking a button linked to that URL. You will be redirected to the payment widget.
    2. Retrieve Wallet Address: In the browser address bar of the payment widget, locate the walletAddress parameter (e.g., ...&walletAddress=0x...). This is a unique, one-time Polygon wallet address (OTW).
    3. Send Test Payment: Copy the walletAddress and send any amount of USDT (Polygon) to it using a wallet like MetaMask. You do not need to send the exact amount shown in the widget.
    4. Verify Results:
      • Funds: The net amount (minus the iPay fee) should arrive in the Polygon wallet address registered on your iPay dashboard.
      • Callback: Your server endpoint should receive a callback from iPay. Verify that the transferedAmount field matches the net amount received in your wallet.
    // Example of a generated payment URL for testing
    https://us-central1-nfgdatabasedemo.cloudfunctions.net/app/api/invoice_external?apiKey=TTy7Xory54M6KDG8lb1fecVkEsgG3VZi&customId=72295640&onRampProvider=provider1&defaultFiatCurrency=GBP&defaultFiatAmount=1122&colorCode=D000F2&screenTitle=DepositTest
  9. Register and activate an iPay user account

    To begin using iPay, you must first create a user account. This is done by contacting iPay via the 'Apply Now' form on the official website (i-pay.io) or through an iPay representative. After the account is confirmed, you must activate it by visiting the dashboard and using the 'Forgot password' feature to set your initial password via an emailed link. Once activated, you can access the backoffice dashboard to configure companies, wallets, and API keys.
    1. Apply at: https://i-pay.io/
    2. Activate at: https://dash.i-pay.io/ (via 'Forgot password' link)
  10. Secure iPay webhook callbacks using the secret token

    iPay provides a webhook secret token for each API key to ensure that incoming callback requests to your IPN URL are authentic and untampered. This token is transmitted in the authorization HTTP header of every POST request; it is not included in the JSON request body.

    To implement this security measure:

    1. Obtain the secret token from your iPay account manager during API key issuance.
    2. Store the token securely in your environment configuration.
    3. For every incoming HTTP POST callback, compare the value of the authorization header against your stored token before processing the payment data.

    While this check is optional, it is highly recommended. If you choose not to use the secret token, you should protect your IPN endpoint using alternative methods such as IP whitelisting.

    # Example Verification (Pseudo-code)
    if request.headers.get('authorization') == stored_secret_token:
        process_payment(request.json)
    else:
        reject_callback()
  11. Implement the iPay payment callback handler in PHP

    Set up a server-to-server callback endpoint to process JSON payloads sent by iPay upon successful deposit completion. Callbacks are only sent for completed payments. The handler should verify the optional authorization header against your secret token, parse the JSON body, and update the deposit record in your database. Ensure the operation is idempotent by checking if the customerID or blockchainTxId has already been credited. Respond with an HTTP 200 OK to acknowledge receipt.
    <?php
    // iPay callback handler (e.g., callback.php)
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        $secretToken = 'YOUR_SECRET_TOKEN';  // Optional secret token from iPay
    
        // Verify the authorization header (if a secret token is configured)
        $headers = array_change_key_case(getallheaders(), CASE_LOWER);
        if ($secretToken !== '' && (($headers['authorization'] ?? '') !== $secretToken)) {
            http_response_code(401);
            exit('Invalid token');
        }
    
        $payload = json_decode(file_get_contents('php://input'), true);
        if (!is_array($payload) || !isset($payload['customerID'], $payload['transferedAmount'])) {
            http_response_code(400);
            exit('Bad payload');
        }
    
        // Note the field spellings: transferedAmount (single r), transactionFeePrecent
        $depositId      = (string) $payload['customerID'];      // your customId, returned as a string
        $amountReceived = (float) $payload['transferedAmount']; // net USDT delivered to your wallet
        $txId           = $payload['blockchainTxId'] ?? null;
    
        // TODO: Update deposit record $depositId in your CRM/database with $amountReceived.
        // Make this idempotent: ignore the callback if $depositId (or $txId) was already credited.
    
        // Send HTTP 200 OK to iPay
        http_response_code(200);
        exit('OK');
    }
  12. Generate an iPay REST API URL

    To create a functional iPay REST API URL, you must provide a set of required parameters including the API Key, Custom ID, and On-Ramp Provider. Once these parameters are entered into the builder tool, the URL can be generated, copied, and tested. It is recommended to verify the generated URL using a browser or a tool like Postman to ensure the API key is valid and the request is successful.