@yosle/tropipayjs 0.1.13 → 0.1.14

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.
@@ -8,6 +8,7 @@ import { Axios } from "axios";
8
8
  import { TropipayConfig, AccountBalance, Country, PaymentLink, mediationPaymentCardConfig, LoginResponse, AccountDeposits } from "../interfaces";
9
9
  type ServerMode = "Development" | "Production";
10
10
  import { TropipayHooks } from "../hooks/TropipayHooks";
11
+ import { PaymentCard } from "../paymentcard/PaymentCard";
11
12
  export declare class Tropipay {
12
13
  readonly clientId: string;
13
14
  readonly clientSecret: string;
@@ -16,6 +17,7 @@ export declare class Tropipay {
16
17
  static refreshToken: string | undefined;
17
18
  serverMode: ServerMode;
18
19
  hooks: TropipayHooks;
20
+ paymentcards: PaymentCard;
19
21
  constructor(config: TropipayConfig);
20
22
  login(): Promise<LoginResponse>;
21
23
  /**
package/index.d.ts CHANGED
@@ -198,6 +198,25 @@ declare class TropipayHooks {
198
198
  events(): Promise<any>;
199
199
  }
200
200
 
201
+ declare class PaymentCard {
202
+ private tropipay;
203
+ constructor(tropipayInstance: Tropipay);
204
+ /**
205
+ * Create a paymentLink with the specified options.
206
+ * @param payload PaymentLinkPayload Object.
207
+ * @returns Promise<PaymentLink> or throws an Exception.
208
+ * @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge
209
+ */
210
+ create(payload: PaymentLinkPayload): Promise<PaymentLink>;
211
+ /**
212
+ * Shows a list of stored paymentcards created by user.
213
+ * This list includes active and closed paylinks
214
+ * @returns Array of paymentlinks
215
+ */
216
+ list(): Promise<any>;
217
+ get(id: string): Promise<any>;
218
+ }
219
+
201
220
  /**
202
221
  * Tropipayjs is a Typescript/Javascript library for the Tropipay API.
203
222
  *
@@ -215,6 +234,7 @@ declare class Tropipay {
215
234
  static refreshToken: string | undefined;
216
235
  serverMode: ServerMode;
217
236
  hooks: TropipayHooks;
237
+ paymentcards: PaymentCard;
218
238
  constructor(config: TropipayConfig);
219
239
  login(): Promise<LoginResponse>;
220
240
  /**
@@ -300,25 +320,6 @@ declare class ServerSideUtils {
300
320
  } | Tropipay, originalCurrencyAmount: string, bankOrderCode: string, signature: string): boolean;
301
321
  }
302
322
 
303
- declare class PaymentCard {
304
- private tropipay;
305
- constructor(tropipayInstance: Tropipay);
306
- /**
307
- * Create a paymentLink with the specified options.
308
- * @param payload PaymentLinkPayload Object.
309
- * @returns Promise<PaymentLink> or throws an Exception.
310
- * @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge
311
- */
312
- create(payload: PaymentLinkPayload): Promise<PaymentLink>;
313
- /**
314
- * Shows a list of stored paymentcards created by user.
315
- * This list includes active and closed paylinks
316
- * @returns Array of paymentlinks
317
- */
318
- list(): Promise<any>;
319
- get(id: string): Promise<any>;
320
- }
321
-
322
323
  declare const SERVER_MODE: ServerMode$1;
323
324
 
324
325
  export { AccountBalance, AccountDeposits, ClientSideUtils, Country, Deposit, HookEventType, HookTargetType, LoginError, LoginResponse, PaymentCard, PaymentLink, PaymentLinkPayload, SERVER_MODE, ServerMode$1 as ServerMode, ServerSideUtils, Tropipay, TropipayConfig, TropipayCredentials, TropipayHooks, UserHook, UserHookSubscribed, mediationPaymentCardConfig };
package/index.js CHANGED
@@ -158,6 +158,78 @@ class TropipayHooks {
158
158
  }
159
159
  }
160
160
 
161
+ class PaymentCard {
162
+ tropipay;
163
+ constructor(tropipayInstance) {
164
+ this.tropipay = tropipayInstance;
165
+ }
166
+ /**
167
+ * Create a paymentLink with the specified options.
168
+ * @param payload PaymentLinkPayload Object.
169
+ * @returns Promise<PaymentLink> or throws an Exception.
170
+ * @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge
171
+ */
172
+ async create(payload) {
173
+ if (!Tropipay.accessToken) {
174
+ await this.tropipay.login();
175
+ }
176
+ try {
177
+ const paylink = await this.tropipay.request.post("/api/v2/paymentcards", payload, {
178
+ headers: {
179
+ "Content-Type": "application/json",
180
+ Authorization: `Bearer ${Tropipay.accessToken}`,
181
+ Accept: "application/json",
182
+ },
183
+ });
184
+ return paylink.data;
185
+ }
186
+ catch (error) {
187
+ throw new Error(`TropipayJS - Error creating the Payment Card.`);
188
+ }
189
+ }
190
+ /**
191
+ * Shows a list of stored paymentcards created by user.
192
+ * This list includes active and closed paylinks
193
+ * @returns Array of paymentlinks
194
+ */
195
+ async list() {
196
+ if (!Tropipay.accessToken) {
197
+ await this.tropipay.login();
198
+ }
199
+ try {
200
+ const paymentcards = await this.tropipay.request.get(`/api/v2/paymentcards`, {
201
+ headers: {
202
+ "Content-Type": "application/json",
203
+ Authorization: `Bearer ${Tropipay.accessToken}`,
204
+ Accept: "application/json",
205
+ },
206
+ });
207
+ return paymentcards.data;
208
+ }
209
+ catch (error) {
210
+ throw new Error(`Could not retrieve PaymenCards list`);
211
+ }
212
+ }
213
+ async get(id) {
214
+ if (!Tropipay.accessToken) {
215
+ await this.tropipay.login();
216
+ }
217
+ try {
218
+ const paymentcard = await this.tropipay.request.get(`/api/v2/paymentcards/${id}`, {
219
+ headers: {
220
+ "Content-Type": "application/json",
221
+ Authorization: `Bearer ${Tropipay.accessToken}`,
222
+ Accept: "application/json",
223
+ },
224
+ });
225
+ return paymentcard.data;
226
+ }
227
+ catch (error) {
228
+ throw new Error(`Could not retrieve PaymenCards`);
229
+ }
230
+ }
231
+ }
232
+
161
233
  /**
162
234
  * Tropipayjs is a Typescript/Javascript library for the Tropipay API.
163
235
  *
@@ -172,6 +244,7 @@ class Tropipay {
172
244
  static refreshToken;
173
245
  serverMode;
174
246
  hooks;
247
+ paymentcards;
175
248
  constructor(config) {
176
249
  this.clientId = config.clientId;
177
250
  this.clientSecret = config.clientSecret;
@@ -187,6 +260,7 @@ class Tropipay {
187
260
  },
188
261
  });
189
262
  this.hooks = new TropipayHooks(this);
263
+ this.paymentcards = new PaymentCard(this);
190
264
  }
191
265
  async login() {
192
266
  try {
@@ -436,78 +510,6 @@ class ServerSideUtils {
436
510
  }
437
511
  }
438
512
 
439
- class PaymentCard {
440
- tropipay;
441
- constructor(tropipayInstance) {
442
- this.tropipay = tropipayInstance;
443
- }
444
- /**
445
- * Create a paymentLink with the specified options.
446
- * @param payload PaymentLinkPayload Object.
447
- * @returns Promise<PaymentLink> or throws an Exception.
448
- * @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge
449
- */
450
- async create(payload) {
451
- if (!Tropipay.accessToken) {
452
- await this.tropipay.login();
453
- }
454
- try {
455
- const paylink = await this.tropipay.request.post("/api/v2/paymentcards", payload, {
456
- headers: {
457
- "Content-Type": "application/json",
458
- Authorization: `Bearer ${Tropipay.accessToken}`,
459
- Accept: "application/json",
460
- },
461
- });
462
- return paylink.data;
463
- }
464
- catch (error) {
465
- throw new Error(`TropipayJS - Error creating the Payment Card.`);
466
- }
467
- }
468
- /**
469
- * Shows a list of stored paymentcards created by user.
470
- * This list includes active and closed paylinks
471
- * @returns Array of paymentlinks
472
- */
473
- async list() {
474
- if (!Tropipay.accessToken) {
475
- await this.tropipay.login();
476
- }
477
- try {
478
- const paymentcards = await this.tropipay.request.get(`/api/v2/paymentcards`, {
479
- headers: {
480
- "Content-Type": "application/json",
481
- Authorization: `Bearer ${Tropipay.accessToken}`,
482
- Accept: "application/json",
483
- },
484
- });
485
- return paymentcards.data;
486
- }
487
- catch (error) {
488
- throw new Error(`Could not retrieve PaymenCards list`);
489
- }
490
- }
491
- async get(id) {
492
- if (!Tropipay.accessToken) {
493
- await this.tropipay.login();
494
- }
495
- try {
496
- const paymentcard = await this.tropipay.request.get(`/api/v2/paymentcards/${id}`, {
497
- headers: {
498
- "Content-Type": "application/json",
499
- Authorization: `Bearer ${Tropipay.accessToken}`,
500
- Accept: "application/json",
501
- },
502
- });
503
- return paymentcard.data;
504
- }
505
- catch (error) {
506
- throw new Error(`Could not retrieve PaymenCards`);
507
- }
508
- }
509
- }
510
-
511
513
  const SERVER_MODE = "Development"; // Move the constant here
512
514
 
513
515
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yosle/tropipayjs",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Javascript / Typescript SDK for the Tropipay API",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -18,6 +18,7 @@ import {
18
18
  } from "../interfaces";
19
19
  type ServerMode = "Development" | "Production";
20
20
  import { TropipayHooks } from "../hooks/TropipayHooks";
21
+ import { PaymentCard } from "../paymentcard/PaymentCard";
21
22
  export class Tropipay {
22
23
  readonly clientId: string;
23
24
  readonly clientSecret: string;
@@ -26,6 +27,7 @@ export class Tropipay {
26
27
  public static refreshToken: string | undefined;
27
28
  public serverMode: ServerMode;
28
29
  public hooks: TropipayHooks;
30
+ public paymentcards: PaymentCard;
29
31
 
30
32
  constructor(config: TropipayConfig) {
31
33
  this.clientId = config.clientId;
@@ -43,6 +45,7 @@ export class Tropipay {
43
45
  },
44
46
  });
45
47
  this.hooks = new TropipayHooks(this);
48
+ this.paymentcards = new PaymentCard(this);
46
49
  }
47
50
 
48
51
  public async login() {