@yosle/tropipayjs 0.1.12 → 0.1.13

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
@@ -300,6 +300,25 @@ declare class ServerSideUtils {
300
300
  } | Tropipay, originalCurrencyAmount: string, bankOrderCode: string, signature: string): boolean;
301
301
  }
302
302
 
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
+
303
322
  declare const SERVER_MODE: ServerMode$1;
304
323
 
305
- export { AccountBalance, AccountDeposits, ClientSideUtils, Country, Deposit, HookEventType, HookTargetType, LoginError, LoginResponse, PaymentLink, PaymentLinkPayload, SERVER_MODE, ServerMode$1 as ServerMode, ServerSideUtils, Tropipay, TropipayConfig, TropipayCredentials, TropipayHooks, UserHook, UserHookSubscribed, mediationPaymentCardConfig };
324
+ 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
@@ -436,6 +436,78 @@ class ServerSideUtils {
436
436
  }
437
437
  }
438
438
 
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
+
439
511
  const SERVER_MODE = "Development"; // Move the constant here
440
512
 
441
513
  /**
@@ -454,6 +526,7 @@ if (typeof window !== "undefined") {
454
526
  }
455
527
 
456
528
  exports.ClientSideUtils = ClientSideUtils;
529
+ exports.PaymentCard = PaymentCard;
457
530
  exports.SERVER_MODE = SERVER_MODE;
458
531
  exports.ServerSideUtils = ServerSideUtils;
459
532
  exports.Tropipay = Tropipay;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yosle/tropipayjs",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "Javascript / Typescript SDK for the Tropipay API",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -20,6 +20,7 @@ export { Tropipay } from "./api/TropipayAPI";
20
20
  export { ClientSideUtils } from "./api/TropipayAPI";
21
21
  export { ServerSideUtils } from "./utils/TropipayUtils";
22
22
  export { TropipayHooks } from "./hooks/TropipayHooks";
23
+ export { PaymentCard } from "./paymentcard/PaymentCard";
23
24
  export * from "./interfaces/index";
24
25
  export { SERVER_MODE } from "./config/TropipayConfig";
25
26
  export * from "./constants/TropipayConstants";