gap-nodejs-sdk 1.0.66 → 1.0.69
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 +14 -8
- package/dist/clover/Clover.d.ts.map +1 -1
- package/dist/clover/Clover.js +49 -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;
|
|
@@ -45,6 +50,7 @@ export default class Clover {
|
|
|
45
50
|
doCloseout(): void;
|
|
46
51
|
cleanup(): void;
|
|
47
52
|
showMessage(message: any): void;
|
|
53
|
+
checkDeviceStatus(): void;
|
|
48
54
|
private buildCloverConnectionListener;
|
|
49
55
|
private getDeviceConfigurationForNetwork;
|
|
50
56
|
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,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAE3F,MAAM,CAAC,OAAO,OAAO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AC,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;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);
|
|
@@ -187,8 +200,17 @@ export default class Clover {
|
|
|
187
200
|
var _a;
|
|
188
201
|
(_a = this.cloverConnector) === null || _a === void 0 ? void 0 : _a.showMessage(message);
|
|
189
202
|
}
|
|
203
|
+
checkDeviceStatus() {
|
|
204
|
+
var _a;
|
|
205
|
+
this.retrieveDeviceStatusResponse = null;
|
|
206
|
+
let retrieveDeviceStatus = new clover.remotepay.RetrieveDeviceStatusRequest();
|
|
207
|
+
(_a = this.cloverConnector) === null || _a === void 0 ? void 0 : _a.retrieveDeviceStatus(retrieveDeviceStatus);
|
|
208
|
+
}
|
|
190
209
|
buildCloverConnectionListener() {
|
|
191
210
|
return Object.assign({}, clover.remotepay.ICloverConnectorListener.prototype, {
|
|
211
|
+
onDeviceConnected: () => {
|
|
212
|
+
this.deviceDisconnected = false;
|
|
213
|
+
},
|
|
192
214
|
onSaleResponse: (response) => {
|
|
193
215
|
var _a;
|
|
194
216
|
console.log({ message: "Payment response received", response: response });
|
|
@@ -196,6 +218,7 @@ export default class Clover {
|
|
|
196
218
|
const requestExternalId = this.pendingSaleRequest.getExternalId();
|
|
197
219
|
this.pendingSaleRequest = null; // The sale is complete
|
|
198
220
|
this.saleResponse = response;
|
|
221
|
+
this.paymentResponse = PaymentResponseModel.build(response);
|
|
199
222
|
if (response.getSuccess()) {
|
|
200
223
|
const payment = response.getPayment();
|
|
201
224
|
// We are choosing to void the payment if it was not authorized for the full amount.
|
|
@@ -223,6 +246,7 @@ export default class Clover {
|
|
|
223
246
|
const requestExternalId = this.pendingSaleRequest.getExternalId();
|
|
224
247
|
this.pendingSaleRequest = null; // The sale is complete
|
|
225
248
|
this.authResponse = response;
|
|
249
|
+
this.paymentResponse = PaymentResponseModel.build(response);
|
|
226
250
|
if (response.getSuccess()) {
|
|
227
251
|
const payment = response.getPayment();
|
|
228
252
|
//auto tip = 0 on auth
|
|
@@ -253,6 +277,7 @@ export default class Clover {
|
|
|
253
277
|
console.log({ message: "Payment response received", response: response });
|
|
254
278
|
this.pendingSaleRequest = null; // The sale is complete
|
|
255
279
|
this.tipAdjustAuthResponse = response;
|
|
280
|
+
this.paymentResponse = PaymentResponseModel.build(response);
|
|
256
281
|
if (response.getSuccess()) {
|
|
257
282
|
}
|
|
258
283
|
else {
|
|
@@ -263,6 +288,7 @@ export default class Clover {
|
|
|
263
288
|
console.log({ message: "Payment response received", response: response });
|
|
264
289
|
this.pendingSaleRequest = null; // The sale is complete
|
|
265
290
|
this.voidPaymentResponse = response;
|
|
291
|
+
this.paymentResponse = PaymentResponseModel.build(response);
|
|
266
292
|
if (response.getSuccess()) {
|
|
267
293
|
}
|
|
268
294
|
else {
|
|
@@ -273,6 +299,7 @@ export default class Clover {
|
|
|
273
299
|
console.log({ message: "Payment response received", response: response });
|
|
274
300
|
this.pendingSaleRequest = null; // The sale is complete
|
|
275
301
|
this.refundPaymentResponse = response;
|
|
302
|
+
this.paymentResponse = PaymentResponseModel.build(response);
|
|
276
303
|
if (response.getSuccess()) {
|
|
277
304
|
}
|
|
278
305
|
else {
|
|
@@ -283,6 +310,7 @@ export default class Clover {
|
|
|
283
310
|
console.log({ message: "Payment response received", response: response });
|
|
284
311
|
this.pendingSaleRequest = null; // The sale is complete
|
|
285
312
|
this.closeoutResponse = response;
|
|
313
|
+
this.paymentResponse = PaymentResponseModel.build(response);
|
|
286
314
|
if (response.getSuccess()) {
|
|
287
315
|
}
|
|
288
316
|
else {
|
|
@@ -344,6 +372,7 @@ export default class Clover {
|
|
|
344
372
|
if (!this.pendingSaleRequest) {
|
|
345
373
|
console.log({ message: "Device Ready to process requests!", merchantInfo: merchantInfo });
|
|
346
374
|
this.isReady = true;
|
|
375
|
+
this.deviceError = null;
|
|
347
376
|
}
|
|
348
377
|
else {
|
|
349
378
|
// We have an unresolved sale. The connection to the device was lost and the customer is in the
|
|
@@ -355,27 +384,31 @@ export default class Clover {
|
|
|
355
384
|
(_a = this.cloverConnector) === null || _a === void 0 ? void 0 : _a.retrieveDeviceStatus(retrieveDeviceStatusRequest);
|
|
356
385
|
}
|
|
357
386
|
},
|
|
358
|
-
onDeviceError:
|
|
359
|
-
|
|
360
|
-
console.log(`An error has occurred: ${cloverDeviceErrorEvent.getMessage()}`, false);
|
|
387
|
+
onDeviceError: (cloverDeviceErrorEvent) => {
|
|
388
|
+
this.deviceError = cloverDeviceErrorEvent;
|
|
361
389
|
},
|
|
362
|
-
onDeviceDisconnected:
|
|
363
|
-
|
|
364
|
-
|
|
390
|
+
onDeviceDisconnected: () => {
|
|
391
|
+
this.deviceDisconnected = true;
|
|
392
|
+
},
|
|
393
|
+
onRetrieveDeviceStatusResponse: (response) => {
|
|
394
|
+
this.retrieveDeviceStatusResponse = response;
|
|
365
395
|
}
|
|
366
396
|
});
|
|
367
397
|
}
|
|
368
398
|
getDeviceConfigurationForNetwork() {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
399
|
+
const onPairingCode = (pairingCode) => {
|
|
400
|
+
const pairingCodeMessage = `Please enter pairing code ${pairingCode} on the device`;
|
|
401
|
+
console.log(` > ${pairingCodeMessage}`);
|
|
402
|
+
};
|
|
403
|
+
const onPairingSuccess = (authTokenFromPairing) => {
|
|
404
|
+
console.log(` > Got Pairing Auth Token: ${authTokenFromPairing}`);
|
|
405
|
+
};
|
|
406
|
+
if (typeof this.pairingCode === 'undefined') {
|
|
407
|
+
this.pairingCode = onPairingCode;
|
|
408
|
+
}
|
|
409
|
+
if (typeof this.onPairingSuccess === 'undefined') {
|
|
410
|
+
this.pairingCode = onPairingSuccess;
|
|
411
|
+
}
|
|
379
412
|
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
413
|
return configBuilder.build();
|
|
381
414
|
}
|
|
@@ -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;IACx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ructor() {
|
|
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";
|