@kuvarpay/sdk 1.0.0 → 1.2.0

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/index.d.ts CHANGED
@@ -78,8 +78,6 @@ export class KuvarPayServer {
78
78
  toDate?: string;
79
79
  }): Promise<any>;
80
80
 
81
- refundTransaction(transactionId: string, data?: { amount?: number; reason?: string }): Promise<any>;
82
- getExpiredTransactions(): Promise<any>;
83
81
  getOptimalTransferFee(amount: number, currency?: string): Promise<any>;
84
82
  sendInvoiceEmail(sessionId: string): Promise<any>;
85
83
 
package/index.js CHANGED
@@ -10,10 +10,10 @@
10
10
 
11
11
  const crypto = require('crypto');
12
12
 
13
- const DEFAULT_BASE = (process.env.PAYMENT_API_BASE_URL
14
- || process.env.PAYMENT_SERVER_URL
15
- || process.env.NEXT_PUBLIC_PAYMENT_API_BASE_URL
16
- || 'http://localhost:3002').replace(/\/+$/, '');
13
+ const DEFAULT_BASE = (process.env.KUVARPAY_API_BASE_URL
14
+ || process.env.PAYMENT_API_BASE_URL
15
+ || 'https://payment.kuvarpay.com'
16
+ ).replace(/\/$/, '');
17
17
 
18
18
  class KuvarPayServer {
19
19
  /**
@@ -39,7 +39,6 @@ class KuvarPayServer {
39
39
  _headers(extra = {}) {
40
40
  return Object.assign({
41
41
  'Accept': 'application/json',
42
- 'Authorization': this.secretApiKey,
43
42
  'X-API-Key': this.secretApiKey,
44
43
  'X-Business-ID': this.businessId,
45
44
  }, extra);
@@ -143,6 +142,22 @@ class KuvarPayServer {
143
142
  };
144
143
  }
145
144
 
145
+ /**
146
+ * Update transaction status (Admin/Internal)
147
+ * PATCH /api/v1/transactions/{id}/status
148
+ */
149
+ async updateTransactionStatus(transactionId, data) {
150
+ return this._patch(`/api/v1/transactions/${encodeURIComponent(transactionId)}/status`, data);
151
+ }
152
+
153
+ /**
154
+ * Simulate a payment (Sandbox only)
155
+ * POST /api/v1/transactions/{id}/demo-pay
156
+ */
157
+ async demoPay(transactionId) {
158
+ return this._post(`/api/v1/transactions/${encodeURIComponent(transactionId)}/demo-pay`, {});
159
+ }
160
+
146
161
  /**
147
162
  * Get transaction status by merchant reference
148
163
  * GET /api/v1/transactions/status/{reference}
@@ -162,22 +177,6 @@ class KuvarPayServer {
162
177
  return this._get(path);
163
178
  }
164
179
 
165
- /**
166
- * Refund a transaction
167
- * @param {string} transactionId
168
- * @param {Object} data - { amount?, reason? }
169
- */
170
- async refundTransaction(transactionId, data = {}) {
171
- return this._post(`/api/v1/transactions/${encodeURIComponent(transactionId)}/refund`, data);
172
- }
173
-
174
- /**
175
- * Get expired transactions
176
- */
177
- async getExpiredTransactions() {
178
- return this._get('/api/v1/transactions/expired');
179
- }
180
-
181
180
  /**
182
181
  * Calculate fees
183
182
  */
@@ -249,7 +248,7 @@ class KuvarPayServer {
249
248
  const payload = Object.assign({}, transactionData, {
250
249
  businessId: transactionData.businessId || this.businessId,
251
250
  });
252
- return this._post('/api/v1/transactions', payload);
251
+ return this._post('/api/v1/transactions/create', payload);
253
252
  }
254
253
 
255
254
  /**
@@ -450,11 +449,11 @@ class KuvarPayServer {
450
449
 
451
450
  /**
452
451
  * Cancel a subscription (confirm cancellation)
453
- * POST {Payment API Base}/api/v1/subscriptions/{subscriptionId}/cancel
452
+ * POST {Payment API Base}/api/v1/subscriptions/{subscriptionId}/cancel/confirm
454
453
  */
455
454
  async cancelSubscription(subscriptionId, body = {}) {
456
455
  if (!subscriptionId) throw new Error('subscriptionId is required');
457
- return this._post(`/api/v1/subscriptions/${encodeURIComponent(subscriptionId)}/cancel`, body);
456
+ return this._post(`/api/v1/subscriptions/${encodeURIComponent(subscriptionId)}/cancel/confirm`, body);
458
457
  }
459
458
 
460
459
  /**
@@ -464,14 +463,12 @@ class KuvarPayServer {
464
463
  return this._post('/api/v1/subscriptions/relay/authorizations', body);
465
464
  }
466
465
 
467
- async getRelayAuthorizationStatus(body) {
468
- return this._post('/api/v1/subscriptions/relay/authorization-status', body);
466
+ async getRelayAuthorizationStatus(subscriptionId) {
467
+ return this._get(`/api/v1/subscriptions/relay/authorizations/${encodeURIComponent(subscriptionId)}/status`);
469
468
  }
470
469
 
471
470
  async revokeRelayAuthorization(body) {
472
- // Some environments use '/relay/revokeAuth'; support both via path param
473
- const path = body?.useLegacyPath ? '/api/v1/subscriptions/relay/revokeAuth' : '/api/v1/subscriptions/revoke-authorization';
474
- return this._post(path, body);
471
+ return this._post('/api/v1/subscriptions/relay/revokeAuth', body);
475
472
  }
476
473
 
477
474
  /**
package/index.mjs CHANGED
@@ -8,10 +8,10 @@
8
8
 
9
9
  import crypto from 'node:crypto';
10
10
 
11
- const DEFAULT_BASE = (process.env.PAYMENT_API_BASE_URL
12
- || process.env.PAYMENT_SERVER_URL
13
- || process.env.NEXT_PUBLIC_PAYMENT_API_BASE_URL
14
- || 'http://localhost:3002').replace(/\/+$/, '');
11
+ const DEFAULT_BASE = (process.env.KUVARPAY_API_BASE_URL
12
+ || process.env.PAYMENT_API_BASE_URL
13
+ || 'https://payment.kuvarpay.com'
14
+ ).replace(/\/$/, '');
15
15
 
16
16
  export class KuvarPayServer {
17
17
  /**
@@ -37,7 +37,6 @@ export class KuvarPayServer {
37
37
  _headers(extra = {}) {
38
38
  return Object.assign({
39
39
  'Accept': 'application/json',
40
- 'Authorization': this.secretApiKey,
41
40
  'X-API-Key': this.secretApiKey,
42
41
  'X-Business-ID': this.businessId,
43
42
  }, extra);
@@ -140,14 +139,6 @@ export class KuvarPayServer {
140
139
  return this._get(path);
141
140
  }
142
141
 
143
- async refundTransaction(transactionId, data = {}) {
144
- return this._post(`/api/v1/transactions/${encodeURIComponent(transactionId)}/refund`, data);
145
- }
146
-
147
- async getExpiredTransactions() {
148
- return this._get('/api/v1/transactions/expired');
149
- }
150
-
151
142
  async getOptimalTransferFee(amount, currency = 'NGN') {
152
143
  return this._get(`/api/v1/optimal-transfer-fee?amount=${amount}&currency=${currency}`);
153
144
  }
@@ -193,7 +184,7 @@ export class KuvarPayServer {
193
184
  const payload = Object.assign({}, transactionData, {
194
185
  businessId: transactionData.businessId || this.businessId,
195
186
  });
196
- return this._post('/api/v1/transactions', payload);
187
+ return this._post('/api/v1/transactions/create', payload);
197
188
  }
198
189
 
199
190
  async sendInvoiceEmail(sessionId) {
@@ -318,20 +309,19 @@ export class KuvarPayServer {
318
309
 
319
310
  async cancelSubscription(subscriptionId, body = {}) {
320
311
  if (!subscriptionId) throw new Error('subscriptionId is required');
321
- return this._post(`/api/v1/subscriptions/${encodeURIComponent(subscriptionId)}/cancel`, body);
312
+ return this._post(`/api/v1/subscriptions/${encodeURIComponent(subscriptionId)}/cancel/confirm`, body);
322
313
  }
323
314
 
324
315
  async createRelayAuthorization(body) {
325
316
  return this._post('/api/v1/subscriptions/relay/authorizations', body);
326
317
  }
327
318
 
328
- async getRelayAuthorizationStatus(body) {
329
- return this._post('/api/v1/subscriptions/relay/authorization-status', body);
319
+ async getRelayAuthorizationStatus(subscriptionId) {
320
+ return this._get(`/api/v1/subscriptions/relay/authorizations/${encodeURIComponent(subscriptionId)}/status`);
330
321
  }
331
322
 
332
323
  async revokeRelayAuthorization(body) {
333
- const path = body?.useLegacyPath ? '/api/v1/subscriptions/relay/revokeAuth' : '/api/v1/subscriptions/revoke-authorization';
334
- return this._post(path, body);
324
+ return this._post('/api/v1/subscriptions/relay/revokeAuth', body);
335
325
  }
336
326
 
337
327
  async createRenewalCheckoutSession(body) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kuvarpay/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Official KuvarPay Server SDK for Node.js",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -27,4 +27,4 @@
27
27
  },
28
28
  "author": "KuvarPay Team",
29
29
  "license": "MIT"
30
- }
30
+ }