SDKs & Client Libraries
Official SDKs for integrating Inkress into your applications.
@inkress/admin-sdk
v1.1.3
The official server-side SDK for managing merchants, orders, subscriptions, and webhooks.
Installation
Install Admin SDK
npm install @inkress/admin-sdk@1.1.3Basic Setup
Initialize the SDK with your access token. Never expose this key on the client side.
SDK Initialization
import InkressSDK from "@inkress/admin-sdk";
const sdk = new InkressSDK({
accessToken: process.env.INKRESS_API_KEY,
mode: 'sandbox', // or 'live' for production
username: 'your-merchant-username' // optional: for sub-merchant operations
});Creating Merchants
Create sub-merchant accounts for your platform vendors.
Merchant Creation
const merchant = await sdk.merchants.create({
name: 'Acme Corporation',
email: 'vendor@acme.com',
username: 'acme-corp',
business_type: 'service',
webhook_url: 'https://your-platform.com/webhooks/inkress',
data: {
internal_id: 'vendor_12345'
}
});
console.log('Merchant ID:', merchant.id);
console.log('Username:', merchant.username);Subscription Links
Create subscription payment links for recurring billing.
Creating Subscription Links
const result = await sdk.subscriptions.createLink({
title: 'Pro Plan Subscription',
plan_uid: 'plan_abc123',
customer: {
first_name: 'John',
last_name: 'Doe',
email: 'john@example.com'
},
meta_data: {
return_url: 'https://your-app.com/success',
merchant_id: 'vendor_12345'
},
reference_id: 'sub_' + Date.now()
});
// Redirect user to payment link
window.location.href = result.payment_urls.short_link;Creating Products
Add products to your merchant catalog.
Product Creation
const product = await sdk.products.create({
title: 'Premium Service',
price: 99.99,
currency: 'USD',
description: 'Our premium service offering',
category: 'services',
stock: 100,
images: ['https://example.com/image.jpg']
});
console.log('Product created:', product.id);Payment Links
Generate one-time payment links for orders.
Creating Payment Links
const paymentLink = await sdk.orders.create({
title: 'Order #12345',
amount: 149.99,
currency: 'USD',
customer: {
first_name: 'Jane',
last_name: 'Smith',
email: 'jane@example.com',
phone: '+1234567890'
},
items: [
{
product_id: 'prod_xyz789',
quantity: 2,
price: 74.99
}
],
meta_data: {
order_id: 'order_12345'
}
});
// Get the payment URL
const paymentUrl = paymentLink.payment_urls.short_link;Webhooks
Handle webhook events for payment notifications.
Webhook Handler
// Express.js example
app.post('/webhooks/inkress', async (req, res) => {
const event = req.body;
switch (event.type) {
case 'payment.completed':
// Handle successful payment
await handlePaymentSuccess(event.data);
break;
case 'subscription.activated':
// Handle subscription activation
await activateSubscription(event.data);
break;
case 'payment.failed':
// Handle failed payment
await handlePaymentFailure(event.data);
break;
}
res.json({ received: true });
});