@inkress/admin-sdk 1.1.46 → 1.1.47
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 +227 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +88 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +88 -0
- package/dist/index.js.map +1 -1
- package/dist/resources/checkout-sessions.d.ts +201 -0
- package/dist/resources/checkout-sessions.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { HttpClient } from '../client';
|
|
2
|
+
import { ApiResponse, CreateOrderData } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Fee mapping details for checkout session
|
|
5
|
+
*/
|
|
6
|
+
export interface CheckoutSessionFeeMapping {
|
|
7
|
+
charged_party: number;
|
|
8
|
+
computed_value: number;
|
|
9
|
+
currency: string;
|
|
10
|
+
fee_id: number;
|
|
11
|
+
group: number;
|
|
12
|
+
is_compounded: boolean;
|
|
13
|
+
recipient_merchant_id: number;
|
|
14
|
+
sequence: number;
|
|
15
|
+
unit: number;
|
|
16
|
+
value: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Fee breakdown for checkout session
|
|
20
|
+
*/
|
|
21
|
+
export interface CheckoutSessionFees {
|
|
22
|
+
after_tax_fee_total: number;
|
|
23
|
+
before_tax_fee_total: number;
|
|
24
|
+
customer_total: number;
|
|
25
|
+
discount_total: number;
|
|
26
|
+
fee_ids: number[];
|
|
27
|
+
fee_mappings: CheckoutSessionFeeMapping[];
|
|
28
|
+
merchant_total: number;
|
|
29
|
+
platform_total: number;
|
|
30
|
+
provider_total: number;
|
|
31
|
+
shipping_total: number;
|
|
32
|
+
sub_total: number;
|
|
33
|
+
tax_total: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Totals breakdown for checkout session
|
|
37
|
+
*/
|
|
38
|
+
export interface CheckoutSessionTotals {
|
|
39
|
+
sub_total: number;
|
|
40
|
+
customer_total: number;
|
|
41
|
+
merchant_total: number;
|
|
42
|
+
platform_total: number;
|
|
43
|
+
provider_total: number;
|
|
44
|
+
shipping_total: number;
|
|
45
|
+
tax_total: number;
|
|
46
|
+
discount_total: number;
|
|
47
|
+
before_tax_fee_total: number;
|
|
48
|
+
after_tax_fee_total: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Response data from creating a checkout session
|
|
52
|
+
*/
|
|
53
|
+
export interface CreateCheckoutSessionResponseData {
|
|
54
|
+
session_id: string;
|
|
55
|
+
reference_id: string;
|
|
56
|
+
status: string;
|
|
57
|
+
order_id: string;
|
|
58
|
+
currency: string;
|
|
59
|
+
currency_code: string;
|
|
60
|
+
created_at: string;
|
|
61
|
+
payment_initiated_at: string;
|
|
62
|
+
completed_at: string | null;
|
|
63
|
+
expires: number;
|
|
64
|
+
totals: CheckoutSessionTotals;
|
|
65
|
+
customer: CheckoutSessionCustomer;
|
|
66
|
+
title: string;
|
|
67
|
+
products: any[];
|
|
68
|
+
frame_url: string;
|
|
69
|
+
redirect_data: string;
|
|
70
|
+
spi_token: string;
|
|
71
|
+
transaction_id: string;
|
|
72
|
+
amount: number;
|
|
73
|
+
transaction_type: string | null;
|
|
74
|
+
three_d_secure: any | null;
|
|
75
|
+
is_subscription: boolean;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Currency info for checkout session
|
|
79
|
+
*/
|
|
80
|
+
export interface CheckoutSessionCurrency {
|
|
81
|
+
code: string;
|
|
82
|
+
id: number;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Customer info for checkout session
|
|
86
|
+
*/
|
|
87
|
+
export interface CheckoutSessionCustomer {
|
|
88
|
+
id: number | null;
|
|
89
|
+
email: string;
|
|
90
|
+
first_name: string;
|
|
91
|
+
last_name: string;
|
|
92
|
+
phone: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Checkout session status
|
|
96
|
+
*/
|
|
97
|
+
export type CheckoutSessionStatus = 'pending' | 'awaiting_payment' | 'completed' | 'cancelled' | 'expired';
|
|
98
|
+
/**
|
|
99
|
+
* Response data from getting a checkout session
|
|
100
|
+
*/
|
|
101
|
+
export interface CheckoutSession {
|
|
102
|
+
status: CheckoutSessionStatus;
|
|
103
|
+
title: string;
|
|
104
|
+
currency: CheckoutSessionCurrency;
|
|
105
|
+
customer: CheckoutSessionCustomer;
|
|
106
|
+
session_id: string;
|
|
107
|
+
order_id: number | null;
|
|
108
|
+
reference_id: string;
|
|
109
|
+
fees: CheckoutSessionFees;
|
|
110
|
+
products: any[];
|
|
111
|
+
created_at: string;
|
|
112
|
+
completed_at: string | null;
|
|
113
|
+
payment_initiated_at: string | null;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Response data from deleting a checkout session
|
|
117
|
+
*/
|
|
118
|
+
export interface DeleteCheckoutSessionResponseData {
|
|
119
|
+
status: 'cancelled';
|
|
120
|
+
session_id: string;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Checkout Sessions Resource
|
|
124
|
+
*
|
|
125
|
+
* Handles creation and management of checkout sessions for payments.
|
|
126
|
+
* Checkout sessions provide a way to create temporary payment sessions
|
|
127
|
+
* with pre-calculated fees and payment URLs.
|
|
128
|
+
*/
|
|
129
|
+
export declare class CheckoutSessionsResource {
|
|
130
|
+
private client;
|
|
131
|
+
constructor(client: HttpClient);
|
|
132
|
+
/**
|
|
133
|
+
* Create a new checkout session
|
|
134
|
+
*
|
|
135
|
+
* Creates a checkout session with pre-calculated fees and returns
|
|
136
|
+
* payment URLs for processing the payment.
|
|
137
|
+
*
|
|
138
|
+
* Requires Client-Id header to be set in the configuration.
|
|
139
|
+
*
|
|
140
|
+
* @param data - Order data for the checkout session (same as order creation)
|
|
141
|
+
* @returns The created checkout session with payment URLs and fee breakdown
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* const session = await sdk.checkoutSessions.create({
|
|
146
|
+
* reference_id: 'order-123',
|
|
147
|
+
* total: 100.00,
|
|
148
|
+
* kind: 'online',
|
|
149
|
+
* currency_code: 'JMD',
|
|
150
|
+
* customer: {
|
|
151
|
+
* email: 'customer@example.com',
|
|
152
|
+
* first_name: 'John',
|
|
153
|
+
* last_name: 'Doe',
|
|
154
|
+
* phone: '+1234567890'
|
|
155
|
+
* },
|
|
156
|
+
* title: 'My Order'
|
|
157
|
+
* });
|
|
158
|
+
*
|
|
159
|
+
* // Redirect customer to payment URL
|
|
160
|
+
* console.log(session.result.payment_url);
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
create(data: CreateOrderData): Promise<ApiResponse<CreateCheckoutSessionResponseData>>;
|
|
164
|
+
/**
|
|
165
|
+
* Get checkout session details by session ID
|
|
166
|
+
*
|
|
167
|
+
* Retrieves the current state of a checkout session including
|
|
168
|
+
* payment status, customer info, and fee breakdown.
|
|
169
|
+
*
|
|
170
|
+
* Requires Client-Id header to be set in the configuration.
|
|
171
|
+
*
|
|
172
|
+
* @param sessionId - The session ID (e.g., 'S.75a29ad32e52')
|
|
173
|
+
* @returns The checkout session details
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* const session = await sdk.checkoutSessions.get('S.75a29ad32e52');
|
|
178
|
+
* console.log(session.result.status); // 'awaiting_payment'
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
get(sessionId: string): Promise<ApiResponse<CheckoutSession>>;
|
|
182
|
+
/**
|
|
183
|
+
* Delete (cancel) a checkout session
|
|
184
|
+
*
|
|
185
|
+
* Cancels an active checkout session. Once cancelled, the session
|
|
186
|
+
* can no longer be used for payment.
|
|
187
|
+
*
|
|
188
|
+
* Requires Client-Id header to be set in the configuration.
|
|
189
|
+
*
|
|
190
|
+
* @param sessionId - The session ID to cancel (e.g., 'S.75a29ad32e52')
|
|
191
|
+
* @returns Confirmation of the cancellation
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* const result = await sdk.checkoutSessions.delete('S.75a29ad32e52');
|
|
196
|
+
* console.log(result.result); // 'Session cancelled'
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
delete(sessionId: string): Promise<ApiResponse<string>>;
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=checkout-sessions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout-sessions.d.ts","sourceRoot":"","sources":["../../src/resources/checkout-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EACL,WAAW,EACX,eAAe,EAChB,MAAM,UAAU,CAAC;AAMlB;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,OAAO,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,yBAAyB,EAAE,CAAC;IAC1C,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,SA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