@internxt/sdk 1.10.11 → 1.10.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.
@@ -1,6 +1,6 @@
1
- import { CreatedPaymentIntent, CreatedSubscriptionData } from '../drive/payments/types/types';
1
+ import { CreatedSubscriptionData } from '../drive/payments/types/types';
2
2
  import { ApiSecurity, ApiUrl, AppDetails } from '../shared';
3
- import { CreatePaymentIntentPayload, CreateSubscriptionPayload, CryptoCurrency, GetPriceByIdPayload, PriceWithTax } from './types';
3
+ import { CreatePaymentIntentPayload, CreateSubscriptionPayload, CryptoCurrency, GetPriceByIdPayload, PaymentIntent, PriceWithTax } from './types';
4
4
  export declare class Checkout {
5
5
  private readonly client;
6
6
  private readonly appDetails;
@@ -49,8 +49,13 @@ export declare class Checkout {
49
49
  * - `clientSecret`: The client secret for the invoice to be used with Stripe Elements
50
50
  * - `id`: The ID of the invoice
51
51
  * - `invoiceStatus`: The status of the invoice (only when the status is 'paid')
52
+ * - `type`: The type of the currency - 'fiat' or 'crypto'
53
+ * - `payload`: The payload of the invoice if the type is 'crypto' containing { paymentRequestUri, url, qrUrl }
54
+ * - `payload.paymentRequestUri`: The payment request URI for the invoice
55
+ * - `payload.url`: The URL of the invoice
56
+ * - `payload.qrUrl`: The QR code URL of the invoice
52
57
  */
53
- createPaymentIntent({ customerId, priceId, token, currency, promoCodeId, }: CreatePaymentIntentPayload): Promise<CreatedPaymentIntent>;
58
+ createPaymentIntent({ customerId, priceId, token, currency, promoCodeId, }: CreatePaymentIntentPayload): Promise<PaymentIntent>;
54
59
  /**
55
60
  * @description Fetch a requested price by its ID and its tax rate
56
61
  * @param priceId - The ID of the price
@@ -59,7 +64,17 @@ export declare class Checkout {
59
64
  * @returns The price object containing the details of the requested price
60
65
  */
61
66
  getPriceById({ priceId, promoCodeName, userAddress, currency, postalCode, country, }: GetPriceByIdPayload): Promise<PriceWithTax>;
67
+ /**
68
+ * @description Fetches all available cryptocurrencies for the checkout module
69
+ * @returns A promise which resolves to an array of available cryptocurrencies
70
+ */
62
71
  getAvailableCryptoCurrencies(): Promise<CryptoCurrency[]>;
72
+ /**
73
+ * @description Verifies a cryptocurrency payment
74
+ * @param token - The encoded token we need to verify the payment
75
+ * @returns A promise that resolves to a boolean indicating whether the payment is verified
76
+ */
77
+ verifyCryptoPayment(token: string): Promise<boolean>;
63
78
  /**
64
79
  * Returns the needed headers with authorization header for the module requests
65
80
  * @private
@@ -76,6 +76,11 @@ var Checkout = /** @class */ (function () {
76
76
  * - `clientSecret`: The client secret for the invoice to be used with Stripe Elements
77
77
  * - `id`: The ID of the invoice
78
78
  * - `invoiceStatus`: The status of the invoice (only when the status is 'paid')
79
+ * - `type`: The type of the currency - 'fiat' or 'crypto'
80
+ * - `payload`: The payload of the invoice if the type is 'crypto' containing { paymentRequestUri, url, qrUrl }
81
+ * - `payload.paymentRequestUri`: The payment request URI for the invoice
82
+ * - `payload.url`: The URL of the invoice
83
+ * - `payload.qrUrl`: The QR code URL of the invoice
79
84
  */
80
85
  Checkout.prototype.createPaymentIntent = function (_a) {
81
86
  var customerId = _a.customerId, priceId = _a.priceId, token = _a.token, currency = _a.currency, promoCodeId = _a.promoCodeId;
@@ -110,8 +115,22 @@ var Checkout = /** @class */ (function () {
110
115
  query.set('country', country);
111
116
  return this.client.get("/checkout/price-by-id?".concat(query.toString()), this.headers());
112
117
  };
118
+ /**
119
+ * @description Fetches all available cryptocurrencies for the checkout module
120
+ * @returns A promise which resolves to an array of available cryptocurrencies
121
+ */
113
122
  Checkout.prototype.getAvailableCryptoCurrencies = function () {
114
- return this.client.get('/checkout/currencies/crypto', this.headers());
123
+ return this.client.get('/checkout/crypto/currencies', this.headers());
124
+ };
125
+ /**
126
+ * @description Verifies a cryptocurrency payment
127
+ * @param token - The encoded token we need to verify the payment
128
+ * @returns A promise that resolves to a boolean indicating whether the payment is verified
129
+ */
130
+ Checkout.prototype.verifyCryptoPayment = function (token) {
131
+ return this.client.post('/checkout/crypto/verify/payment', {
132
+ token: token,
133
+ }, this.authHeaders());
115
134
  };
116
135
  /**
117
136
  * Returns the needed headers with authorization header for the module requests
@@ -11,7 +11,7 @@ export interface CreatePaymentIntentPayload {
11
11
  customerId: string;
12
12
  priceId: string;
13
13
  token: string;
14
- currency?: string;
14
+ currency: string;
15
15
  promoCodeId?: string;
16
16
  }
17
17
  export interface PaymentMethodVerificationPayload {
@@ -39,7 +39,7 @@ export type Price = {
39
39
  currency: string;
40
40
  amount: number;
41
41
  bytes: number;
42
- interval: 'lifetime' | 'year';
42
+ interval: 'month' | 'year' | 'lifetime';
43
43
  decimalAmount: number;
44
44
  type: UserType;
45
45
  product: string;
@@ -67,3 +67,23 @@ export interface CryptoCurrency {
67
67
  }[];
68
68
  imageUrl: string;
69
69
  }
70
+ export interface PaymentIntentCrypto {
71
+ id: string;
72
+ type: 'crypto';
73
+ token: string;
74
+ payload: {
75
+ paymentRequestUri: string;
76
+ payAmount: number;
77
+ payCurrency: string;
78
+ paymentAddress: string;
79
+ url: string;
80
+ qrUrl: string;
81
+ };
82
+ }
83
+ export interface PaymentIntentFiat {
84
+ id: string;
85
+ type: 'fiat';
86
+ clientSecret: string | null;
87
+ invoiceStatus?: string;
88
+ }
89
+ export type PaymentIntent = PaymentIntentCrypto | PaymentIntentFiat;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@internxt/sdk",
3
3
  "author": "Internxt <hello@internxt.com>",
4
- "version": "1.10.11",
4
+ "version": "1.10.13",
5
5
  "description": "An sdk for interacting with Internxt's services",
6
6
  "repository": {
7
7
  "type": "git",