@whop/sdk 0.0.9 → 0.0.10

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/client.d.mts +11 -5
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +11 -5
  5. package/client.d.ts.map +1 -1
  6. package/client.js +6 -0
  7. package/client.js.map +1 -1
  8. package/client.mjs +6 -0
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/app-builds.d.mts +4 -0
  12. package/resources/app-builds.d.mts.map +1 -1
  13. package/resources/app-builds.d.ts +4 -0
  14. package/resources/app-builds.d.ts.map +1 -1
  15. package/resources/index.d.mts +4 -2
  16. package/resources/index.d.mts.map +1 -1
  17. package/resources/index.d.ts +4 -2
  18. package/resources/index.d.ts.map +1 -1
  19. package/resources/index.js +5 -1
  20. package/resources/index.js.map +1 -1
  21. package/resources/index.mjs +2 -0
  22. package/resources/index.mjs.map +1 -1
  23. package/resources/payment-tokens.d.mts +157 -0
  24. package/resources/payment-tokens.d.mts.map +1 -0
  25. package/resources/payment-tokens.d.ts +157 -0
  26. package/resources/payment-tokens.d.ts.map +1 -0
  27. package/resources/payment-tokens.js +34 -0
  28. package/resources/payment-tokens.js.map +1 -0
  29. package/resources/payment-tokens.mjs +30 -0
  30. package/resources/payment-tokens.mjs.map +1 -0
  31. package/resources/payments.d.mts +255 -1
  32. package/resources/payments.d.mts.map +1 -1
  33. package/resources/payments.d.ts +255 -1
  34. package/resources/payments.d.ts.map +1 -1
  35. package/resources/payments.js +31 -0
  36. package/resources/payments.js.map +1 -1
  37. package/resources/payments.mjs +31 -0
  38. package/resources/payments.mjs.map +1 -1
  39. package/resources/setup-intents.d.mts +359 -0
  40. package/resources/setup-intents.d.mts.map +1 -0
  41. package/resources/setup-intents.d.ts +359 -0
  42. package/resources/setup-intents.d.ts.map +1 -0
  43. package/resources/setup-intents.js +38 -0
  44. package/resources/setup-intents.js.map +1 -0
  45. package/resources/setup-intents.mjs +34 -0
  46. package/resources/setup-intents.mjs.map +1 -0
  47. package/resources/shared.d.mts +50 -0
  48. package/resources/shared.d.mts.map +1 -1
  49. package/resources/shared.d.ts +50 -0
  50. package/resources/shared.d.ts.map +1 -1
  51. package/resources/webhooks.d.mts +72 -2
  52. package/resources/webhooks.d.mts.map +1 -1
  53. package/resources/webhooks.d.ts +72 -2
  54. package/resources/webhooks.d.ts.map +1 -1
  55. package/resources/webhooks.js.map +1 -1
  56. package/resources/webhooks.mjs.map +1 -1
  57. package/src/client.ts +47 -1
  58. package/src/resources/app-builds.ts +5 -0
  59. package/src/resources/index.ts +20 -0
  60. package/src/resources/payment-tokens.ts +207 -0
  61. package/src/resources/payments.ts +306 -0
  62. package/src/resources/setup-intents.ts +435 -0
  63. package/src/resources/shared.ts +59 -0
  64. package/src/resources/webhooks.ts +91 -0
  65. package/src/version.ts +1 -1
  66. package/version.d.mts +1 -1
  67. package/version.d.mts.map +1 -1
  68. package/version.d.ts +1 -1
  69. package/version.d.ts.map +1 -1
  70. package/version.js +1 -1
  71. package/version.js.map +1 -1
  72. package/version.mjs +1 -1
  73. package/version.mjs.map +1 -1
@@ -179,12 +179,21 @@ export {
179
179
  type NotificationCreateResponse,
180
180
  type NotificationCreateParams,
181
181
  } from './notifications';
182
+ export {
183
+ PaymentTokens,
184
+ type PaymentTokenRetrieveResponse,
185
+ type PaymentTokenListResponse,
186
+ type PaymentTokenRetrieveParams,
187
+ type PaymentTokenListParams,
188
+ type PaymentTokenListResponsesCursorPage,
189
+ } from './payment-tokens';
182
190
  export {
183
191
  Payments,
184
192
  type BillingReasons,
185
193
  type CardBrands,
186
194
  type PaymentMethodTypes,
187
195
  type PaymentListResponse,
196
+ type PaymentCreateParams,
188
197
  type PaymentListParams,
189
198
  type PaymentRefundParams,
190
199
  type PaymentListResponsesCursorPage,
@@ -242,6 +251,14 @@ export {
242
251
  type ReviewListParams,
243
252
  type ReviewListResponsesCursorPage,
244
253
  } from './reviews';
254
+ export {
255
+ SetupIntents,
256
+ type SetupIntent,
257
+ type SetupIntentStatus,
258
+ type SetupIntentListResponse,
259
+ type SetupIntentListParams,
260
+ type SetupIntentListResponsesCursorPage,
261
+ } from './setup-intents';
245
262
  export {
246
263
  Shipments,
247
264
  type ShipmentListResponse,
@@ -281,6 +298,9 @@ export {
281
298
  type EntryApprovedWebhookEvent,
282
299
  type EntryDeniedWebhookEvent,
283
300
  type EntryDeletedWebhookEvent,
301
+ type SetupIntentRequiresActionWebhookEvent,
302
+ type SetupIntentSucceededWebhookEvent,
303
+ type SetupIntentCanceledWebhookEvent,
284
304
  type CourseLessonInteractionCompletedWebhookEvent,
285
305
  type PaymentSucceededWebhookEvent,
286
306
  type PaymentFailedWebhookEvent,
@@ -0,0 +1,207 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import * as PaymentsAPI from './payments';
5
+ import * as Shared from './shared';
6
+ import { APIPromise } from '../core/api-promise';
7
+ import { CursorPage, type CursorPageParams, PagePromise } from '../core/pagination';
8
+ import { RequestOptions } from '../internal/request-options';
9
+ import { path } from '../internal/utils/path';
10
+
11
+ export class PaymentTokens extends APIResource {
12
+ /**
13
+ * Retrieves a PaymentToken by ID
14
+ *
15
+ * Required permissions:
16
+ *
17
+ * - `member:payment_methods:read`
18
+ */
19
+ retrieve(
20
+ id: string,
21
+ query: PaymentTokenRetrieveParams,
22
+ options?: RequestOptions,
23
+ ): APIPromise<PaymentTokenRetrieveResponse> {
24
+ return this._client.get(path`/payment_tokens/${id}`, { query, ...options });
25
+ }
26
+
27
+ /**
28
+ * Lists PaymentTokens
29
+ *
30
+ * Required permissions:
31
+ *
32
+ * - `member:payment_methods:read`
33
+ */
34
+ list(
35
+ query: PaymentTokenListParams,
36
+ options?: RequestOptions,
37
+ ): PagePromise<PaymentTokenListResponsesCursorPage, PaymentTokenListResponse> {
38
+ return this._client.getAPIList('/payment_tokens', CursorPage<PaymentTokenListResponse>, {
39
+ query,
40
+ ...options,
41
+ });
42
+ }
43
+ }
44
+
45
+ export type PaymentTokenListResponsesCursorPage = CursorPage<PaymentTokenListResponse>;
46
+
47
+ /**
48
+ * A payment token used to process payments.
49
+ */
50
+ export interface PaymentTokenRetrieveResponse {
51
+ /**
52
+ * The ID of the payment token
53
+ */
54
+ id: string;
55
+
56
+ /**
57
+ * The card data associated with the payment token, if its a debit or credit card
58
+ * token.
59
+ */
60
+ card: PaymentTokenRetrieveResponse.Card | null;
61
+
62
+ /**
63
+ * The date and time the payment token was created
64
+ */
65
+ created_at: string;
66
+
67
+ /**
68
+ * The payment method type of the payment token
69
+ */
70
+ payment_method_type: PaymentsAPI.PaymentMethodTypes;
71
+ }
72
+
73
+ export namespace PaymentTokenRetrieveResponse {
74
+ /**
75
+ * The card data associated with the payment token, if its a debit or credit card
76
+ * token.
77
+ */
78
+ export interface Card {
79
+ /**
80
+ * Possible card brands that a payment token can have
81
+ */
82
+ brand: PaymentsAPI.CardBrands | null;
83
+
84
+ /**
85
+ * Card expiration month, like 03 for March.
86
+ */
87
+ exp_month: number | null;
88
+
89
+ /**
90
+ * Card expiration year, like 27 for 2027.
91
+ */
92
+ exp_year: number | null;
93
+
94
+ /**
95
+ * Last four digits of the card.
96
+ */
97
+ last4: string | null;
98
+ }
99
+ }
100
+
101
+ /**
102
+ * A payment token used to process payments.
103
+ */
104
+ export interface PaymentTokenListResponse {
105
+ /**
106
+ * The ID of the payment token
107
+ */
108
+ id: string;
109
+
110
+ /**
111
+ * The card data associated with the payment token, if its a debit or credit card
112
+ * token.
113
+ */
114
+ card: PaymentTokenListResponse.Card | null;
115
+
116
+ /**
117
+ * The date and time the payment token was created
118
+ */
119
+ created_at: string;
120
+
121
+ /**
122
+ * The payment method type of the payment token
123
+ */
124
+ payment_method_type: PaymentsAPI.PaymentMethodTypes;
125
+ }
126
+
127
+ export namespace PaymentTokenListResponse {
128
+ /**
129
+ * The card data associated with the payment token, if its a debit or credit card
130
+ * token.
131
+ */
132
+ export interface Card {
133
+ /**
134
+ * Possible card brands that a payment token can have
135
+ */
136
+ brand: PaymentsAPI.CardBrands | null;
137
+
138
+ /**
139
+ * Card expiration month, like 03 for March.
140
+ */
141
+ exp_month: number | null;
142
+
143
+ /**
144
+ * Card expiration year, like 27 for 2027.
145
+ */
146
+ exp_year: number | null;
147
+
148
+ /**
149
+ * Last four digits of the card.
150
+ */
151
+ last4: string | null;
152
+ }
153
+ }
154
+
155
+ export interface PaymentTokenRetrieveParams {
156
+ /**
157
+ * The ID of the Member associated with the PaymentToken
158
+ */
159
+ member_id: string;
160
+ }
161
+
162
+ export interface PaymentTokenListParams extends CursorPageParams {
163
+ /**
164
+ * The ID of the Member to list payment tokens for
165
+ */
166
+ member_id: string;
167
+
168
+ /**
169
+ * Returns the elements in the list that come before the specified cursor.
170
+ */
171
+ before?: string | null;
172
+
173
+ /**
174
+ * The minimum creation date to filter by
175
+ */
176
+ created_after?: string | null;
177
+
178
+ /**
179
+ * The maximum creation date to filter by
180
+ */
181
+ created_before?: string | null;
182
+
183
+ /**
184
+ * The direction of the sort.
185
+ */
186
+ direction?: Shared.Direction | null;
187
+
188
+ /**
189
+ * Returns the first _n_ elements from the list.
190
+ */
191
+ first?: number | null;
192
+
193
+ /**
194
+ * Returns the last _n_ elements from the list.
195
+ */
196
+ last?: number | null;
197
+ }
198
+
199
+ export declare namespace PaymentTokens {
200
+ export {
201
+ type PaymentTokenRetrieveResponse as PaymentTokenRetrieveResponse,
202
+ type PaymentTokenListResponse as PaymentTokenListResponse,
203
+ type PaymentTokenListResponsesCursorPage as PaymentTokenListResponsesCursorPage,
204
+ type PaymentTokenRetrieveParams as PaymentTokenRetrieveParams,
205
+ type PaymentTokenListParams as PaymentTokenListParams,
206
+ };
207
+ }
@@ -1,6 +1,7 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import { APIResource } from '../core/resource';
4
+ import * as PaymentsAPI from './payments';
4
5
  import * as Shared from './shared';
5
6
  import { APIPromise } from '../core/api-promise';
6
7
  import { CursorPage, type CursorPageParams, PagePromise } from '../core/pagination';
@@ -8,6 +9,38 @@ import { RequestOptions } from '../internal/request-options';
8
9
  import { path } from '../internal/utils/path';
9
10
 
10
11
  export class Payments extends APIResource {
12
+ /**
13
+ * Creates a payment. This endpoint will respond with a payment object immediately,
14
+ * but the payment is processed asynchronously in the background. Use webhooks to
15
+ * be notified when the payment succeeds or fails.
16
+ *
17
+ * Required permissions:
18
+ *
19
+ * - `payment:charge`
20
+ * - `plan:create`
21
+ * - `access_pass:create`
22
+ * - `access_pass:update`
23
+ * - `plan:basic:read`
24
+ * - `access_pass:basic:read`
25
+ * - `member:email:read`
26
+ * - `member:basic:read`
27
+ * - `member:phone:read`
28
+ * - `promo_code:basic:read`
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * const payment = await client.payments.create({
33
+ * company_id: 'biz_xxxxxxxxxxxxxx',
34
+ * member_id: 'mber_xxxxxxxxxxxxx',
35
+ * payment_token_id: 'payt_xxxxxxxxxxxxx',
36
+ * plan: { currency: 'usd' },
37
+ * });
38
+ * ```
39
+ */
40
+ create(body: PaymentCreateParams, options?: RequestOptions): APIPromise<Shared.Payment> {
41
+ return this._client.post('/payments', { body, ...options });
42
+ }
43
+
11
44
  /**
12
45
  * Retrieves a payment by ID
13
46
  *
@@ -360,6 +393,11 @@ export interface PaymentListResponse {
360
393
  */
361
394
  payment_method_type: PaymentMethodTypes | null;
362
395
 
396
+ /**
397
+ * The payment token used for the payment, if available.
398
+ */
399
+ payment_token: PaymentListResponse.PaymentToken | null;
400
+
363
401
  /**
364
402
  * The plan attached to this payment.
365
403
  */
@@ -526,6 +564,60 @@ export namespace PaymentListResponse {
526
564
  status: Shared.MembershipStatus;
527
565
  }
528
566
 
567
+ /**
568
+ * The payment token used for the payment, if available.
569
+ */
570
+ export interface PaymentToken {
571
+ /**
572
+ * The ID of the payment token
573
+ */
574
+ id: string;
575
+
576
+ /**
577
+ * The card data associated with the payment token, if its a debit or credit card
578
+ * token.
579
+ */
580
+ card: PaymentToken.Card | null;
581
+
582
+ /**
583
+ * The date and time the payment token was created
584
+ */
585
+ created_at: string;
586
+
587
+ /**
588
+ * The payment method type of the payment token
589
+ */
590
+ payment_method_type: PaymentsAPI.PaymentMethodTypes;
591
+ }
592
+
593
+ export namespace PaymentToken {
594
+ /**
595
+ * The card data associated with the payment token, if its a debit or credit card
596
+ * token.
597
+ */
598
+ export interface Card {
599
+ /**
600
+ * Possible card brands that a payment token can have
601
+ */
602
+ brand: PaymentsAPI.CardBrands | null;
603
+
604
+ /**
605
+ * Card expiration month, like 03 for March.
606
+ */
607
+ exp_month: number | null;
608
+
609
+ /**
610
+ * Card expiration year, like 27 for 2027.
611
+ */
612
+ exp_year: number | null;
613
+
614
+ /**
615
+ * Last four digits of the card.
616
+ */
617
+ last4: string | null;
618
+ }
619
+ }
620
+
529
621
  /**
530
622
  * The plan attached to this payment.
531
623
  */
@@ -617,6 +709,219 @@ export namespace PaymentListResponse {
617
709
  }
618
710
  }
619
711
 
712
+ export type PaymentCreateParams =
713
+ | PaymentCreateParams.CreatePaymentInputWithPlan
714
+ | PaymentCreateParams.CreatePaymentInputWithPlanID;
715
+
716
+ export declare namespace PaymentCreateParams {
717
+ export interface CreatePaymentInputWithPlan {
718
+ /**
719
+ * The ID of the company to create the payment for.
720
+ */
721
+ company_id: string;
722
+
723
+ /**
724
+ * The ID of the member to create the payment for.
725
+ */
726
+ member_id: string;
727
+
728
+ /**
729
+ * The ID of the payment token to use for the payment. It must be connected to the
730
+ * Member being charged.
731
+ */
732
+ payment_token_id: string;
733
+
734
+ /**
735
+ * Pass this object to create a new plan for this payment
736
+ */
737
+ plan: CreatePaymentInputWithPlan.Plan;
738
+ }
739
+
740
+ export namespace CreatePaymentInputWithPlan {
741
+ /**
742
+ * Pass this object to create a new plan for this payment
743
+ */
744
+ export interface Plan {
745
+ /**
746
+ * The respective currency identifier for the plan.
747
+ */
748
+ currency: Shared.Currency;
749
+
750
+ /**
751
+ * The interval at which the plan charges (renewal plans).
752
+ */
753
+ billing_period?: number | null;
754
+
755
+ /**
756
+ * The description of the plan.
757
+ */
758
+ description?: string | null;
759
+
760
+ /**
761
+ * The interval at which the plan charges (expiration plans).
762
+ */
763
+ expiration_days?: number | null;
764
+
765
+ /**
766
+ * Whether to force the creation of a new plan even if one with the same attributes
767
+ * already exists.
768
+ */
769
+ force_create_new_plan?: boolean | null;
770
+
771
+ /**
772
+ * An additional amount charged upon first purchase.
773
+ */
774
+ initial_price?: number | null;
775
+
776
+ /**
777
+ * A personal description or notes section for the business.
778
+ */
779
+ internal_notes?: string | null;
780
+
781
+ /**
782
+ * The type of plan that can be attached to a product
783
+ */
784
+ plan_type?: Shared.PlanType | null;
785
+
786
+ /**
787
+ * Pass this object to create a new product for this plan. We will use the product
788
+ * external identifier to find or create an existing product.
789
+ */
790
+ product?: Plan.Product | null;
791
+
792
+ /**
793
+ * The product the plan is related to. Either this or product is required.
794
+ */
795
+ product_id?: string | null;
796
+
797
+ /**
798
+ * The amount the customer is charged every billing period.
799
+ */
800
+ renewal_price?: number | null;
801
+
802
+ /**
803
+ * The title of the plan. This will be visible on the product page to customers.
804
+ */
805
+ title?: string | null;
806
+
807
+ /**
808
+ * The number of free trial days added before a renewal plan.
809
+ */
810
+ trial_period_days?: number | null;
811
+
812
+ /**
813
+ * Visibility of a resource
814
+ */
815
+ visibility?: Shared.Visibility | null;
816
+ }
817
+
818
+ export namespace Plan {
819
+ /**
820
+ * Pass this object to create a new product for this plan. We will use the product
821
+ * external identifier to find or create an existing product.
822
+ */
823
+ export interface Product {
824
+ /**
825
+ * A unique ID used to find or create a product. When provided during creation, we
826
+ * will look for an existing product with this external identifier — if found, it
827
+ * will be updated; otherwise, a new product will be created.
828
+ */
829
+ external_identifier: string;
830
+
831
+ /**
832
+ * The title of the product.
833
+ */
834
+ title: string;
835
+
836
+ /**
837
+ * The different business types a company can be.
838
+ */
839
+ business_type?: Shared.BusinessTypes | null;
840
+
841
+ /**
842
+ * Whether or not to collect shipping information at checkout from the customer.
843
+ */
844
+ collect_shipping_address?: boolean | null;
845
+
846
+ /**
847
+ * The custom statement descriptor for the product i.e. WHOP\*SPORTS, must be
848
+ * between 5 and 22 characters, contain at least one letter, and not contain any of
849
+ * the following characters: <, >, \, ', "
850
+ */
851
+ custom_statement_descriptor?: string | null;
852
+
853
+ /**
854
+ * A written description of the product.
855
+ */
856
+ description?: string | null;
857
+
858
+ /**
859
+ * The percentage of the revenue that goes to the global affiliate program.
860
+ */
861
+ global_affiliate_percentage?: number | null;
862
+
863
+ /**
864
+ * The different statuses of the global affiliate program for a product.
865
+ */
866
+ global_affiliate_status?: Shared.GlobalAffiliateStatus | null;
867
+
868
+ /**
869
+ * The headline of the product.
870
+ */
871
+ headline?: string | null;
872
+
873
+ /**
874
+ * The different industry types a company can be in.
875
+ */
876
+ industry_type?: Shared.IndustryTypes | null;
877
+
878
+ /**
879
+ * The ID of the product tax code to apply to this product.
880
+ */
881
+ product_tax_code_id?: string | null;
882
+
883
+ /**
884
+ * The URL to redirect the customer to after a purchase.
885
+ */
886
+ redirect_purchase_url?: string | null;
887
+
888
+ /**
889
+ * The route of the product.
890
+ */
891
+ route?: string | null;
892
+
893
+ /**
894
+ * Visibility of a resource
895
+ */
896
+ visibility?: Shared.Visibility | null;
897
+ }
898
+ }
899
+ }
900
+
901
+ export interface CreatePaymentInputWithPlanID {
902
+ /**
903
+ * The ID of the company to create the payment for.
904
+ */
905
+ company_id: string;
906
+
907
+ /**
908
+ * The ID of the member to create the payment for.
909
+ */
910
+ member_id: string;
911
+
912
+ /**
913
+ * The ID of the payment token to use for the payment. It must be connected to the
914
+ * Member being charged.
915
+ */
916
+ payment_token_id: string;
917
+
918
+ /**
919
+ * An ID of an existing plan to use for the payment.
920
+ */
921
+ plan_id: string;
922
+ }
923
+ }
924
+
620
925
  export interface PaymentListParams extends CursorPageParams {
621
926
  /**
622
927
  * The ID of the company to list payments for
@@ -708,6 +1013,7 @@ export declare namespace Payments {
708
1013
  type PaymentMethodTypes as PaymentMethodTypes,
709
1014
  type PaymentListResponse as PaymentListResponse,
710
1015
  type PaymentListResponsesCursorPage as PaymentListResponsesCursorPage,
1016
+ type PaymentCreateParams as PaymentCreateParams,
711
1017
  type PaymentListParams as PaymentListParams,
712
1018
  type PaymentRefundParams as PaymentRefundParams,
713
1019
  };