@internxt/sdk 1.16.0 → 1.16.1

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,50 +1,23 @@
1
1
  import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
2
2
  import { Tier } from './types/tiers';
3
- import { AvailableProducts, CreateCheckoutSessionPayload, CreatedSubscriptionData, CreatePaymentSessionPayload, CustomerBillingInfo, DisplayPrice, FreeTrialAvailable, Invoice, InvoicePayload, PaymentMethod, ProductData, RedeemCodePayload, UpdateSubscriptionPaymentMethod, UserSubscription, UserType } from './types/types';
3
+ import { AvailableProducts, CouponCodeData, CustomerBillingInfo, DisplayPrice, Invoice, InvoicePayload, PaymentMethod, RedeemCodePayload, UpdateSubscriptionPaymentMethod, UserSubscription, UserType } from './types/types';
4
4
  export declare class Payments {
5
5
  private readonly client;
6
6
  private readonly appDetails;
7
7
  private readonly apiSecurity;
8
8
  static client(apiUrl: ApiUrl, appDetails: AppDetails, apiSecurity: ApiSecurity): Payments;
9
9
  private constructor();
10
- createCustomer(name: string, email: string, country?: string, companyVatId?: string): Promise<{
11
- customerId: string;
12
- token: string;
13
- }>;
14
- createSubscription(customerId: string, priceId: string, token: string, quantity: number, currency?: string, promoCodeId?: string): Promise<CreatedSubscriptionData>;
15
- createPaymentIntent(customerId: string, amount: number, planId: string, token: string, currency?: string, promoCodeName?: string): Promise<{
16
- clientSecret: string;
17
- id: string;
18
- invoiceStatus?: string;
19
- }>;
20
- /**
21
- * Fetches the existing products and its details
22
- */
23
- getProducts(): Promise<ProductData[]>;
24
- /**
25
- * Creates and returns a new session identifier for the client to go to payment platform
26
- * @param payload
27
- */
28
- createSession(payload: CreatePaymentSessionPayload): Promise<{
29
- id: string;
30
- }>;
31
10
  getSetupIntent(userType?: UserType): Promise<{
32
11
  clientSecret: string;
33
12
  }>;
34
13
  getDefaultPaymentMethod(userType?: UserType): Promise<PaymentMethod>;
35
14
  getInvoices({ subscriptionId, userType, startingAfter, limit, }: InvoicePayload): Promise<Invoice[]>;
36
- isCouponUsedByUser({ couponCode }: {
37
- couponCode: string;
38
- }): Promise<{
39
- couponUsed: boolean;
40
- }>;
41
15
  getPromoCodesUsedByUser(): Promise<{
42
16
  usedCoupons: string[];
43
17
  }>;
44
18
  getUserSubscription(userType?: UserType): Promise<UserSubscription>;
19
+ fetchPromotionCodeByName(priceId: string, promotionCodeName: string): Promise<CouponCodeData>;
45
20
  getPrices(currency?: string, userType?: UserType): Promise<DisplayPrice[]>;
46
- requestPreventCancellation(): Promise<FreeTrialAvailable>;
47
- preventCancellation(): Promise<void>;
48
21
  applyRedeemCode(payload: RedeemCodePayload): Promise<void>;
49
22
  updateSubscriptionPaymentMethod(payload: UpdateSubscriptionPaymentMethod): Promise<void | Error>;
50
23
  updateSubscriptionPrice({ priceId, couponCode, userType, }: {
@@ -58,9 +31,6 @@ export declare class Payments {
58
31
  }>;
59
32
  updateWorkspaceMembers(workspaceId: string, subscriptionId: string, updatedSeats: number): Promise<unknown>;
60
33
  cancelSubscription(userType?: UserType): Promise<void>;
61
- createCheckoutSession(payload: CreateCheckoutSessionPayload): Promise<{
62
- sessionId: string;
63
- }>;
64
34
  updateCustomerBillingInfo(payload: CustomerBillingInfo): Promise<void>;
65
35
  /**
66
36
  * Gets the available products from the user
@@ -16,51 +16,6 @@ class Payments {
16
16
  this.appDetails = appDetails;
17
17
  this.apiSecurity = apiSecurity;
18
18
  }
19
- createCustomer(name, email, country, companyVatId) {
20
- return this.client.post('/create-customer', { name, email, country, companyVatId }, this.headers());
21
- }
22
- createSubscription(customerId, priceId, token, quantity, currency, promoCodeId) {
23
- return this.client.post('/create-subscription', {
24
- customerId,
25
- priceId,
26
- token,
27
- quantity,
28
- currency,
29
- promoCodeId,
30
- }, this.headers());
31
- }
32
- createPaymentIntent(customerId, amount, planId, token, currency, promoCodeName) {
33
- const query = new URLSearchParams();
34
- query.set('customerId', customerId);
35
- query.set('amount', String(amount));
36
- query.set('planId', planId);
37
- query.set('token', token);
38
- if (currency !== undefined)
39
- query.set('currency', currency);
40
- if (promoCodeName !== undefined)
41
- query.set('promoCodeName', promoCodeName);
42
- return this.client.get(`/payment-intent?${query.toString()}`, this.headers());
43
- }
44
- /**
45
- * Fetches the existing products and its details
46
- */
47
- getProducts() {
48
- return this.client.get('/v3/stripe/products', this.headers());
49
- }
50
- /**
51
- * Creates and returns a new session identifier for the client to go to payment platform
52
- * @param payload
53
- */
54
- createSession(payload) {
55
- return this.client.post('/v2/stripe/session', {
56
- test: payload.test,
57
- lifetime_tier: payload.lifetime_tier,
58
- mode: payload.mode,
59
- priceId: payload.priceId,
60
- successUrl: payload.successUrl,
61
- canceledUrl: payload.canceledUrl,
62
- }, this.headers());
63
- }
64
19
  getSetupIntent(userType) {
65
20
  const query = new URLSearchParams();
66
21
  if (userType)
@@ -85,12 +40,6 @@ class Payments {
85
40
  query.set('limit', limit.toString());
86
41
  return this.client.get(`/invoices?${query.toString()}`, this.headers());
87
42
  }
88
- isCouponUsedByUser({ couponCode }) {
89
- const query = new URLSearchParams();
90
- if (couponCode !== undefined)
91
- query.set('code', couponCode);
92
- return this.client.get(`/coupon-in-use?${query.toString()}`, this.headers());
93
- }
94
43
  getPromoCodesUsedByUser() {
95
44
  return this.client.get('/customer/redeemed-promotion-codes', this.headers());
96
45
  }
@@ -106,6 +55,15 @@ class Payments {
106
55
  throw err;
107
56
  });
108
57
  }
58
+ async fetchPromotionCodeByName(priceId, promotionCodeName) {
59
+ const promotionCode = await this.client.get(`/promo-code-by-name?priceId=${priceId}&promotionCode=${promotionCodeName}`, this.headers());
60
+ return {
61
+ codeId: promotionCode.codeId,
62
+ codeName: promotionCodeName,
63
+ amountOff: promotionCode.amountOff,
64
+ percentOff: promotionCode.percentOff,
65
+ };
66
+ }
109
67
  async getPrices(currency, userType) {
110
68
  const query = new URLSearchParams();
111
69
  if (currency !== undefined)
@@ -114,12 +72,6 @@ class Payments {
114
72
  query.set('userType', userType);
115
73
  return this.client.get(`/prices?${query.toString()}`, this.headers());
116
74
  }
117
- requestPreventCancellation() {
118
- return this.client.get('/request-prevent-cancellation', this.headers());
119
- }
120
- preventCancellation() {
121
- return this.client.put('/prevent-cancellation', {}, this.headers());
122
- }
123
75
  applyRedeemCode(payload) {
124
76
  return this.client.post('/licenses', { code: payload.code, provider: payload.provider }, this.headers());
125
77
  }
@@ -142,9 +94,6 @@ class Payments {
142
94
  query.set('userType', userType);
143
95
  return this.client.delete(`/subscriptions?${query.toString()}`, this.headers());
144
96
  }
145
- createCheckoutSession(payload) {
146
- return this.client.post('/checkout-session', { ...payload }, this.headers());
147
- }
148
97
  updateCustomerBillingInfo(payload) {
149
98
  return this.client.patch('/billing', { ...payload }, this.headers());
150
99
  }
@@ -200,3 +200,9 @@ export type AvailableProducts = {
200
200
  backups: boolean;
201
201
  };
202
202
  };
203
+ export interface CouponCodeData {
204
+ codeId: string;
205
+ codeName: string;
206
+ amountOff?: number;
207
+ percentOff?: number;
208
+ }
@@ -39,7 +39,7 @@ export declare class Checkout {
39
39
  * - `subscriptionId`: The ID of the subscription (optional)
40
40
  * - `paymentIntentId`: The ID of the payment intent (optional)
41
41
  */
42
- createSubscription({ customerId, priceId, token, currency, captchaToken, promoCodeId, quantity, }: CreateSubscriptionPayload): Promise<CreatedSubscriptionData>;
42
+ createSubscription({ customerId, priceId, token, currency, captchaToken, promoCodeId, }: CreateSubscriptionPayload): Promise<CreatedSubscriptionData>;
43
43
  /**
44
44
  * @description Creates a payment intent for a given customer
45
45
  * @param customerId - The ID of the customer
@@ -56,7 +56,7 @@ class Checkout {
56
56
  * - `subscriptionId`: The ID of the subscription (optional)
57
57
  * - `paymentIntentId`: The ID of the payment intent (optional)
58
58
  */
59
- createSubscription({ customerId, priceId, token, currency, captchaToken, promoCodeId, quantity, }) {
59
+ createSubscription({ customerId, priceId, token, currency, captchaToken, promoCodeId, }) {
60
60
  return this.client.post('/checkout/subscription', {
61
61
  customerId,
62
62
  priceId,
@@ -64,7 +64,6 @@ class Checkout {
64
64
  currency,
65
65
  captchaToken,
66
66
  promoCodeId,
67
- quantity,
68
67
  }, this.authHeaders());
69
68
  }
70
69
  /**
@@ -17,7 +17,6 @@ export interface CreateSubscriptionPayload {
17
17
  captchaToken: string;
18
18
  currency?: string;
19
19
  promoCodeId?: string;
20
- quantity?: number;
21
20
  }
22
21
  export interface CreatePaymentIntentPayload {
23
22
  customerId: string;
@@ -57,8 +56,6 @@ export type Price = {
57
56
  decimalAmount: number;
58
57
  type: UserType;
59
58
  product: string;
60
- minimumSeats?: number;
61
- maximumSeats?: number;
62
59
  };
63
60
  export type Taxes = {
64
61
  tax: number;
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.16.0",
4
+ "version": "1.16.1",
5
5
  "description": "An sdk for interacting with Internxt's services",
6
6
  "repository": {
7
7
  "type": "git",