gap-nodejs-sdk 1.0.76 → 1.0.77
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/dist/clover/Clover.d.ts +15 -8
- package/dist/clover/Clover.d.ts.map +1 -1
- package/dist/clover/Clover.js +53 -16
- package/dist/clover/payment_response_model.d.ts +27 -0
- package/dist/clover/payment_response_model.d.ts.map +1 -0
- package/dist/clover/payment_response_model.js +93 -0
- package/dist/gap-sdk.js +1 -1
- package/package.json +1 -1
package/dist/clover/Clover.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as clover from "@xuantan97/remote-pay-cloud";
|
|
2
|
+
import { PaymentResponseModel } from "./payment_response_model";
|
|
2
3
|
import { AdjustInput, PaymentInput, RefundInput, RetrieveInput, VoidInput } from "./types";
|
|
3
4
|
export default class Clover {
|
|
4
5
|
static instance: Clover | null;
|
|
@@ -9,8 +10,10 @@ export default class Clover {
|
|
|
9
10
|
cloverConfig: any;
|
|
10
11
|
cloverConnectionListener: clover.remotepay.ICloverConnectorListener;
|
|
11
12
|
isReady: boolean;
|
|
12
|
-
onPairingCode
|
|
13
|
-
onPairingSuccess
|
|
13
|
+
onPairingCode?: (pairingCode: string) => void;
|
|
14
|
+
onPairingSuccess?: (authToken: string) => void;
|
|
15
|
+
deviceError: clover.remotepay.CloverDeviceErrorEvent | null;
|
|
16
|
+
deviceDisconnected: boolean;
|
|
14
17
|
saleResponse: clover.remotepay.SaleResponse | null;
|
|
15
18
|
authResponse: clover.remotepay.AuthResponse | null;
|
|
16
19
|
tipAdjustAuthResponse: clover.remotepay.TipAdjustAuthResponse | null;
|
|
@@ -19,20 +22,22 @@ export default class Clover {
|
|
|
19
22
|
closeoutResponse: clover.remotepay.CloseoutResponse | null;
|
|
20
23
|
retrievePaymentResponse: clover.remotepay.RetrievePaymentResponse | null;
|
|
21
24
|
retrievePendingPaymentsResponse: clover.remotepay.RetrievePendingPaymentsResponse | null;
|
|
25
|
+
retrieveDeviceStatusResponse: clover.remotepay.RetrieveDeviceStatusResponse | null;
|
|
26
|
+
paymentResponse: PaymentResponseModel | null;
|
|
22
27
|
constructor({ cloverConfig, onPairingCode, onPairingSuccess }: {
|
|
23
28
|
cloverConfig: any;
|
|
24
|
-
onPairingCode
|
|
25
|
-
onPairingSuccess
|
|
29
|
+
onPairingCode?: (pairingCode: string) => void;
|
|
30
|
+
onPairingSuccess?: (authToken: string) => void;
|
|
26
31
|
});
|
|
27
32
|
static createInstance(options?: {
|
|
28
33
|
cloverConfig: any;
|
|
29
|
-
onPairingCode
|
|
30
|
-
onPairingSuccess
|
|
34
|
+
onPairingCode?: (pairingCode: string) => void;
|
|
35
|
+
onPairingSuccess?: (authToken: string) => void;
|
|
31
36
|
}): Clover;
|
|
32
37
|
static getInstance(options?: {
|
|
33
38
|
cloverConfig: any;
|
|
34
|
-
onPairingCode
|
|
35
|
-
onPairingSuccess
|
|
39
|
+
onPairingCode?: (pairingCode: string) => void;
|
|
40
|
+
onPairingSuccess?: (authToken: string) => void;
|
|
36
41
|
}): Clover;
|
|
37
42
|
connect(): void;
|
|
38
43
|
doSale(paymentInput: PaymentInput): void;
|
|
@@ -43,8 +48,10 @@ export default class Clover {
|
|
|
43
48
|
doRetrievePayment(retrieveInput: RetrieveInput): void;
|
|
44
49
|
doRetrievePendingPayment(): void;
|
|
45
50
|
doCloseout(): void;
|
|
51
|
+
doPrint(printRequest: clover.remotepay.PrintRequest): void;
|
|
46
52
|
cleanup(): void;
|
|
47
53
|
showMessage(message: any): void;
|
|
54
|
+
checkDeviceStatus(): void;
|
|
48
55
|
private buildCloverConnectionListener;
|
|
49
56
|
private getDeviceConfigurationForNetwork;
|
|
50
57
|
private resetDevice;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Clover.d.ts","sourceRoot":"","sources":["../../src/clover/Clover.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD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,EAAE,MAAM,KAAK,IAAI,CAAC;QAC9C,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;KAClD;IAQD,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE;QACzB,YAAY,EAAE,GAAG,CAAC;QAClB,aAAa,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;QAC9C,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;KAClD;IASD,OAAO;IAYP,MAAM,CAAC,YAAY,EAAE,YAAY;IAoBjC,MAAM,CAAC,YAAY,EAAE,YAAY;IAoBjC,WAAW,CAAC,WAAW,EAAE,WAAW;IAiBpC,MAAM,CAAC,SAAS,EAAE,SAAS;IAiB3B,QAAQ,CAAC,WAAW,EAAE,WAAW;IAiBjC,iBAAiB,CAAC,aAAa,EAAE,aAAa;IAe9C,wBAAwB;IAWxB,UAAU;IAeV,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,SAAS,CAAC,YAAY;IAInD,OAAO;IAMP,WAAW,CAAC,OAAO,KAAA;IAInB,iBAAiB;IAMjB,OAAO,CAAC,6BAA6B;IAmMrC,OAAO,CAAC,gCAAgC;IA2BxC,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,kBAAkB;CAmB7B"}
|
package/dist/clover/Clover.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as clover from "@xuantan97/remote-pay-cloud";
|
|
2
|
+
import { PaymentResponseModel } from "./payment_response_model";
|
|
2
3
|
export default class Clover {
|
|
3
4
|
constructor({ cloverConfig, onPairingCode, onPairingSuccess }) {
|
|
4
5
|
this.cloverConnector = null;
|
|
@@ -7,6 +8,8 @@ export default class Clover {
|
|
|
7
8
|
// across page refreshes, etc.
|
|
8
9
|
this.pendingSaleRequest = null;
|
|
9
10
|
this.isReady = false;
|
|
11
|
+
this.deviceError = null;
|
|
12
|
+
this.deviceDisconnected = true;
|
|
10
13
|
this.saleResponse = null;
|
|
11
14
|
this.authResponse = null;
|
|
12
15
|
this.tipAdjustAuthResponse = null;
|
|
@@ -15,6 +18,8 @@ export default class Clover {
|
|
|
15
18
|
this.closeoutResponse = null;
|
|
16
19
|
this.retrievePaymentResponse = null;
|
|
17
20
|
this.retrievePendingPaymentsResponse = null;
|
|
21
|
+
this.retrieveDeviceStatusResponse = null;
|
|
22
|
+
this.paymentResponse = null;
|
|
18
23
|
this.cloverConfig = cloverConfig;
|
|
19
24
|
this.onPairingCode = onPairingCode;
|
|
20
25
|
this.onPairingSuccess = onPairingSuccess;
|
|
@@ -49,6 +54,7 @@ export default class Clover {
|
|
|
49
54
|
doSale(paymentInput) {
|
|
50
55
|
var _a;
|
|
51
56
|
this.saleResponse = null;
|
|
57
|
+
this.paymentResponse = null;
|
|
52
58
|
if (!this.pendingSaleRequest) {
|
|
53
59
|
this.pendingSaleRequest = new clover.remotepay.SaleRequest();
|
|
54
60
|
this.pendingSaleRequest.setExternalId(paymentInput.refId);
|
|
@@ -69,6 +75,7 @@ export default class Clover {
|
|
|
69
75
|
doAuth(paymentInput) {
|
|
70
76
|
var _a;
|
|
71
77
|
this.authResponse = null;
|
|
78
|
+
this.paymentResponse = null;
|
|
72
79
|
if (!this.pendingSaleRequest) {
|
|
73
80
|
this.pendingSaleRequest = new clover.remotepay.AuthRequest();
|
|
74
81
|
this.pendingSaleRequest.setExternalId(paymentInput.refId);
|
|
@@ -89,6 +96,7 @@ export default class Clover {
|
|
|
89
96
|
doTipAdjust(adjustInput) {
|
|
90
97
|
var _a;
|
|
91
98
|
this.tipAdjustAuthResponse = null;
|
|
99
|
+
this.paymentResponse = null;
|
|
92
100
|
if (!this.pendingSaleRequest) {
|
|
93
101
|
this.pendingSaleRequest = new clover.remotepay.TipAdjustAuthRequest();
|
|
94
102
|
this.pendingSaleRequest.setOrderId(adjustInput.orderId);
|
|
@@ -106,6 +114,7 @@ export default class Clover {
|
|
|
106
114
|
doVoid(voidInput) {
|
|
107
115
|
var _a;
|
|
108
116
|
this.voidPaymentResponse = null;
|
|
117
|
+
this.paymentResponse = null;
|
|
109
118
|
if (!this.pendingSaleRequest) {
|
|
110
119
|
this.pendingSaleRequest = new clover.remotepay.VoidPaymentRequest();
|
|
111
120
|
this.pendingSaleRequest.setOrderId(voidInput.orderId);
|
|
@@ -123,6 +132,7 @@ export default class Clover {
|
|
|
123
132
|
doRefund(refundInput) {
|
|
124
133
|
var _a;
|
|
125
134
|
this.refundPaymentResponse = null;
|
|
135
|
+
this.paymentResponse = null;
|
|
126
136
|
if (!this.pendingSaleRequest) {
|
|
127
137
|
this.pendingSaleRequest = new clover.remotepay.RefundPaymentRequest();
|
|
128
138
|
this.pendingSaleRequest.setOrderId(refundInput.orderId);
|
|
@@ -140,6 +150,7 @@ export default class Clover {
|
|
|
140
150
|
doRetrievePayment(retrieveInput) {
|
|
141
151
|
var _a;
|
|
142
152
|
this.retrievePaymentResponse = null;
|
|
153
|
+
this.paymentResponse = null;
|
|
143
154
|
if (!this.pendingSaleRequest) {
|
|
144
155
|
this.pendingSaleRequest = new clover.remotepay.RetrievePaymentRequest();
|
|
145
156
|
this.pendingSaleRequest.setExternalId(retrieveInput.refId);
|
|
@@ -155,6 +166,7 @@ export default class Clover {
|
|
|
155
166
|
doRetrievePendingPayment() {
|
|
156
167
|
var _a;
|
|
157
168
|
this.retrievePendingPaymentsResponse = null;
|
|
169
|
+
this.paymentResponse = null;
|
|
158
170
|
if (!this.pendingSaleRequest) {
|
|
159
171
|
console.log({ message: "Sending retrieve pending payments" });
|
|
160
172
|
(_a = this.cloverConnector) === null || _a === void 0 ? void 0 : _a.retrievePendingPayments();
|
|
@@ -166,6 +178,7 @@ export default class Clover {
|
|
|
166
178
|
doCloseout() {
|
|
167
179
|
var _a;
|
|
168
180
|
this.closeoutResponse = null;
|
|
181
|
+
this.paymentResponse = null;
|
|
169
182
|
if (!this.pendingSaleRequest) {
|
|
170
183
|
this.pendingSaleRequest = new clover.remotepay.CloseoutRequest();
|
|
171
184
|
this.pendingSaleRequest.setAllowOpenTabs(false);
|
|
@@ -178,6 +191,10 @@ export default class Clover {
|
|
|
178
191
|
this.checkPaymentStatus();
|
|
179
192
|
}
|
|
180
193
|
}
|
|
194
|
+
doPrint(printRequest) {
|
|
195
|
+
var _a;
|
|
196
|
+
(_a = this.cloverConnector) === null || _a === void 0 ? void 0 : _a.print(printRequest);
|
|
197
|
+
}
|
|
181
198
|
cleanup() {
|
|
182
199
|
if (this.cloverConnector) {
|
|
183
200
|
this.cloverConnector.dispose();
|
|
@@ -187,8 +204,17 @@ export default class Clover {
|
|
|
187
204
|
var _a;
|
|
188
205
|
(_a = this.cloverConnector) === null || _a === void 0 ? void 0 : _a.showMessage(message);
|
|
189
206
|
}
|
|
207
|
+
checkDeviceStatus() {
|
|
208
|
+
var _a;
|
|
209
|
+
this.retrieveDeviceStatusResponse = null;
|
|
210
|
+
let retrieveDeviceStatus = new clover.remotepay.RetrieveDeviceStatusRequest();
|
|
211
|
+
(_a = this.cloverConnector) === null || _a === void 0 ? void 0 : _a.retrieveDeviceStatus(retrieveDeviceStatus);
|
|
212
|
+
}
|
|
190
213
|
buildCloverConnectionListener() {
|
|
191
214
|
return Object.assign({}, clover.remotepay.ICloverConnectorListener.prototype, {
|
|
215
|
+
onDeviceConnected: () => {
|
|
216
|
+
this.deviceDisconnected = false;
|
|
217
|
+
},
|
|
192
218
|
onSaleResponse: (response) => {
|
|
193
219
|
var _a;
|
|
194
220
|
console.log({ message: "Payment response received", response: response });
|
|
@@ -196,6 +222,7 @@ export default class Clover {
|
|
|
196
222
|
const requestExternalId = this.pendingSaleRequest.getExternalId();
|
|
197
223
|
this.pendingSaleRequest = null; // The sale is complete
|
|
198
224
|
this.saleResponse = response;
|
|
225
|
+
this.paymentResponse = PaymentResponseModel.build(response);
|
|
199
226
|
if (response.getSuccess()) {
|
|
200
227
|
const payment = response.getPayment();
|
|
201
228
|
// We are choosing to void the payment if it was not authorized for the full amount.
|
|
@@ -223,6 +250,7 @@ export default class Clover {
|
|
|
223
250
|
const requestExternalId = this.pendingSaleRequest.getExternalId();
|
|
224
251
|
this.pendingSaleRequest = null; // The sale is complete
|
|
225
252
|
this.authResponse = response;
|
|
253
|
+
this.paymentResponse = PaymentResponseModel.build(response);
|
|
226
254
|
if (response.getSuccess()) {
|
|
227
255
|
const payment = response.getPayment();
|
|
228
256
|
//auto tip = 0 on auth
|
|
@@ -253,6 +281,7 @@ export default class Clover {
|
|
|
253
281
|
console.log({ message: "Payment response received", response: response });
|
|
254
282
|
this.pendingSaleRequest = null; // The sale is complete
|
|
255
283
|
this.tipAdjustAuthResponse = response;
|
|
284
|
+
this.paymentResponse = PaymentResponseModel.build(response);
|
|
256
285
|
if (response.getSuccess()) {
|
|
257
286
|
}
|
|
258
287
|
else {
|
|
@@ -263,6 +292,7 @@ export default class Clover {
|
|
|
263
292
|
console.log({ message: "Payment response received", response: response });
|
|
264
293
|
this.pendingSaleRequest = null; // The sale is complete
|
|
265
294
|
this.voidPaymentResponse = response;
|
|
295
|
+
this.paymentResponse = PaymentResponseModel.build(response);
|
|
266
296
|
if (response.getSuccess()) {
|
|
267
297
|
}
|
|
268
298
|
else {
|
|
@@ -273,6 +303,7 @@ export default class Clover {
|
|
|
273
303
|
console.log({ message: "Payment response received", response: response });
|
|
274
304
|
this.pendingSaleRequest = null; // The sale is complete
|
|
275
305
|
this.refundPaymentResponse = response;
|
|
306
|
+
this.paymentResponse = PaymentResponseModel.build(response);
|
|
276
307
|
if (response.getSuccess()) {
|
|
277
308
|
}
|
|
278
309
|
else {
|
|
@@ -283,6 +314,7 @@ export default class Clover {
|
|
|
283
314
|
console.log({ message: "Payment response received", response: response });
|
|
284
315
|
this.pendingSaleRequest = null; // The sale is complete
|
|
285
316
|
this.closeoutResponse = response;
|
|
317
|
+
this.paymentResponse = PaymentResponseModel.build(response);
|
|
286
318
|
if (response.getSuccess()) {
|
|
287
319
|
}
|
|
288
320
|
else {
|
|
@@ -344,6 +376,7 @@ export default class Clover {
|
|
|
344
376
|
if (!this.pendingSaleRequest) {
|
|
345
377
|
console.log({ message: "Device Ready to process requests!", merchantInfo: merchantInfo });
|
|
346
378
|
this.isReady = true;
|
|
379
|
+
this.deviceError = null;
|
|
347
380
|
}
|
|
348
381
|
else {
|
|
349
382
|
// We have an unresolved sale. The connection to the device was lost and the customer is in the
|
|
@@ -355,27 +388,31 @@ export default class Clover {
|
|
|
355
388
|
(_a = this.cloverConnector) === null || _a === void 0 ? void 0 : _a.retrieveDeviceStatus(retrieveDeviceStatusRequest);
|
|
356
389
|
}
|
|
357
390
|
},
|
|
358
|
-
onDeviceError:
|
|
359
|
-
|
|
360
|
-
|
|
391
|
+
onDeviceError: (cloverDeviceErrorEvent) => {
|
|
392
|
+
this.deviceError = cloverDeviceErrorEvent;
|
|
393
|
+
},
|
|
394
|
+
onDeviceDisconnected: () => {
|
|
395
|
+
this.deviceDisconnected = true;
|
|
361
396
|
},
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
console.log("The connection to your Clover Device has been dropped.", false);
|
|
397
|
+
onRetrieveDeviceStatusResponse: (response) => {
|
|
398
|
+
this.retrieveDeviceStatusResponse = response;
|
|
365
399
|
}
|
|
366
400
|
});
|
|
367
401
|
}
|
|
368
402
|
getDeviceConfigurationForNetwork() {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
403
|
+
const onPairingCode = (pairingCode) => {
|
|
404
|
+
const pairingCodeMessage = `Please enter pairing code ${pairingCode} on the device`;
|
|
405
|
+
console.log(` > ${pairingCodeMessage}`);
|
|
406
|
+
};
|
|
407
|
+
const onPairingSuccess = (authTokenFromPairing) => {
|
|
408
|
+
console.log(` > Got Pairing Auth Token: ${authTokenFromPairing}`);
|
|
409
|
+
};
|
|
410
|
+
if (typeof this.pairingCode === 'undefined') {
|
|
411
|
+
this.pairingCode = onPairingCode;
|
|
412
|
+
}
|
|
413
|
+
if (typeof this.onPairingSuccess === 'undefined') {
|
|
414
|
+
this.pairingCode = onPairingSuccess;
|
|
415
|
+
}
|
|
379
416
|
const configBuilder = new clover.WebSocketPairedCloverDeviceConfigurationBuilder(this.cloverConfig.applicationId, this.cloverConfig.endpoint, this.cloverConfig.posName, this.cloverConfig.serialNumber, this.cloverConfig.authToken, this.onPairingCode, this.onPairingSuccess);
|
|
380
417
|
return configBuilder.build();
|
|
381
418
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as clover from "@xuantan97/remote-pay-cloud";
|
|
2
|
+
export declare class PaymentResponseModel {
|
|
3
|
+
static STATUS_OK: string;
|
|
4
|
+
static STATUS_FAIL: string;
|
|
5
|
+
static STATUS_CODE_OK: string;
|
|
6
|
+
static STATUS_CODE_FAIL: string;
|
|
7
|
+
static STATUS_CODE_WARNING: string;
|
|
8
|
+
static STATUS_CODE_TIMEOUT: string;
|
|
9
|
+
static ACTION_CLOVER_AUTH_RESPONSE: string;
|
|
10
|
+
static ACTION_CLOVER_ADJUST_RESPONSE: string;
|
|
11
|
+
static ACTION_CLOVER_SALE_RESPONSE: string;
|
|
12
|
+
static ACTION_CLOVER_VOID_RESPONSE: string;
|
|
13
|
+
static ACTION_CLOVER_BATCH_CLOSE_RESPONSE: string;
|
|
14
|
+
static ACTION_CLOVER_RETURN_RESPONSE: string;
|
|
15
|
+
static ACTION_CLOVER_CANCEL_TRANSACTION_WITH_DUE_AMOUNT: string;
|
|
16
|
+
static ACTION_CLOVER_RETRIEVE_PAYMENT_RESPONSE: string;
|
|
17
|
+
status: string | null;
|
|
18
|
+
statusCode: string | null;
|
|
19
|
+
statusMessage: string | null;
|
|
20
|
+
data: any;
|
|
21
|
+
refID: string | null;
|
|
22
|
+
action: string | null;
|
|
23
|
+
approveAmount: number | null;
|
|
24
|
+
amountDue: number | null;
|
|
25
|
+
static build(data: clover.remotepay.SaleResponse | clover.remotepay.AuthResponse | clover.remotepay.TipAdjustAuthResponse | clover.remotepay.VoidPaymentResponse | clover.remotepay.RefundPaymentResponse | clover.remotepay.CloseoutResponse | clover.remotepay.RetrievePaymentResponse | clover.remotepay.RetrievePendingPaymentsResponse): PaymentResponseModel;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=payment_response_model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment_response_model.d.ts","sourceRoot":"","sources":["../../src/clover/payment_response_model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AAEtD,qBAAa,oBAAoB;IAC7B,MAAM,CAAC,SAAS,SAAQ;IACxB,MAAM,CAAC,WAAW,SAAU;IAE5B,MAAM,CAAC,cAAc,SAAQ;IAC7B,MAAM,CAAC,gBAAgB,SAAU;IACjC,MAAM,CAAC,mBAAmB,SAAa;IACvC,MAAM,CAAC,mBAAmB,SAAa;IAEvC,MAAM,CAAC,2BAA2B,SAA0B;IAC5D,MAAM,CAAC,6BAA6B,SAA4B;IAChE,MAAM,CAAC,2BAA2B,SAA0B;IAC5D,MAAM,CAAC,2BAA2B,SAA0B;IAC5D,MAAM,CAAC,kCAAkC,SAAiC;IAC1E,MAAM,CAAC,6BAA6B,SAA4B;IAChE,MAAM,CAAC,gDAAgD,SAA+C;IACtG,MAAM,CAAC,uCAAuC,SAAsC;IAGpF,MAAM,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC7B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAQ;IACjC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAQ;IACpC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC5B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC7B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAQ;IACpC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEhC,MAAM,CAAC,KAAK,CAAC,IAAI,EACb,MAAM,CAAC,SAAS,CAAC,YAAY,GAC3B,MAAM,CAAC,SAAS,CAAC,YAAY,GAC7B,MAAM,CAAC,SAAS,CAAC,qBAAqB,GACtC,MAAM,CAAC,SAAS,CAAC,mBAAmB,GACpC,MAAM,CAAC,SAAS,CAAC,qBAAqB,GACtC,MAAM,CAAC,SAAS,CAAC,gBAAgB,GACjC,MAAM,CAAC,SAAS,CAAC,uBAAuB,GACxC,MAAM,CAAC,SAAS,CAAC,+BAA+B;CAmEzD"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import * as clover from "@xuantan97/remote-pay-cloud";
|
|
2
|
+
export class PaymentResponseModel {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.status = null;
|
|
5
|
+
this.statusCode = null;
|
|
6
|
+
this.statusMessage = null;
|
|
7
|
+
this.refID = null;
|
|
8
|
+
this.action = null;
|
|
9
|
+
this.approveAmount = null;
|
|
10
|
+
this.amountDue = null;
|
|
11
|
+
}
|
|
12
|
+
static build(data) {
|
|
13
|
+
let paymentResponse = new PaymentResponseModel();
|
|
14
|
+
//Check status of reponse
|
|
15
|
+
if (data.getSuccess()) {
|
|
16
|
+
paymentResponse.status = PaymentResponseModel.STATUS_OK;
|
|
17
|
+
paymentResponse.statusCode = PaymentResponseModel.STATUS_CODE_OK;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
paymentResponse.status = PaymentResponseModel.STATUS_FAIL;
|
|
21
|
+
paymentResponse.statusCode = PaymentResponseModel.STATUS_CODE_FAIL;
|
|
22
|
+
}
|
|
23
|
+
paymentResponse.statusMessage = data.getMessage();
|
|
24
|
+
paymentResponse.data = data;
|
|
25
|
+
switch (true) {
|
|
26
|
+
case data instanceof clover.remotepay.SaleResponse:
|
|
27
|
+
data = data;
|
|
28
|
+
paymentResponse.action = PaymentResponseModel.ACTION_CLOVER_SALE_RESPONSE;
|
|
29
|
+
if (data.getPayment()) {
|
|
30
|
+
paymentResponse.refID = data.getPayment().getId();
|
|
31
|
+
paymentResponse.approveAmount = data.getPayment().getAmount();
|
|
32
|
+
}
|
|
33
|
+
break;
|
|
34
|
+
case data instanceof clover.remotepay.AuthResponse:
|
|
35
|
+
data = data;
|
|
36
|
+
paymentResponse.action = PaymentResponseModel.ACTION_CLOVER_AUTH_RESPONSE;
|
|
37
|
+
if (data.getPayment()) {
|
|
38
|
+
paymentResponse.refID = data.getPayment().getId();
|
|
39
|
+
paymentResponse.approveAmount = data.getPayment().getAmount();
|
|
40
|
+
}
|
|
41
|
+
break;
|
|
42
|
+
case data instanceof clover.remotepay.TipAdjustAuthResponse:
|
|
43
|
+
data = data;
|
|
44
|
+
paymentResponse.action = PaymentResponseModel.ACTION_CLOVER_ADJUST_RESPONSE;
|
|
45
|
+
paymentResponse.refID = data.getPaymentId();
|
|
46
|
+
break;
|
|
47
|
+
case data instanceof clover.remotepay.VoidPaymentResponse:
|
|
48
|
+
data = data;
|
|
49
|
+
paymentResponse.action = PaymentResponseModel.ACTION_CLOVER_VOID_RESPONSE;
|
|
50
|
+
if (data.getReason() == clover.order.VoidReason.REJECT_PARTIAL_AUTH) {
|
|
51
|
+
paymentResponse.action = PaymentResponseModel.ACTION_CLOVER_CANCEL_TRANSACTION_WITH_DUE_AMOUNT;
|
|
52
|
+
}
|
|
53
|
+
if (data.getPayment()) {
|
|
54
|
+
paymentResponse.refID = data.getPayment().getId();
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
case data instanceof clover.remotepay.RefundPaymentResponse:
|
|
58
|
+
data = data;
|
|
59
|
+
paymentResponse.action = PaymentResponseModel.ACTION_CLOVER_RETURN_RESPONSE;
|
|
60
|
+
paymentResponse.refID = data.getPaymentId();
|
|
61
|
+
break;
|
|
62
|
+
case data instanceof clover.remotepay.CloseoutResponse:
|
|
63
|
+
data = data;
|
|
64
|
+
paymentResponse.action = PaymentResponseModel.ACTION_CLOVER_BATCH_CLOSE_RESPONSE;
|
|
65
|
+
break;
|
|
66
|
+
case data instanceof clover.remotepay.RetrievePaymentResponse:
|
|
67
|
+
data = data;
|
|
68
|
+
paymentResponse.action = PaymentResponseModel.ACTION_CLOVER_RETRIEVE_PAYMENT_RESPONSE;
|
|
69
|
+
if (data.getPayment()) {
|
|
70
|
+
paymentResponse.refID = data.getPayment().getId();
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
case data instanceof clover.remotepay.RetrievePendingPaymentsResponse:
|
|
74
|
+
data = data;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
return paymentResponse;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
PaymentResponseModel.STATUS_OK = "OK";
|
|
81
|
+
PaymentResponseModel.STATUS_FAIL = "FAIL";
|
|
82
|
+
PaymentResponseModel.STATUS_CODE_OK = "OK";
|
|
83
|
+
PaymentResponseModel.STATUS_CODE_FAIL = "FAIL";
|
|
84
|
+
PaymentResponseModel.STATUS_CODE_WARNING = "WARNING";
|
|
85
|
+
PaymentResponseModel.STATUS_CODE_TIMEOUT = "TIMEOUT";
|
|
86
|
+
PaymentResponseModel.ACTION_CLOVER_AUTH_RESPONSE = "CLOVER_AUTH_RESPONSE";
|
|
87
|
+
PaymentResponseModel.ACTION_CLOVER_ADJUST_RESPONSE = "CLOVER_ADJUST_RESPONSE";
|
|
88
|
+
PaymentResponseModel.ACTION_CLOVER_SALE_RESPONSE = "CLOVER_SALE_RESPONSE";
|
|
89
|
+
PaymentResponseModel.ACTION_CLOVER_VOID_RESPONSE = "CLOVER_VOID_RESPONSE";
|
|
90
|
+
PaymentResponseModel.ACTION_CLOVER_BATCH_CLOSE_RESPONSE = "CLOVER_BATCH_CLOSE_RESPONSE";
|
|
91
|
+
PaymentResponseModel.ACTION_CLOVER_RETURN_RESPONSE = "CLOVER_RETURN_RESPONSE";
|
|
92
|
+
PaymentResponseModel.ACTION_CLOVER_CANCEL_TRANSACTION_WITH_DUE_AMOUNT = "CLOVER_CANCEL_TRANSACTION_WITH_DUE_AMOUNT";
|
|
93
|
+
PaymentResponseModel.ACTION_CLOVER_RETRIEVE_PAYMENT_RESPONSE = "CLOVER_RETRIEVE_PAYMENT_RESPONSE";
|