DocumentationMarketplace Integration

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

npm install @inkress/admin-sdk

Environment Variables

INKRESS_API_KEY

Checklist

1

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).

lib/inkress.ts
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, 
  });
}
2

Merchant Onboarding

When a new vendor joins, create a corresponding "Merchant" entity in Inkress. This links their account to the payment infrastructure.

services/onboarding.ts
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 };
}
3

Subscription Management

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.

services/billing.ts
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;
}
4

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.

services/catalog.ts
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;
}
5

Order Processing

Handle customer transactions by creating Orders. This supports full payments, deposits, and payment links.

services/orders.ts
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;
}
6

Webhook Integration

A single webhook endpoint handles updates for all merchants and subscriptions.

api/webhooks.ts
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 };
}
7

Testing & Sandbox

Use these test card numbers to simulate different payment scenarios in the sandbox environment.

Successful Payments

Instant Approval (No Password)

Card NumberBrandDescription
4012000000020071VisaStandard success
4012000000020089VisaSuccess with authentication attempt
5100270000000023MastercardStandard success
341111000000009AMEXStandard success

Success with Background Check

Card NumberBrandDescription
4012010000020070VisaSilent authentication check
4012010000020088VisaSilent check with attempt
5100271000000120MastercardSilent authentication check
341112000008012AMEXSilent authentication check

Success with Password Prompt

These cards simulate a bank asking for a one-time password. Enter 3ds2 when prompted.

Card NumberBrandDescription
4012000000020006VisaPassword required
5100270000000031MastercardPassword required
4012010000020005VisaPassword + Background check
341111000000037AMEXPassword required

Basic Cards

Older card types without modern authentication features (these should all be declined).

Card NumberBrand
4333333333332222Visa
5333333333332222Mastercard
343333333333335AMEX
6011111111111111Discover
3528111111111108JCB

Declined Payments

Card NumberBrandResult
4012000000020121VisaAuthentication Failed
5100270000000098MastercardAuthentication Failed
4666666666662222VisaIncorrect CVV
4111111111119999VisaGeneral Decline
4111111111110000VisaDeclined after password