@paygentic/sdk 0.7.2 → 0.7.4

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 (121) hide show
  1. package/README.md +7 -3
  2. package/dist/commonjs/funcs/customersCreateCustomerPaymentMethod.d.ts +19 -0
  3. package/dist/commonjs/funcs/customersCreateCustomerPaymentMethod.d.ts.map +1 -0
  4. package/dist/commonjs/funcs/customersCreateCustomerPaymentMethod.js +125 -0
  5. package/dist/commonjs/funcs/customersCreateCustomerPaymentMethod.js.map +1 -0
  6. package/dist/commonjs/funcs/customersListCustomerPaymentMethods.d.ts +18 -0
  7. package/dist/commonjs/funcs/customersListCustomerPaymentMethods.d.ts.map +1 -0
  8. package/dist/commonjs/funcs/customersListCustomerPaymentMethods.js +123 -0
  9. package/dist/commonjs/funcs/customersListCustomerPaymentMethods.js.map +1 -0
  10. package/dist/commonjs/lib/config.d.ts +2 -2
  11. package/dist/commonjs/lib/config.js +2 -2
  12. package/dist/commonjs/models/index.d.ts +2 -0
  13. package/dist/commonjs/models/index.d.ts.map +1 -1
  14. package/dist/commonjs/models/index.js +2 -0
  15. package/dist/commonjs/models/index.js.map +1 -1
  16. package/dist/commonjs/models/operations/createcustomerpaymentmethod.d.ts +44 -0
  17. package/dist/commonjs/models/operations/createcustomerpaymentmethod.d.ts.map +1 -0
  18. package/dist/commonjs/models/operations/createcustomerpaymentmethod.js +65 -0
  19. package/dist/commonjs/models/operations/createcustomerpaymentmethod.js.map +1 -0
  20. package/dist/commonjs/models/operations/index.d.ts +2 -0
  21. package/dist/commonjs/models/operations/index.d.ts.map +1 -1
  22. package/dist/commonjs/models/operations/index.js +2 -0
  23. package/dist/commonjs/models/operations/index.js.map +1 -1
  24. package/dist/commonjs/models/operations/listcustomerpaymentmethods.d.ts +35 -0
  25. package/dist/commonjs/models/operations/listcustomerpaymentmethods.d.ts.map +1 -0
  26. package/dist/commonjs/models/operations/listcustomerpaymentmethods.js +65 -0
  27. package/dist/commonjs/models/operations/listcustomerpaymentmethods.js.map +1 -0
  28. package/dist/commonjs/models/operations/listinvoices.d.ts +1 -1
  29. package/dist/commonjs/models/operations/listinvoices.d.ts.map +1 -1
  30. package/dist/commonjs/models/operations/listinvoices.js +1 -1
  31. package/dist/commonjs/models/operations/listinvoices.js.map +1 -1
  32. package/dist/commonjs/models/operations/listpaymentsessions.d.ts +1 -1
  33. package/dist/commonjs/models/operations/listpaymentsessions.d.ts.map +1 -1
  34. package/dist/commonjs/models/operations/listpaymentsessions.js +1 -1
  35. package/dist/commonjs/models/operations/listpaymentsessions.js.map +1 -1
  36. package/dist/commonjs/models/paymentmethod.d.ts +30 -0
  37. package/dist/commonjs/models/paymentmethod.d.ts.map +1 -0
  38. package/dist/commonjs/models/paymentmethod.js +62 -0
  39. package/dist/commonjs/models/paymentmethod.js.map +1 -0
  40. package/dist/commonjs/models/paymentsession.d.ts +18 -33
  41. package/dist/commonjs/models/paymentsession.d.ts.map +1 -1
  42. package/dist/commonjs/models/paymentsession.js +14 -11
  43. package/dist/commonjs/models/paymentsession.js.map +1 -1
  44. package/dist/commonjs/models/purchasegrantresponse.js +1 -1
  45. package/dist/commonjs/models/purchasegrantresponse.js.map +1 -1
  46. package/dist/commonjs/models/schemaspaymentsession.d.ts +68 -0
  47. package/dist/commonjs/models/schemaspaymentsession.d.ts.map +1 -0
  48. package/dist/commonjs/models/schemaspaymentsession.js +78 -0
  49. package/dist/commonjs/models/schemaspaymentsession.js.map +1 -0
  50. package/dist/commonjs/sdk/customers.d.ts +14 -0
  51. package/dist/commonjs/sdk/customers.d.ts.map +1 -1
  52. package/dist/commonjs/sdk/customers.js +20 -0
  53. package/dist/commonjs/sdk/customers.js.map +1 -1
  54. package/dist/esm/funcs/customersCreateCustomerPaymentMethod.d.ts +19 -0
  55. package/dist/esm/funcs/customersCreateCustomerPaymentMethod.d.ts.map +1 -0
  56. package/dist/esm/funcs/customersCreateCustomerPaymentMethod.js +89 -0
  57. package/dist/esm/funcs/customersCreateCustomerPaymentMethod.js.map +1 -0
  58. package/dist/esm/funcs/customersListCustomerPaymentMethods.d.ts +18 -0
  59. package/dist/esm/funcs/customersListCustomerPaymentMethods.d.ts.map +1 -0
  60. package/dist/esm/funcs/customersListCustomerPaymentMethods.js +87 -0
  61. package/dist/esm/funcs/customersListCustomerPaymentMethods.js.map +1 -0
  62. package/dist/esm/lib/config.d.ts +2 -2
  63. package/dist/esm/lib/config.js +2 -2
  64. package/dist/esm/models/index.d.ts +2 -0
  65. package/dist/esm/models/index.d.ts.map +1 -1
  66. package/dist/esm/models/index.js +2 -0
  67. package/dist/esm/models/index.js.map +1 -1
  68. package/dist/esm/models/operations/createcustomerpaymentmethod.d.ts +44 -0
  69. package/dist/esm/models/operations/createcustomerpaymentmethod.d.ts.map +1 -0
  70. package/dist/esm/models/operations/createcustomerpaymentmethod.js +27 -0
  71. package/dist/esm/models/operations/createcustomerpaymentmethod.js.map +1 -0
  72. package/dist/esm/models/operations/index.d.ts +2 -0
  73. package/dist/esm/models/operations/index.d.ts.map +1 -1
  74. package/dist/esm/models/operations/index.js +2 -0
  75. package/dist/esm/models/operations/index.js.map +1 -1
  76. package/dist/esm/models/operations/listcustomerpaymentmethods.d.ts +35 -0
  77. package/dist/esm/models/operations/listcustomerpaymentmethods.d.ts.map +1 -0
  78. package/dist/esm/models/operations/listcustomerpaymentmethods.js +27 -0
  79. package/dist/esm/models/operations/listcustomerpaymentmethods.js.map +1 -0
  80. package/dist/esm/models/operations/listinvoices.d.ts +1 -1
  81. package/dist/esm/models/operations/listinvoices.d.ts.map +1 -1
  82. package/dist/esm/models/operations/listinvoices.js +1 -1
  83. package/dist/esm/models/operations/listinvoices.js.map +1 -1
  84. package/dist/esm/models/operations/listpaymentsessions.d.ts +1 -1
  85. package/dist/esm/models/operations/listpaymentsessions.d.ts.map +1 -1
  86. package/dist/esm/models/operations/listpaymentsessions.js +1 -1
  87. package/dist/esm/models/operations/listpaymentsessions.js.map +1 -1
  88. package/dist/esm/models/paymentmethod.d.ts +30 -0
  89. package/dist/esm/models/paymentmethod.d.ts.map +1 -0
  90. package/dist/esm/models/paymentmethod.js +25 -0
  91. package/dist/esm/models/paymentmethod.js.map +1 -0
  92. package/dist/esm/models/paymentsession.d.ts +18 -33
  93. package/dist/esm/models/paymentsession.d.ts.map +1 -1
  94. package/dist/esm/models/paymentsession.js +13 -10
  95. package/dist/esm/models/paymentsession.js.map +1 -1
  96. package/dist/esm/models/purchasegrantresponse.js +1 -1
  97. package/dist/esm/models/purchasegrantresponse.js.map +1 -1
  98. package/dist/esm/models/schemaspaymentsession.d.ts +68 -0
  99. package/dist/esm/models/schemaspaymentsession.d.ts.map +1 -0
  100. package/dist/esm/models/schemaspaymentsession.js +41 -0
  101. package/dist/esm/models/schemaspaymentsession.js.map +1 -0
  102. package/dist/esm/sdk/customers.d.ts +14 -0
  103. package/dist/esm/sdk/customers.d.ts.map +1 -1
  104. package/dist/esm/sdk/customers.js +20 -0
  105. package/dist/esm/sdk/customers.js.map +1 -1
  106. package/jsr.json +1 -1
  107. package/package.json +1 -1
  108. package/src/funcs/customersCreateCustomerPaymentMethod.ts +182 -0
  109. package/src/funcs/customersListCustomerPaymentMethods.ts +176 -0
  110. package/src/lib/config.ts +2 -2
  111. package/src/models/index.ts +2 -0
  112. package/src/models/operations/createcustomerpaymentmethod.ts +90 -0
  113. package/src/models/operations/index.ts +2 -0
  114. package/src/models/operations/listcustomerpaymentmethods.ts +82 -0
  115. package/src/models/operations/listinvoices.ts +2 -2
  116. package/src/models/operations/listpaymentsessions.ts +2 -2
  117. package/src/models/paymentmethod.ts +62 -0
  118. package/src/models/paymentsession.ts +26 -39
  119. package/src/models/purchasegrantresponse.ts +1 -1
  120. package/src/models/schemaspaymentsession.ts +113 -0
  121. package/src/sdk/customers.ts +36 -0
@@ -9,13 +9,16 @@ import { Result as SafeParseResult } from "../types/fp.js";
9
9
  import { SDKValidationError } from "./errors/sdkvalidationerror.js";
10
10
 
11
11
  export const PaymentSessionObject = {
12
- PaymentSession: "payment_session",
12
+ PaymentSession: "paymentSession",
13
13
  } as const;
14
14
  export type PaymentSessionObject = ClosedEnum<typeof PaymentSessionObject>;
15
15
 
16
- /**
17
- * Lifecycle status of the session.
18
- */
16
+ export const Mode = {
17
+ Payment: "payment",
18
+ Setup: "setup",
19
+ } as const;
20
+ export type Mode = ClosedEnum<typeof Mode>;
21
+
19
22
  export const PaymentSessionStatus = {
20
23
  Pending: "pending",
21
24
  Processing: "processing",
@@ -24,47 +27,26 @@ export const PaymentSessionStatus = {
24
27
  Expired: "expired",
25
28
  Cancelled: "cancelled",
26
29
  } as const;
27
- /**
28
- * Lifecycle status of the session.
29
- */
30
30
  export type PaymentSessionStatus = ClosedEnum<typeof PaymentSessionStatus>;
31
31
 
32
32
  export type PaymentSession = {
33
33
  object: PaymentSessionObject;
34
34
  /**
35
- * Payment session ID (ps_*).
35
+ * Payment session identifier (e.g. `ps_...`).
36
36
  */
37
37
  id: string;
38
- /**
39
- * Type of entity the session pays for (invoice, subscription, payment, topup).
40
- */
41
- entityType: string;
42
- /**
43
- * ID of the entity the session pays for.
44
- */
45
- entityId: string;
46
- /**
47
- * Amount in decimal dollars.
48
- */
49
- amount: string;
50
- /**
51
- * ISO 4217 currency code.
52
- */
53
- currency: string;
54
- /**
55
- * Lifecycle status of the session.
56
- */
38
+ mode: Mode;
57
39
  status: PaymentSessionStatus;
58
40
  /**
59
- * Stripe Connect account ID (acct_*) when the session is routed to a connected account.
60
- */
61
- merchantPaymentAccountId?: string | null | undefined;
62
- /**
63
- * Timestamp the session reached terminal completion. Null until the session completes.
41
+ * Hosted page URL. Redirect the customer here, or load it inside an iframe — when iframed, the page reports outcomes via `postMessage` (`payment_success` / `payment_error`) to the parent window.
64
42
  */
43
+ url: string;
44
+ successRedirectUrl?: string | null | undefined;
45
+ failureRedirectUrl?: string | null | undefined;
46
+ metadata?: { [k: string]: any } | undefined;
47
+ expiresAt: Date;
65
48
  completedAt?: Date | null | undefined;
66
49
  createdAt: Date;
67
- updatedAt: Date;
68
50
  };
69
51
 
70
52
  /** @internal */
@@ -72,6 +54,11 @@ export const PaymentSessionObject$inboundSchema: z.ZodNativeEnum<
72
54
  typeof PaymentSessionObject
73
55
  > = z.nativeEnum(PaymentSessionObject);
74
56
 
57
+ /** @internal */
58
+ export const Mode$inboundSchema: z.ZodNativeEnum<typeof Mode> = z.nativeEnum(
59
+ Mode,
60
+ );
61
+
75
62
  /** @internal */
76
63
  export const PaymentSessionStatus$inboundSchema: z.ZodNativeEnum<
77
64
  typeof PaymentSessionStatus
@@ -85,17 +72,17 @@ export const PaymentSession$inboundSchema: z.ZodType<
85
72
  > = z.object({
86
73
  object: PaymentSessionObject$inboundSchema,
87
74
  id: z.string(),
88
- entityType: z.string(),
89
- entityId: z.string(),
90
- amount: z.string(),
91
- currency: z.string(),
75
+ mode: Mode$inboundSchema,
92
76
  status: PaymentSessionStatus$inboundSchema,
93
- merchantPaymentAccountId: z.nullable(z.string()).optional(),
77
+ url: z.string(),
78
+ successRedirectUrl: z.nullable(z.string()).optional(),
79
+ failureRedirectUrl: z.nullable(z.string()).optional(),
80
+ metadata: z.record(z.any()).optional(),
81
+ expiresAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
94
82
  completedAt: z.nullable(
95
83
  z.string().datetime({ offset: true }).transform(v => new Date(v)),
96
84
  ).optional(),
97
85
  createdAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
98
- updatedAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
99
86
  });
100
87
 
101
88
  export function paymentSessionFromJSON(
@@ -96,7 +96,7 @@ export const PurchaseGrantResponse$inboundSchema: z.ZodType<
96
96
  object: PurchaseGrantResponseObject$inboundSchema.default("grant_purchase"),
97
97
  invoiceId: z.string(),
98
98
  entitlementId: z.string(),
99
- grantAmount: z.number().int(),
99
+ grantAmount: z.number(),
100
100
  price: z.string(),
101
101
  currency: z.string(),
102
102
  paymentSessions: z.array(
@@ -0,0 +1,113 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import { ClosedEnum } from "../types/enums.js";
8
+ import { Result as SafeParseResult } from "../types/fp.js";
9
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
10
+
11
+ export const SchemasPaymentSessionObject = {
12
+ PaymentSession: "payment_session",
13
+ } as const;
14
+ export type SchemasPaymentSessionObject = ClosedEnum<
15
+ typeof SchemasPaymentSessionObject
16
+ >;
17
+
18
+ /**
19
+ * Lifecycle status of the session.
20
+ */
21
+ export const SchemasPaymentSessionStatus = {
22
+ Pending: "pending",
23
+ Processing: "processing",
24
+ Completed: "completed",
25
+ Failed: "failed",
26
+ Expired: "expired",
27
+ Cancelled: "cancelled",
28
+ } as const;
29
+ /**
30
+ * Lifecycle status of the session.
31
+ */
32
+ export type SchemasPaymentSessionStatus = ClosedEnum<
33
+ typeof SchemasPaymentSessionStatus
34
+ >;
35
+
36
+ export type SchemasPaymentSession = {
37
+ object: SchemasPaymentSessionObject;
38
+ /**
39
+ * Payment session ID (ps_*).
40
+ */
41
+ id: string;
42
+ /**
43
+ * Type of entity the session pays for (invoice, subscription, payment, topup).
44
+ */
45
+ entityType: string;
46
+ /**
47
+ * ID of the entity the session pays for.
48
+ */
49
+ entityId: string;
50
+ /**
51
+ * Amount in decimal dollars.
52
+ */
53
+ amount: string;
54
+ /**
55
+ * ISO 4217 currency code.
56
+ */
57
+ currency: string;
58
+ /**
59
+ * Lifecycle status of the session.
60
+ */
61
+ status: SchemasPaymentSessionStatus;
62
+ /**
63
+ * Stripe Connect account ID (acct_*) when the session is routed to a connected account.
64
+ */
65
+ merchantPaymentAccountId?: string | null | undefined;
66
+ /**
67
+ * Timestamp the session reached terminal completion. Null until the session completes.
68
+ */
69
+ completedAt?: Date | null | undefined;
70
+ createdAt: Date;
71
+ updatedAt: Date;
72
+ };
73
+
74
+ /** @internal */
75
+ export const SchemasPaymentSessionObject$inboundSchema: z.ZodNativeEnum<
76
+ typeof SchemasPaymentSessionObject
77
+ > = z.nativeEnum(SchemasPaymentSessionObject);
78
+
79
+ /** @internal */
80
+ export const SchemasPaymentSessionStatus$inboundSchema: z.ZodNativeEnum<
81
+ typeof SchemasPaymentSessionStatus
82
+ > = z.nativeEnum(SchemasPaymentSessionStatus);
83
+
84
+ /** @internal */
85
+ export const SchemasPaymentSession$inboundSchema: z.ZodType<
86
+ SchemasPaymentSession,
87
+ z.ZodTypeDef,
88
+ unknown
89
+ > = z.object({
90
+ object: SchemasPaymentSessionObject$inboundSchema,
91
+ id: z.string(),
92
+ entityType: z.string(),
93
+ entityId: z.string(),
94
+ amount: z.string(),
95
+ currency: z.string(),
96
+ status: SchemasPaymentSessionStatus$inboundSchema,
97
+ merchantPaymentAccountId: z.nullable(z.string()).optional(),
98
+ completedAt: z.nullable(
99
+ z.string().datetime({ offset: true }).transform(v => new Date(v)),
100
+ ).optional(),
101
+ createdAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
102
+ updatedAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
103
+ });
104
+
105
+ export function schemasPaymentSessionFromJSON(
106
+ jsonString: string,
107
+ ): SafeParseResult<SchemasPaymentSession, SDKValidationError> {
108
+ return safeParse(
109
+ jsonString,
110
+ (x) => SchemasPaymentSession$inboundSchema.parse(JSON.parse(x)),
111
+ `Failed to parse 'SchemasPaymentSession' from JSON`,
112
+ );
113
+ }
@@ -3,9 +3,11 @@
3
3
  */
4
4
 
5
5
  import { customersCreate } from "../funcs/customersCreate.js";
6
+ import { customersCreateCustomerPaymentMethod } from "../funcs/customersCreateCustomerPaymentMethod.js";
6
7
  import { customersDelete } from "../funcs/customersDelete.js";
7
8
  import { customersGet } from "../funcs/customersGet.js";
8
9
  import { customersList } from "../funcs/customersList.js";
10
+ import { customersListCustomerPaymentMethods } from "../funcs/customersListCustomerPaymentMethods.js";
9
11
  import { customersUpdate } from "../funcs/customersUpdate.js";
10
12
  import { ClientSDK, RequestOptions } from "../lib/sdks.js";
11
13
  import * as models from "../models/index.js";
@@ -85,4 +87,38 @@ export class Customers extends ClientSDK {
85
87
  options,
86
88
  ));
87
89
  }
90
+
91
+ /**
92
+ * List payment methods
93
+ *
94
+ * @remarks
95
+ * List off-session payment methods saved for this customer.
96
+ */
97
+ async listCustomerPaymentMethods(
98
+ request: operations.ListCustomerPaymentMethodsRequest,
99
+ options?: RequestOptions,
100
+ ): Promise<operations.ListCustomerPaymentMethodsResponse> {
101
+ return unwrapAsync(customersListCustomerPaymentMethods(
102
+ this,
103
+ request,
104
+ options,
105
+ ));
106
+ }
107
+
108
+ /**
109
+ * Set up a payment method
110
+ *
111
+ * @remarks
112
+ * Create a payment session that captures a new off-session payment method for this customer without charging. The response contains a hosted-page URL — redirect the customer to it, or load it inside an iframe (when iframed, the page reports outcomes via `postMessage` to the parent window).
113
+ */
114
+ async createCustomerPaymentMethod(
115
+ request: operations.CreateCustomerPaymentMethodRequest,
116
+ options?: RequestOptions,
117
+ ): Promise<models.PaymentSession> {
118
+ return unwrapAsync(customersCreateCustomerPaymentMethod(
119
+ this,
120
+ request,
121
+ options,
122
+ ));
123
+ }
88
124
  }