@paygentic/sdk 0.7.2 → 0.7.3
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/README.md +7 -3
- package/dist/commonjs/funcs/customersCreateCustomerPaymentMethod.d.ts +19 -0
- package/dist/commonjs/funcs/customersCreateCustomerPaymentMethod.d.ts.map +1 -0
- package/dist/commonjs/funcs/customersCreateCustomerPaymentMethod.js +125 -0
- package/dist/commonjs/funcs/customersCreateCustomerPaymentMethod.js.map +1 -0
- package/dist/commonjs/funcs/customersListCustomerPaymentMethods.d.ts +18 -0
- package/dist/commonjs/funcs/customersListCustomerPaymentMethods.d.ts.map +1 -0
- package/dist/commonjs/funcs/customersListCustomerPaymentMethods.js +123 -0
- package/dist/commonjs/funcs/customersListCustomerPaymentMethods.js.map +1 -0
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/models/index.d.ts +2 -0
- package/dist/commonjs/models/index.d.ts.map +1 -1
- package/dist/commonjs/models/index.js +2 -0
- package/dist/commonjs/models/index.js.map +1 -1
- package/dist/commonjs/models/operations/createcustomerpaymentmethod.d.ts +44 -0
- package/dist/commonjs/models/operations/createcustomerpaymentmethod.d.ts.map +1 -0
- package/dist/commonjs/models/operations/createcustomerpaymentmethod.js +65 -0
- package/dist/commonjs/models/operations/createcustomerpaymentmethod.js.map +1 -0
- package/dist/commonjs/models/operations/index.d.ts +2 -0
- package/dist/commonjs/models/operations/index.d.ts.map +1 -1
- package/dist/commonjs/models/operations/index.js +2 -0
- package/dist/commonjs/models/operations/index.js.map +1 -1
- package/dist/commonjs/models/operations/listcustomerpaymentmethods.d.ts +35 -0
- package/dist/commonjs/models/operations/listcustomerpaymentmethods.d.ts.map +1 -0
- package/dist/commonjs/models/operations/listcustomerpaymentmethods.js +65 -0
- package/dist/commonjs/models/operations/listcustomerpaymentmethods.js.map +1 -0
- package/dist/commonjs/models/operations/listinvoices.d.ts +1 -1
- package/dist/commonjs/models/operations/listinvoices.d.ts.map +1 -1
- package/dist/commonjs/models/operations/listinvoices.js +1 -1
- package/dist/commonjs/models/operations/listinvoices.js.map +1 -1
- package/dist/commonjs/models/operations/listpaymentsessions.d.ts +1 -1
- package/dist/commonjs/models/operations/listpaymentsessions.d.ts.map +1 -1
- package/dist/commonjs/models/operations/listpaymentsessions.js +1 -1
- package/dist/commonjs/models/operations/listpaymentsessions.js.map +1 -1
- package/dist/commonjs/models/paymentmethod.d.ts +30 -0
- package/dist/commonjs/models/paymentmethod.d.ts.map +1 -0
- package/dist/commonjs/models/paymentmethod.js +62 -0
- package/dist/commonjs/models/paymentmethod.js.map +1 -0
- package/dist/commonjs/models/paymentsession.d.ts +18 -33
- package/dist/commonjs/models/paymentsession.d.ts.map +1 -1
- package/dist/commonjs/models/paymentsession.js +14 -11
- package/dist/commonjs/models/paymentsession.js.map +1 -1
- package/dist/commonjs/models/schemaspaymentsession.d.ts +68 -0
- package/dist/commonjs/models/schemaspaymentsession.d.ts.map +1 -0
- package/dist/commonjs/models/schemaspaymentsession.js +78 -0
- package/dist/commonjs/models/schemaspaymentsession.js.map +1 -0
- package/dist/commonjs/sdk/customers.d.ts +14 -0
- package/dist/commonjs/sdk/customers.d.ts.map +1 -1
- package/dist/commonjs/sdk/customers.js +20 -0
- package/dist/commonjs/sdk/customers.js.map +1 -1
- package/dist/esm/funcs/customersCreateCustomerPaymentMethod.d.ts +19 -0
- package/dist/esm/funcs/customersCreateCustomerPaymentMethod.d.ts.map +1 -0
- package/dist/esm/funcs/customersCreateCustomerPaymentMethod.js +89 -0
- package/dist/esm/funcs/customersCreateCustomerPaymentMethod.js.map +1 -0
- package/dist/esm/funcs/customersListCustomerPaymentMethods.d.ts +18 -0
- package/dist/esm/funcs/customersListCustomerPaymentMethods.d.ts.map +1 -0
- package/dist/esm/funcs/customersListCustomerPaymentMethods.js +87 -0
- package/dist/esm/funcs/customersListCustomerPaymentMethods.js.map +1 -0
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/models/index.d.ts +2 -0
- package/dist/esm/models/index.d.ts.map +1 -1
- package/dist/esm/models/index.js +2 -0
- package/dist/esm/models/index.js.map +1 -1
- package/dist/esm/models/operations/createcustomerpaymentmethod.d.ts +44 -0
- package/dist/esm/models/operations/createcustomerpaymentmethod.d.ts.map +1 -0
- package/dist/esm/models/operations/createcustomerpaymentmethod.js +27 -0
- package/dist/esm/models/operations/createcustomerpaymentmethod.js.map +1 -0
- package/dist/esm/models/operations/index.d.ts +2 -0
- package/dist/esm/models/operations/index.d.ts.map +1 -1
- package/dist/esm/models/operations/index.js +2 -0
- package/dist/esm/models/operations/index.js.map +1 -1
- package/dist/esm/models/operations/listcustomerpaymentmethods.d.ts +35 -0
- package/dist/esm/models/operations/listcustomerpaymentmethods.d.ts.map +1 -0
- package/dist/esm/models/operations/listcustomerpaymentmethods.js +27 -0
- package/dist/esm/models/operations/listcustomerpaymentmethods.js.map +1 -0
- package/dist/esm/models/operations/listinvoices.d.ts +1 -1
- package/dist/esm/models/operations/listinvoices.d.ts.map +1 -1
- package/dist/esm/models/operations/listinvoices.js +1 -1
- package/dist/esm/models/operations/listinvoices.js.map +1 -1
- package/dist/esm/models/operations/listpaymentsessions.d.ts +1 -1
- package/dist/esm/models/operations/listpaymentsessions.d.ts.map +1 -1
- package/dist/esm/models/operations/listpaymentsessions.js +1 -1
- package/dist/esm/models/operations/listpaymentsessions.js.map +1 -1
- package/dist/esm/models/paymentmethod.d.ts +30 -0
- package/dist/esm/models/paymentmethod.d.ts.map +1 -0
- package/dist/esm/models/paymentmethod.js +25 -0
- package/dist/esm/models/paymentmethod.js.map +1 -0
- package/dist/esm/models/paymentsession.d.ts +18 -33
- package/dist/esm/models/paymentsession.d.ts.map +1 -1
- package/dist/esm/models/paymentsession.js +13 -10
- package/dist/esm/models/paymentsession.js.map +1 -1
- package/dist/esm/models/schemaspaymentsession.d.ts +68 -0
- package/dist/esm/models/schemaspaymentsession.d.ts.map +1 -0
- package/dist/esm/models/schemaspaymentsession.js +41 -0
- package/dist/esm/models/schemaspaymentsession.js.map +1 -0
- package/dist/esm/sdk/customers.d.ts +14 -0
- package/dist/esm/sdk/customers.d.ts.map +1 -1
- package/dist/esm/sdk/customers.js +20 -0
- package/dist/esm/sdk/customers.js.map +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/funcs/customersCreateCustomerPaymentMethod.ts +182 -0
- package/src/funcs/customersListCustomerPaymentMethods.ts +176 -0
- package/src/lib/config.ts +2 -2
- package/src/models/index.ts +2 -0
- package/src/models/operations/createcustomerpaymentmethod.ts +90 -0
- package/src/models/operations/index.ts +2 -0
- package/src/models/operations/listcustomerpaymentmethods.ts +82 -0
- package/src/models/operations/listinvoices.ts +2 -2
- package/src/models/operations/listpaymentsessions.ts +2 -2
- package/src/models/paymentmethod.ts +62 -0
- package/src/models/paymentsession.ts +26 -39
- package/src/models/schemaspaymentsession.ts +113 -0
- 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: "
|
|
12
|
+
PaymentSession: "paymentSession",
|
|
13
13
|
} as const;
|
|
14
14
|
export type PaymentSessionObject = ClosedEnum<typeof PaymentSessionObject>;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
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
|
-
*
|
|
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
|
-
|
|
89
|
-
entityId: z.string(),
|
|
90
|
-
amount: z.string(),
|
|
91
|
-
currency: z.string(),
|
|
75
|
+
mode: Mode$inboundSchema,
|
|
92
76
|
status: PaymentSessionStatus$inboundSchema,
|
|
93
|
-
|
|
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(
|
|
@@ -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
|
+
}
|
package/src/sdk/customers.ts
CHANGED
|
@@ -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
|
}
|