@imerchantsolutions/sdk 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +48 -25
- package/dist/index.d.ts +48 -25
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
interface iMerchantConfig {
|
|
2
|
-
/** Your iMerchant API key (starts with
|
|
2
|
+
/** Your iMerchant API key (starts with mk_test_ or mk_live_) */
|
|
3
3
|
apiKey: string;
|
|
4
|
-
/** API base URL (defaults to https://
|
|
4
|
+
/** API base URL (defaults to https://imerchantsolutions.com) */
|
|
5
5
|
baseUrl?: string;
|
|
6
6
|
/** Request timeout in milliseconds (default: 30000) */
|
|
7
7
|
timeout?: number;
|
|
@@ -214,48 +214,71 @@ interface ListCustomersParams extends PaginationParams {
|
|
|
214
214
|
createdBefore?: string;
|
|
215
215
|
}
|
|
216
216
|
type SubscriptionStatus = 'active' | 'paused' | 'cancelled' | 'past_due' | 'trialing';
|
|
217
|
-
type BillingInterval = '
|
|
217
|
+
type BillingInterval = 'daily' | 'weekly' | 'monthly' | 'yearly';
|
|
218
218
|
interface Subscription {
|
|
219
219
|
/** Unique subscription identifier */
|
|
220
220
|
id: string;
|
|
221
|
-
/** Associated
|
|
222
|
-
|
|
221
|
+
/** Associated plan ID */
|
|
222
|
+
planId: string;
|
|
223
|
+
/** Customer email */
|
|
224
|
+
customerEmail: string;
|
|
225
|
+
/** Customer name */
|
|
226
|
+
customerName?: string;
|
|
227
|
+
/** Associated customer ID (optional) */
|
|
228
|
+
customerId?: string;
|
|
223
229
|
/** Current subscription status */
|
|
224
230
|
status: SubscriptionStatus;
|
|
225
|
-
/** Billing amount */
|
|
226
|
-
amount: Amount;
|
|
227
|
-
/** Billing interval */
|
|
228
|
-
interval: BillingInterval;
|
|
229
|
-
/** Number of intervals between billings */
|
|
230
|
-
intervalCount: number;
|
|
231
231
|
/** Current billing period start */
|
|
232
232
|
currentPeriodStart: string;
|
|
233
233
|
/** Current billing period end */
|
|
234
234
|
currentPeriodEnd: string;
|
|
235
235
|
/** Whether subscription cancels at period end */
|
|
236
236
|
cancelAtPeriodEnd: boolean;
|
|
237
|
+
/** When subscription was cancelled */
|
|
238
|
+
cancelledAt?: string;
|
|
239
|
+
/** Reason for cancellation */
|
|
240
|
+
cancelReason?: string;
|
|
241
|
+
/** Stored payment method for auto-billing */
|
|
242
|
+
storedPaymentMethodId?: string;
|
|
243
|
+
/** Shopper reference for payment processing */
|
|
244
|
+
shopperReference?: string;
|
|
237
245
|
/** Additional metadata */
|
|
238
246
|
metadata?: Record<string, string>;
|
|
239
247
|
/** ISO timestamp of creation */
|
|
240
248
|
createdAt: string;
|
|
249
|
+
/** ISO timestamp of last update */
|
|
250
|
+
updatedAt: string;
|
|
251
|
+
/** Associated plan details */
|
|
252
|
+
plan?: SubscriptionPlan;
|
|
241
253
|
}
|
|
242
|
-
interface
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
254
|
+
interface SubscriptionPlan {
|
|
255
|
+
id: string;
|
|
256
|
+
name: string;
|
|
257
|
+
description?: string;
|
|
246
258
|
amount: number;
|
|
247
|
-
/** Currency code */
|
|
248
259
|
currency: string;
|
|
249
|
-
/** Billing interval */
|
|
250
260
|
interval: BillingInterval;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
261
|
+
intervalCount: number;
|
|
262
|
+
trialDays: number;
|
|
263
|
+
active: boolean;
|
|
264
|
+
}
|
|
265
|
+
interface CreateSubscriptionParams {
|
|
266
|
+
/** Plan ID (required) */
|
|
267
|
+
planId: string;
|
|
268
|
+
/** Customer email (required) */
|
|
269
|
+
customerEmail: string;
|
|
270
|
+
/** Customer name (optional) */
|
|
271
|
+
customerName?: string;
|
|
272
|
+
/** Customer ID for reference (optional) */
|
|
273
|
+
customerId?: string;
|
|
274
|
+
/** Stored payment method ID for auto-billing (optional) */
|
|
275
|
+
storedPaymentMethodId?: string;
|
|
276
|
+
/** Shopper reference for tokenization (optional) */
|
|
277
|
+
shopperReference?: string;
|
|
255
278
|
/** Additional metadata */
|
|
256
279
|
metadata?: Record<string, string>;
|
|
257
280
|
}
|
|
258
|
-
type WebhookEventType = 'payment.
|
|
281
|
+
type WebhookEventType = 'payment.completed' | 'payment.failed' | 'payment.refunded' | 'dispute.created' | 'dispute.updated' | 'dispute.resolved' | 'payout.scheduled' | 'payout.completed' | 'payout.failed' | 'subscription.created' | 'subscription.renewed' | 'subscription.activated' | 'subscription.paused' | 'subscription.resumed' | 'subscription.cancelled' | 'subscription.payment_failed';
|
|
259
282
|
interface WebhookEvent<T = unknown> {
|
|
260
283
|
/** Unique event identifier */
|
|
261
284
|
id: string;
|
|
@@ -269,7 +292,7 @@ interface WebhookEvent<T = unknown> {
|
|
|
269
292
|
interface WebhookPayload {
|
|
270
293
|
/** Raw request body as string */
|
|
271
294
|
body: string;
|
|
272
|
-
/** Signature from
|
|
295
|
+
/** Signature from X-Webhook-Signature header */
|
|
273
296
|
signature: string;
|
|
274
297
|
}
|
|
275
298
|
|
|
@@ -639,7 +662,7 @@ declare class Webhooks {
|
|
|
639
662
|
* import { iMerchant } from '@imerchant/sdk';
|
|
640
663
|
*
|
|
641
664
|
* const client = new iMerchant({
|
|
642
|
-
* apiKey: '
|
|
665
|
+
* apiKey: 'mk_test_your_api_key',
|
|
643
666
|
* });
|
|
644
667
|
*
|
|
645
668
|
* // Create a payment
|
|
@@ -691,7 +714,7 @@ declare class iMerchant {
|
|
|
691
714
|
*
|
|
692
715
|
* @param config - Client configuration
|
|
693
716
|
* @param config.apiKey - Your iMerchant API key (required)
|
|
694
|
-
* @param config.baseUrl - API base URL (optional, defaults to https://
|
|
717
|
+
* @param config.baseUrl - API base URL (optional, defaults to https://imerchantsolutions.com)
|
|
695
718
|
* @param config.timeout - Request timeout in ms (optional, defaults to 30000)
|
|
696
719
|
* @param config.apiVersion - API version (optional, defaults to 'v1')
|
|
697
720
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
interface iMerchantConfig {
|
|
2
|
-
/** Your iMerchant API key (starts with
|
|
2
|
+
/** Your iMerchant API key (starts with mk_test_ or mk_live_) */
|
|
3
3
|
apiKey: string;
|
|
4
|
-
/** API base URL (defaults to https://
|
|
4
|
+
/** API base URL (defaults to https://imerchantsolutions.com) */
|
|
5
5
|
baseUrl?: string;
|
|
6
6
|
/** Request timeout in milliseconds (default: 30000) */
|
|
7
7
|
timeout?: number;
|
|
@@ -214,48 +214,71 @@ interface ListCustomersParams extends PaginationParams {
|
|
|
214
214
|
createdBefore?: string;
|
|
215
215
|
}
|
|
216
216
|
type SubscriptionStatus = 'active' | 'paused' | 'cancelled' | 'past_due' | 'trialing';
|
|
217
|
-
type BillingInterval = '
|
|
217
|
+
type BillingInterval = 'daily' | 'weekly' | 'monthly' | 'yearly';
|
|
218
218
|
interface Subscription {
|
|
219
219
|
/** Unique subscription identifier */
|
|
220
220
|
id: string;
|
|
221
|
-
/** Associated
|
|
222
|
-
|
|
221
|
+
/** Associated plan ID */
|
|
222
|
+
planId: string;
|
|
223
|
+
/** Customer email */
|
|
224
|
+
customerEmail: string;
|
|
225
|
+
/** Customer name */
|
|
226
|
+
customerName?: string;
|
|
227
|
+
/** Associated customer ID (optional) */
|
|
228
|
+
customerId?: string;
|
|
223
229
|
/** Current subscription status */
|
|
224
230
|
status: SubscriptionStatus;
|
|
225
|
-
/** Billing amount */
|
|
226
|
-
amount: Amount;
|
|
227
|
-
/** Billing interval */
|
|
228
|
-
interval: BillingInterval;
|
|
229
|
-
/** Number of intervals between billings */
|
|
230
|
-
intervalCount: number;
|
|
231
231
|
/** Current billing period start */
|
|
232
232
|
currentPeriodStart: string;
|
|
233
233
|
/** Current billing period end */
|
|
234
234
|
currentPeriodEnd: string;
|
|
235
235
|
/** Whether subscription cancels at period end */
|
|
236
236
|
cancelAtPeriodEnd: boolean;
|
|
237
|
+
/** When subscription was cancelled */
|
|
238
|
+
cancelledAt?: string;
|
|
239
|
+
/** Reason for cancellation */
|
|
240
|
+
cancelReason?: string;
|
|
241
|
+
/** Stored payment method for auto-billing */
|
|
242
|
+
storedPaymentMethodId?: string;
|
|
243
|
+
/** Shopper reference for payment processing */
|
|
244
|
+
shopperReference?: string;
|
|
237
245
|
/** Additional metadata */
|
|
238
246
|
metadata?: Record<string, string>;
|
|
239
247
|
/** ISO timestamp of creation */
|
|
240
248
|
createdAt: string;
|
|
249
|
+
/** ISO timestamp of last update */
|
|
250
|
+
updatedAt: string;
|
|
251
|
+
/** Associated plan details */
|
|
252
|
+
plan?: SubscriptionPlan;
|
|
241
253
|
}
|
|
242
|
-
interface
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
254
|
+
interface SubscriptionPlan {
|
|
255
|
+
id: string;
|
|
256
|
+
name: string;
|
|
257
|
+
description?: string;
|
|
246
258
|
amount: number;
|
|
247
|
-
/** Currency code */
|
|
248
259
|
currency: string;
|
|
249
|
-
/** Billing interval */
|
|
250
260
|
interval: BillingInterval;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
261
|
+
intervalCount: number;
|
|
262
|
+
trialDays: number;
|
|
263
|
+
active: boolean;
|
|
264
|
+
}
|
|
265
|
+
interface CreateSubscriptionParams {
|
|
266
|
+
/** Plan ID (required) */
|
|
267
|
+
planId: string;
|
|
268
|
+
/** Customer email (required) */
|
|
269
|
+
customerEmail: string;
|
|
270
|
+
/** Customer name (optional) */
|
|
271
|
+
customerName?: string;
|
|
272
|
+
/** Customer ID for reference (optional) */
|
|
273
|
+
customerId?: string;
|
|
274
|
+
/** Stored payment method ID for auto-billing (optional) */
|
|
275
|
+
storedPaymentMethodId?: string;
|
|
276
|
+
/** Shopper reference for tokenization (optional) */
|
|
277
|
+
shopperReference?: string;
|
|
255
278
|
/** Additional metadata */
|
|
256
279
|
metadata?: Record<string, string>;
|
|
257
280
|
}
|
|
258
|
-
type WebhookEventType = 'payment.
|
|
281
|
+
type WebhookEventType = 'payment.completed' | 'payment.failed' | 'payment.refunded' | 'dispute.created' | 'dispute.updated' | 'dispute.resolved' | 'payout.scheduled' | 'payout.completed' | 'payout.failed' | 'subscription.created' | 'subscription.renewed' | 'subscription.activated' | 'subscription.paused' | 'subscription.resumed' | 'subscription.cancelled' | 'subscription.payment_failed';
|
|
259
282
|
interface WebhookEvent<T = unknown> {
|
|
260
283
|
/** Unique event identifier */
|
|
261
284
|
id: string;
|
|
@@ -269,7 +292,7 @@ interface WebhookEvent<T = unknown> {
|
|
|
269
292
|
interface WebhookPayload {
|
|
270
293
|
/** Raw request body as string */
|
|
271
294
|
body: string;
|
|
272
|
-
/** Signature from
|
|
295
|
+
/** Signature from X-Webhook-Signature header */
|
|
273
296
|
signature: string;
|
|
274
297
|
}
|
|
275
298
|
|
|
@@ -639,7 +662,7 @@ declare class Webhooks {
|
|
|
639
662
|
* import { iMerchant } from '@imerchant/sdk';
|
|
640
663
|
*
|
|
641
664
|
* const client = new iMerchant({
|
|
642
|
-
* apiKey: '
|
|
665
|
+
* apiKey: 'mk_test_your_api_key',
|
|
643
666
|
* });
|
|
644
667
|
*
|
|
645
668
|
* // Create a payment
|
|
@@ -691,7 +714,7 @@ declare class iMerchant {
|
|
|
691
714
|
*
|
|
692
715
|
* @param config - Client configuration
|
|
693
716
|
* @param config.apiKey - Your iMerchant API key (required)
|
|
694
|
-
* @param config.baseUrl - API base URL (optional, defaults to https://
|
|
717
|
+
* @param config.baseUrl - API base URL (optional, defaults to https://imerchantsolutions.com)
|
|
695
718
|
* @param config.timeout - Request timeout in ms (optional, defaults to 30000)
|
|
696
719
|
* @param config.apiVersion - API version (optional, defaults to 'v1')
|
|
697
720
|
*/
|
package/dist/index.js
CHANGED
|
@@ -98,7 +98,7 @@ var WebhookSignatureError = class _WebhookSignatureError extends iMerchantError
|
|
|
98
98
|
};
|
|
99
99
|
|
|
100
100
|
// src/http.ts
|
|
101
|
-
var DEFAULT_BASE_URL = "https://
|
|
101
|
+
var DEFAULT_BASE_URL = "https://imerchantsolutions.com";
|
|
102
102
|
var DEFAULT_TIMEOUT = 3e4;
|
|
103
103
|
var DEFAULT_API_VERSION = "v1";
|
|
104
104
|
var HttpClient = class {
|
|
@@ -156,7 +156,7 @@ var HttpClient = class {
|
|
|
156
156
|
const url = this.getUrl(path);
|
|
157
157
|
const timeout = options?.timeout || this.config.timeout;
|
|
158
158
|
const headers = {
|
|
159
|
-
"
|
|
159
|
+
"X-API-Key": this.config.apiKey,
|
|
160
160
|
"Content-Type": "application/json",
|
|
161
161
|
"X-SDK-Version": "1.0.0"
|
|
162
162
|
};
|
|
@@ -711,7 +711,7 @@ var iMerchant = class {
|
|
|
711
711
|
*
|
|
712
712
|
* @param config - Client configuration
|
|
713
713
|
* @param config.apiKey - Your iMerchant API key (required)
|
|
714
|
-
* @param config.baseUrl - API base URL (optional, defaults to https://
|
|
714
|
+
* @param config.baseUrl - API base URL (optional, defaults to https://imerchantsolutions.com)
|
|
715
715
|
* @param config.timeout - Request timeout in ms (optional, defaults to 30000)
|
|
716
716
|
* @param config.apiVersion - API version (optional, defaults to 'v1')
|
|
717
717
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -60,7 +60,7 @@ var WebhookSignatureError = class _WebhookSignatureError extends iMerchantError
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
// src/http.ts
|
|
63
|
-
var DEFAULT_BASE_URL = "https://
|
|
63
|
+
var DEFAULT_BASE_URL = "https://imerchantsolutions.com";
|
|
64
64
|
var DEFAULT_TIMEOUT = 3e4;
|
|
65
65
|
var DEFAULT_API_VERSION = "v1";
|
|
66
66
|
var HttpClient = class {
|
|
@@ -118,7 +118,7 @@ var HttpClient = class {
|
|
|
118
118
|
const url = this.getUrl(path);
|
|
119
119
|
const timeout = options?.timeout || this.config.timeout;
|
|
120
120
|
const headers = {
|
|
121
|
-
"
|
|
121
|
+
"X-API-Key": this.config.apiKey,
|
|
122
122
|
"Content-Type": "application/json",
|
|
123
123
|
"X-SDK-Version": "1.0.0"
|
|
124
124
|
};
|
|
@@ -673,7 +673,7 @@ var iMerchant = class {
|
|
|
673
673
|
*
|
|
674
674
|
* @param config - Client configuration
|
|
675
675
|
* @param config.apiKey - Your iMerchant API key (required)
|
|
676
|
-
* @param config.baseUrl - API base URL (optional, defaults to https://
|
|
676
|
+
* @param config.baseUrl - API base URL (optional, defaults to https://imerchantsolutions.com)
|
|
677
677
|
* @param config.timeout - Request timeout in ms (optional, defaults to 30000)
|
|
678
678
|
* @param config.apiVersion - API version (optional, defaults to 'v1')
|
|
679
679
|
*/
|