@chargehive/types 1.0.18
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/address.d.ts +23 -0
- package/chargehive.d.ts +355 -0
- package/package.json +13 -0
- package/validation.d.ts +10 -0
package/address.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface Person
|
|
2
|
+
{
|
|
3
|
+
title?: string;
|
|
4
|
+
firstName: string;
|
|
5
|
+
lastName: string;
|
|
6
|
+
fullName: string;
|
|
7
|
+
email: string;
|
|
8
|
+
phone?: string;
|
|
9
|
+
language?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface Address
|
|
13
|
+
{
|
|
14
|
+
fao?: string;
|
|
15
|
+
companyName?: string;
|
|
16
|
+
address1: string;
|
|
17
|
+
address2?: string;
|
|
18
|
+
address3?: string;
|
|
19
|
+
city: string;
|
|
20
|
+
county: string;
|
|
21
|
+
country: string;
|
|
22
|
+
postal: string;
|
|
23
|
+
}
|
package/chargehive.d.ts
ADDED
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FieldName as PCIBFieldName,
|
|
3
|
+
EventName as PCIBEventName,
|
|
4
|
+
PCIBridgeTokenizeResponse,
|
|
5
|
+
PCIBridgeTokenizeEphemeralResponse,
|
|
6
|
+
} from '@pci-bridge/types/pcibridge';
|
|
7
|
+
import {FieldValidation} from '@pci-bridge/types/validation';
|
|
8
|
+
import {Address, Person} from './address';
|
|
9
|
+
import ApplePayPaymentToken = ApplePayJS.ApplePayPaymentToken;
|
|
10
|
+
|
|
11
|
+
type EmptyObject = Record<string, never>;
|
|
12
|
+
|
|
13
|
+
declare global
|
|
14
|
+
{
|
|
15
|
+
// noinspection ES6ConvertVarToLetConst
|
|
16
|
+
var ChargeHive: ChargeHiveType; // eslint-disable-line no-var
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare type FieldName = PCIBFieldName;
|
|
20
|
+
|
|
21
|
+
export interface ChargeHiveEventTarget extends Omit<EventTarget, 'dispatchEvent'>
|
|
22
|
+
{
|
|
23
|
+
addEventListener(
|
|
24
|
+
type: EventName, callback: EventListenerOrEventListenerObject | null,
|
|
25
|
+
options?: AddEventListenerOptions | boolean,
|
|
26
|
+
): void;
|
|
27
|
+
|
|
28
|
+
removeEventListener(
|
|
29
|
+
type: EventName, callback: EventListenerOrEventListenerObject | null,
|
|
30
|
+
options?: EventListenerOptions | boolean,
|
|
31
|
+
): void;
|
|
32
|
+
|
|
33
|
+
triggerEvent(type: EventName, data?: object);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ChargeHiveType extends ChargeType, ChargeHiveEventTarget
|
|
37
|
+
{
|
|
38
|
+
/**
|
|
39
|
+
* Chargehive Major Version
|
|
40
|
+
*/
|
|
41
|
+
readonly version: string;
|
|
42
|
+
|
|
43
|
+
initialize(options: ChargeHiveInitOptions);
|
|
44
|
+
|
|
45
|
+
isInitialized(): boolean;
|
|
46
|
+
|
|
47
|
+
readonly getInitOptions: ChargeHiveInitOptions | undefined;
|
|
48
|
+
|
|
49
|
+
getInitResponse(): InitResponse | undefined;
|
|
50
|
+
|
|
51
|
+
validate(field?: FieldName, timeout?: number): Promise<Map<FieldName, FieldValidation>>;
|
|
52
|
+
|
|
53
|
+
tokenize(): Promise<TokenizeResponse>;
|
|
54
|
+
|
|
55
|
+
tokenizeEphemeral<T extends PaymentMethodType>(): Promise<PaymentMethodEphemeralDataTypes[T]>;
|
|
56
|
+
|
|
57
|
+
authorize(): Promise<AuthorizeResponse>;
|
|
58
|
+
|
|
59
|
+
clear(field: FieldName);
|
|
60
|
+
|
|
61
|
+
setNameOnCard(value: string);
|
|
62
|
+
|
|
63
|
+
setCardExpiry(month: number, year: number);
|
|
64
|
+
|
|
65
|
+
setPaymentMethod<T extends PaymentMethodType>(type: T, data?: object | PaymentMethodDataTypes[T]): void;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface WalletOptions
|
|
69
|
+
{
|
|
70
|
+
/**
|
|
71
|
+
* @default true
|
|
72
|
+
*/
|
|
73
|
+
requireEmail?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* @default true
|
|
76
|
+
*/
|
|
77
|
+
requireBillingAddress?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* @default false
|
|
80
|
+
*/
|
|
81
|
+
requireBillingPhone?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* @default false
|
|
84
|
+
*/
|
|
85
|
+
requireShippingAddress?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* @default false
|
|
88
|
+
*/
|
|
89
|
+
requireShippingPhone?: boolean;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface ChargeHiveInitOptions
|
|
93
|
+
{
|
|
94
|
+
projectId: string;
|
|
95
|
+
projectPlacement: string;
|
|
96
|
+
merchantHash: string;
|
|
97
|
+
merchantPlacement: string;
|
|
98
|
+
country: string;
|
|
99
|
+
currency: string;
|
|
100
|
+
environment?: ChargeEnvironment;
|
|
101
|
+
walletOptions?: WalletOptions;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface InitResponse
|
|
105
|
+
{
|
|
106
|
+
riskCheckers: { [key: string]: RiskChecker };
|
|
107
|
+
capabilities: PaymentMethodType[];
|
|
108
|
+
serverTime: number;
|
|
109
|
+
sandboxMode: boolean;
|
|
110
|
+
defaultPaymentType: PaymentMethodType;
|
|
111
|
+
projectName: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export type RiskChecker = {
|
|
115
|
+
[key: string]: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export type PaymentMethodType =
|
|
119
|
+
| 'PLACEMENT_CAPABILITY_TOKEN'
|
|
120
|
+
| 'PLACEMENT_CAPABILITY_CARD_FORM'
|
|
121
|
+
| 'PLACEMENT_CAPABILITY_PAYPAL'
|
|
122
|
+
| 'PLACEMENT_CAPABILITY_APPLE_PAY'
|
|
123
|
+
| 'PLACEMENT_CAPABILITY_GOOGLE_PAY'
|
|
124
|
+
| 'PLACEMENT_CAPABILITY_DIRECTDEBIT_FORM'
|
|
125
|
+
|
|
126
|
+
export type PaymentMethodDataTypes = {
|
|
127
|
+
PLACEMENT_CAPABILITY_TOKEN: {
|
|
128
|
+
token: string;
|
|
129
|
+
}
|
|
130
|
+
PLACEMENT_CAPABILITY_CARD_FORM: PCIBridgeTokenizeResponse
|
|
131
|
+
PLACEMENT_CAPABILITY_PAYPAL: EmptyObject
|
|
132
|
+
PLACEMENT_CAPABILITY_APPLE_PAY: {
|
|
133
|
+
initiativeContext?: string;
|
|
134
|
+
sessionUrl?: string;
|
|
135
|
+
session?: string;
|
|
136
|
+
token?: ApplePayPaymentToken;
|
|
137
|
+
}
|
|
138
|
+
PLACEMENT_CAPABILITY_GOOGLE_PAY: {
|
|
139
|
+
description: string | undefined;
|
|
140
|
+
cardDetails: string | undefined;
|
|
141
|
+
cardNetwork: google.payments.api.CardNetwork | undefined;
|
|
142
|
+
token: string;
|
|
143
|
+
}
|
|
144
|
+
PLACEMENT_CAPABILITY_DIRECTDEBIT_FORM: {
|
|
145
|
+
accountName: string;
|
|
146
|
+
accountNum: string;
|
|
147
|
+
sortCode: string;
|
|
148
|
+
payerReference: string;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export type PaymentMethodEphemeralDataTypes = {
|
|
153
|
+
PLACEMENT_CAPABILITY_TOKEN: EmptyObject
|
|
154
|
+
PLACEMENT_CAPABILITY_CARD_FORM: PCIBridgeTokenizeEphemeralResponse
|
|
155
|
+
PLACEMENT_CAPABILITY_PAYPAL: EmptyObject
|
|
156
|
+
PLACEMENT_CAPABILITY_APPLE_PAY: EmptyObject
|
|
157
|
+
PLACEMENT_CAPABILITY_GOOGLE_PAY: EmptyObject
|
|
158
|
+
PLACEMENT_CAPABILITY_DIRECTDEBIT_FORM: EmptyObject
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export type PaymentMethodEphemeralTokenizationConfig = {
|
|
162
|
+
PLACEMENT_CAPABILITY_TOKEN: EmptyObject
|
|
163
|
+
PLACEMENT_CAPABILITY_CARD_FORM: EmptyObject
|
|
164
|
+
PLACEMENT_CAPABILITY_PAYPAL: EmptyObject
|
|
165
|
+
PLACEMENT_CAPABILITY_APPLE_PAY: EmptyObject
|
|
166
|
+
PLACEMENT_CAPABILITY_GOOGLE_PAY: EmptyObject
|
|
167
|
+
PLACEMENT_CAPABILITY_DIRECTDEBIT_FORM: EmptyObject
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export type PaymentMethodTokenizationConfig = {
|
|
171
|
+
PLACEMENT_CAPABILITY_TOKEN: EmptyObject
|
|
172
|
+
PLACEMENT_CAPABILITY_PAYPAL: EmptyObject
|
|
173
|
+
PLACEMENT_CAPABILITY_CARD_FORM: EmptyObject
|
|
174
|
+
PLACEMENT_CAPABILITY_APPLE_PAY: {
|
|
175
|
+
Session?: string;
|
|
176
|
+
InitiativeContext?: string;
|
|
177
|
+
SessionUrl?: string;
|
|
178
|
+
}
|
|
179
|
+
PLACEMENT_CAPABILITY_GOOGLE_PAY: {
|
|
180
|
+
environment?: string;
|
|
181
|
+
googlePayConfig?: google.payments.api.PaymentDataRequest | string;
|
|
182
|
+
token?: string;
|
|
183
|
+
}
|
|
184
|
+
PLACEMENT_CAPABILITY_DIRECTDEBIT_FORM: EmptyObject
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export type PaymentMethodAuthenticationTypes = {
|
|
188
|
+
cvv: string;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export type ChargeEnvironment =
|
|
192
|
+
| 'CHARGE_ENVIRONMENT_RETAIL'
|
|
193
|
+
| 'CHARGE_ENVIRONMENT_ECOMMERCE'
|
|
194
|
+
| 'CHARGE_ENVIRONMENT_MOTO'
|
|
195
|
+
| 'CHARGE_ENVIRONMENT_RENEWAL';
|
|
196
|
+
|
|
197
|
+
export interface ChargeMeta
|
|
198
|
+
{
|
|
199
|
+
customerInfo?: Person;
|
|
200
|
+
billingAddress?: Address;
|
|
201
|
+
shippingAddress?: Address;
|
|
202
|
+
orderItems?: OrderItem[];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface ChargeData
|
|
206
|
+
{
|
|
207
|
+
billingProfileId: string;
|
|
208
|
+
amount: number;
|
|
209
|
+
currency: string;
|
|
210
|
+
references?: Dictionary;
|
|
211
|
+
labels?: Dictionary;
|
|
212
|
+
language?: string;
|
|
213
|
+
meta?: ChargeMeta;
|
|
214
|
+
connectorId?: string;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export interface ChargeType
|
|
218
|
+
{
|
|
219
|
+
readonly charge: ChargeData;
|
|
220
|
+
|
|
221
|
+
prepareChargeWithId(chargeId: string, cfg: ChargeData): void;
|
|
222
|
+
|
|
223
|
+
prepareCharge(merchantReference: string, cfg: ChargeData): void;
|
|
224
|
+
|
|
225
|
+
updateCharge(data: ChargeData): void;
|
|
226
|
+
|
|
227
|
+
setBillingAddress(address: Address): void;
|
|
228
|
+
|
|
229
|
+
setShippingAddress(address: Address): void;
|
|
230
|
+
|
|
231
|
+
setCustomerInfo(customer: Person): void;
|
|
232
|
+
|
|
233
|
+
setOrderItems(items: OrderItem[]): void;
|
|
234
|
+
|
|
235
|
+
addOrderItem(item: OrderItem): void;
|
|
236
|
+
|
|
237
|
+
clearOrderItems(): void;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export interface OrderItem
|
|
241
|
+
{
|
|
242
|
+
subscriptionId: string;
|
|
243
|
+
renewalNumber: number;
|
|
244
|
+
duration: number;
|
|
245
|
+
startDate: number;
|
|
246
|
+
endDate: number;
|
|
247
|
+
productType: number;
|
|
248
|
+
skuType: number;
|
|
249
|
+
deliveryType: number;
|
|
250
|
+
quantity?: number;
|
|
251
|
+
unitPrice: number;
|
|
252
|
+
taxAmount?: number;
|
|
253
|
+
discountAmount?: number;
|
|
254
|
+
name: string;
|
|
255
|
+
description: string;
|
|
256
|
+
productCode: string;
|
|
257
|
+
skuCode: string;
|
|
258
|
+
termType: number;
|
|
259
|
+
termUnits: number;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export type EventName = PCIBEventName
|
|
263
|
+
| 'init'
|
|
264
|
+
| 'token'
|
|
265
|
+
| 'token-config'
|
|
266
|
+
| 'success'
|
|
267
|
+
| 'declined'
|
|
268
|
+
| 'error'
|
|
269
|
+
| 'cancel'
|
|
270
|
+
| 'authentication'
|
|
271
|
+
| 'ready'
|
|
272
|
+
| 'paste'
|
|
273
|
+
| 'method-type-changed'
|
|
274
|
+
| 'charge-id';
|
|
275
|
+
|
|
276
|
+
export type ChargeHiveEventType = Extract<EventName, 'token' | 'success' | 'declined' | 'authentication' | 'error' | 'token-config'>
|
|
277
|
+
|
|
278
|
+
export type TransactionResponse = {
|
|
279
|
+
responseCode: string;
|
|
280
|
+
responseMessage: string;
|
|
281
|
+
merchantMessage: string;
|
|
282
|
+
failureType: string;
|
|
283
|
+
category: string;
|
|
284
|
+
errorType: string;
|
|
285
|
+
errorProperties: Dictionary;
|
|
286
|
+
originatingCode: string;
|
|
287
|
+
specificErrors: TransactionResponse[];
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export type ChargeHiveEventData = {
|
|
291
|
+
token: {
|
|
292
|
+
name: string;
|
|
293
|
+
scheme: string;
|
|
294
|
+
expiry: string;
|
|
295
|
+
token: string;
|
|
296
|
+
additionalData: Dictionary;
|
|
297
|
+
connectorId: string;
|
|
298
|
+
customerError: string;
|
|
299
|
+
merchantError: string;
|
|
300
|
+
}
|
|
301
|
+
success: {
|
|
302
|
+
chargeId: string;
|
|
303
|
+
transactionId: string;
|
|
304
|
+
transactedAmount: {
|
|
305
|
+
currency: string;
|
|
306
|
+
units: number;
|
|
307
|
+
};
|
|
308
|
+
responseBreakdown: TransactionResponse;
|
|
309
|
+
}
|
|
310
|
+
declined: {
|
|
311
|
+
chargeId: string;
|
|
312
|
+
message: string;
|
|
313
|
+
responseCode: string;
|
|
314
|
+
paymentScheme: string;
|
|
315
|
+
responseBreakdown: TransactionResponse;
|
|
316
|
+
}
|
|
317
|
+
authentication: {
|
|
318
|
+
environment: string;
|
|
319
|
+
type: string;
|
|
320
|
+
connector: string;
|
|
321
|
+
connectorData: Dictionary;
|
|
322
|
+
paymentType: string;
|
|
323
|
+
}
|
|
324
|
+
error: object;
|
|
325
|
+
'token-config': PaymentMethodTokenizationConfig[PaymentMethodType];
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export type Dictionary = { [key: string]: string };
|
|
329
|
+
|
|
330
|
+
export interface AuthorizeResponse
|
|
331
|
+
{
|
|
332
|
+
result: string;
|
|
333
|
+
message: string;
|
|
334
|
+
continuationId: string;
|
|
335
|
+
chargeId: string;
|
|
336
|
+
events: ChargeHiveEvent<ChargeHiveEventType>[];
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export interface ChargeHiveEvent<T extends ChargeHiveEventType>
|
|
340
|
+
{
|
|
341
|
+
type: T;
|
|
342
|
+
data: ChargeHiveEventData[T];
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export interface TokenizeResponse
|
|
346
|
+
{
|
|
347
|
+
name: string;
|
|
348
|
+
scheme: string;
|
|
349
|
+
expiry: string;
|
|
350
|
+
token: string;
|
|
351
|
+
additionalData: Dictionary;
|
|
352
|
+
connectorID: string;
|
|
353
|
+
customerError: string;
|
|
354
|
+
merchantError: string;
|
|
355
|
+
}
|
package/package.json
ADDED
package/validation.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FieldValidation as PCIBFieldValidation,
|
|
3
|
+
CardFieldValidation as PCIBCardFieldValidation,
|
|
4
|
+
} from '@pci-bridge/types/validation';
|
|
5
|
+
|
|
6
|
+
export type FieldValidation = PCIBFieldValidation
|
|
7
|
+
|
|
8
|
+
export type CardFieldValidation = PCIBCardFieldValidation
|
|
9
|
+
|
|
10
|
+
export type ValidationEvent = CustomEvent<FieldValidation | CardFieldValidation>;
|