🚀 Appfinity Pay Later SDK

Complete API Documentation for Third-Party Integration

v1.0.0 Production Ready 100% Test Coverage

📋 Overview

The Appfinity Pay Later SDK enables third-party platforms to seamlessly integrate our Pay Later solution into their applications. Our SDK provides a complete credit system with instant approvals, flexible repayment options, and comprehensive fraud protection.

✨ Key Features

🎯 Perfect For: E-commerce platforms, gaming platforms, subscription services, marketplace applications, and any platform requiring flexible payment solutions.

Callback URL Behavior

The SDK forwards callbackUrl to your Telegram bot/server for server-side notifications. By default it does not automatically redirect the page after payment. You can either enable auto-redirect in the SDK or manually handle it via events.

// Enable auto-redirect on success/verified DirectPayment.init({ apiBase: window.location.origin, debug: true, autoRedirect: true });
// Example: redirect after success or verified Telegram payment DirectPayment.onEvent(function (evt) { if (!evt) return; var isSuccess = evt.type === 'payment_success' && evt.payload && evt.payload.success; var isVerified = evt.type === 'payment_verified' && evt.payload && evt.payload.verified; if (isSuccess || isVerified) { var tx = (evt.payload && (evt.payload.transaction_id || evt.transaction_id)) || ''; var redirectUrl = 'https://yourapp.com/telegram/callback?tx=' + encodeURIComponent(tx); window.location.href = redirectUrl; } });

🔐 Authentication

All API requests require authentication using Platform API Keys. Contact our team to get your production API keys.

API Key Types

Environment Key Format Usage
Sandbox pk_test_... Development and testing
Production pk_live_... Live transactions

Authentication Headers

// Required headers for all API requests Headers: 'X-Platform-API-Key': 'your_platform_api_key' 'X-Platform-ID': 'your_platform_id' 'Content-Type': 'application/json'

🪙 Crypto Payment

Create cryptocurrency payments using NOWPayments. You pass a fiat amount and currency (e.g., USD) and select a crypto to pay with (e.g., USDT, BTC, ETH). The response includes a payment address and estimated crypto amount to transfer. Optionally provide a clientWebhook URL to receive forwarded IPN updates.

What is a webhook?

A webhook is an HTTP callback endpoint on your server. When the payment status changes, our server sends a POST request to your webhook URL so your app can automatically update the order state and notify users without polling.

Endpoint

POST /checkout/crypto Headers: 'Content-Type': 'application/json' 'x-api-key': 'YOUR_PLATFORM_API_KEY'

Request Body

Name Type Required Description
order_id string Required Alphanumeric identifier for your order (max 64 chars)
fiat_amount number Required Fiat amount to charge (e.g., 49.99)
fiat_currency string Required Fiat currency code (e.g., USD)
pay_currency string Required Crypto currency code to pay with (e.g., USDT, BTC, ETH)
customer object Optional { user_id, email } to associate payment with a user
clientWebhook string Optional HTTPS URL to receive forwarded IPN payloads from our server

Example Request

// JavaScript (fetch) await fetch('/checkout/crypto', { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-api-key': 'YOUR_PLATFORM_API_KEY' }, body: JSON.stringify({ order_id: 'ORDER_12345', fiat_amount: 49.99, fiat_currency: 'USD', pay_currency: 'USDT', customer: { user_id: 'user_001', email: 'user@example.com' }, clientWebhook: 'https://yourapp.com/webhooks/crypto-ipn' }) });
# cURL curl -X POST \ -H "Content-Type: application/json" \ -H "x-api-key: YOUR_PLATFORM_API_KEY" \ "https://appfinitystore.com/checkout/crypto" \ -d '{ "order_id": "ORDER_12345", "fiat_amount": 49.99, "fiat_currency": "USD", "pay_currency": "USDT", "customer": { "user_id": "user_001", "email": "user@example.com" }, "clientWebhook": "https://yourapp.com/webhooks/crypto-ipn" }'

Success Response

{ "success": true, "order_id": "ORDER_12345", "fiat_amount": 49.99, "fiat_currency": "USD", "pay_currency": "USDT", "estimate": { "estimated_amount": 49.99 }, "nowpayments": { "payment_id": "np_abc123", "pay_address": "TXYZ...", "payment_status": "pending" }, "payment_id": "np_abc123", "pay_address": "TXYZ...", "pay_amount": 49.99, "status": "pending", "description": "Order #ORDER_12345 for Appfinity Store", "expires_at": "2025-02-01T12:00:00.000Z", "clientWebhookUrl": "https://yourapp.com/webhooks/crypto-ipn" }

IPN Webhook

NOWPayments sends IPN callbacks to your server at /webhook/crypto-payment. Our server verifies signatures when NOWPAYMENTS_IPN_SECRET is configured and will forward the received payload to your provided clientWebhook URL. You receive events for statuses like paid, partially_paid, expired, cancelled, failed, and pending.

// Example IPN payload (forwarded to your clientWebhook) { "order_id": "ORDER_12345", "payment_id": "np_abc123", "payment_status": "paid", "pay_amount": "49.99", "pay_currency": "USDT" }
Notes:
  • Ensure your clientWebhook is publicly reachable over HTTPS.
  • Store order_id in your system to reconcile IPN events.
  • Forwarding failures are logged and do not block processing.

Telegram Crypto (TON)

Create a crypto payment via Telegram using TON. The SDK opens the Telegram payment bot in a new tab and provides an overlay to verify payment status. Fiat and crypto currencies are fixed to USD and TON respectively; the SDK auto-generates the order_id internally.

SDK Usage

// Include SDK // Initialize and start Telegram crypto DirectPayment.init({ apiBase: window.location.origin, debug: true }); await DirectPayment.startTelegramCrypto({ // Optional inputs; if omitted, the SDK overlay collects values customerEmail: 'user@example.com', platformId: 'Appfinity Store', gameId: 'HINGEY', credits: 100, // optional: purchase app credits with the payment callbackUrl: 'https://yourapp.com/telegram/callback' });

Parameters

Name Type Required Description
customerEmail string No User email for receipts and verification; shown in overlay if omitted.
platformId string No Your platform identifier/name for multi-tenant setups.
gameId string No Optional game/app identifier for attribution.
credits number No Optional numeric credits to purchase alongside the Telegram payment.
callbackUrl string (URL) No Optional URL to receive server-side updates related to the Telegram transaction.
Behavior & Internals:
  • orderId is auto-generated by the SDK.
  • fiatCurrency is fixed to USD; payCurrency is fixed to TON.
  • userId is auto-assigned per request as a random 6-digit number.
  • The SDK creates the transaction via your bot API and opens telegram_payment_url in a new tab.

Bot Config Endpoint

The SDK fetches the Telegram bot API URL and key from your server:

GET /payment/config/telegram-bot-url // Response { "success": true, "telegramBotUrl": "https://your-telegram-bot-api/create-transaction", "telegramBotApiKey": "pk_live_..." }

Transaction Creation

The SDK posts to the Telegram bot API to create the transaction and opens the returned payment URL in a new tab. A simplified response from the bot looks like:

{ "success": true, "data": { "transaction_id": "tx_123456", "telegram_payment_url": "https://t.me/your_bot?start=abcdef" } }

Status & Verification

Use the overlay's Verify Payment button, or call these endpoints programmatically:

// Check status GET /api/transaction/{transaction_id} // Verify on blockchain if still pending POST /api/transaction/{transaction_id}/check-blockchain // Headers 'Accept': 'application/json' 'x-api-key': 'YOUR_PLATFORM_API_KEY'
Notes:
  • The SDK hides internal-only fields (order ID, user/platform IDs) but uses fixed values internally.
  • The SDK opens response.data.telegram_payment_url in a new tab automatically.
  • The overlay includes a Verify Payment button to check status and perform blockchain verification.
  • callbackUrl is forwarded to your bot/server for server-side notifications; the SDK does not auto-redirect.
  • To redirect after verification, handle events via DirectPayment.onEvent:
// Redirect on verified Telegram payment DirectPayment.onEvent(function (evt) { if (evt && evt.type === 'payment_verified' && evt.payload && evt.payload.verified) { const tx = evt.payload.transaction_id; window.location.href = 'https://yourapp.com/telegram/callback?tx=' + encodeURIComponent(tx); } });

💳 Direct Payment

Render a centered modal overlay with an iframe to complete card payments. A spinner appears while the iframe loads and during message processing. Your callback receives the full payload for both success and failure.

Include SDK

<script src="https://appfinitystore.com/js/direct-payment.js"></script>

Initialize for Direct/One-Time Payment

This initializes Direct Payment for a one-time card checkout. It does not set up recurring charges or subscriptions.

DirectPayment.init({ apiKey: 'YOUR_PLATFORM_API_KEY', debug: true, apiBase: "https://appfinitystore.com", onEvent: function (payload) { // Called for both success and failure console.log('Callback payload:', payload); if (payload && payload.success) { console.log('Payment success!'); // e.g., update UI, call backend, redirect DirectPayment.close(); } else { console.log('Payment not successful'); // e.g., show retry option DirectPayment.close(); } } });

For Recurring: Initialize and Save Identifiers

Initialize the SDK and capture identifiers for recurring charges. On a successful payload, save the following per user for future billing:

DirectPayment.init({ apiKey: 'YOUR_PLATFORM_API_KEY', debug: true, apiBase: " `https://appfinitystore.com` ", onEvent: function (payload) { // Called for both success and failure console.log('Callback payload:', payload); if (payload && payload.success) { console.log('Payment success!'); // Save identifiers per user for recurring charges // e.g., persist payload.customer_id, payload.gateway, payload.payment_method_id DirectPayment.close(); } else { console.log('Payment not successful'); // e.g., show retry option DirectPayment.close(); } } });

After saving these identifiers, use them to perform actual recurring billing with the SDK method below.

Recurring: chargeByMethod

Server-side recurring charge using saved customer and payment method identifiers. No iframe is rendered; results are delivered via your onEvent callback.

// JavaScript SDK: create a recurring charge (async function chargeSavedMethod() { try { const res = await DirectPayment.chargeByMethod({ gateway: 'flutterwave', // Required: 'flutterwave' or 'stripe' customer_id: 'cus_12345', // Required: platform-specific customer identifier payment_method_id: 'pm_98765', // Required: saved payment method/token id amount: 49.99, // Required: amount to charge currency: 'USD', // Required: 3-letter currency code email: 'user@example.com', // Optional: for receipts/trace platformId: 'your_platform_id', // Optional: your platform id/name }); console.log('Recurring charge result:', res); } catch (err) { console.error('Recurring charge failed:', err.message); } })();

Parameters

Name Type Required Description
gateway string Yes Payment gateway to use; supported: flutterwave, stripe.
customer_id string Yes Your saved customer identifier on the selected gateway/platform.
payment_method_id string Yes Saved payment method/token id for the customer.
amount number Yes Amount to charge.
currency string Yes Three-letter currency code (e.g., USD, NGN).
email string No User email for receipts and traceability.
platformId string No Your platform identifier/name for multi-tenant setups.

Non-SDK (REST API)

Call the backend directly if you prefer not to use the SDK.

// Endpoint POST https://appfinitystore.com/direct-recurring/charge/by_method // Headers 'Content-Type': 'application/json' 'x-api-key': 'YOUR_PLATFORM_API_KEY' // JSON Body { "gateway": "flutterwave", "customer_id": "cus_12345", "payment_method_id": "pm_98765", "amount": 49.99, "currency": "USD", "email": "user@example.com", "platformId": "your_platform_id" }
# cURL Example curl -X POST \ -H "Content-Type: application/json" \ -H "x-api-key: YOUR_PLATFORM_API_KEY" \ "https://appfinitystore.com/direct-recurring/charge/by_method" \ -d '{ "gateway": "stripe", "customer_id": "cus_12345", "payment_method_id": "pm_98765", "amount": 49.99, "currency": "USD", "email": "user@example.com", "platformId": "Appfinity Store", "callback_url": "https://yourapp.com/webhooks/recurring", "no_auth": false }'

Start Payment

Omit containerId to use overlay mode (centered modal). Provide containerId to render inline.

(async function startPayment() { try { await DirectPayment.initiate({ email: 'user@example.com', amount: 100, platformId: 'Appfinity Store', currency: 'USD' // containerId: 'payment-container' // optional for inline mount }); } catch (err) { console.error('Failed to initiate payment:', err); alert('Failed to initiate payment: ' + err.message); } })();

Close Overlay

DirectPayment.close();
Behavior: Spinner shows before iframe load and while processing messages; hides after processing. Background scrolling is disabled while overlay is open. Iframe height defaults to ~88vh.

Telegram Crypto (SDK)

The Direct Payment SDK also supports a Telegram-based crypto flow for TON. This presents a guided overlay to collect required fields, creates the transaction via your Telegram bot API, opens the payment in Telegram, and provides a verification button.

// Include SDK // Initialize DirectPayment DirectPayment.init({ apiBase: window.location.origin, debug: true }); // Start Telegram crypto payment (TON) await DirectPayment.startTelegramCrypto({ customerEmail: 'user@example.com', platformId: 'Appfinity Store', gameId: 'HINGEY', credits: 100, callbackUrl: 'https://yourapp.com/telegram/callback' }); // Optional: listen for events (success, failure, status updates) DirectPayment.onEvent(function (event) { console.log('DirectPayment Event:', event); });
What happens:
  • Overlay shows fixed fiat/crypto values at the top (USD / TON).
  • Order ID is auto-generated and hidden from the form.
  • Transaction is created and telegram_payment_url opens in a new tab.
  • Use Verify Payment to check status and perform blockchain verification.
  • userId is auto-assigned per request as a random 6-digit number.
  • If credits is provided, it is included in the transaction payload.

⚡ SDK Integration Flow

Complete guide to integrating Appfinity Pay Later SDK into your application:

Step 1: Include the SDK

Add our JavaScript SDK to your website. The SDK handles all Pay Later interactions, UI components, and API communications:

<!-- Include the Appfinity Pay Later SDK --> <script src="https://appfinitystore.com/js/appfinity-sdk.js"></script> <!-- Optional: Include CSS for default styling --> <link rel="stylesheet" href="https://appfinitystore.com/css/paylater-ui.css">

Step 2: Initialize the SDK

Initialize the SDK with your platform credentials:

Appfinity.init({ platformId: "SLOTGAME", baseUrl: "appfinitystore.com", apiKey: "SLOT_eueue_your_key" }); const startFlow = () => { Appfinity.startFlow({ email: "user@example.com", deductAmount: 50, callbackFunction: (res) => { console.log("PayLater callback", res); if(res.success) { // redirect to success page } else { // redirect to failure page } } }); }

Note: The deductAmount parameter is optional and is used when you want to immediately purchase coins from the Appfinity wallet. When provided, the system will attempt to deduct the specified amount from the user's wallet during Step 1 of the flow. The response of this deduction operation will be received in the callbackFunction, allowing you to handle success or failure scenarios accordingly.

Expected Response Format

The callbackFunction(res) will receive a response object with the following structure:

// Success Response (Top Up - Step 3) { type: 'top-up', step: 3, success: true, message: 'TopUp successful', data: { success: true, message: "Wallet balance deducted successfully", data: { wallet: { amountDeducted: 50, currency: "USD", description: "SDK deduction", email: "user@example.com", eventId: 98, newBalance: 250, platformId: "your_platform_id", previousBalance: 300, transactionAt: "2025-09-23T11:32:58.947Z", userId: "your_user_id" } } } } // Error Response { success: false, message: "Insufficient wallet balance", error: { code: "INSUFFICIENT_FUNDS", details: "Current balance: $25.50, Required: $50.00" } } // Other possible error codes: // "INVALID_AMOUNT" - Amount is invalid or negative // "USER_NOT_FOUND" - User account not found // "WALLET_LOCKED" - User wallet is temporarily locked // "NETWORK_ERROR" - Connection or server error

Step 3: Add Pay Later Button

Add the Pay Later button to your checkout page:

<button onclick="startFlow()" id="pay-later-btn" class="paylater-button"> <span>Pay Later</span> <small>Get instant approval</small> </button>

Callback Types

The type field in the callback can be "step", "deduction", or "top-up". To get a callback for Step 3 (card save), check response.type == "step" and response.step == 3. For deductions, response.type == "deduction". For top up, response.type == "top-up".

// Examples of handling callback types Appfinity.startFlow({ email: "user@example.com", callbackFunction: (response) => { // Step 3: card save completed if (response.type === 'step' && response.step === 3) { console.log('Card saved / Step 3 completed'); // Handle post-card-save logic } // Deduction event (wallet deduction during Step 1) else if (response.type === 'deduction') { console.log('Wallet deduction event:', response); // Handle deduction success/failure } // Top Up flow completed else if (response.type === 'top-up') { console.log('Top Up successful:', response); // Handle top-up success } } }); // Note: If your integration wraps callback payload under `data`, // you can equivalently check: // response.data && response.data.type === 'step' && response.data.step === 3 // response.data && response.data.type === 'deduction' // response.data && response.data.type === 'top-up'

Top-Up Flow Function

The startTopupThenFlow function is designed specifically for displaying the top-up interface to users. This function opens the top-up modal where users can add funds to their wallet, and provides a callback mechanism to handle the top-up completion events.

Appfinity.startTopupThenFlow({ email: config.email, deductAmount: 50, callbackFunction: (res) => { console.log("PayLater TopUp callback", res); if(res.success) { // redirect to success page fetchDueBalance(); // Refresh balance } else { // redirect to failure page } setButtonLoading('pay-later-btn', false); } });

How it works:

  • Display Top-Up UI: Opens the top-up interface in a modal overlay
  • User Interaction: User selects top-up amount and completes payment
  • Callback Execution: Upon completion, the callback function receives the result
  • Balance Update: Successful top-ups automatically update the user's wallet balance
  • Flow Continuation: Optionally continues the subscription flow if user category requirements are met

Demo Button Implementation

Here's a complete example of how to create a button that triggers the top-up flow:

<!-- HTML Button --> <button onclick="handleTopupClick()" id="topup-btn" class="topup-button"> Top Up Wallet </button> <script> function handleTopupClick() { const button = document.getElementById('topup-btn'); const originalText = button.innerHTML; // Show loading state button.innerHTML = 'Loading...'; button.disabled = true; // Trigger the top-up flow Appfinity.startTopupThenFlow({ email: config.email, deductAmount: 50, callbackFunction: (res) => { console.log("TopUp callback", res); // Reset button state button.innerHTML = originalText; button.disabled = false; if(res.success) { // Handle success - redirect or update UI alert('Top-up successful!'); fetchDueBalance(); // Refresh balance } else { // Handle failure - show error message alert('Top-up failed: ' + res.message); } } }); } </script> <!-- Optional CSS for styling --> <style> .topup-button { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border: none; padding: 12px 24px; border-radius: 6px; cursor: pointer; font-size: 16px; font-weight: 500; transition: all 0.3s; } .topup-button:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4); } .topup-button:disabled { opacity: 0.6; cursor: not-allowed; transform: none; } </style>

Step 4: Optional Parameters

The startFlow function can contain additional user parameters for better user experience:

// The startFlow can contain other parameters like first_name, last_name, date_of_birth, address, city, zip, country Appfinity.startFlow({ email: "user@example.com", first_name: "John", last_name: "Doe" }); // etc

Step 5: Wallet API Endpoints

Use these wallet API endpoints to manage user balances and transactions:

// Get wallet balance fetch('/v1/wallet?email=user@example.com', { method: 'GET', headers: { 'Content-Type': 'application/json', 'x-api-key': 'your_api_key', 'x-platform-id': 'your_platform_id' } }) .then(response => response.json()) .then(data => console.log('Balance:', data.balance)); // Deduct from wallet fetch('/v1/wallet/deduct', { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-api-key': 'your_api_key', 'Idempotency-Key': `deduct-${Date.now()}-${Math.random()}` }, body: JSON.stringify({ email: "user@example.com", amount: 50.00, description: 'Game purchase', metadata: { orderId: 'order_123', productId: 'game_coins' } }) }) .then(response => response.json()) .then(data => { if (data.success) { console.log('Deduction successful:', data.newBalance); } else { console.error('Deduction failed:', data.message); } }); // Expected Response: { "success": true, "message": "Wallet deduction successful", "data": { "transaction_id": "txn_abc123def456", "amount_deducted": 50.00, "previous_balance": 200.00, "new_balance": 150.00, "currency": "USD", "description": "Game purchase", "timestamp": "2024-01-15T10:30:00Z" } }

Step 6: Get Transaction History

Retrieve wallet transaction history for user account management:

// Get wallet transaction history fetch('/v1/wallet/transactions', { method: 'GET', headers: { 'Content-Type': 'application/json', 'x-api-key': 'your_api_key', 'x-platform-id': 'your_platform_id' } }) .then(response => response.json()) .then(data => { if (data.success) { console.log('Transaction history:', data.transactions); // Display transactions in UI data.transactions.forEach(transaction => { console.log(`${transaction.type}: ${transaction.amount} - ${transaction.description}`); }); } else { console.error('Failed to get transactions:', data.message); } }); // Expected Response: { "success": true, "data": { "transactions": [ { "id": "txn_abc123def456", "type": "debit", "amount": -50.00, "balance_after": 150.00, "description": "Game purchase", "metadata": { "orderId": "order_123", "productId": "game_coins" }, "timestamp": "2024-01-15T10:30:00Z", "status": "completed" }, { "id": "txn_def456ghi789", "type": "credit", "amount": 100.00, "balance_after": 200.00, "description": "Wallet top-up", "timestamp": "2024-01-14T15:20:00Z", "status": "completed" } ], "pagination": { "current_page": 1, "total_pages": 3, "total_transactions": 25, "per_page": 10 } } } // Required headers for all wallet API requests: // - Content-Type: application/json // - x-api-key: Your platform API key // - x-platform-id: Your platform ID // - Idempotency-Key: Unique key for POST requests (prevents duplicate transactions)

💡 Integration Best Practices

  • Always check eligibility before showing Pay Later options
  • Handle all event types to provide smooth user experience
  • Verify payments server-side for security and compliance
  • Implement proper error handling and user feedback
  • Test thoroughly in sandbox environment before going live
  • Monitor payment status and handle edge cases

🔗 API Endpoints

Complete reference for all Pay Later API endpoints:

GET Get Wallet Balance

Endpoint: /v1/wallet

Retrieve the current wallet balance for a user.

Query Parameters

Parameter Type Required Description
email string Required User's email address
Success Response (200):
{ "success": true, "data": { "balance": 150.00, "currency": "USD", "available_credit": 500.00 } }

POST Apply for Pay Later

Endpoint: /v1/paylater/apply

Submit a Pay Later credit application.

Request Body

Parameter Type Required Description
email string Required User's email address
amount number Required Credit amount requested
currency string Optional Currency code (default: USD)
country string Optional Country code (auto-detected)
Success Response (200):
{ "success": true, "data": { "application_id": "app_123456", "status": "approved", "credit_limit": 500.00, "expires_at": "2024-12-31T23:59:59Z" } }

GET Check Application Status

Endpoint: /v1/paylater/status

Check the status of a Pay Later application.

Query Parameters

Parameter Type Required Description
email string Required User's email address
application_id string Optional Specific application ID
Success Response (200):
{ "success": true, "data": { "application_id": "app_123456", "status": "approved", "credit_limit": 500.00, "available_credit": 500.00, "currency": "USD", "expires_at": "2024-12-31T23:59:59Z", "created_at": "2024-01-15T09:00:00Z", "approved_at": "2024-01-15T09:15:00Z" } }

POST Activate Pay Later Account

Endpoint: /v1/paylater/activate

Activate an approved Pay Later account.

Request Body

Parameter Type Required Description
email string Required User's email address
application_id string Required Approved application ID
Success Response (200):
{ "success": true, "message": "Pay Later account activated successfully", "data": { "account_id": "acc_789012345", "status": "active", "credit_limit": 500.00, "available_credit": 500.00, "currency": "USD", "activated_at": "2024-01-15T10:00:00Z" } }

GET Transaction History

Endpoint: /v1/paylater/transactions

Retrieve transaction history for a user.

Query Parameters

Parameter Type Required Description
email string Required User's email address
limit number Optional Number of transactions to return (default: 10, max: 100)
offset number Optional Number of transactions to skip (default: 0)
Success Response (200):
{ "success": true, "data": { "transactions": [ { "id": "txn_paylater_123", "type": "purchase", "amount": 299.99, "status": "completed", "description": "Premium subscription purchase", "merchant": "GameStore Pro", "created_at": "2024-01-15T10:30:00Z", "due_date": "2024-02-15T23:59:59Z" }, { "id": "txn_paylater_124", "type": "repayment", "amount": -149.99, "status": "completed", "description": "Partial repayment", "created_at": "2024-01-10T14:20:00Z" } ], "pagination": { "total": 25, "limit": 10, "offset": 0, "has_more": true } } }

POST Auto Pay Due Balance (SDK: payAutoDueBalance)

SDK Usage

// Ensure SDK is initialized Appfinity.init({ platformId: 'SLOTGAME', apiKey: 'pub_live_12345', baseUrl: 'https://api.appfinity.com' }); // Trigger auto payment of due balance Appfinity.payAutoDueBalance({ email: 'user@example.com', callbackFunction: (res) => { console.log('auto-pay result:', res); } });
Callback (Success):
{ "type": "due_balance_auto_pay", "success": true, "data": { "success": true, "message": "Auto payment processed successfully", "data": { "payment_id": "pay_auto_123456", "amount": 50.00, "currency": "USD", "payment_method_used": "wallet", "remaining_balance": 100.00, "status": "completed", "processed_at": "2024-01-15T12:30:00Z", "transaction_id": "txn_auto_789012" } } }
Callback (Category < 3):
{ "type": "due_balance_auto_pay", "success": false, "message": "User not eligible (category < 3). Starting onboarding flow." }
Callback (Error):
{ "type": "due_balance_auto_pay", "success": false, "error": "Insufficient funds or processing error" }

🆘 Support & Resources

📚 Additional Documentation

🔧 Technical Support

Need Help? Our technical team is here to assist with your integration:

🚀 Production Checklist

Get Production API Keys

Contact our team to obtain your production API credentials.

Test All Scenarios

Run the complete test suite and verify all integration points.

Configure Webhooks

Set up webhook endpoints for real-time transaction updates.

Monitor Performance

Implement logging and monitoring for production usage.

🎉 Ready for Production! The Appfinity Pay Later SDK is production-ready with 100% test coverage, comprehensive documentation, and full technical support.