I Pay Documentation
website·Indexed 30 days ago
https://docs.i-pay.ioSearchable website documentation for I Pay from https://docs.i-pay.io.
What's inside I Pay Documentation
- 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.
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.Integrate iPay into a business workflow
Integrating iPay requires a combination of dashboard configuration and technical implementation. The process consists of five primary steps:
- Register and Configure: Create an account, set up company details, and link a crypto wallet.
- 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.
- Build Payment URLs: Construct REST API URLs using required parameters to create customer transaction links.
- Handle Callbacks: Implement listeners to process real-time transaction notifications via HTTP POST callbacks.
- Manage Errors: Implement error handling based on iPay's error code table to resolve integration issues.
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
statusfield in the payload; the receipt of the callback itself indicates a completed payment.Processing Workflow:
- Authentication: Verify the
authorizationheader against your configured secret token. - Identification: Use the
customerID(which corresponds to thecustomIdpassed in the payment URL) to identify the customer in your records. - Credit: Credit the user based on the
transferedAmount(the net amount received in the wallet). - Acknowledgment: Respond with an HTTP
200 OKto confirm receipt.
Technical Constraints:
- Request Header:
Content-Type: application/json - Field Naming: You must match field names literally, including specific spellings:
transferedAmountandtransactionFeePrecent.
POST /your-ipn-endpoint HTTP/1.1 Content-Type: application/json authorization: <your secret token>- Authentication: Verify the
Access and set up the iPay dashboard
After account approval, follow these steps to access the dashboard and complete the initial configuration:
- First-time Login: Visit dash.i-pay.io, click "Forgot password", and follow the emailed link to set your password.
- Company Registration: Enter your business details in the dashboard.
- Account Setup: Connect your crypto wallet.
- 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.
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 theauthorizationheader. The callback payload contains thecustomerID(which corresponds to thecustomIdsent in the payment URL) and thetransferedAmount(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); });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:
- Navigate to the Companies menu (👤).
- Click + Open New Account next to your company's name.
- Enter a descriptive name for the account (e.g., "CRM Deposits").
- Select Polygon USDT.
- 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.
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:
- 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.
- Retrieve Wallet Address: In the browser address bar of the payment widget, locate the
walletAddressparameter (e.g.,...&walletAddress=0x...). This is a unique, one-time Polygon wallet address (OTW). - Send Test Payment: Copy the
walletAddressand 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. - 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
transferedAmountfield 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=DepositTestRegister 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)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
authorizationHTTP header of every POST request; it is not included in the JSON request body.To implement this security measure:
- Obtain the secret token from your iPay account manager during API key issuance.
- Store the token securely in your environment configuration.
- For every incoming HTTP POST callback, compare the value of the
authorizationheader 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()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 optionalauthorizationheader against your secret token, parse the JSON body, and update the deposit record in your database. Ensure the operation is idempotent by checking if thecustomerIDorblockchainTxIdhas 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'); }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.