@gr4vy/sdk 1.1.38 → 1.1.39

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 (48) hide show
  1. package/README.md +2 -0
  2. package/docs/sdks/transactions/README.md +94 -0
  3. package/funcs/transactionsCancel.d.ts +18 -0
  4. package/funcs/transactionsCancel.d.ts.map +1 -0
  5. package/funcs/transactionsCancel.js +144 -0
  6. package/funcs/transactionsCancel.js.map +1 -0
  7. package/jsr.json +1 -1
  8. package/lib/config.d.ts +3 -3
  9. package/lib/config.js +3 -3
  10. package/lib/config.js.map +1 -1
  11. package/models/components/cancelstatus.d.ts +23 -0
  12. package/models/components/cancelstatus.d.ts.map +1 -0
  13. package/models/components/cancelstatus.js +69 -0
  14. package/models/components/cancelstatus.js.map +1 -0
  15. package/models/components/index.d.ts +2 -0
  16. package/models/components/index.d.ts.map +1 -1
  17. package/models/components/index.js +2 -0
  18. package/models/components/index.js.map +1 -1
  19. package/models/components/transactioncancel.d.ts +56 -0
  20. package/models/components/transactioncancel.d.ts.map +1 -0
  21. package/models/components/transactioncancel.js +92 -0
  22. package/models/components/transactioncancel.js.map +1 -0
  23. package/models/components/transactionevent.d.ts +1 -0
  24. package/models/components/transactionevent.d.ts.map +1 -1
  25. package/models/components/transactionevent.js +1 -0
  26. package/models/components/transactionevent.js.map +1 -1
  27. package/models/operations/canceltransaction.d.ts +62 -0
  28. package/models/operations/canceltransaction.d.ts.map +1 -0
  29. package/models/operations/canceltransaction.js +107 -0
  30. package/models/operations/canceltransaction.js.map +1 -0
  31. package/models/operations/index.d.ts +1 -0
  32. package/models/operations/index.d.ts.map +1 -1
  33. package/models/operations/index.js +1 -0
  34. package/models/operations/index.js.map +1 -1
  35. package/package.json +1 -1
  36. package/sdk/transactions.d.ts +7 -0
  37. package/sdk/transactions.d.ts.map +1 -1
  38. package/sdk/transactions.js +10 -0
  39. package/sdk/transactions.js.map +1 -1
  40. package/src/funcs/transactionsCancel.ts +248 -0
  41. package/src/lib/config.ts +3 -3
  42. package/src/models/components/cancelstatus.ts +49 -0
  43. package/src/models/components/index.ts +2 -0
  44. package/src/models/components/transactioncancel.ts +123 -0
  45. package/src/models/components/transactionevent.ts +2 -0
  46. package/src/models/operations/canceltransaction.ts +143 -0
  47. package/src/models/operations/index.ts +1 -0
  48. package/src/sdk/transactions.ts +20 -0
@@ -0,0 +1,248 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { Gr4vyCore } 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 * as components from "../models/components/index.js";
14
+ import { Gr4vyError } from "../models/errors/gr4vyerror.js";
15
+ import {
16
+ ConnectionError,
17
+ InvalidRequestError,
18
+ RequestAbortedError,
19
+ RequestTimeoutError,
20
+ UnexpectedClientError,
21
+ } from "../models/errors/httpclienterrors.js";
22
+ import * as errors from "../models/errors/index.js";
23
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
24
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.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
+ * Cancel transaction
31
+ *
32
+ * @remarks
33
+ * Cancels a pending transaction. If the transaction was successfully authorized, or was already captured, the cancel will not be processed.
34
+ */
35
+ export function transactionsCancel(
36
+ client: Gr4vyCore,
37
+ transactionId: string,
38
+ merchantAccountId?: string | null | undefined,
39
+ options?: RequestOptions,
40
+ ): APIPromise<
41
+ Result<
42
+ components.TransactionCancel,
43
+ | errors.Error400
44
+ | errors.Error401
45
+ | errors.Error403
46
+ | errors.Error404
47
+ | errors.Error405
48
+ | errors.Error409
49
+ | errors.HTTPValidationError
50
+ | errors.Error425
51
+ | errors.Error429
52
+ | errors.Error500
53
+ | errors.Error502
54
+ | errors.Error504
55
+ | Gr4vyError
56
+ | ResponseValidationError
57
+ | ConnectionError
58
+ | RequestAbortedError
59
+ | RequestTimeoutError
60
+ | InvalidRequestError
61
+ | UnexpectedClientError
62
+ | SDKValidationError
63
+ >
64
+ > {
65
+ return new APIPromise($do(
66
+ client,
67
+ transactionId,
68
+ merchantAccountId,
69
+ options,
70
+ ));
71
+ }
72
+
73
+ async function $do(
74
+ client: Gr4vyCore,
75
+ transactionId: string,
76
+ merchantAccountId?: string | null | undefined,
77
+ options?: RequestOptions,
78
+ ): Promise<
79
+ [
80
+ Result<
81
+ components.TransactionCancel,
82
+ | errors.Error400
83
+ | errors.Error401
84
+ | errors.Error403
85
+ | errors.Error404
86
+ | errors.Error405
87
+ | errors.Error409
88
+ | errors.HTTPValidationError
89
+ | errors.Error425
90
+ | errors.Error429
91
+ | errors.Error500
92
+ | errors.Error502
93
+ | errors.Error504
94
+ | Gr4vyError
95
+ | ResponseValidationError
96
+ | ConnectionError
97
+ | RequestAbortedError
98
+ | RequestTimeoutError
99
+ | InvalidRequestError
100
+ | UnexpectedClientError
101
+ | SDKValidationError
102
+ >,
103
+ APICall,
104
+ ]
105
+ > {
106
+ const input: operations.CancelTransactionRequest = {
107
+ transactionId: transactionId,
108
+ merchantAccountId: merchantAccountId,
109
+ };
110
+
111
+ const parsed = safeParse(
112
+ input,
113
+ (value) => operations.CancelTransactionRequest$outboundSchema.parse(value),
114
+ "Input validation failed",
115
+ );
116
+ if (!parsed.ok) {
117
+ return [parsed, { status: "invalid" }];
118
+ }
119
+ const payload = parsed.value;
120
+ const body = null;
121
+
122
+ const pathParams = {
123
+ transaction_id: encodeSimple("transaction_id", payload.transaction_id, {
124
+ explode: false,
125
+ charEncoding: "percent",
126
+ }),
127
+ };
128
+
129
+ const path = pathToFunc("/transactions/{transaction_id}/cancel")(pathParams);
130
+
131
+ const headers = new Headers(compactMap({
132
+ Accept: "application/json",
133
+ "x-gr4vy-merchant-account-id": encodeSimple(
134
+ "x-gr4vy-merchant-account-id",
135
+ payload.merchantAccountId ?? client._options.merchantAccountId,
136
+ { explode: false, charEncoding: "none" },
137
+ ),
138
+ }));
139
+
140
+ const secConfig = await extractSecurity(client._options.bearerAuth);
141
+ const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
142
+ const requestSecurity = resolveGlobalSecurity(securityInput);
143
+
144
+ const context = {
145
+ options: client._options,
146
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
147
+ operationID: "cancel_transaction",
148
+ oAuth2Scopes: [],
149
+
150
+ resolvedSecurity: requestSecurity,
151
+
152
+ securitySource: client._options.bearerAuth,
153
+ retryConfig: options?.retries
154
+ || client._options.retryConfig
155
+ || { strategy: "none" },
156
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
157
+ };
158
+
159
+ const requestRes = client._createRequest(context, {
160
+ security: requestSecurity,
161
+ method: "POST",
162
+ baseURL: options?.serverURL,
163
+ path: path,
164
+ headers: headers,
165
+ body: body,
166
+ userAgent: client._options.userAgent,
167
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
168
+ }, options);
169
+ if (!requestRes.ok) {
170
+ return [requestRes, { status: "invalid" }];
171
+ }
172
+ const req = requestRes.value;
173
+
174
+ const doResult = await client._do(req, {
175
+ context,
176
+ errorCodes: [
177
+ "400",
178
+ "401",
179
+ "403",
180
+ "404",
181
+ "405",
182
+ "409",
183
+ "422",
184
+ "425",
185
+ "429",
186
+ "4XX",
187
+ "500",
188
+ "502",
189
+ "504",
190
+ "5XX",
191
+ ],
192
+ retryConfig: context.retryConfig,
193
+ retryCodes: context.retryCodes,
194
+ });
195
+ if (!doResult.ok) {
196
+ return [doResult, { status: "request-error", request: req }];
197
+ }
198
+ const response = doResult.value;
199
+
200
+ const responseFields = {
201
+ HttpMeta: { Response: response, Request: req },
202
+ };
203
+
204
+ const [result] = await M.match<
205
+ components.TransactionCancel,
206
+ | errors.Error400
207
+ | errors.Error401
208
+ | errors.Error403
209
+ | errors.Error404
210
+ | errors.Error405
211
+ | errors.Error409
212
+ | errors.HTTPValidationError
213
+ | errors.Error425
214
+ | errors.Error429
215
+ | errors.Error500
216
+ | errors.Error502
217
+ | errors.Error504
218
+ | Gr4vyError
219
+ | ResponseValidationError
220
+ | ConnectionError
221
+ | RequestAbortedError
222
+ | RequestTimeoutError
223
+ | InvalidRequestError
224
+ | UnexpectedClientError
225
+ | SDKValidationError
226
+ >(
227
+ M.json(200, components.TransactionCancel$inboundSchema),
228
+ M.jsonErr(400, errors.Error400$inboundSchema),
229
+ M.jsonErr(401, errors.Error401$inboundSchema),
230
+ M.jsonErr(403, errors.Error403$inboundSchema),
231
+ M.jsonErr(404, errors.Error404$inboundSchema),
232
+ M.jsonErr(405, errors.Error405$inboundSchema),
233
+ M.jsonErr(409, errors.Error409$inboundSchema),
234
+ M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
235
+ M.jsonErr(425, errors.Error425$inboundSchema),
236
+ M.jsonErr(429, errors.Error429$inboundSchema),
237
+ M.jsonErr(500, errors.Error500$inboundSchema),
238
+ M.jsonErr(502, errors.Error502$inboundSchema),
239
+ M.jsonErr(504, errors.Error504$inboundSchema),
240
+ M.fail("4XX"),
241
+ M.fail("5XX"),
242
+ )(response, req, { extraFields: responseFields });
243
+ if (!result.ok) {
244
+ return [result, { status: "complete", request: req, response }];
245
+ }
246
+
247
+ return [result, { status: "complete", request: req, response }];
248
+ }
package/src/lib/config.ts CHANGED
@@ -77,7 +77,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
77
77
  export const SDK_METADATA = {
78
78
  language: "typescript",
79
79
  openapiDocVersion: "1.0.0",
80
- sdkVersion: "1.1.38",
81
- genVersion: "2.686.7",
82
- userAgent: "speakeasy-sdk/typescript 1.1.38 2.686.7 1.0.0 @gr4vy/sdk",
80
+ sdkVersion: "1.1.39",
81
+ genVersion: "2.687.13",
82
+ userAgent: "speakeasy-sdk/typescript 1.1.39 2.687.13 1.0.0 @gr4vy/sdk",
83
83
  } as const;
@@ -0,0 +1,49 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod";
6
+ import {
7
+ catchUnrecognizedEnum,
8
+ OpenEnum,
9
+ Unrecognized,
10
+ } from "../../types/enums.js";
11
+
12
+ export const CancelStatus = {
13
+ Succeeded: "succeeded",
14
+ Pending: "pending",
15
+ Failed: "failed",
16
+ } as const;
17
+ export type CancelStatus = OpenEnum<typeof CancelStatus>;
18
+
19
+ /** @internal */
20
+ export const CancelStatus$inboundSchema: z.ZodType<
21
+ CancelStatus,
22
+ z.ZodTypeDef,
23
+ unknown
24
+ > = z
25
+ .union([
26
+ z.nativeEnum(CancelStatus),
27
+ z.string().transform(catchUnrecognizedEnum),
28
+ ]);
29
+
30
+ /** @internal */
31
+ export const CancelStatus$outboundSchema: z.ZodType<
32
+ CancelStatus,
33
+ z.ZodTypeDef,
34
+ CancelStatus
35
+ > = z.union([
36
+ z.nativeEnum(CancelStatus),
37
+ z.string().and(z.custom<Unrecognized<string>>()),
38
+ ]);
39
+
40
+ /**
41
+ * @internal
42
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
43
+ */
44
+ export namespace CancelStatus$ {
45
+ /** @deprecated use `CancelStatus$inboundSchema` instead. */
46
+ export const inboundSchema = CancelStatus$inboundSchema;
47
+ /** @deprecated use `CancelStatus$outboundSchema` instead. */
48
+ export const outboundSchema = CancelStatus$outboundSchema;
49
+ }
@@ -38,6 +38,7 @@ export * from "./buyer.js";
38
38
  export * from "./buyercreate.js";
39
39
  export * from "./buyers.js";
40
40
  export * from "./buyerupdate.js";
41
+ export * from "./cancelstatus.js";
41
42
  export * from "./capturestatus.js";
42
43
  export * from "./cardpaymentmethodcreate.js";
43
44
  export * from "./cardscheme.js";
@@ -220,6 +221,7 @@ export * from "./threedsecurev2.js";
220
221
  export * from "./tokenpaymentmethodcreate.js";
221
222
  export * from "./transaction.js";
222
223
  export * from "./transactionbuyer.js";
224
+ export * from "./transactioncancel.js";
223
225
  export * from "./transactioncapture.js";
224
226
  export * from "./transactioncapturecreate.js";
225
227
  export * from "./transactionconnectionoptions.js";
@@ -0,0 +1,123 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { safeParse } from "../../lib/schemas.js";
8
+ import { Result as SafeParseResult } from "../../types/fp.js";
9
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
+ import {
11
+ CancelStatus,
12
+ CancelStatus$inboundSchema,
13
+ CancelStatus$outboundSchema,
14
+ } from "./cancelstatus.js";
15
+ import {
16
+ Transaction,
17
+ Transaction$inboundSchema,
18
+ Transaction$Outbound,
19
+ Transaction$outboundSchema,
20
+ } from "./transaction.js";
21
+
22
+ export type TransactionCancel = {
23
+ /**
24
+ * Always `transaction-cancel`.
25
+ */
26
+ type?: "transaction-cancel" | undefined;
27
+ status: CancelStatus;
28
+ /**
29
+ * The standardized error code set by Gr4vy.
30
+ */
31
+ code: string | null;
32
+ /**
33
+ * This is the response code received from the payment service. This can be set to any value and is not standardized across different payment services.
34
+ */
35
+ rawResponseCode: string | null;
36
+ /**
37
+ * This is the response description received from the payment service. This can be set to any value and is not standardized across different payment services.
38
+ */
39
+ rawResponseDescription: string | null;
40
+ /**
41
+ * A full transaction resource.
42
+ */
43
+ transaction: Transaction;
44
+ };
45
+
46
+ /** @internal */
47
+ export const TransactionCancel$inboundSchema: z.ZodType<
48
+ TransactionCancel,
49
+ z.ZodTypeDef,
50
+ unknown
51
+ > = z.object({
52
+ type: z.literal("transaction-cancel").default("transaction-cancel"),
53
+ status: CancelStatus$inboundSchema,
54
+ code: z.nullable(z.string()),
55
+ raw_response_code: z.nullable(z.string()),
56
+ raw_response_description: z.nullable(z.string()),
57
+ transaction: Transaction$inboundSchema,
58
+ }).transform((v) => {
59
+ return remap$(v, {
60
+ "raw_response_code": "rawResponseCode",
61
+ "raw_response_description": "rawResponseDescription",
62
+ });
63
+ });
64
+
65
+ /** @internal */
66
+ export type TransactionCancel$Outbound = {
67
+ type: "transaction-cancel";
68
+ status: string;
69
+ code: string | null;
70
+ raw_response_code: string | null;
71
+ raw_response_description: string | null;
72
+ transaction: Transaction$Outbound;
73
+ };
74
+
75
+ /** @internal */
76
+ export const TransactionCancel$outboundSchema: z.ZodType<
77
+ TransactionCancel$Outbound,
78
+ z.ZodTypeDef,
79
+ TransactionCancel
80
+ > = z.object({
81
+ type: z.literal("transaction-cancel").default("transaction-cancel" as const),
82
+ status: CancelStatus$outboundSchema,
83
+ code: z.nullable(z.string()),
84
+ rawResponseCode: z.nullable(z.string()),
85
+ rawResponseDescription: z.nullable(z.string()),
86
+ transaction: Transaction$outboundSchema,
87
+ }).transform((v) => {
88
+ return remap$(v, {
89
+ rawResponseCode: "raw_response_code",
90
+ rawResponseDescription: "raw_response_description",
91
+ });
92
+ });
93
+
94
+ /**
95
+ * @internal
96
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
97
+ */
98
+ export namespace TransactionCancel$ {
99
+ /** @deprecated use `TransactionCancel$inboundSchema` instead. */
100
+ export const inboundSchema = TransactionCancel$inboundSchema;
101
+ /** @deprecated use `TransactionCancel$outboundSchema` instead. */
102
+ export const outboundSchema = TransactionCancel$outboundSchema;
103
+ /** @deprecated use `TransactionCancel$Outbound` instead. */
104
+ export type Outbound = TransactionCancel$Outbound;
105
+ }
106
+
107
+ export function transactionCancelToJSON(
108
+ transactionCancel: TransactionCancel,
109
+ ): string {
110
+ return JSON.stringify(
111
+ TransactionCancel$outboundSchema.parse(transactionCancel),
112
+ );
113
+ }
114
+
115
+ export function transactionCancelFromJSON(
116
+ jsonString: string,
117
+ ): SafeParseResult<TransactionCancel, SDKValidationError> {
118
+ return safeParse(
119
+ jsonString,
120
+ (x) => TransactionCancel$inboundSchema.parse(JSON.parse(x)),
121
+ `Failed to parse 'TransactionCancel' from JSON`,
122
+ );
123
+ }
@@ -57,6 +57,8 @@ export const Name = {
57
57
  "payment-connector-response-transaction-capture-declined",
58
58
  PaymentConnectorResponseTransactionCancelSucceeded:
59
59
  "payment-connector-response-transaction-cancel-succeeded",
60
+ PaymentConnectorResponseTransactionCancelPending:
61
+ "payment-connector-response-transaction-cancel-pending",
60
62
  PaymentConnectorResponseTransactionCancelFailed:
61
63
  "payment-connector-response-transaction-cancel-failed",
62
64
  PaymentConnectorResponseTransactionVoidSucceeded:
@@ -0,0 +1,143 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { safeParse } from "../../lib/schemas.js";
8
+ import { Result as SafeParseResult } from "../../types/fp.js";
9
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
+
11
+ export type CancelTransactionGlobals = {
12
+ merchantAccountId?: string | undefined;
13
+ };
14
+
15
+ export type CancelTransactionRequest = {
16
+ /**
17
+ * The ID of the transaction
18
+ */
19
+ transactionId: string;
20
+ /**
21
+ * The ID of the merchant account to use for this request.
22
+ */
23
+ merchantAccountId?: string | null | undefined;
24
+ };
25
+
26
+ /** @internal */
27
+ export const CancelTransactionGlobals$inboundSchema: z.ZodType<
28
+ CancelTransactionGlobals,
29
+ z.ZodTypeDef,
30
+ unknown
31
+ > = z.object({
32
+ merchantAccountId: z.string().optional(),
33
+ });
34
+
35
+ /** @internal */
36
+ export type CancelTransactionGlobals$Outbound = {
37
+ merchantAccountId?: string | undefined;
38
+ };
39
+
40
+ /** @internal */
41
+ export const CancelTransactionGlobals$outboundSchema: z.ZodType<
42
+ CancelTransactionGlobals$Outbound,
43
+ z.ZodTypeDef,
44
+ CancelTransactionGlobals
45
+ > = z.object({
46
+ merchantAccountId: z.string().optional(),
47
+ });
48
+
49
+ /**
50
+ * @internal
51
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
52
+ */
53
+ export namespace CancelTransactionGlobals$ {
54
+ /** @deprecated use `CancelTransactionGlobals$inboundSchema` instead. */
55
+ export const inboundSchema = CancelTransactionGlobals$inboundSchema;
56
+ /** @deprecated use `CancelTransactionGlobals$outboundSchema` instead. */
57
+ export const outboundSchema = CancelTransactionGlobals$outboundSchema;
58
+ /** @deprecated use `CancelTransactionGlobals$Outbound` instead. */
59
+ export type Outbound = CancelTransactionGlobals$Outbound;
60
+ }
61
+
62
+ export function cancelTransactionGlobalsToJSON(
63
+ cancelTransactionGlobals: CancelTransactionGlobals,
64
+ ): string {
65
+ return JSON.stringify(
66
+ CancelTransactionGlobals$outboundSchema.parse(cancelTransactionGlobals),
67
+ );
68
+ }
69
+
70
+ export function cancelTransactionGlobalsFromJSON(
71
+ jsonString: string,
72
+ ): SafeParseResult<CancelTransactionGlobals, SDKValidationError> {
73
+ return safeParse(
74
+ jsonString,
75
+ (x) => CancelTransactionGlobals$inboundSchema.parse(JSON.parse(x)),
76
+ `Failed to parse 'CancelTransactionGlobals' from JSON`,
77
+ );
78
+ }
79
+
80
+ /** @internal */
81
+ export const CancelTransactionRequest$inboundSchema: z.ZodType<
82
+ CancelTransactionRequest,
83
+ z.ZodTypeDef,
84
+ unknown
85
+ > = z.object({
86
+ transaction_id: z.string(),
87
+ merchantAccountId: z.nullable(z.string()).optional(),
88
+ }).transform((v) => {
89
+ return remap$(v, {
90
+ "transaction_id": "transactionId",
91
+ });
92
+ });
93
+
94
+ /** @internal */
95
+ export type CancelTransactionRequest$Outbound = {
96
+ transaction_id: string;
97
+ merchantAccountId?: string | null | undefined;
98
+ };
99
+
100
+ /** @internal */
101
+ export const CancelTransactionRequest$outboundSchema: z.ZodType<
102
+ CancelTransactionRequest$Outbound,
103
+ z.ZodTypeDef,
104
+ CancelTransactionRequest
105
+ > = z.object({
106
+ transactionId: z.string(),
107
+ merchantAccountId: z.nullable(z.string()).optional(),
108
+ }).transform((v) => {
109
+ return remap$(v, {
110
+ transactionId: "transaction_id",
111
+ });
112
+ });
113
+
114
+ /**
115
+ * @internal
116
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
117
+ */
118
+ export namespace CancelTransactionRequest$ {
119
+ /** @deprecated use `CancelTransactionRequest$inboundSchema` instead. */
120
+ export const inboundSchema = CancelTransactionRequest$inboundSchema;
121
+ /** @deprecated use `CancelTransactionRequest$outboundSchema` instead. */
122
+ export const outboundSchema = CancelTransactionRequest$outboundSchema;
123
+ /** @deprecated use `CancelTransactionRequest$Outbound` instead. */
124
+ export type Outbound = CancelTransactionRequest$Outbound;
125
+ }
126
+
127
+ export function cancelTransactionRequestToJSON(
128
+ cancelTransactionRequest: CancelTransactionRequest,
129
+ ): string {
130
+ return JSON.stringify(
131
+ CancelTransactionRequest$outboundSchema.parse(cancelTransactionRequest),
132
+ );
133
+ }
134
+
135
+ export function cancelTransactionRequestFromJSON(
136
+ jsonString: string,
137
+ ): SafeParseResult<CancelTransactionRequest, SDKValidationError> {
138
+ return safeParse(
139
+ jsonString,
140
+ (x) => CancelTransactionRequest$inboundSchema.parse(JSON.parse(x)),
141
+ `Failed to parse 'CancelTransactionRequest' from JSON`,
142
+ );
143
+ }
@@ -6,6 +6,7 @@ export * from "./addbuyer.js";
6
6
  export * from "./addbuyershippingdetails.js";
7
7
  export * from "./addpaymentlink.js";
8
8
  export * from "./addreport.js";
9
+ export * from "./canceltransaction.js";
9
10
  export * from "./capturetransaction.js";
10
11
  export * from "./configuredigitalwallet.js";
11
12
  export * from "./createaccountupdaterjob.js";
@@ -2,6 +2,7 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  */
4
4
 
5
+ import { transactionsCancel } from "../funcs/transactionsCancel.js";
5
6
  import { transactionsCapture } from "../funcs/transactionsCapture.js";
6
7
  import { transactionsCreate } from "../funcs/transactionsCreate.js";
7
8
  import { transactionsGet } from "../funcs/transactionsGet.js";
@@ -160,6 +161,25 @@ export class Transactions extends ClientSDK {
160
161
  ));
161
162
  }
162
163
 
164
+ /**
165
+ * Cancel transaction
166
+ *
167
+ * @remarks
168
+ * Cancels a pending transaction. If the transaction was successfully authorized, or was already captured, the cancel will not be processed.
169
+ */
170
+ async cancel(
171
+ transactionId: string,
172
+ merchantAccountId?: string | null | undefined,
173
+ options?: RequestOptions,
174
+ ): Promise<components.TransactionCancel> {
175
+ return unwrapAsync(transactionsCancel(
176
+ this,
177
+ transactionId,
178
+ merchantAccountId,
179
+ options,
180
+ ));
181
+ }
182
+
163
183
  /**
164
184
  * Sync transaction
165
185
  *