@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
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { PaygenticCore } from "../core.js";
|
|
6
|
+
import { encodeJSON, encodeSimple } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
11
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import {
|
|
14
|
+
ConnectionError,
|
|
15
|
+
InvalidRequestError,
|
|
16
|
+
RequestAbortedError,
|
|
17
|
+
RequestTimeoutError,
|
|
18
|
+
UnexpectedClientError,
|
|
19
|
+
} from "../models/errors/httpclienterrors.js";
|
|
20
|
+
import * as errors from "../models/errors/index.js";
|
|
21
|
+
import { PaygenticError } from "../models/errors/paygenticerror.js";
|
|
22
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
23
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
24
|
+
import * as models from "../models/index.js";
|
|
25
|
+
import * as operations from "../models/operations/index.js";
|
|
26
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
27
|
+
import { Result } from "../types/fp.js";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Set up a payment method
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* 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).
|
|
34
|
+
*/
|
|
35
|
+
export function customersCreateCustomerPaymentMethod(
|
|
36
|
+
client: PaygenticCore,
|
|
37
|
+
request: operations.CreateCustomerPaymentMethodRequest,
|
|
38
|
+
options?: RequestOptions,
|
|
39
|
+
): APIPromise<
|
|
40
|
+
Result<
|
|
41
|
+
models.PaymentSession,
|
|
42
|
+
| errors.BadRequest
|
|
43
|
+
| errors.ErrorT
|
|
44
|
+
| PaygenticError
|
|
45
|
+
| ResponseValidationError
|
|
46
|
+
| ConnectionError
|
|
47
|
+
| RequestAbortedError
|
|
48
|
+
| RequestTimeoutError
|
|
49
|
+
| InvalidRequestError
|
|
50
|
+
| UnexpectedClientError
|
|
51
|
+
| SDKValidationError
|
|
52
|
+
>
|
|
53
|
+
> {
|
|
54
|
+
return new APIPromise($do(
|
|
55
|
+
client,
|
|
56
|
+
request,
|
|
57
|
+
options,
|
|
58
|
+
));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function $do(
|
|
62
|
+
client: PaygenticCore,
|
|
63
|
+
request: operations.CreateCustomerPaymentMethodRequest,
|
|
64
|
+
options?: RequestOptions,
|
|
65
|
+
): Promise<
|
|
66
|
+
[
|
|
67
|
+
Result<
|
|
68
|
+
models.PaymentSession,
|
|
69
|
+
| errors.BadRequest
|
|
70
|
+
| errors.ErrorT
|
|
71
|
+
| PaygenticError
|
|
72
|
+
| ResponseValidationError
|
|
73
|
+
| ConnectionError
|
|
74
|
+
| RequestAbortedError
|
|
75
|
+
| RequestTimeoutError
|
|
76
|
+
| InvalidRequestError
|
|
77
|
+
| UnexpectedClientError
|
|
78
|
+
| SDKValidationError
|
|
79
|
+
>,
|
|
80
|
+
APICall,
|
|
81
|
+
]
|
|
82
|
+
> {
|
|
83
|
+
const parsed = safeParse(
|
|
84
|
+
request,
|
|
85
|
+
(value) =>
|
|
86
|
+
operations.CreateCustomerPaymentMethodRequest$outboundSchema.parse(value),
|
|
87
|
+
"Input validation failed",
|
|
88
|
+
);
|
|
89
|
+
if (!parsed.ok) {
|
|
90
|
+
return [parsed, { status: "invalid" }];
|
|
91
|
+
}
|
|
92
|
+
const payload = parsed.value;
|
|
93
|
+
const body = encodeJSON("body", payload.RequestBody, { explode: true });
|
|
94
|
+
|
|
95
|
+
const pathParams = {
|
|
96
|
+
id: encodeSimple("id", payload.id, {
|
|
97
|
+
explode: false,
|
|
98
|
+
charEncoding: "percent",
|
|
99
|
+
}),
|
|
100
|
+
};
|
|
101
|
+
const path = pathToFunc("/v0/customers/{id}/paymentMethods")(pathParams);
|
|
102
|
+
|
|
103
|
+
const headers = new Headers(compactMap({
|
|
104
|
+
"Content-Type": "application/json",
|
|
105
|
+
Accept: "application/json",
|
|
106
|
+
}));
|
|
107
|
+
|
|
108
|
+
const secConfig = await extractSecurity(client._options.bearerAuth);
|
|
109
|
+
const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
|
|
110
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
111
|
+
|
|
112
|
+
const context = {
|
|
113
|
+
options: client._options,
|
|
114
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
115
|
+
operationID: "createCustomerPaymentMethod",
|
|
116
|
+
oAuth2Scopes: null,
|
|
117
|
+
|
|
118
|
+
resolvedSecurity: requestSecurity,
|
|
119
|
+
|
|
120
|
+
securitySource: client._options.bearerAuth,
|
|
121
|
+
retryConfig: options?.retries
|
|
122
|
+
|| client._options.retryConfig
|
|
123
|
+
|| { strategy: "none" },
|
|
124
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const requestRes = client._createRequest(context, {
|
|
128
|
+
security: requestSecurity,
|
|
129
|
+
method: "POST",
|
|
130
|
+
baseURL: options?.serverURL,
|
|
131
|
+
path: path,
|
|
132
|
+
headers: headers,
|
|
133
|
+
body: body,
|
|
134
|
+
userAgent: client._options.userAgent,
|
|
135
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
136
|
+
}, options);
|
|
137
|
+
if (!requestRes.ok) {
|
|
138
|
+
return [requestRes, { status: "invalid" }];
|
|
139
|
+
}
|
|
140
|
+
const req = requestRes.value;
|
|
141
|
+
|
|
142
|
+
const doResult = await client._do(req, {
|
|
143
|
+
context,
|
|
144
|
+
errorCodes: ["400", "403", "404", "4XX", "500", "5XX"],
|
|
145
|
+
retryConfig: context.retryConfig,
|
|
146
|
+
retryCodes: context.retryCodes,
|
|
147
|
+
});
|
|
148
|
+
if (!doResult.ok) {
|
|
149
|
+
return [doResult, { status: "request-error", request: req }];
|
|
150
|
+
}
|
|
151
|
+
const response = doResult.value;
|
|
152
|
+
|
|
153
|
+
const responseFields = {
|
|
154
|
+
HttpMeta: { Response: response, Request: req },
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const [result] = await M.match<
|
|
158
|
+
models.PaymentSession,
|
|
159
|
+
| errors.BadRequest
|
|
160
|
+
| errors.ErrorT
|
|
161
|
+
| PaygenticError
|
|
162
|
+
| ResponseValidationError
|
|
163
|
+
| ConnectionError
|
|
164
|
+
| RequestAbortedError
|
|
165
|
+
| RequestTimeoutError
|
|
166
|
+
| InvalidRequestError
|
|
167
|
+
| UnexpectedClientError
|
|
168
|
+
| SDKValidationError
|
|
169
|
+
>(
|
|
170
|
+
M.json(201, models.PaymentSession$inboundSchema),
|
|
171
|
+
M.jsonErr(400, errors.BadRequest$inboundSchema),
|
|
172
|
+
M.jsonErr([403, 404], errors.ErrorT$inboundSchema),
|
|
173
|
+
M.jsonErr(500, errors.ErrorT$inboundSchema),
|
|
174
|
+
M.fail("4XX"),
|
|
175
|
+
M.fail("5XX"),
|
|
176
|
+
)(response, req, { extraFields: responseFields });
|
|
177
|
+
if (!result.ok) {
|
|
178
|
+
return [result, { status: "complete", request: req, response }];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return [result, { status: "complete", request: req, response }];
|
|
182
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { PaygenticCore } from "../core.js";
|
|
6
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
11
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import {
|
|
14
|
+
ConnectionError,
|
|
15
|
+
InvalidRequestError,
|
|
16
|
+
RequestAbortedError,
|
|
17
|
+
RequestTimeoutError,
|
|
18
|
+
UnexpectedClientError,
|
|
19
|
+
} from "../models/errors/httpclienterrors.js";
|
|
20
|
+
import * as errors from "../models/errors/index.js";
|
|
21
|
+
import { PaygenticError } from "../models/errors/paygenticerror.js";
|
|
22
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
23
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
24
|
+
import * as operations from "../models/operations/index.js";
|
|
25
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
26
|
+
import { Result } from "../types/fp.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* List payment methods
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* List off-session payment methods saved for this customer.
|
|
33
|
+
*/
|
|
34
|
+
export function customersListCustomerPaymentMethods(
|
|
35
|
+
client: PaygenticCore,
|
|
36
|
+
request: operations.ListCustomerPaymentMethodsRequest,
|
|
37
|
+
options?: RequestOptions,
|
|
38
|
+
): APIPromise<
|
|
39
|
+
Result<
|
|
40
|
+
operations.ListCustomerPaymentMethodsResponse,
|
|
41
|
+
| errors.ErrorT
|
|
42
|
+
| PaygenticError
|
|
43
|
+
| ResponseValidationError
|
|
44
|
+
| ConnectionError
|
|
45
|
+
| RequestAbortedError
|
|
46
|
+
| RequestTimeoutError
|
|
47
|
+
| InvalidRequestError
|
|
48
|
+
| UnexpectedClientError
|
|
49
|
+
| SDKValidationError
|
|
50
|
+
>
|
|
51
|
+
> {
|
|
52
|
+
return new APIPromise($do(
|
|
53
|
+
client,
|
|
54
|
+
request,
|
|
55
|
+
options,
|
|
56
|
+
));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function $do(
|
|
60
|
+
client: PaygenticCore,
|
|
61
|
+
request: operations.ListCustomerPaymentMethodsRequest,
|
|
62
|
+
options?: RequestOptions,
|
|
63
|
+
): Promise<
|
|
64
|
+
[
|
|
65
|
+
Result<
|
|
66
|
+
operations.ListCustomerPaymentMethodsResponse,
|
|
67
|
+
| errors.ErrorT
|
|
68
|
+
| PaygenticError
|
|
69
|
+
| ResponseValidationError
|
|
70
|
+
| ConnectionError
|
|
71
|
+
| RequestAbortedError
|
|
72
|
+
| RequestTimeoutError
|
|
73
|
+
| InvalidRequestError
|
|
74
|
+
| UnexpectedClientError
|
|
75
|
+
| SDKValidationError
|
|
76
|
+
>,
|
|
77
|
+
APICall,
|
|
78
|
+
]
|
|
79
|
+
> {
|
|
80
|
+
const parsed = safeParse(
|
|
81
|
+
request,
|
|
82
|
+
(value) =>
|
|
83
|
+
operations.ListCustomerPaymentMethodsRequest$outboundSchema.parse(value),
|
|
84
|
+
"Input validation failed",
|
|
85
|
+
);
|
|
86
|
+
if (!parsed.ok) {
|
|
87
|
+
return [parsed, { status: "invalid" }];
|
|
88
|
+
}
|
|
89
|
+
const payload = parsed.value;
|
|
90
|
+
const body = null;
|
|
91
|
+
|
|
92
|
+
const pathParams = {
|
|
93
|
+
id: encodeSimple("id", payload.id, {
|
|
94
|
+
explode: false,
|
|
95
|
+
charEncoding: "percent",
|
|
96
|
+
}),
|
|
97
|
+
};
|
|
98
|
+
const path = pathToFunc("/v0/customers/{id}/paymentMethods")(pathParams);
|
|
99
|
+
|
|
100
|
+
const headers = new Headers(compactMap({
|
|
101
|
+
Accept: "application/json",
|
|
102
|
+
}));
|
|
103
|
+
|
|
104
|
+
const secConfig = await extractSecurity(client._options.bearerAuth);
|
|
105
|
+
const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
|
|
106
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
107
|
+
|
|
108
|
+
const context = {
|
|
109
|
+
options: client._options,
|
|
110
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
111
|
+
operationID: "listCustomerPaymentMethods",
|
|
112
|
+
oAuth2Scopes: null,
|
|
113
|
+
|
|
114
|
+
resolvedSecurity: requestSecurity,
|
|
115
|
+
|
|
116
|
+
securitySource: client._options.bearerAuth,
|
|
117
|
+
retryConfig: options?.retries
|
|
118
|
+
|| client._options.retryConfig
|
|
119
|
+
|| { strategy: "none" },
|
|
120
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const requestRes = client._createRequest(context, {
|
|
124
|
+
security: requestSecurity,
|
|
125
|
+
method: "GET",
|
|
126
|
+
baseURL: options?.serverURL,
|
|
127
|
+
path: path,
|
|
128
|
+
headers: headers,
|
|
129
|
+
body: body,
|
|
130
|
+
userAgent: client._options.userAgent,
|
|
131
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
132
|
+
}, options);
|
|
133
|
+
if (!requestRes.ok) {
|
|
134
|
+
return [requestRes, { status: "invalid" }];
|
|
135
|
+
}
|
|
136
|
+
const req = requestRes.value;
|
|
137
|
+
|
|
138
|
+
const doResult = await client._do(req, {
|
|
139
|
+
context,
|
|
140
|
+
errorCodes: ["403", "404", "4XX", "500", "5XX"],
|
|
141
|
+
retryConfig: context.retryConfig,
|
|
142
|
+
retryCodes: context.retryCodes,
|
|
143
|
+
});
|
|
144
|
+
if (!doResult.ok) {
|
|
145
|
+
return [doResult, { status: "request-error", request: req }];
|
|
146
|
+
}
|
|
147
|
+
const response = doResult.value;
|
|
148
|
+
|
|
149
|
+
const responseFields = {
|
|
150
|
+
HttpMeta: { Response: response, Request: req },
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const [result] = await M.match<
|
|
154
|
+
operations.ListCustomerPaymentMethodsResponse,
|
|
155
|
+
| errors.ErrorT
|
|
156
|
+
| PaygenticError
|
|
157
|
+
| ResponseValidationError
|
|
158
|
+
| ConnectionError
|
|
159
|
+
| RequestAbortedError
|
|
160
|
+
| RequestTimeoutError
|
|
161
|
+
| InvalidRequestError
|
|
162
|
+
| UnexpectedClientError
|
|
163
|
+
| SDKValidationError
|
|
164
|
+
>(
|
|
165
|
+
M.json(200, operations.ListCustomerPaymentMethodsResponse$inboundSchema),
|
|
166
|
+
M.jsonErr([403, 404], errors.ErrorT$inboundSchema),
|
|
167
|
+
M.jsonErr(500, errors.ErrorT$inboundSchema),
|
|
168
|
+
M.fail("4XX"),
|
|
169
|
+
M.fail("5XX"),
|
|
170
|
+
)(response, req, { extraFields: responseFields });
|
|
171
|
+
if (!result.ok) {
|
|
172
|
+
return [result, { status: "complete", request: req, response }];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return [result, { status: "complete", request: req, response }];
|
|
176
|
+
}
|
package/src/lib/config.ts
CHANGED
|
@@ -65,7 +65,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
65
65
|
export const SDK_METADATA = {
|
|
66
66
|
language: "typescript",
|
|
67
67
|
openapiDocVersion: "0.1.0",
|
|
68
|
-
sdkVersion: "0.7.
|
|
68
|
+
sdkVersion: "0.7.3",
|
|
69
69
|
genVersion: "2.879.13",
|
|
70
|
-
userAgent: "speakeasy-sdk/typescript 0.7.
|
|
70
|
+
userAgent: "speakeasy-sdk/typescript 0.7.3 2.879.13 0.1.0 @paygentic/sdk",
|
|
71
71
|
} as const;
|
package/src/models/index.ts
CHANGED
|
@@ -40,6 +40,7 @@ export * from "./meterevent.js";
|
|
|
40
40
|
export * from "./metereventlist.js";
|
|
41
41
|
export * from "./offsetpagination.js";
|
|
42
42
|
export * from "./payment.js";
|
|
43
|
+
export * from "./paymentmethod.js";
|
|
43
44
|
export * from "./paymentsession.js";
|
|
44
45
|
export * from "./paymentsummary.js";
|
|
45
46
|
export * from "./plan.js";
|
|
@@ -56,6 +57,7 @@ export * from "./purchasegrantresponse.js";
|
|
|
56
57
|
export * from "./revenuesummaryresponse.js";
|
|
57
58
|
export * from "./revenuetrendbucket.js";
|
|
58
59
|
export * from "./rulecondition.js";
|
|
60
|
+
export * from "./schemaspaymentsession.js";
|
|
59
61
|
export * from "./schemasprice.js";
|
|
60
62
|
export * from "./security.js";
|
|
61
63
|
export * from "./source.js";
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
7
|
+
|
|
8
|
+
export type CreateCustomerPaymentMethodRequestBody = {
|
|
9
|
+
/**
|
|
10
|
+
* URL the customer is redirected to on success. When the page is iframed, success is reported via `postMessage` instead.
|
|
11
|
+
*/
|
|
12
|
+
successRedirectUrl?: string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* URL the customer is redirected to on failure. When the page is iframed, failure is reported via `postMessage` instead.
|
|
15
|
+
*/
|
|
16
|
+
failureRedirectUrl?: string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Arbitrary key/value pairs to attach to the session.
|
|
19
|
+
*/
|
|
20
|
+
metadata?: { [k: string]: any } | undefined;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type CreateCustomerPaymentMethodRequest = {
|
|
24
|
+
/**
|
|
25
|
+
* The unique identifier of the customer.
|
|
26
|
+
*/
|
|
27
|
+
id: string;
|
|
28
|
+
requestBody?: CreateCustomerPaymentMethodRequestBody | undefined;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/** @internal */
|
|
32
|
+
export type CreateCustomerPaymentMethodRequestBody$Outbound = {
|
|
33
|
+
successRedirectUrl?: string | undefined;
|
|
34
|
+
failureRedirectUrl?: string | undefined;
|
|
35
|
+
metadata?: { [k: string]: any } | undefined;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** @internal */
|
|
39
|
+
export const CreateCustomerPaymentMethodRequestBody$outboundSchema: z.ZodType<
|
|
40
|
+
CreateCustomerPaymentMethodRequestBody$Outbound,
|
|
41
|
+
z.ZodTypeDef,
|
|
42
|
+
CreateCustomerPaymentMethodRequestBody
|
|
43
|
+
> = z.object({
|
|
44
|
+
successRedirectUrl: z.string().optional(),
|
|
45
|
+
failureRedirectUrl: z.string().optional(),
|
|
46
|
+
metadata: z.record(z.any()).optional(),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export function createCustomerPaymentMethodRequestBodyToJSON(
|
|
50
|
+
createCustomerPaymentMethodRequestBody:
|
|
51
|
+
CreateCustomerPaymentMethodRequestBody,
|
|
52
|
+
): string {
|
|
53
|
+
return JSON.stringify(
|
|
54
|
+
CreateCustomerPaymentMethodRequestBody$outboundSchema.parse(
|
|
55
|
+
createCustomerPaymentMethodRequestBody,
|
|
56
|
+
),
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** @internal */
|
|
61
|
+
export type CreateCustomerPaymentMethodRequest$Outbound = {
|
|
62
|
+
id: string;
|
|
63
|
+
RequestBody?: CreateCustomerPaymentMethodRequestBody$Outbound | undefined;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** @internal */
|
|
67
|
+
export const CreateCustomerPaymentMethodRequest$outboundSchema: z.ZodType<
|
|
68
|
+
CreateCustomerPaymentMethodRequest$Outbound,
|
|
69
|
+
z.ZodTypeDef,
|
|
70
|
+
CreateCustomerPaymentMethodRequest
|
|
71
|
+
> = z.object({
|
|
72
|
+
id: z.string(),
|
|
73
|
+
requestBody: z.lazy(() =>
|
|
74
|
+
CreateCustomerPaymentMethodRequestBody$outboundSchema
|
|
75
|
+
).optional(),
|
|
76
|
+
}).transform((v) => {
|
|
77
|
+
return remap$(v, {
|
|
78
|
+
requestBody: "RequestBody",
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export function createCustomerPaymentMethodRequestToJSON(
|
|
83
|
+
createCustomerPaymentMethodRequest: CreateCustomerPaymentMethodRequest,
|
|
84
|
+
): string {
|
|
85
|
+
return JSON.stringify(
|
|
86
|
+
CreateCustomerPaymentMethodRequest$outboundSchema.parse(
|
|
87
|
+
createCustomerPaymentMethodRequest,
|
|
88
|
+
),
|
|
89
|
+
);
|
|
90
|
+
}
|
|
@@ -9,6 +9,7 @@ export * from "./bulkrejectsourceevents.js";
|
|
|
9
9
|
export * from "./createbillablemetric.js";
|
|
10
10
|
export * from "./createcost.js";
|
|
11
11
|
export * from "./createcustomer.js";
|
|
12
|
+
export * from "./createcustomerpaymentmethod.js";
|
|
12
13
|
export * from "./createentitlementgrant.js";
|
|
13
14
|
export * from "./createfeature.js";
|
|
14
15
|
export * from "./createfee.js";
|
|
@@ -57,6 +58,7 @@ export * from "./listavailableplans.js";
|
|
|
57
58
|
export * from "./listbillablemetricevents.js";
|
|
58
59
|
export * from "./listbillablemetrics.js";
|
|
59
60
|
export * from "./listcosts.js";
|
|
61
|
+
export * from "./listcustomerpaymentmethods.js";
|
|
60
62
|
export * from "./listcustomers.js";
|
|
61
63
|
export * from "./listentitlementgrants.js";
|
|
62
64
|
export * from "./listentitlements.js";
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
import * as models from "../index.js";
|
|
11
|
+
|
|
12
|
+
export type ListCustomerPaymentMethodsRequest = {
|
|
13
|
+
/**
|
|
14
|
+
* The unique identifier of the customer.
|
|
15
|
+
*/
|
|
16
|
+
id: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const ListCustomerPaymentMethodsObject = {
|
|
20
|
+
List: "list",
|
|
21
|
+
} as const;
|
|
22
|
+
export type ListCustomerPaymentMethodsObject = ClosedEnum<
|
|
23
|
+
typeof ListCustomerPaymentMethodsObject
|
|
24
|
+
>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* List of payment methods
|
|
28
|
+
*/
|
|
29
|
+
export type ListCustomerPaymentMethodsResponse = {
|
|
30
|
+
object: ListCustomerPaymentMethodsObject;
|
|
31
|
+
data: Array<models.PaymentMethod>;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** @internal */
|
|
35
|
+
export type ListCustomerPaymentMethodsRequest$Outbound = {
|
|
36
|
+
id: string;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** @internal */
|
|
40
|
+
export const ListCustomerPaymentMethodsRequest$outboundSchema: z.ZodType<
|
|
41
|
+
ListCustomerPaymentMethodsRequest$Outbound,
|
|
42
|
+
z.ZodTypeDef,
|
|
43
|
+
ListCustomerPaymentMethodsRequest
|
|
44
|
+
> = z.object({
|
|
45
|
+
id: z.string(),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export function listCustomerPaymentMethodsRequestToJSON(
|
|
49
|
+
listCustomerPaymentMethodsRequest: ListCustomerPaymentMethodsRequest,
|
|
50
|
+
): string {
|
|
51
|
+
return JSON.stringify(
|
|
52
|
+
ListCustomerPaymentMethodsRequest$outboundSchema.parse(
|
|
53
|
+
listCustomerPaymentMethodsRequest,
|
|
54
|
+
),
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** @internal */
|
|
59
|
+
export const ListCustomerPaymentMethodsObject$inboundSchema: z.ZodNativeEnum<
|
|
60
|
+
typeof ListCustomerPaymentMethodsObject
|
|
61
|
+
> = z.nativeEnum(ListCustomerPaymentMethodsObject);
|
|
62
|
+
|
|
63
|
+
/** @internal */
|
|
64
|
+
export const ListCustomerPaymentMethodsResponse$inboundSchema: z.ZodType<
|
|
65
|
+
ListCustomerPaymentMethodsResponse,
|
|
66
|
+
z.ZodTypeDef,
|
|
67
|
+
unknown
|
|
68
|
+
> = z.object({
|
|
69
|
+
object: ListCustomerPaymentMethodsObject$inboundSchema,
|
|
70
|
+
data: z.array(models.PaymentMethod$inboundSchema),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
export function listCustomerPaymentMethodsResponseFromJSON(
|
|
74
|
+
jsonString: string,
|
|
75
|
+
): SafeParseResult<ListCustomerPaymentMethodsResponse, SDKValidationError> {
|
|
76
|
+
return safeParse(
|
|
77
|
+
jsonString,
|
|
78
|
+
(x) =>
|
|
79
|
+
ListCustomerPaymentMethodsResponse$inboundSchema.parse(JSON.parse(x)),
|
|
80
|
+
`Failed to parse 'ListCustomerPaymentMethodsResponse' from JSON`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
@@ -82,7 +82,7 @@ export type ListInvoicesResponse = {
|
|
|
82
82
|
/**
|
|
83
83
|
* Offset-based pagination response.
|
|
84
84
|
*/
|
|
85
|
-
pagination
|
|
85
|
+
pagination: models.OffsetPagination;
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
/** @internal */
|
|
@@ -139,7 +139,7 @@ export const ListInvoicesResponse$inboundSchema: z.ZodType<
|
|
|
139
139
|
> = z.object({
|
|
140
140
|
object: ListInvoicesObject$inboundSchema,
|
|
141
141
|
data: z.array(models.Invoice$inboundSchema),
|
|
142
|
-
pagination: models.OffsetPagination$inboundSchema
|
|
142
|
+
pagination: models.OffsetPagination$inboundSchema,
|
|
143
143
|
});
|
|
144
144
|
|
|
145
145
|
export function listInvoicesResponseFromJSON(
|
|
@@ -84,7 +84,7 @@ export type ListPaymentSessionsObject = ClosedEnum<
|
|
|
84
84
|
*/
|
|
85
85
|
export type ListPaymentSessionsResponse = {
|
|
86
86
|
object: ListPaymentSessionsObject;
|
|
87
|
-
data: Array<models.
|
|
87
|
+
data: Array<models.SchemasPaymentSession>;
|
|
88
88
|
/**
|
|
89
89
|
* Offset-based pagination response.
|
|
90
90
|
*/
|
|
@@ -146,7 +146,7 @@ export const ListPaymentSessionsResponse$inboundSchema: z.ZodType<
|
|
|
146
146
|
unknown
|
|
147
147
|
> = z.object({
|
|
148
148
|
object: ListPaymentSessionsObject$inboundSchema,
|
|
149
|
-
data: z.array(models.
|
|
149
|
+
data: z.array(models.SchemasPaymentSession$inboundSchema),
|
|
150
150
|
pagination: models.OffsetPagination$inboundSchema,
|
|
151
151
|
});
|
|
152
152
|
|
|
@@ -0,0 +1,62 @@
|
|
|
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 PaymentMethodObject = {
|
|
12
|
+
PaymentMethod: "paymentMethod",
|
|
13
|
+
} as const;
|
|
14
|
+
export type PaymentMethodObject = ClosedEnum<typeof PaymentMethodObject>;
|
|
15
|
+
|
|
16
|
+
export type PaymentMethod = {
|
|
17
|
+
object: PaymentMethodObject;
|
|
18
|
+
/**
|
|
19
|
+
* Payment method identifier.
|
|
20
|
+
*/
|
|
21
|
+
id: string;
|
|
22
|
+
/**
|
|
23
|
+
* Payment method type (e.g. `card`, `sepa_debit`).
|
|
24
|
+
*/
|
|
25
|
+
type?: string | null | undefined;
|
|
26
|
+
brand?: string | null | undefined;
|
|
27
|
+
last4?: string | null | undefined;
|
|
28
|
+
expMonth?: number | null | undefined;
|
|
29
|
+
expYear?: number | null | undefined;
|
|
30
|
+
createdAt: Date;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** @internal */
|
|
34
|
+
export const PaymentMethodObject$inboundSchema: z.ZodNativeEnum<
|
|
35
|
+
typeof PaymentMethodObject
|
|
36
|
+
> = z.nativeEnum(PaymentMethodObject);
|
|
37
|
+
|
|
38
|
+
/** @internal */
|
|
39
|
+
export const PaymentMethod$inboundSchema: z.ZodType<
|
|
40
|
+
PaymentMethod,
|
|
41
|
+
z.ZodTypeDef,
|
|
42
|
+
unknown
|
|
43
|
+
> = z.object({
|
|
44
|
+
object: PaymentMethodObject$inboundSchema,
|
|
45
|
+
id: z.string(),
|
|
46
|
+
type: z.nullable(z.string()).optional(),
|
|
47
|
+
brand: z.nullable(z.string()).optional(),
|
|
48
|
+
last4: z.nullable(z.string()).optional(),
|
|
49
|
+
expMonth: z.nullable(z.number().int()).optional(),
|
|
50
|
+
expYear: z.nullable(z.number().int()).optional(),
|
|
51
|
+
createdAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export function paymentMethodFromJSON(
|
|
55
|
+
jsonString: string,
|
|
56
|
+
): SafeParseResult<PaymentMethod, SDKValidationError> {
|
|
57
|
+
return safeParse(
|
|
58
|
+
jsonString,
|
|
59
|
+
(x) => PaymentMethod$inboundSchema.parse(JSON.parse(x)),
|
|
60
|
+
`Failed to parse 'PaymentMethod' from JSON`,
|
|
61
|
+
);
|
|
62
|
+
}
|