@gr4vy/sdk 1.1.12 → 1.1.14
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 +4 -4
- package/docs/sdks/paymentservicedefinitions/README.md +1 -1
- package/docs/sdks/paymentservices/README.md +1 -1
- package/docs/sdks/transactions/README.md +3 -2
- package/funcs/paymentServiceDefinitionsSession.d.ts +1 -1
- package/funcs/paymentServiceDefinitionsSession.js +1 -1
- package/funcs/paymentServicesSession.d.ts +1 -1
- package/funcs/paymentServicesSession.js +1 -1
- package/funcs/transactionsCapture.d.ts +2 -1
- package/funcs/transactionsCapture.d.ts.map +1 -1
- package/funcs/transactionsCapture.js +11 -7
- package/funcs/transactionsCapture.js.map +1 -1
- package/jsr.json +1 -1
- package/lib/config.d.ts +3 -3
- package/lib/config.js +3 -3
- package/models/components/capturestatus.d.ts +24 -0
- package/models/components/capturestatus.d.ts.map +1 -0
- package/models/components/capturestatus.js +60 -0
- package/models/components/capturestatus.js.map +1 -0
- package/models/components/index.d.ts +2 -0
- package/models/components/index.d.ts.map +1 -1
- package/models/components/index.js +2 -0
- package/models/components/index.js.map +1 -1
- package/models/components/transactioncapture.d.ts +25 -10
- package/models/components/transactioncapture.d.ts.map +1 -1
- package/models/components/transactioncapture.js +25 -5
- package/models/components/transactioncapture.js.map +1 -1
- package/models/components/transactioncapturecreate.d.ts +41 -0
- package/models/components/transactioncapturecreate.d.ts.map +1 -0
- package/models/components/transactioncapturecreate.js +62 -0
- package/models/components/transactioncapturecreate.js.map +1 -0
- package/models/operations/capturetransaction.d.ts +31 -2
- package/models/operations/capturetransaction.d.ts.map +1 -1
- package/models/operations/capturetransaction.js +36 -5
- package/models/operations/capturetransaction.js.map +1 -1
- package/package.json +1 -1
- package/sdk/paymentservicedefinitions.d.ts +1 -1
- package/sdk/paymentservicedefinitions.js +1 -1
- package/sdk/paymentservices.d.ts +1 -1
- package/sdk/paymentservices.js +1 -1
- package/sdk/transactions.d.ts +1 -1
- package/sdk/transactions.d.ts.map +1 -1
- package/sdk/transactions.js +2 -2
- package/sdk/transactions.js.map +1 -1
- package/src/funcs/paymentServiceDefinitionsSession.ts +1 -1
- package/src/funcs/paymentServicesSession.ts +1 -1
- package/src/funcs/transactionsCapture.ts +20 -9
- package/src/lib/config.ts +3 -3
- package/src/models/components/capturestatus.ts +50 -0
- package/src/models/components/index.ts +2 -0
- package/src/models/components/transactioncapture.ts +58 -18
- package/src/models/components/transactioncapturecreate.ts +85 -0
- package/src/models/operations/capturetransaction.ts +89 -6
- package/src/sdk/paymentservicedefinitions.ts +1 -1
- package/src/sdk/paymentservices.ts +1 -1
- package/src/sdk/transactions.ts +5 -3
|
@@ -3,28 +3,44 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import * as z from "zod";
|
|
6
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
6
7
|
import { safeParse } from "../../lib/schemas.js";
|
|
7
8
|
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
8
9
|
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
9
10
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
CaptureStatus,
|
|
12
|
+
CaptureStatus$inboundSchema,
|
|
13
|
+
CaptureStatus$outboundSchema,
|
|
14
|
+
} from "./capturestatus.js";
|
|
15
|
+
import {
|
|
16
|
+
Transaction,
|
|
17
|
+
Transaction$inboundSchema,
|
|
18
|
+
Transaction$Outbound,
|
|
19
|
+
Transaction$outboundSchema,
|
|
20
|
+
} from "./transaction.js";
|
|
15
21
|
|
|
16
|
-
/**
|
|
17
|
-
* Request body for capturing an authorized transaction.
|
|
18
|
-
*/
|
|
19
22
|
export type TransactionCapture = {
|
|
20
23
|
/**
|
|
21
|
-
*
|
|
24
|
+
* Always `transaction-capture`.
|
|
25
|
+
*/
|
|
26
|
+
type?: "transaction-capture" | undefined;
|
|
27
|
+
status: CaptureStatus;
|
|
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.
|
|
22
38
|
*/
|
|
23
|
-
|
|
39
|
+
rawResponseDescription: string | null;
|
|
24
40
|
/**
|
|
25
|
-
*
|
|
41
|
+
* A full transaction resource.
|
|
26
42
|
*/
|
|
27
|
-
|
|
43
|
+
transaction: Transaction;
|
|
28
44
|
};
|
|
29
45
|
|
|
30
46
|
/** @internal */
|
|
@@ -33,14 +49,27 @@ export const TransactionCapture$inboundSchema: z.ZodType<
|
|
|
33
49
|
z.ZodTypeDef,
|
|
34
50
|
unknown
|
|
35
51
|
> = z.object({
|
|
36
|
-
|
|
37
|
-
|
|
52
|
+
type: z.literal("transaction-capture").default("transaction-capture"),
|
|
53
|
+
status: CaptureStatus$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
|
+
});
|
|
38
63
|
});
|
|
39
64
|
|
|
40
65
|
/** @internal */
|
|
41
66
|
export type TransactionCapture$Outbound = {
|
|
42
|
-
|
|
43
|
-
|
|
67
|
+
type: "transaction-capture";
|
|
68
|
+
status: string;
|
|
69
|
+
code: string | null;
|
|
70
|
+
raw_response_code: string | null;
|
|
71
|
+
raw_response_description: string | null;
|
|
72
|
+
transaction: Transaction$Outbound;
|
|
44
73
|
};
|
|
45
74
|
|
|
46
75
|
/** @internal */
|
|
@@ -49,8 +78,19 @@ export const TransactionCapture$outboundSchema: z.ZodType<
|
|
|
49
78
|
z.ZodTypeDef,
|
|
50
79
|
TransactionCapture
|
|
51
80
|
> = z.object({
|
|
52
|
-
|
|
53
|
-
|
|
81
|
+
type: z.literal("transaction-capture").default(
|
|
82
|
+
"transaction-capture" as const,
|
|
83
|
+
),
|
|
84
|
+
status: CaptureStatus$outboundSchema,
|
|
85
|
+
code: z.nullable(z.string()),
|
|
86
|
+
rawResponseCode: z.nullable(z.string()),
|
|
87
|
+
rawResponseDescription: z.nullable(z.string()),
|
|
88
|
+
transaction: Transaction$outboundSchema,
|
|
89
|
+
}).transform((v) => {
|
|
90
|
+
return remap$(v, {
|
|
91
|
+
rawResponseCode: "raw_response_code",
|
|
92
|
+
rawResponseDescription: "raw_response_description",
|
|
93
|
+
});
|
|
54
94
|
});
|
|
55
95
|
|
|
56
96
|
/**
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
7
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
8
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
9
|
+
import {
|
|
10
|
+
Airline,
|
|
11
|
+
Airline$inboundSchema,
|
|
12
|
+
Airline$Outbound,
|
|
13
|
+
Airline$outboundSchema,
|
|
14
|
+
} from "./airline.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Request body for capturing an authorized transaction.
|
|
18
|
+
*/
|
|
19
|
+
export type TransactionCaptureCreate = {
|
|
20
|
+
/**
|
|
21
|
+
* The amount to capture, in the smallest currency unit (e.g., cents). This must be less than or equal to the authorized amount, unless over-capture is available.
|
|
22
|
+
*/
|
|
23
|
+
amount?: number | null | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The airline data to submit to the payment service during the capture call.
|
|
26
|
+
*/
|
|
27
|
+
airline?: Airline | null | undefined;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** @internal */
|
|
31
|
+
export const TransactionCaptureCreate$inboundSchema: z.ZodType<
|
|
32
|
+
TransactionCaptureCreate,
|
|
33
|
+
z.ZodTypeDef,
|
|
34
|
+
unknown
|
|
35
|
+
> = z.object({
|
|
36
|
+
amount: z.nullable(z.number().int()).optional(),
|
|
37
|
+
airline: z.nullable(Airline$inboundSchema).optional(),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
/** @internal */
|
|
41
|
+
export type TransactionCaptureCreate$Outbound = {
|
|
42
|
+
amount?: number | null | undefined;
|
|
43
|
+
airline?: Airline$Outbound | null | undefined;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** @internal */
|
|
47
|
+
export const TransactionCaptureCreate$outboundSchema: z.ZodType<
|
|
48
|
+
TransactionCaptureCreate$Outbound,
|
|
49
|
+
z.ZodTypeDef,
|
|
50
|
+
TransactionCaptureCreate
|
|
51
|
+
> = z.object({
|
|
52
|
+
amount: z.nullable(z.number().int()).optional(),
|
|
53
|
+
airline: z.nullable(Airline$outboundSchema).optional(),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @internal
|
|
58
|
+
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
|
|
59
|
+
*/
|
|
60
|
+
export namespace TransactionCaptureCreate$ {
|
|
61
|
+
/** @deprecated use `TransactionCaptureCreate$inboundSchema` instead. */
|
|
62
|
+
export const inboundSchema = TransactionCaptureCreate$inboundSchema;
|
|
63
|
+
/** @deprecated use `TransactionCaptureCreate$outboundSchema` instead. */
|
|
64
|
+
export const outboundSchema = TransactionCaptureCreate$outboundSchema;
|
|
65
|
+
/** @deprecated use `TransactionCaptureCreate$Outbound` instead. */
|
|
66
|
+
export type Outbound = TransactionCaptureCreate$Outbound;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function transactionCaptureCreateToJSON(
|
|
70
|
+
transactionCaptureCreate: TransactionCaptureCreate,
|
|
71
|
+
): string {
|
|
72
|
+
return JSON.stringify(
|
|
73
|
+
TransactionCaptureCreate$outboundSchema.parse(transactionCaptureCreate),
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function transactionCaptureCreateFromJSON(
|
|
78
|
+
jsonString: string,
|
|
79
|
+
): SafeParseResult<TransactionCaptureCreate, SDKValidationError> {
|
|
80
|
+
return safeParse(
|
|
81
|
+
jsonString,
|
|
82
|
+
(x) => TransactionCaptureCreate$inboundSchema.parse(JSON.parse(x)),
|
|
83
|
+
`Failed to parse 'TransactionCaptureCreate' from JSON`,
|
|
84
|
+
);
|
|
85
|
+
}
|
|
@@ -18,13 +18,24 @@ export type CaptureTransactionRequest = {
|
|
|
18
18
|
* The ID of the transaction
|
|
19
19
|
*/
|
|
20
20
|
transactionId: string;
|
|
21
|
+
/**
|
|
22
|
+
* The preferred resource type in the response.
|
|
23
|
+
*/
|
|
24
|
+
prefer?: string | null | undefined;
|
|
21
25
|
/**
|
|
22
26
|
* The ID of the merchant account to use for this request.
|
|
23
27
|
*/
|
|
24
28
|
merchantAccountId?: string | null | undefined;
|
|
25
|
-
|
|
29
|
+
transactionCaptureCreate: components.TransactionCaptureCreate;
|
|
26
30
|
};
|
|
27
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Successful Response
|
|
34
|
+
*/
|
|
35
|
+
export type CaptureTransactionResponseCaptureTransaction =
|
|
36
|
+
| components.Transaction
|
|
37
|
+
| components.TransactionCapture;
|
|
38
|
+
|
|
28
39
|
/** @internal */
|
|
29
40
|
export const CaptureTransactionGlobals$inboundSchema: z.ZodType<
|
|
30
41
|
CaptureTransactionGlobals,
|
|
@@ -86,20 +97,22 @@ export const CaptureTransactionRequest$inboundSchema: z.ZodType<
|
|
|
86
97
|
unknown
|
|
87
98
|
> = z.object({
|
|
88
99
|
transaction_id: z.string(),
|
|
100
|
+
prefer: z.nullable(z.string()).optional(),
|
|
89
101
|
merchantAccountId: z.nullable(z.string()).optional(),
|
|
90
|
-
|
|
102
|
+
TransactionCaptureCreate: components.TransactionCaptureCreate$inboundSchema,
|
|
91
103
|
}).transform((v) => {
|
|
92
104
|
return remap$(v, {
|
|
93
105
|
"transaction_id": "transactionId",
|
|
94
|
-
"
|
|
106
|
+
"TransactionCaptureCreate": "transactionCaptureCreate",
|
|
95
107
|
});
|
|
96
108
|
});
|
|
97
109
|
|
|
98
110
|
/** @internal */
|
|
99
111
|
export type CaptureTransactionRequest$Outbound = {
|
|
100
112
|
transaction_id: string;
|
|
113
|
+
prefer?: string | null | undefined;
|
|
101
114
|
merchantAccountId?: string | null | undefined;
|
|
102
|
-
|
|
115
|
+
TransactionCaptureCreate: components.TransactionCaptureCreate$Outbound;
|
|
103
116
|
};
|
|
104
117
|
|
|
105
118
|
/** @internal */
|
|
@@ -109,12 +122,13 @@ export const CaptureTransactionRequest$outboundSchema: z.ZodType<
|
|
|
109
122
|
CaptureTransactionRequest
|
|
110
123
|
> = z.object({
|
|
111
124
|
transactionId: z.string(),
|
|
125
|
+
prefer: z.nullable(z.string()).optional(),
|
|
112
126
|
merchantAccountId: z.nullable(z.string()).optional(),
|
|
113
|
-
|
|
127
|
+
transactionCaptureCreate: components.TransactionCaptureCreate$outboundSchema,
|
|
114
128
|
}).transform((v) => {
|
|
115
129
|
return remap$(v, {
|
|
116
130
|
transactionId: "transaction_id",
|
|
117
|
-
|
|
131
|
+
transactionCaptureCreate: "TransactionCaptureCreate",
|
|
118
132
|
});
|
|
119
133
|
});
|
|
120
134
|
|
|
@@ -148,3 +162,72 @@ export function captureTransactionRequestFromJSON(
|
|
|
148
162
|
`Failed to parse 'CaptureTransactionRequest' from JSON`,
|
|
149
163
|
);
|
|
150
164
|
}
|
|
165
|
+
|
|
166
|
+
/** @internal */
|
|
167
|
+
export const CaptureTransactionResponseCaptureTransaction$inboundSchema:
|
|
168
|
+
z.ZodType<
|
|
169
|
+
CaptureTransactionResponseCaptureTransaction,
|
|
170
|
+
z.ZodTypeDef,
|
|
171
|
+
unknown
|
|
172
|
+
> = z.union([
|
|
173
|
+
components.Transaction$inboundSchema,
|
|
174
|
+
components.TransactionCapture$inboundSchema,
|
|
175
|
+
]);
|
|
176
|
+
|
|
177
|
+
/** @internal */
|
|
178
|
+
export type CaptureTransactionResponseCaptureTransaction$Outbound =
|
|
179
|
+
| components.Transaction$Outbound
|
|
180
|
+
| components.TransactionCapture$Outbound;
|
|
181
|
+
|
|
182
|
+
/** @internal */
|
|
183
|
+
export const CaptureTransactionResponseCaptureTransaction$outboundSchema:
|
|
184
|
+
z.ZodType<
|
|
185
|
+
CaptureTransactionResponseCaptureTransaction$Outbound,
|
|
186
|
+
z.ZodTypeDef,
|
|
187
|
+
CaptureTransactionResponseCaptureTransaction
|
|
188
|
+
> = z.union([
|
|
189
|
+
components.Transaction$outboundSchema,
|
|
190
|
+
components.TransactionCapture$outboundSchema,
|
|
191
|
+
]);
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* @internal
|
|
195
|
+
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
|
|
196
|
+
*/
|
|
197
|
+
export namespace CaptureTransactionResponseCaptureTransaction$ {
|
|
198
|
+
/** @deprecated use `CaptureTransactionResponseCaptureTransaction$inboundSchema` instead. */
|
|
199
|
+
export const inboundSchema =
|
|
200
|
+
CaptureTransactionResponseCaptureTransaction$inboundSchema;
|
|
201
|
+
/** @deprecated use `CaptureTransactionResponseCaptureTransaction$outboundSchema` instead. */
|
|
202
|
+
export const outboundSchema =
|
|
203
|
+
CaptureTransactionResponseCaptureTransaction$outboundSchema;
|
|
204
|
+
/** @deprecated use `CaptureTransactionResponseCaptureTransaction$Outbound` instead. */
|
|
205
|
+
export type Outbound = CaptureTransactionResponseCaptureTransaction$Outbound;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function captureTransactionResponseCaptureTransactionToJSON(
|
|
209
|
+
captureTransactionResponseCaptureTransaction:
|
|
210
|
+
CaptureTransactionResponseCaptureTransaction,
|
|
211
|
+
): string {
|
|
212
|
+
return JSON.stringify(
|
|
213
|
+
CaptureTransactionResponseCaptureTransaction$outboundSchema.parse(
|
|
214
|
+
captureTransactionResponseCaptureTransaction,
|
|
215
|
+
),
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export function captureTransactionResponseCaptureTransactionFromJSON(
|
|
220
|
+
jsonString: string,
|
|
221
|
+
): SafeParseResult<
|
|
222
|
+
CaptureTransactionResponseCaptureTransaction,
|
|
223
|
+
SDKValidationError
|
|
224
|
+
> {
|
|
225
|
+
return safeParse(
|
|
226
|
+
jsonString,
|
|
227
|
+
(x) =>
|
|
228
|
+
CaptureTransactionResponseCaptureTransaction$inboundSchema.parse(
|
|
229
|
+
JSON.parse(x),
|
|
230
|
+
),
|
|
231
|
+
`Failed to parse 'CaptureTransactionResponseCaptureTransaction' from JSON`,
|
|
232
|
+
);
|
|
233
|
+
}
|
|
@@ -54,7 +54,7 @@ export class PaymentServiceDefinitions extends ClientSDK {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
* Create a session for
|
|
57
|
+
* Create a session for a payment service definition
|
|
58
58
|
*
|
|
59
59
|
* @remarks
|
|
60
60
|
* Creates a session for a payment service that supports sessions.
|
|
@@ -133,7 +133,7 @@ export class PaymentServices extends ClientSDK {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
/**
|
|
136
|
-
* Create a session for
|
|
136
|
+
* Create a session for a payment service definition
|
|
137
137
|
*
|
|
138
138
|
* @remarks
|
|
139
139
|
* Creates a session for a payment service that supports sessions.
|
package/src/sdk/transactions.ts
CHANGED
|
@@ -123,15 +123,17 @@ export class Transactions extends ClientSDK {
|
|
|
123
123
|
* Captures a previously authorized transaction. You can capture the full or a partial amount, as long as it does not exceed the authorized amount (unless over-capture is enabled).
|
|
124
124
|
*/
|
|
125
125
|
async capture(
|
|
126
|
-
|
|
126
|
+
transactionCaptureCreate: components.TransactionCaptureCreate,
|
|
127
127
|
transactionId: string,
|
|
128
|
+
prefer?: string | null | undefined,
|
|
128
129
|
merchantAccountId?: string | null | undefined,
|
|
129
130
|
options?: RequestOptions,
|
|
130
|
-
): Promise<
|
|
131
|
+
): Promise<operations.CaptureTransactionResponseCaptureTransaction> {
|
|
131
132
|
return unwrapAsync(transactionsCapture(
|
|
132
133
|
this,
|
|
133
|
-
|
|
134
|
+
transactionCaptureCreate,
|
|
134
135
|
transactionId,
|
|
136
|
+
prefer,
|
|
135
137
|
merchantAccountId,
|
|
136
138
|
options,
|
|
137
139
|
));
|