@chargehive/types 2.0.0
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 +263 -0
- package/package.json +12 -0
- package/validation.d.ts +3 -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 | null;
|
|
15
|
+
companyName: string | null;
|
|
16
|
+
address1: string;
|
|
17
|
+
address2: string | null;
|
|
18
|
+
address3: string | null;
|
|
19
|
+
city: string;
|
|
20
|
+
county: string;
|
|
21
|
+
country: string;
|
|
22
|
+
postal: string;
|
|
23
|
+
}
|
package/chargehive.d.ts
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import {FieldName as PCIBFieldName, PCIBridgeTokenizeResponse} from '@pci-bridge/types/pcibridge';
|
|
2
|
+
import {FieldValidation} from '@pci-bridge/types/validation';
|
|
3
|
+
import {Address, Person} from './address';
|
|
4
|
+
|
|
5
|
+
declare global
|
|
6
|
+
{
|
|
7
|
+
/* eslint-disable no-var */
|
|
8
|
+
// noinspection ES6ConvertVarToLetConst
|
|
9
|
+
var ChargeHive: ChargeHiveType;
|
|
10
|
+
/* eslint-enable no-var */
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare type FieldName = PCIBFieldName;
|
|
14
|
+
|
|
15
|
+
export interface ChargeHiveEventTarget extends Omit<EventTarget, 'dispatchEvent'>
|
|
16
|
+
{
|
|
17
|
+
addEventListener(
|
|
18
|
+
type: EventName, callback: EventListenerOrEventListenerObject | null,
|
|
19
|
+
options?: AddEventListenerOptions | boolean,
|
|
20
|
+
): void;
|
|
21
|
+
|
|
22
|
+
removeEventListener(
|
|
23
|
+
type: EventName, callback: EventListenerOrEventListenerObject | null,
|
|
24
|
+
options?: EventListenerOptions | boolean,
|
|
25
|
+
): void;
|
|
26
|
+
|
|
27
|
+
triggerEvent(type: EventName, data?: object);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ChargeHiveType extends ChargeType, ChargeHiveEventTarget
|
|
31
|
+
{
|
|
32
|
+
/**
|
|
33
|
+
* PCIBridge Major Version
|
|
34
|
+
*/
|
|
35
|
+
get version(): string;
|
|
36
|
+
|
|
37
|
+
initialize(placementToken: string, projectId: string, options: ChargeHiveInitOptions);
|
|
38
|
+
|
|
39
|
+
validate(field?: FieldName, timeout?: number): Promise<Map<FieldName, FieldValidation>>;
|
|
40
|
+
|
|
41
|
+
tokenize(): Promise<TokenizeResponse>;
|
|
42
|
+
|
|
43
|
+
authorize(): Promise<AuthorizeResponse>;
|
|
44
|
+
|
|
45
|
+
clear(field: FieldName);
|
|
46
|
+
|
|
47
|
+
setNameOnCard(value: string);
|
|
48
|
+
|
|
49
|
+
setCardExpiry(month: number, year: number);
|
|
50
|
+
|
|
51
|
+
setPaymentMethod<T extends PaymentMethodType>(type: T, data: PaymentMethodDataTypes[T]): void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface ChargeHiveInitOptions
|
|
55
|
+
{
|
|
56
|
+
billingProfileID: string;
|
|
57
|
+
country: string;
|
|
58
|
+
currency: string;
|
|
59
|
+
environment?: ChargeEnvironment;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type PaymentMethodType =
|
|
63
|
+
| 'PLACEMENT_CAPABILITY_TOKEN'
|
|
64
|
+
| 'PLACEMENT_CAPABILITY_CARD_FORM'
|
|
65
|
+
| 'PLACEMENT_CAPABILITY_PAYPAL'
|
|
66
|
+
| 'PLACEMENT_CAPABILITY_APPLE_PAY'
|
|
67
|
+
| 'PLACEMENT_CAPABILITY_GOOGLE_PAY'
|
|
68
|
+
| 'PLACEMENT_CAPABILITY_DIRECTDEBIT_FORM'
|
|
69
|
+
|
|
70
|
+
export type PaymentMethodDataTypes = {
|
|
71
|
+
PLACEMENT_CAPABILITY_TOKEN: {
|
|
72
|
+
token: string;
|
|
73
|
+
}
|
|
74
|
+
PLACEMENT_CAPABILITY_CARD_FORM: PCIBridgeTokenizeResponse
|
|
75
|
+
PLACEMENT_CAPABILITY_PAYPAL: {}
|
|
76
|
+
PLACEMENT_CAPABILITY_APPLE_PAY: {
|
|
77
|
+
initiativeContext: string;
|
|
78
|
+
sessionUrl: string;
|
|
79
|
+
session: string;
|
|
80
|
+
token: string;
|
|
81
|
+
}
|
|
82
|
+
PLACEMENT_CAPABILITY_GOOGLE_PAY: {
|
|
83
|
+
description: string;
|
|
84
|
+
cardDetails: string;
|
|
85
|
+
cardNetwork: string;
|
|
86
|
+
token: string;
|
|
87
|
+
}
|
|
88
|
+
PLACEMENT_CAPABILITY_DIRECTDEBIT_FORM: {
|
|
89
|
+
accountName: string;
|
|
90
|
+
accountNum: string;
|
|
91
|
+
sortCode: string;
|
|
92
|
+
payerReference: string;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export type PaymentMethodAuthenticationTypes = {
|
|
97
|
+
cvv: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export type ChargeEnvironment =
|
|
101
|
+
| 'CHARGE_ENVIRONMENT_RETAIL'
|
|
102
|
+
| 'CHARGE_ENVIRONMENT_ECOMMERCE'
|
|
103
|
+
| 'CHARGE_ENVIRONMENT_MOTO'
|
|
104
|
+
| 'CHARGE_ENVIRONMENT_RENEWAL';
|
|
105
|
+
|
|
106
|
+
export interface ChargeMeta
|
|
107
|
+
{
|
|
108
|
+
customerInfo?: Person;
|
|
109
|
+
billingAddress?: Address;
|
|
110
|
+
shippingAddress?: Address;
|
|
111
|
+
orderItems?: OrderItem[];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface ChargeData
|
|
115
|
+
{
|
|
116
|
+
amount: number;
|
|
117
|
+
currency: string;
|
|
118
|
+
references?: Dictionary;
|
|
119
|
+
labels?: Dictionary;
|
|
120
|
+
language?: string;
|
|
121
|
+
meta?: ChargeMeta;
|
|
122
|
+
connectorId?: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface ChargeType
|
|
126
|
+
{
|
|
127
|
+
readonly charge: ChargeData;
|
|
128
|
+
|
|
129
|
+
prepareChargeWithId(chargeId: string, cfg: ChargeData): void;
|
|
130
|
+
|
|
131
|
+
prepareCharge(merchantReference: string, cfg: ChargeData): void;
|
|
132
|
+
|
|
133
|
+
updateCharge(data: ChargeData): void;
|
|
134
|
+
|
|
135
|
+
setBillingAddress(address: Address): void;
|
|
136
|
+
|
|
137
|
+
setShippingAddress(address: Address): void;
|
|
138
|
+
|
|
139
|
+
setCustomerInfo(customer: Person): void;
|
|
140
|
+
|
|
141
|
+
setOrderItems(items: OrderItem[]): void;
|
|
142
|
+
|
|
143
|
+
addOrderItem(item: OrderItem): void;
|
|
144
|
+
|
|
145
|
+
clearOrderItems(): void;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface OrderItem
|
|
149
|
+
{
|
|
150
|
+
subscriptionId: string;
|
|
151
|
+
renewalNumber: number;
|
|
152
|
+
duration: number;
|
|
153
|
+
startDate: number;
|
|
154
|
+
endDate: number;
|
|
155
|
+
productType: number;
|
|
156
|
+
skuType: number;
|
|
157
|
+
deliveryType: number;
|
|
158
|
+
quantity: number;
|
|
159
|
+
unitPrice: number;
|
|
160
|
+
taxAmount: number;
|
|
161
|
+
discountAmount: number;
|
|
162
|
+
name: string;
|
|
163
|
+
description: string;
|
|
164
|
+
productCode: string;
|
|
165
|
+
skuCode: string;
|
|
166
|
+
termType: number;
|
|
167
|
+
termUnits: number;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export type EventName =
|
|
171
|
+
| 'init'
|
|
172
|
+
| 'token'
|
|
173
|
+
| 'success'
|
|
174
|
+
| 'declined'
|
|
175
|
+
| 'error'
|
|
176
|
+
| 'cancel'
|
|
177
|
+
| 'authentication'
|
|
178
|
+
| 'ready'
|
|
179
|
+
| 'paste'
|
|
180
|
+
| 'all-valid'
|
|
181
|
+
| 'submit'
|
|
182
|
+
| 'method-type-changed'
|
|
183
|
+
| 'charge-created'
|
|
184
|
+
| 'charge-id';
|
|
185
|
+
|
|
186
|
+
export type ChargeHiveEventType = Extract<EventName, 'token' | 'success' | 'declined' | 'authentication'>
|
|
187
|
+
|
|
188
|
+
export type TransactionResponse = {
|
|
189
|
+
responseCode: string;
|
|
190
|
+
responseMessage: string;
|
|
191
|
+
merchantMessage: string;
|
|
192
|
+
failureType: string;
|
|
193
|
+
category: string;
|
|
194
|
+
errorType: string;
|
|
195
|
+
errorProperties: Dictionary;
|
|
196
|
+
originatingCode: string;
|
|
197
|
+
specificErrors: TransactionResponse[];
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export type ChargeHiveEventData = {
|
|
201
|
+
token: {
|
|
202
|
+
name: string;
|
|
203
|
+
scheme: string;
|
|
204
|
+
expiry: string;
|
|
205
|
+
token: string;
|
|
206
|
+
additionalData: Dictionary;
|
|
207
|
+
connectorId: string;
|
|
208
|
+
customerError: string;
|
|
209
|
+
merchantError: string;
|
|
210
|
+
}
|
|
211
|
+
success: {
|
|
212
|
+
chargeId: string;
|
|
213
|
+
transactionId: string;
|
|
214
|
+
transactedAmount: {
|
|
215
|
+
currency: string;
|
|
216
|
+
units: number;
|
|
217
|
+
};
|
|
218
|
+
responseBreakdown: TransactionResponse;
|
|
219
|
+
}
|
|
220
|
+
declined: {
|
|
221
|
+
chargeId: string
|
|
222
|
+
message: string
|
|
223
|
+
responseCode: string
|
|
224
|
+
paymentScheme: string
|
|
225
|
+
responseBreakdown: TransactionResponse
|
|
226
|
+
}
|
|
227
|
+
authentication: {
|
|
228
|
+
environment: string;
|
|
229
|
+
type: string;
|
|
230
|
+
connector: string;
|
|
231
|
+
connectorData: Dictionary;
|
|
232
|
+
paymentType: string;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export type Dictionary = { [key: PropertyKey]: string };
|
|
237
|
+
|
|
238
|
+
export interface AuthorizeResponse
|
|
239
|
+
{
|
|
240
|
+
result: string;
|
|
241
|
+
message: string;
|
|
242
|
+
continuationId: string;
|
|
243
|
+
chargeId: string;
|
|
244
|
+
events: ChargeHiveEvent[];
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export interface ChargeHiveEvent<T extends ChargeHiveEventType = any>
|
|
248
|
+
{
|
|
249
|
+
type: T;
|
|
250
|
+
data: ChargeHiveEventData[T];
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export interface TokenizeResponse
|
|
254
|
+
{
|
|
255
|
+
name: string;
|
|
256
|
+
scheme: string;
|
|
257
|
+
expiry: string;
|
|
258
|
+
token: string;
|
|
259
|
+
additionalData: Dictionary;
|
|
260
|
+
connectorID: string;
|
|
261
|
+
customerError: string;
|
|
262
|
+
merchantError: string;
|
|
263
|
+
}
|
package/package.json
ADDED
package/validation.d.ts
ADDED