@paygentic/sdk 0.7.17 → 0.7.19
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 +9 -3
- package/dist/commonjs/funcs/entitlementsList.d.ts +1 -1
- package/dist/commonjs/funcs/entitlementsList.d.ts.map +1 -1
- package/dist/commonjs/funcs/entitlementsList.js +10 -8
- package/dist/commonjs/funcs/entitlementsList.js.map +1 -1
- package/dist/commonjs/funcs/invoicesV2CreateInvoiceRefund.d.ts +19 -0
- package/dist/commonjs/funcs/invoicesV2CreateInvoiceRefund.d.ts.map +1 -0
- package/dist/commonjs/funcs/invoicesV2CreateInvoiceRefund.js +125 -0
- package/dist/commonjs/funcs/invoicesV2CreateInvoiceRefund.js.map +1 -0
- package/dist/commonjs/funcs/invoicesV2ListInvoiceRefunds.d.ts +19 -0
- package/dist/commonjs/funcs/invoicesV2ListInvoiceRefunds.d.ts.map +1 -0
- package/dist/commonjs/funcs/invoicesV2ListInvoiceRefunds.js +124 -0
- package/dist/commonjs/funcs/invoicesV2ListInvoiceRefunds.js.map +1 -0
- package/dist/commonjs/funcs/invoicesV2VoidInvoiceRefund.d.ts +19 -0
- package/dist/commonjs/funcs/invoicesV2VoidInvoiceRefund.d.ts.map +1 -0
- package/dist/commonjs/funcs/invoicesV2VoidInvoiceRefund.js +129 -0
- package/dist/commonjs/funcs/invoicesV2VoidInvoiceRefund.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/invoicerefund.d.ts +95 -0
- package/dist/commonjs/models/invoicerefund.d.ts.map +1 -0
- package/dist/commonjs/models/invoicerefund.js +81 -0
- package/dist/commonjs/models/invoicerefund.js.map +1 -0
- package/dist/commonjs/models/invoicerefundlist.d.ts +31 -0
- package/dist/commonjs/models/invoicerefundlist.d.ts.map +1 -0
- package/dist/commonjs/models/invoicerefundlist.js +60 -0
- package/dist/commonjs/models/invoicerefundlist.js.map +1 -0
- package/dist/commonjs/models/operations/createcustomerpaymentmethod.d.ts +5 -0
- package/dist/commonjs/models/operations/createcustomerpaymentmethod.d.ts.map +1 -1
- package/dist/commonjs/models/operations/createcustomerpaymentmethod.js +1 -0
- package/dist/commonjs/models/operations/createcustomerpaymentmethod.js.map +1 -1
- package/dist/commonjs/models/operations/createinvoicerefund.d.ts +30 -0
- package/dist/commonjs/models/operations/createinvoicerefund.d.ts.map +1 -0
- package/dist/commonjs/models/operations/createinvoicerefund.js +64 -0
- package/dist/commonjs/models/operations/createinvoicerefund.js.map +1 -0
- package/dist/commonjs/models/operations/index.d.ts +3 -0
- package/dist/commonjs/models/operations/index.d.ts.map +1 -1
- package/dist/commonjs/models/operations/index.js +3 -0
- package/dist/commonjs/models/operations/index.js.map +1 -1
- package/dist/commonjs/models/operations/listentitlements.d.ts +13 -3
- package/dist/commonjs/models/operations/listentitlements.d.ts.map +1 -1
- package/dist/commonjs/models/operations/listentitlements.js +3 -1
- package/dist/commonjs/models/operations/listentitlements.js.map +1 -1
- package/dist/commonjs/models/operations/listinvoicerefunds.d.ts +15 -0
- package/dist/commonjs/models/operations/listinvoicerefunds.d.ts.map +1 -0
- package/dist/commonjs/models/operations/listinvoicerefunds.js +49 -0
- package/dist/commonjs/models/operations/listinvoicerefunds.js.map +1 -0
- package/dist/commonjs/models/operations/voidinvoicerefund.d.ts +35 -0
- package/dist/commonjs/models/operations/voidinvoicerefund.d.ts.map +1 -0
- package/dist/commonjs/models/operations/voidinvoicerefund.js +65 -0
- package/dist/commonjs/models/operations/voidinvoicerefund.js.map +1 -0
- package/dist/commonjs/models/revenuesummaryresponse.d.ts +9 -1
- package/dist/commonjs/models/revenuesummaryresponse.d.ts.map +1 -1
- package/dist/commonjs/models/revenuesummaryresponse.js +2 -0
- package/dist/commonjs/models/revenuesummaryresponse.js.map +1 -1
- package/dist/commonjs/sdk/entitlements.d.ts +1 -1
- package/dist/commonjs/sdk/entitlements.d.ts.map +1 -1
- package/dist/commonjs/sdk/entitlements.js.map +1 -1
- package/dist/commonjs/sdk/invoicesv2.d.ts +21 -0
- package/dist/commonjs/sdk/invoicesv2.d.ts.map +1 -1
- package/dist/commonjs/sdk/invoicesv2.js +30 -0
- package/dist/commonjs/sdk/invoicesv2.js.map +1 -1
- package/dist/esm/funcs/entitlementsList.d.ts +1 -1
- package/dist/esm/funcs/entitlementsList.d.ts.map +1 -1
- package/dist/esm/funcs/entitlementsList.js +10 -8
- package/dist/esm/funcs/entitlementsList.js.map +1 -1
- package/dist/esm/funcs/invoicesV2CreateInvoiceRefund.d.ts +19 -0
- package/dist/esm/funcs/invoicesV2CreateInvoiceRefund.d.ts.map +1 -0
- package/dist/esm/funcs/invoicesV2CreateInvoiceRefund.js +89 -0
- package/dist/esm/funcs/invoicesV2CreateInvoiceRefund.js.map +1 -0
- package/dist/esm/funcs/invoicesV2ListInvoiceRefunds.d.ts +19 -0
- package/dist/esm/funcs/invoicesV2ListInvoiceRefunds.d.ts.map +1 -0
- package/dist/esm/funcs/invoicesV2ListInvoiceRefunds.js +88 -0
- package/dist/esm/funcs/invoicesV2ListInvoiceRefunds.js.map +1 -0
- package/dist/esm/funcs/invoicesV2VoidInvoiceRefund.d.ts +19 -0
- package/dist/esm/funcs/invoicesV2VoidInvoiceRefund.d.ts.map +1 -0
- package/dist/esm/funcs/invoicesV2VoidInvoiceRefund.js +93 -0
- package/dist/esm/funcs/invoicesV2VoidInvoiceRefund.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/invoicerefund.d.ts +95 -0
- package/dist/esm/models/invoicerefund.d.ts.map +1 -0
- package/dist/esm/models/invoicerefund.js +44 -0
- package/dist/esm/models/invoicerefund.js.map +1 -0
- package/dist/esm/models/invoicerefundlist.d.ts +31 -0
- package/dist/esm/models/invoicerefundlist.d.ts.map +1 -0
- package/dist/esm/models/invoicerefundlist.js +23 -0
- package/dist/esm/models/invoicerefundlist.js.map +1 -0
- package/dist/esm/models/operations/createcustomerpaymentmethod.d.ts +5 -0
- package/dist/esm/models/operations/createcustomerpaymentmethod.d.ts.map +1 -1
- package/dist/esm/models/operations/createcustomerpaymentmethod.js +1 -0
- package/dist/esm/models/operations/createcustomerpaymentmethod.js.map +1 -1
- package/dist/esm/models/operations/createinvoicerefund.d.ts +30 -0
- package/dist/esm/models/operations/createinvoicerefund.d.ts.map +1 -0
- package/dist/esm/models/operations/createinvoicerefund.js +26 -0
- package/dist/esm/models/operations/createinvoicerefund.js.map +1 -0
- package/dist/esm/models/operations/index.d.ts +3 -0
- package/dist/esm/models/operations/index.d.ts.map +1 -1
- package/dist/esm/models/operations/index.js +3 -0
- package/dist/esm/models/operations/index.js.map +1 -1
- package/dist/esm/models/operations/listentitlements.d.ts +13 -3
- package/dist/esm/models/operations/listentitlements.d.ts.map +1 -1
- package/dist/esm/models/operations/listentitlements.js +3 -1
- package/dist/esm/models/operations/listentitlements.js.map +1 -1
- package/dist/esm/models/operations/listinvoicerefunds.d.ts +15 -0
- package/dist/esm/models/operations/listinvoicerefunds.d.ts.map +1 -0
- package/dist/esm/models/operations/listinvoicerefunds.js +12 -0
- package/dist/esm/models/operations/listinvoicerefunds.js.map +1 -0
- package/dist/esm/models/operations/voidinvoicerefund.d.ts +35 -0
- package/dist/esm/models/operations/voidinvoicerefund.d.ts.map +1 -0
- package/dist/esm/models/operations/voidinvoicerefund.js +27 -0
- package/dist/esm/models/operations/voidinvoicerefund.js.map +1 -0
- package/dist/esm/models/revenuesummaryresponse.d.ts +9 -1
- package/dist/esm/models/revenuesummaryresponse.d.ts.map +1 -1
- package/dist/esm/models/revenuesummaryresponse.js +2 -0
- package/dist/esm/models/revenuesummaryresponse.js.map +1 -1
- package/dist/esm/sdk/entitlements.d.ts +1 -1
- package/dist/esm/sdk/entitlements.d.ts.map +1 -1
- package/dist/esm/sdk/entitlements.js.map +1 -1
- package/dist/esm/sdk/invoicesv2.d.ts +21 -0
- package/dist/esm/sdk/invoicesv2.d.ts.map +1 -1
- package/dist/esm/sdk/invoicesv2.js +30 -0
- package/dist/esm/sdk/invoicesv2.js.map +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/funcs/entitlementsList.ts +13 -10
- package/src/funcs/invoicesV2CreateInvoiceRefund.ts +182 -0
- package/src/funcs/invoicesV2ListInvoiceRefunds.ts +176 -0
- package/src/funcs/invoicesV2VoidInvoiceRefund.ts +187 -0
- package/src/lib/config.ts +2 -2
- package/src/models/index.ts +2 -0
- package/src/models/invoicerefund.ts +140 -0
- package/src/models/invoicerefundlist.ts +59 -0
- package/src/models/operations/createcustomerpaymentmethod.ts +6 -0
- package/src/models/operations/createinvoicerefund.ts +74 -0
- package/src/models/operations/index.ts +3 -0
- package/src/models/operations/listentitlements.ts +16 -4
- package/src/models/operations/listinvoicerefunds.ts +34 -0
- package/src/models/operations/voidinvoicerefund.ts +80 -0
- package/src/models/revenuesummaryresponse.ts +11 -1
- package/src/sdk/entitlements.ts +1 -1
- package/src/sdk/invoicesv2.ts +54 -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
|
+
* Refund Invoice
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Issue a full refund against a paid invoice by creating a credit note. The invoice stays PAID; the refund is recorded as a child credit note. Accessible to the owning merchant or platform operators. Only works for invoices in PAID status that have not already been refunded. Full refund only — the entire invoice (subtotal + tax) is credited.
|
|
34
|
+
*/
|
|
35
|
+
export function invoicesV2CreateInvoiceRefund(
|
|
36
|
+
client: PaygenticCore,
|
|
37
|
+
request: operations.CreateInvoiceRefundRequest,
|
|
38
|
+
options?: RequestOptions,
|
|
39
|
+
): APIPromise<
|
|
40
|
+
Result<
|
|
41
|
+
models.InvoiceRefund,
|
|
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.CreateInvoiceRefundRequest,
|
|
64
|
+
options?: RequestOptions,
|
|
65
|
+
): Promise<
|
|
66
|
+
[
|
|
67
|
+
Result<
|
|
68
|
+
models.InvoiceRefund,
|
|
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.CreateInvoiceRefundRequest$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("/v2/invoices/{id}/refunds")(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: "createInvoiceRefund",
|
|
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.InvoiceRefund,
|
|
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.InvoiceRefund$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 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
|
+
* List Invoice Refunds
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* List the credit notes (refunds) recorded against an invoice. Accessible to the owning merchant or platform operators.
|
|
34
|
+
*/
|
|
35
|
+
export function invoicesV2ListInvoiceRefunds(
|
|
36
|
+
client: PaygenticCore,
|
|
37
|
+
request: operations.ListInvoiceRefundsRequest,
|
|
38
|
+
options?: RequestOptions,
|
|
39
|
+
): APIPromise<
|
|
40
|
+
Result<
|
|
41
|
+
models.InvoiceRefundList,
|
|
42
|
+
| errors.ErrorT
|
|
43
|
+
| PaygenticError
|
|
44
|
+
| ResponseValidationError
|
|
45
|
+
| ConnectionError
|
|
46
|
+
| RequestAbortedError
|
|
47
|
+
| RequestTimeoutError
|
|
48
|
+
| InvalidRequestError
|
|
49
|
+
| UnexpectedClientError
|
|
50
|
+
| SDKValidationError
|
|
51
|
+
>
|
|
52
|
+
> {
|
|
53
|
+
return new APIPromise($do(
|
|
54
|
+
client,
|
|
55
|
+
request,
|
|
56
|
+
options,
|
|
57
|
+
));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function $do(
|
|
61
|
+
client: PaygenticCore,
|
|
62
|
+
request: operations.ListInvoiceRefundsRequest,
|
|
63
|
+
options?: RequestOptions,
|
|
64
|
+
): Promise<
|
|
65
|
+
[
|
|
66
|
+
Result<
|
|
67
|
+
models.InvoiceRefundList,
|
|
68
|
+
| errors.ErrorT
|
|
69
|
+
| PaygenticError
|
|
70
|
+
| ResponseValidationError
|
|
71
|
+
| ConnectionError
|
|
72
|
+
| RequestAbortedError
|
|
73
|
+
| RequestTimeoutError
|
|
74
|
+
| InvalidRequestError
|
|
75
|
+
| UnexpectedClientError
|
|
76
|
+
| SDKValidationError
|
|
77
|
+
>,
|
|
78
|
+
APICall,
|
|
79
|
+
]
|
|
80
|
+
> {
|
|
81
|
+
const parsed = safeParse(
|
|
82
|
+
request,
|
|
83
|
+
(value) => operations.ListInvoiceRefundsRequest$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("/v2/invoices/{id}/refunds")(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: "listInvoiceRefunds",
|
|
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
|
+
models.InvoiceRefundList,
|
|
155
|
+
| errors.ErrorT
|
|
156
|
+
| PaygenticError
|
|
157
|
+
| ResponseValidationError
|
|
158
|
+
| ConnectionError
|
|
159
|
+
| RequestAbortedError
|
|
160
|
+
| RequestTimeoutError
|
|
161
|
+
| InvalidRequestError
|
|
162
|
+
| UnexpectedClientError
|
|
163
|
+
| SDKValidationError
|
|
164
|
+
>(
|
|
165
|
+
M.json(200, models.InvoiceRefundList$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
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
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
|
+
* Void Invoice Refund
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Void a previously-issued refund (credit note). Reverses the credit note in the tax provider and excludes it from revenue. Accessible to the owning merchant or platform operators.
|
|
34
|
+
*/
|
|
35
|
+
export function invoicesV2VoidInvoiceRefund(
|
|
36
|
+
client: PaygenticCore,
|
|
37
|
+
request: operations.VoidInvoiceRefundRequest,
|
|
38
|
+
options?: RequestOptions,
|
|
39
|
+
): APIPromise<
|
|
40
|
+
Result<
|
|
41
|
+
models.InvoiceRefund,
|
|
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.VoidInvoiceRefundRequest,
|
|
64
|
+
options?: RequestOptions,
|
|
65
|
+
): Promise<
|
|
66
|
+
[
|
|
67
|
+
Result<
|
|
68
|
+
models.InvoiceRefund,
|
|
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) => operations.VoidInvoiceRefundRequest$outboundSchema.parse(value),
|
|
86
|
+
"Input validation failed",
|
|
87
|
+
);
|
|
88
|
+
if (!parsed.ok) {
|
|
89
|
+
return [parsed, { status: "invalid" }];
|
|
90
|
+
}
|
|
91
|
+
const payload = parsed.value;
|
|
92
|
+
const body = encodeJSON("body", payload.RequestBody, { explode: true });
|
|
93
|
+
|
|
94
|
+
const pathParams = {
|
|
95
|
+
id: encodeSimple("id", payload.id, {
|
|
96
|
+
explode: false,
|
|
97
|
+
charEncoding: "percent",
|
|
98
|
+
}),
|
|
99
|
+
refundId: encodeSimple("refundId", payload.refundId, {
|
|
100
|
+
explode: false,
|
|
101
|
+
charEncoding: "percent",
|
|
102
|
+
}),
|
|
103
|
+
};
|
|
104
|
+
const path = pathToFunc("/v2/invoices/{id}/refunds/{refundId}/void")(
|
|
105
|
+
pathParams,
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const headers = new Headers(compactMap({
|
|
109
|
+
"Content-Type": "application/json",
|
|
110
|
+
Accept: "application/json",
|
|
111
|
+
}));
|
|
112
|
+
|
|
113
|
+
const secConfig = await extractSecurity(client._options.bearerAuth);
|
|
114
|
+
const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
|
|
115
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
116
|
+
|
|
117
|
+
const context = {
|
|
118
|
+
options: client._options,
|
|
119
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
120
|
+
operationID: "voidInvoiceRefund",
|
|
121
|
+
oAuth2Scopes: null,
|
|
122
|
+
|
|
123
|
+
resolvedSecurity: requestSecurity,
|
|
124
|
+
|
|
125
|
+
securitySource: client._options.bearerAuth,
|
|
126
|
+
retryConfig: options?.retries
|
|
127
|
+
|| client._options.retryConfig
|
|
128
|
+
|| { strategy: "none" },
|
|
129
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const requestRes = client._createRequest(context, {
|
|
133
|
+
security: requestSecurity,
|
|
134
|
+
method: "POST",
|
|
135
|
+
baseURL: options?.serverURL,
|
|
136
|
+
path: path,
|
|
137
|
+
headers: headers,
|
|
138
|
+
body: body,
|
|
139
|
+
userAgent: client._options.userAgent,
|
|
140
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
141
|
+
}, options);
|
|
142
|
+
if (!requestRes.ok) {
|
|
143
|
+
return [requestRes, { status: "invalid" }];
|
|
144
|
+
}
|
|
145
|
+
const req = requestRes.value;
|
|
146
|
+
|
|
147
|
+
const doResult = await client._do(req, {
|
|
148
|
+
context,
|
|
149
|
+
errorCodes: ["400", "403", "404", "4XX", "500", "5XX"],
|
|
150
|
+
retryConfig: context.retryConfig,
|
|
151
|
+
retryCodes: context.retryCodes,
|
|
152
|
+
});
|
|
153
|
+
if (!doResult.ok) {
|
|
154
|
+
return [doResult, { status: "request-error", request: req }];
|
|
155
|
+
}
|
|
156
|
+
const response = doResult.value;
|
|
157
|
+
|
|
158
|
+
const responseFields = {
|
|
159
|
+
HttpMeta: { Response: response, Request: req },
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const [result] = await M.match<
|
|
163
|
+
models.InvoiceRefund,
|
|
164
|
+
| errors.BadRequest
|
|
165
|
+
| errors.ErrorT
|
|
166
|
+
| PaygenticError
|
|
167
|
+
| ResponseValidationError
|
|
168
|
+
| ConnectionError
|
|
169
|
+
| RequestAbortedError
|
|
170
|
+
| RequestTimeoutError
|
|
171
|
+
| InvalidRequestError
|
|
172
|
+
| UnexpectedClientError
|
|
173
|
+
| SDKValidationError
|
|
174
|
+
>(
|
|
175
|
+
M.json(200, models.InvoiceRefund$inboundSchema),
|
|
176
|
+
M.jsonErr(400, errors.BadRequest$inboundSchema),
|
|
177
|
+
M.jsonErr([403, 404], errors.ErrorT$inboundSchema),
|
|
178
|
+
M.jsonErr(500, errors.ErrorT$inboundSchema),
|
|
179
|
+
M.fail("4XX"),
|
|
180
|
+
M.fail("5XX"),
|
|
181
|
+
)(response, req, { extraFields: responseFields });
|
|
182
|
+
if (!result.ok) {
|
|
183
|
+
return [result, { status: "complete", request: req, response }];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return [result, { status: "complete", request: req, response }];
|
|
187
|
+
}
|
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.19",
|
|
69
69
|
genVersion: "2.879.13",
|
|
70
|
-
userAgent: "speakeasy-sdk/typescript 0.7.
|
|
70
|
+
userAgent: "speakeasy-sdk/typescript 0.7.19 2.879.13 0.1.0 @paygentic/sdk",
|
|
71
71
|
} as const;
|
package/src/models/index.ts
CHANGED
|
@@ -33,6 +33,8 @@ export * from "./invoice.js";
|
|
|
33
33
|
export * from "./invoicecategorysummary.js";
|
|
34
34
|
export * from "./invoicelineitem.js";
|
|
35
35
|
export * from "./invoicelineitemsresponse.js";
|
|
36
|
+
export * from "./invoicerefund.js";
|
|
37
|
+
export * from "./invoicerefundlist.js";
|
|
36
38
|
export * from "./invoicesummary.js";
|
|
37
39
|
export * from "./issueentitlementrequest.js";
|
|
38
40
|
export * from "./item.js";
|
|
@@ -0,0 +1,140 @@
|
|
|
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
|
+
/**
|
|
12
|
+
* The object type
|
|
13
|
+
*/
|
|
14
|
+
export const InvoiceRefundObject = {
|
|
15
|
+
InvoiceRefund: "invoice_refund",
|
|
16
|
+
} as const;
|
|
17
|
+
/**
|
|
18
|
+
* The object type
|
|
19
|
+
*/
|
|
20
|
+
export type InvoiceRefundObject = ClosedEnum<typeof InvoiceRefundObject>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Credit note status
|
|
24
|
+
*/
|
|
25
|
+
export const InvoiceRefundStatus = {
|
|
26
|
+
Issued: "ISSUED",
|
|
27
|
+
Voided: "VOIDED",
|
|
28
|
+
} as const;
|
|
29
|
+
/**
|
|
30
|
+
* Credit note status
|
|
31
|
+
*/
|
|
32
|
+
export type InvoiceRefundStatus = ClosedEnum<typeof InvoiceRefundStatus>;
|
|
33
|
+
|
|
34
|
+
export type InvoiceRefund = {
|
|
35
|
+
/**
|
|
36
|
+
* The object type
|
|
37
|
+
*/
|
|
38
|
+
object: InvoiceRefundObject;
|
|
39
|
+
/**
|
|
40
|
+
* The credit note ID (crn_*)
|
|
41
|
+
*/
|
|
42
|
+
id: string;
|
|
43
|
+
/**
|
|
44
|
+
* The invoice this refund credits
|
|
45
|
+
*/
|
|
46
|
+
invoiceId: string;
|
|
47
|
+
/**
|
|
48
|
+
* The merchant that owns the invoice
|
|
49
|
+
*/
|
|
50
|
+
merchantId: string;
|
|
51
|
+
/**
|
|
52
|
+
* Refunded subtotal (pre-tax) in decimal dollars
|
|
53
|
+
*/
|
|
54
|
+
amount: string;
|
|
55
|
+
/**
|
|
56
|
+
* Reversed tax in decimal dollars
|
|
57
|
+
*/
|
|
58
|
+
taxAmount: string;
|
|
59
|
+
/**
|
|
60
|
+
* Total refunded (amount + taxAmount) in decimal dollars
|
|
61
|
+
*/
|
|
62
|
+
total: string;
|
|
63
|
+
/**
|
|
64
|
+
* ISO 4217 currency code
|
|
65
|
+
*/
|
|
66
|
+
currency: string;
|
|
67
|
+
/**
|
|
68
|
+
* Credit note status
|
|
69
|
+
*/
|
|
70
|
+
status: InvoiceRefundStatus;
|
|
71
|
+
/**
|
|
72
|
+
* Credit note id in the tax provider
|
|
73
|
+
*/
|
|
74
|
+
externalCreditNoteId: string;
|
|
75
|
+
/**
|
|
76
|
+
* Public URL to view the credit note document
|
|
77
|
+
*/
|
|
78
|
+
permalink?: string | null | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Direct PDF download link
|
|
81
|
+
*/
|
|
82
|
+
pdfUrl?: string | null | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Optional refund reason
|
|
85
|
+
*/
|
|
86
|
+
reason?: string | null | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* When the refund was issued
|
|
89
|
+
*/
|
|
90
|
+
createdAt: Date;
|
|
91
|
+
/**
|
|
92
|
+
* When the refund was voided, if applicable
|
|
93
|
+
*/
|
|
94
|
+
voidedAt?: Date | null | undefined;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/** @internal */
|
|
98
|
+
export const InvoiceRefundObject$inboundSchema: z.ZodNativeEnum<
|
|
99
|
+
typeof InvoiceRefundObject
|
|
100
|
+
> = z.nativeEnum(InvoiceRefundObject);
|
|
101
|
+
|
|
102
|
+
/** @internal */
|
|
103
|
+
export const InvoiceRefundStatus$inboundSchema: z.ZodNativeEnum<
|
|
104
|
+
typeof InvoiceRefundStatus
|
|
105
|
+
> = z.nativeEnum(InvoiceRefundStatus);
|
|
106
|
+
|
|
107
|
+
/** @internal */
|
|
108
|
+
export const InvoiceRefund$inboundSchema: z.ZodType<
|
|
109
|
+
InvoiceRefund,
|
|
110
|
+
z.ZodTypeDef,
|
|
111
|
+
unknown
|
|
112
|
+
> = z.object({
|
|
113
|
+
object: InvoiceRefundObject$inboundSchema,
|
|
114
|
+
id: z.string(),
|
|
115
|
+
invoiceId: z.string(),
|
|
116
|
+
merchantId: z.string(),
|
|
117
|
+
amount: z.string(),
|
|
118
|
+
taxAmount: z.string(),
|
|
119
|
+
total: z.string(),
|
|
120
|
+
currency: z.string(),
|
|
121
|
+
status: InvoiceRefundStatus$inboundSchema,
|
|
122
|
+
externalCreditNoteId: z.string(),
|
|
123
|
+
permalink: z.nullable(z.string()).optional(),
|
|
124
|
+
pdfUrl: z.nullable(z.string()).optional(),
|
|
125
|
+
reason: z.nullable(z.string()).optional(),
|
|
126
|
+
createdAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
|
|
127
|
+
voidedAt: z.nullable(
|
|
128
|
+
z.string().datetime({ offset: true }).transform(v => new Date(v)),
|
|
129
|
+
).optional(),
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
export function invoiceRefundFromJSON(
|
|
133
|
+
jsonString: string,
|
|
134
|
+
): SafeParseResult<InvoiceRefund, SDKValidationError> {
|
|
135
|
+
return safeParse(
|
|
136
|
+
jsonString,
|
|
137
|
+
(x) => InvoiceRefund$inboundSchema.parse(JSON.parse(x)),
|
|
138
|
+
`Failed to parse 'InvoiceRefund' from JSON`,
|
|
139
|
+
);
|
|
140
|
+
}
|