Inkress SDK Integration Guide
Technical documentation for integrating the Inkress Admin SDK. Learn how to manage merchant onboarding, subscriptions, and payments within your multi-tenant platform.
Prerequisites
Before you begin, ensure you have the following set up.
Installation
Environment Variables
INKRESS_API_KEYChecklist
- Register as an Organisation.
- Generate an API Key with Admin permissions.
- Create a Merchant with a unique username (your Platform Merchant).
- Switch to your new Merchant Account using the top right dropdown.
- Create a Subscription Plan and copy the link.
SDK Configuration
Create a centralized service to manage SDK instances. You need to handle two contexts: Platform Context (for managing merchants) and Merchant Context (for acting as a merchant).
import InkressSDK from "@inkress/admin-sdk";
const INKRESS_CONFIG = {
accessToken: process.env.INKRESS_API_KEY,
mode: process.env.NODE_ENV === 'production' ? 'live' : 'sandbox',
platformMerchantId: 'your-platform-username',
};
/**
* Creates an SDK instance.
* @param merchantUsername - (Optional) If provided, scopes actions to this sub-merchant.
*/
export async function createInkressSDK(merchantUsername?: string) {
return new InkressSDK({
accessToken: INKRESS_CONFIG.accessToken,
mode: INKRESS_CONFIG.mode,
username: merchantUsername,
});
}Merchant Onboarding
When a new vendor joins, create a corresponding "Merchant" entity in Inkress. This links their account to the payment infrastructure.
async function onboardMerchant(merchantInfo) {
const platformSdk = await createInkressSDK(); // No username = Platform Context
const merchant = await platformSdk.merchants.create({
name: merchantInfo.business_name,
email: merchantInfo.email,
username: merchantInfo.unique_slug,
business_type: 'service',
webhook_url: 'https://your-platform.com/api/webhooks/inkress',
data: {
internal_id: merchantInfo.id
}
});
return { inkressId: merchant.id, inkressUsername: merchant.username };
}Subscription Management
Important
subscriptions.createLink instead of orders.create for recurring billing.When a merchant selects a plan, create a subscription link using the plan's UID.
You can get your plans UID from API or the last part of your subscription link, which you can copy the from the dashboard.
async function subscribeMerchant(merchantUsername, planUid, merchantDetails) {
const merchantSdk = await createInkressSDK(merchantUsername);
// Create a subscription link
const result = await merchantSdk.subscriptions.createLink({
title: 'Platform Subscription',
plan_uid: planUid, // Use the UID string, e.g., "plan_abc123"
customer: {
first_name: merchantDetails.firstName,
last_name: merchantDetails.lastName,
email: merchantDetails.email
},
meta_data: {
return_url: 'https://your-platform.com/dashboard/plans',
internal_merchant_id: merchantDetails.id
},
reference_id: `sub_${merchantDetails.id}_${Date.now()}`
});
return result.payment_urls.short_link;
}Making Products
Create Inkress products on-the-fly when they are needed (e.g., at the time of first order). and store the Inkress product ID in your local database for future reference.
async function syncProduct(merchantUsername, serviceItem) {
const merchantSdk = await createInkressSDK(merchantUsername);
const product = await merchantSdk.products.create({
title: serviceItem.name,
price: serviceItem.price,
currency_code: 'JMD',
permalink: `item-${serviceItem.id}`,
public: false,
unlimited: true // useful for services
});
return product.id;
}Order Processing
Handle customer transactions by creating Orders. This supports full payments, deposits, and payment links.
async function createTransaction(merchantUsername, orderDetails) {
const merchantSdk = await createInkressSDK(merchantUsername);
// 1. Resolve Product ID
let productId = orderDetails.item.inkress_product_id;
// 2. Create Order
const order = await merchantSdk.orders.create({
customer: {
email: orderDetails.customer.email,
first_name: orderDetails.customer.firstName,
last_name: orderDetails.customer.lastName
},
currency_code: 'JMD',
products: [{
id: productId,
quantity: 1,
}],
kind: 'online',
meta_data: {
return_url: 'https://your-platform.com/checkout/complete',
},
});
return order.payment_urls.short_link;
}Webhook Integration
A single webhook endpoint handles updates for all merchants and subscriptions.
export async function webhookHandler(request) {
const payload = await request.json();
const { event, data } = payload;
switch (event) {
case 'orders.paid':
if (data.order.reference) {
await updateTransactionStatus(data.order.reference, 'paid');
}
break;
case 'subscriptions.activated':
await updateMerchantAccess(data.customer.email, 'active');
break;
}
return { received: true };
}Testing & Sandbox
Use these test card numbers to simulate different payment scenarios in the sandbox environment.
Successful Payments
Instant Approval (No Password)
| Card Number | Brand | Description |
|---|---|---|
| 4012000000020071 | Visa | Standard success |
| 4012000000020089 | Visa | Success with authentication attempt |
| 5100270000000023 | Mastercard | Standard success |
| 341111000000009 | AMEX | Standard success |
Success with Background Check
| Card Number | Brand | Description |
|---|---|---|
| 4012010000020070 | Visa | Silent authentication check |
| 4012010000020088 | Visa | Silent check with attempt |
| 5100271000000120 | Mastercard | Silent authentication check |
| 341112000008012 | AMEX | Silent authentication check |
Success with Password Prompt
These cards simulate a bank asking for a one-time password. Enter 3ds2 when prompted.
| Card Number | Brand | Description |
|---|---|---|
| 4012000000020006 | Visa | Password required |
| 5100270000000031 | Mastercard | Password required |
| 4012010000020005 | Visa | Password + Background check |
| 341111000000037 | AMEX | Password required |
Basic Cards
Older card types without modern authentication features (these should all be declined).
| Card Number | Brand |
|---|---|
| 4333333333332222 | Visa |
| 5333333333332222 | Mastercard |
| 343333333333335 | AMEX |
| 6011111111111111 | Discover |
| 3528111111111108 | JCB |
Declined Payments
| Card Number | Brand | Result |
|---|---|---|
| 4012000000020121 | Visa | Authentication Failed |
| 5100270000000098 | Mastercard | Authentication Failed |
| 4666666666662222 | Visa | Incorrect CVV |
| 4111111111119999 | Visa | General Decline |
| 4111111111110000 | Visa | Declined after password |
Test Card Tips
- Use any future date for expiry (e.g., 12/30)
- Use any 3-digit CVV for Visa/Mastercard/Discover/JCB
- Use any 4-digit CVV for AMEX
- Real card numbers will not work in test mode
- Test cards will not work in live mode