coffee-pay-sdk 1.0.1 โ†’ 1.0.3

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/README.md CHANGED
@@ -11,6 +11,7 @@ Node.js SDK to integrate with the **COFFEE-PAY** payment gateway easily and secu
11
11
 
12
12
  - ๐Ÿ” **Automatic JWT Authentication**: Handles `apiKey` and `apiSecret` encryption automatically.
13
13
  - ๐Ÿงพ **Subscription Management**: Full CRUD support for subscription plans.
14
+ - ๐Ÿ’ณ **Payment Methods**: Consult available payment methods.
14
15
  - ๐Ÿ›ก๏ธ **Web Signing Utilities**: Easy signature generation for secure web payment buttons.
15
16
  - ๐Ÿง  **Fully Typed**: Built with TypeScript for excellent developer experience.
16
17
  - โš™๏ธ **Modern**: Compatible with Node.js v18+.
@@ -84,7 +85,17 @@ const currencies = await coffee.currencies.list(10, 1);
84
85
  const currency = await coffee.currencies.get('CURRENCY_ID');
85
86
  ```
86
87
 
87
- ### 4. Signing for Web Payments
88
+ ### 4. Consult Payment Methods
89
+
90
+ ```typescript
91
+ // List available payment methods
92
+ const methods = await coffee.paymentMethods.list(10, 1);
93
+
94
+ // Get payment method by ID
95
+ const method = await coffee.paymentMethods.get('METHOD_ID');
96
+ ```
97
+
98
+ ### 5. Signing for Web Payments
88
99
 
89
100
  Use this utility to sign requests made from the browser (e.g., for payment buttons).
90
101
 
@@ -128,6 +139,13 @@ const signature = CryptoUtils.generateWebSignature(accountKey, integrityKey, tim
128
139
  | `list(limit, page)` | Returns a list of supported currencies. |
129
140
  | `get(id)` | Retrieves detailed information for a specific currency. |
130
141
 
142
+ ### `paymentMethods`
143
+
144
+ | Method | Description |
145
+ | --- | --- |
146
+ | `list(limit, page)` | Returns a list of available payment methods. |
147
+ | `get(id)` | Retrieves detailed information for a specific payment method. |
148
+
131
149
  ---
132
150
 
133
151
  ## ๐Ÿค Contributing
package/dist/client.d.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  import { CoffeeConfig } from './types';
2
2
  import { SubscriptionsPlans } from './resources/subscriptions-plans';
3
3
  import { Currencies } from './resources/currencies';
4
+ import { PaymentMethods } from './resources/payment-methods';
4
5
  export declare class CoffeeSDK {
5
6
  private axiosInstance;
6
7
  private config;
7
8
  subscriptionsPlans: SubscriptionsPlans;
8
9
  currencies: Currencies;
10
+ paymentMethods: PaymentMethods;
9
11
  constructor(config: CoffeeConfig);
10
12
  }
package/dist/client.js CHANGED
@@ -8,11 +8,13 @@ const axios_1 = __importDefault(require("axios"));
8
8
  const auth_1 = require("./utils/auth");
9
9
  const subscriptions_plans_1 = require("./resources/subscriptions-plans");
10
10
  const currencies_1 = require("./resources/currencies");
11
+ const payment_methods_1 = require("./resources/payment-methods");
11
12
  class CoffeeSDK {
12
13
  axiosInstance;
13
14
  config;
14
15
  subscriptionsPlans;
15
16
  currencies;
17
+ paymentMethods;
16
18
  constructor(config) {
17
19
  this.config = config;
18
20
  this.axiosInstance = axios_1.default.create({
@@ -27,6 +29,7 @@ class CoffeeSDK {
27
29
  });
28
30
  this.subscriptionsPlans = new subscriptions_plans_1.SubscriptionsPlans(this.axiosInstance);
29
31
  this.currencies = new currencies_1.Currencies(this.axiosInstance);
32
+ this.paymentMethods = new payment_methods_1.PaymentMethods(this.axiosInstance);
30
33
  }
31
34
  }
32
35
  exports.CoffeeSDK = CoffeeSDK;
package/dist/index.d.ts CHANGED
@@ -3,3 +3,4 @@ export * from './types';
3
3
  export { CryptoUtils } from './utils/crypto';
4
4
  export { AuthUtils } from './utils/auth';
5
5
  export { Currencies } from './resources/currencies';
6
+ export { PaymentMethods } from './resources/payment-methods';
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Currencies = exports.AuthUtils = exports.CryptoUtils = void 0;
17
+ exports.PaymentMethods = exports.Currencies = exports.AuthUtils = exports.CryptoUtils = void 0;
18
18
  __exportStar(require("./client"), exports);
19
19
  __exportStar(require("./types"), exports);
20
20
  var crypto_1 = require("./utils/crypto");
@@ -23,3 +23,5 @@ var auth_1 = require("./utils/auth");
23
23
  Object.defineProperty(exports, "AuthUtils", { enumerable: true, get: function () { return auth_1.AuthUtils; } });
24
24
  var currencies_1 = require("./resources/currencies");
25
25
  Object.defineProperty(exports, "Currencies", { enumerable: true, get: function () { return currencies_1.Currencies; } });
26
+ var payment_methods_1 = require("./resources/payment-methods");
27
+ Object.defineProperty(exports, "PaymentMethods", { enumerable: true, get: function () { return payment_methods_1.PaymentMethods; } });
@@ -0,0 +1,16 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { ApiResponse, PaymentMethod, ListResponse } from '../types';
3
+ export declare class PaymentMethods {
4
+ private axios;
5
+ constructor(axios: AxiosInstance);
6
+ /**
7
+ * Retrieves a list of available payment methods.
8
+ * @param limit Number of items to retrieve (default: 100)
9
+ * @param page Page number (default: 1)
10
+ */
11
+ list(limit?: number, page?: number): Promise<ListResponse<PaymentMethod>>;
12
+ /**
13
+ * Retrieves a payment method by ID.
14
+ */
15
+ get(id: string): Promise<ApiResponse<PaymentMethod>>;
16
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PaymentMethods = void 0;
4
+ class PaymentMethods {
5
+ axios;
6
+ constructor(axios) {
7
+ this.axios = axios;
8
+ }
9
+ /**
10
+ * Retrieves a list of available payment methods.
11
+ * @param limit Number of items to retrieve (default: 100)
12
+ * @param page Page number (default: 1)
13
+ */
14
+ async list(limit = 100, page = 1) {
15
+ const response = await this.axios.get('/payments-methods', {
16
+ params: { limit, page },
17
+ });
18
+ return response.data;
19
+ }
20
+ /**
21
+ * Retrieves a payment method by ID.
22
+ */
23
+ async get(id) {
24
+ const response = await this.axios.get(`/payments-methods/${id}`);
25
+ return response.data;
26
+ }
27
+ }
28
+ exports.PaymentMethods = PaymentMethods;
@@ -21,7 +21,10 @@ class SubscriptionsPlans {
21
21
  * Creates a new subscription plan.
22
22
  */
23
23
  async create(data) {
24
- const response = await this.axios.post('/subscriptions-plans', data);
24
+ const response = await this.axios.post('/subscriptions-plans', {
25
+ ...data,
26
+ source: 'API',
27
+ });
25
28
  return response.data;
26
29
  }
27
30
  /**
@@ -50,19 +50,18 @@ export interface ListResponse<T> {
50
50
  }
51
51
  export interface CreateSubscriptionPlanDto {
52
52
  name: string;
53
+ reference: string;
53
54
  description: string;
54
55
  price: number;
55
56
  currencyId: string;
56
- interval: 'daily' | 'weekly' | 'monthly' | 'yearly';
57
+ interval: 'daily' | 'weekly' | 'biweekly' | 'monthly' | 'yearly';
58
+ intervalCount: number;
57
59
  billingDay: number;
58
60
  freeDays: number;
61
+ allowProrate: boolean;
59
62
  status: boolean;
60
- source: string;
61
- intervalCount?: number;
62
- reference?: string;
63
- allowProrate?: boolean;
64
- redirectUrl?: string;
65
- urlBack?: string;
63
+ redirectUrl: string;
64
+ urlBack: string;
66
65
  }
67
66
  export type UpdateSubscriptionPlanDto = Partial<CreateSubscriptionPlanDto>;
68
67
  export interface Currency {
@@ -79,3 +78,15 @@ export interface Currency {
79
78
  createdAt: string;
80
79
  updatedAt: string;
81
80
  }
81
+ export interface PaymentMethod {
82
+ id: string;
83
+ name: string;
84
+ slug: string;
85
+ icon?: string;
86
+ status: boolean;
87
+ isDeleted: boolean;
88
+ createdBy: string;
89
+ updatedBy: string;
90
+ createdAt?: string;
91
+ updatedAt?: string;
92
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coffee-pay-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Node.js SDK for Coffee-Pay payment gateway",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",