gap-nodejs-sdk 1.0.76 → 1.0.79

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.
@@ -1,5 +1,7 @@
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";
4
+ export { clover };
3
5
  export default class Clover {
4
6
  static instance: Clover | null;
5
7
  cloverConnector: clover.remotepay.ICloverConnector | null;
@@ -9,8 +11,10 @@ export default class Clover {
9
11
  cloverConfig: any;
10
12
  cloverConnectionListener: clover.remotepay.ICloverConnectorListener;
11
13
  isReady: boolean;
12
- onPairingCode: (pairingCode: string) => void;
13
- onPairingSuccess: (authToken: string) => void;
14
+ onPairingCode?: (pairingCode: string) => void;
15
+ onPairingSuccess?: (authToken: string) => void;
16
+ deviceError: clover.remotepay.CloverDeviceErrorEvent | null;
17
+ deviceDisconnected: boolean;
14
18
  saleResponse: clover.remotepay.SaleResponse | null;
15
19
  authResponse: clover.remotepay.AuthResponse | null;
16
20
  tipAdjustAuthResponse: clover.remotepay.TipAdjustAuthResponse | null;
@@ -19,20 +23,22 @@ export default class Clover {
19
23
  closeoutResponse: clover.remotepay.CloseoutResponse | null;
20
24
  retrievePaymentResponse: clover.remotepay.RetrievePaymentResponse | null;
21
25
  retrievePendingPaymentsResponse: clover.remotepay.RetrievePendingPaymentsResponse | null;
26
+ retrieveDeviceStatusResponse: clover.remotepay.RetrieveDeviceStatusResponse | null;
27
+ paymentResponse: PaymentResponseModel | null;
22
28
  constructor({ cloverConfig, onPairingCode, onPairingSuccess }: {
23
29
  cloverConfig: any;
24
- onPairingCode: (pairingCode: string) => void;
25
- onPairingSuccess: (authToken: string) => void;
30
+ onPairingCode?: (pairingCode: string) => void;
31
+ onPairingSuccess?: (authToken: string) => void;
26
32
  });
27
33
  static createInstance(options?: {
28
34
  cloverConfig: any;
29
- onPairingCode: (pairingCode: string) => void;
30
- onPairingSuccess: (authToken: string) => void;
35
+ onPairingCode?: (pairingCode: string) => void;
36
+ onPairingSuccess?: (authToken: string) => void;
31
37
  }): Clover;
32
38
  static getInstance(options?: {
33
39
  cloverConfig: any;
34
- onPairingCode: (pairingCode: string) => void;
35
- onPairingSuccess: (authToken: string) => void;
40
+ onPairingCode?: (pairingCode: string) => void;
41
+ onPairingSuccess?: (authToken: string) => void;
36
42
  }): Clover;
37
43
  connect(): void;
38
44
  doSale(paymentInput: PaymentInput): void;
@@ -43,8 +49,10 @@ export default class Clover {
43
49
  doRetrievePayment(retrieveInput: RetrieveInput): void;
44
50
  doRetrievePendingPayment(): void;
45
51
  doCloseout(): void;
52
+ doPrint(printRequest: clover.remotepay.PrintRequest): void;
46
53
  cleanup(): void;
47
54
  showMessage(message: any): void;
55
+ checkDeviceStatus(): void;
48
56
  private buildCloverConnectionListener;
49
57
  private getDeviceConfigurationForNetwork;
50
58
  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,MAAM;IACvB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,eAAe,EAAE,MAAM,CAAC,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAQ;IACjE,WAAW,EAAE,GAAG,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAIlB,kBAAkB,EAAE,GAAG,CAAQ;IAC/B,YAAY,EAAE,GAAG,CAAC;IAClB,wBAAwB,EAAE,MAAM,CAAC,SAAS,CAAC,wBAAwB,CAAC;IACpE,OAAO,EAAE,OAAO,CAAS;IAEzB,aAAa,EA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AAE,CAAC,WAAW,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"}
@@ -1,4 +1,6 @@
1
1
  import * as clover from "@xuantan97/remote-pay-cloud";
2
+ import { PaymentResponseModel } from "./payment_response_model";
3
+ export { clover };
2
4
  export default class Clover {
3
5
  constructor({ cloverConfig, onPairingCode, onPairingSuccess }) {
4
6
  this.cloverConnector = null;
@@ -7,6 +9,8 @@ export default class Clover {
7
9
  // across page refreshes, etc.
8
10
  this.pendingSaleRequest = null;
9
11
  this.isReady = false;
12
+ this.deviceError = null;
13
+ this.deviceDisconnected = true;
10
14
  this.saleResponse = null;
11
15
  this.authResponse = null;
12
16
  this.tipAdjustAuthResponse = null;
@@ -15,6 +19,8 @@ export default class Clover {
15
19
  this.closeoutResponse = null;
16
20
  this.retrievePaymentResponse = null;
17
21
  this.retrievePendingPaymentsResponse = null;
22
+ this.retrieveDeviceStatusResponse = null;
23
+ this.paymentResponse = null;
18
24
  this.cloverConfig = cloverConfig;
19
25
  this.onPairingCode = onPairingCode;
20
26
  this.onPairingSuccess = onPairingSuccess;
@@ -49,6 +55,7 @@ export default class Clover {
49
55
  doSale(paymentInput) {
50
56
  var _a;
51
57
  this.saleResponse = null;
58
+ this.paymentResponse = null;
52
59
  if (!this.pendingSaleRequest) {
53
60
  this.pendingSaleRequest = new clover.remotepay.SaleRequest();
54
61
  this.pendingSaleRequest.setExternalId(paymentInput.refId);
@@ -69,6 +76,7 @@ export default class Clover {
69
76
  doAuth(paymentInput) {
70
77
  var _a;
71
78
  this.authResponse = null;
79
+ this.paymentResponse = null;
72
80
  if (!this.pendingSaleRequest) {
73
81
  this.pendingSaleRequest = new clover.remotepay.AuthRequest();
74
82
  this.pendingSaleRequest.setExternalId(paymentInput.refId);
@@ -89,6 +97,7 @@ export default class Clover {
89
97
  doTipAdjust(adjustInput) {
90
98
  var _a;
91
99
  this.tipAdjustAuthResponse = null;
100
+ this.paymentResponse = null;
92
101
  if (!this.pendingSaleRequest) {
93
102
  this.pendingSaleRequest = new clover.remotepay.TipAdjustAuthRequest();
94
103
  this.pendingSaleRequest.setOrderId(adjustInput.orderId);
@@ -106,6 +115,7 @@ export default class Clover {
106
115
  doVoid(voidInput) {
107
116
  var _a;
108
117
  this.voidPaymentResponse = null;
118
+ this.paymentResponse = null;
109
119
  if (!this.pendingSaleRequest) {
110
120
  this.pendingSaleRequest = new clover.remotepay.VoidPaymentRequest();
111
121
  this.pendingSaleRequest.setOrderId(voidInput.orderId);
@@ -123,6 +133,7 @@ export default class Clover {
123
133
  doRefund(refundInput) {
124
134
  var _a;
125
135
  this.refundPaymentResponse = null;
136
+ this.paymentResponse = null;
126
137
  if (!this.pendingSaleRequest) {
127
138
  this.pendingSaleRequest = new clover.remotepay.RefundPaymentRequest();
128
139
  this.pendingSaleRequest.setOrderId(refundInput.orderId);
@@ -140,6 +151,7 @@ export default class Clover {
140
151
  doRetrievePayment(retrieveInput) {
141
152
  var _a;
142
153
  this.retrievePaymentResponse = null;
154
+ this.paymentResponse = null;
143
155
  if (!this.pendingSaleRequest) {
144
156
  this.pendingSaleRequest = new clover.remotepay.RetrievePaymentRequest();
145
157
  this.pendingSaleRequest.setExternalId(retrieveInput.refId);
@@ -155,6 +167,7 @@ export default class Clover {
155
167
  doRetrievePendingPayment() {
156
168
  var _a;
157
169
  this.retrievePendingPaymentsResponse = null;
170
+ this.paymentResponse = null;
158
171
  if (!this.pendingSaleRequest) {
159
172
  console.log({ message: "Sending retrieve pending payments" });
160
173
  (_a = this.cloverConnector) === null || _a === void 0 ? void 0 : _a.retrievePendingPayments();
@@ -166,6 +179,7 @@ export default class Clover {
166
179
  doCloseout() {
167
180
  var _a;
168
181
  this.closeoutResponse = null;
182
+ this.paymentResponse = null;
169
183
  if (!this.pendingSaleRequest) {
170
184
  this.pendingSaleRequest = new clover.remotepay.CloseoutRequest();
171
185
  this.pendingSaleRequest.setAllowOpenTabs(false);
@@ -178,6 +192,10 @@ export default class Clover {
178
192
  this.checkPaymentStatus();
179
193
  }
180
194
  }
195
+ doPrint(printRequest) {
196
+ var _a;
197
+ (_a = this.cloverConnector) === null || _a === void 0 ? void 0 : _a.print(printRequest);
198
+ }
181
199
  cleanup() {
182
200
  if (this.cloverConnector) {
183
201
  this.cloverConnector.dispose();
@@ -187,8 +205,17 @@ export default class Clover {
187
205
  var _a;
188
206
  (_a = this.cloverConnector) === null || _a === void 0 ? void 0 : _a.showMessage(message);
189
207
  }
208
+ checkDeviceStatus() {
209
+ var _a;
210
+ this.retrieveDeviceStatusResponse = null;
211
+ let retrieveDeviceStatus = new clover.remotepay.RetrieveDeviceStatusRequest();
212
+ (_a = this.cloverConnector) === null || _a === void 0 ? void 0 : _a.retrieveDeviceStatus(retrieveDeviceStatus);
213
+ }
190
214
  buildCloverConnectionListener() {
191
215
  return Object.assign({}, clover.remotepay.ICloverConnectorListener.prototype, {
216
+ onDeviceConnected: () => {
217
+ this.deviceDisconnected = false;
218
+ },
192
219
  onSaleResponse: (response) => {
193
220
  var _a;
194
221
  console.log({ message: "Payment response received", response: response });
@@ -196,6 +223,7 @@ export default class Clover {
196
223
  const requestExternalId = this.pendingSaleRequest.getExternalId();
197
224
  this.pendingSaleRequest = null; // The sale is complete
198
225
  this.saleResponse = response;
226
+ this.paymentResponse = PaymentResponseModel.build(response);
199
227
  if (response.getSuccess()) {
200
228
  const payment = response.getPayment();
201
229
  // We are choosing to void the payment if it was not authorized for the full amount.
@@ -223,6 +251,7 @@ export default class Clover {
223
251
  const requestExternalId = this.pendingSaleRequest.getExternalId();
224
252
  this.pendingSaleRequest = null; // The sale is complete
225
253
  this.authResponse = response;
254
+ this.paymentResponse = PaymentResponseModel.build(response);
226
255
  if (response.getSuccess()) {
227
256
  const payment = response.getPayment();
228
257
  //auto tip = 0 on auth
@@ -253,6 +282,7 @@ export default class Clover {
253
282
  console.log({ message: "Payment response received", response: response });
254
283
  this.pendingSaleRequest = null; // The sale is complete
255
284
  this.tipAdjustAuthResponse = response;
285
+ this.paymentResponse = PaymentResponseModel.build(response);
256
286
  if (response.getSuccess()) {
257
287
  }
258
288
  else {
@@ -263,6 +293,7 @@ export default class Clover {
263
293
  console.log({ message: "Payment response received", response: response });
264
294
  this.pendingSaleRequest = null; // The sale is complete
265
295
  this.voidPaymentResponse = response;
296
+ this.paymentResponse = PaymentResponseModel.build(response);
266
297
  if (response.getSuccess()) {
267
298
  }
268
299
  else {
@@ -273,6 +304,7 @@ export default class Clover {
273
304
  console.log({ message: "Payment response received", response: response });
274
305
  this.pendingSaleRequest = null; // The sale is complete
275
306
  this.refundPaymentResponse = response;
307
+ this.paymentResponse = PaymentResponseModel.build(response);
276
308
  if (response.getSuccess()) {
277
309
  }
278
310
  else {
@@ -283,6 +315,7 @@ export default class Clover {
283
315
  console.log({ message: "Payment response received", response: response });
284
316
  this.pendingSaleRequest = null; // The sale is complete
285
317
  this.closeoutResponse = response;
318
+ this.paymentResponse = PaymentResponseModel.build(response);
286
319
  if (response.getSuccess()) {
287
320
  }
288
321
  else {
@@ -344,6 +377,7 @@ export default class Clover {
344
377
  if (!this.pendingSaleRequest) {
345
378
  console.log({ message: "Device Ready to process requests!", merchantInfo: merchantInfo });
346
379
  this.isReady = true;
380
+ this.deviceError = null;
347
381
  }
348
382
  else {
349
383
  // We have an unresolved sale. The connection to the device was lost and the customer is in the
@@ -355,27 +389,31 @@ export default class Clover {
355
389
  (_a = this.cloverConnector) === null || _a === void 0 ? void 0 : _a.retrieveDeviceStatus(retrieveDeviceStatusRequest);
356
390
  }
357
391
  },
358
- onDeviceError: function (cloverDeviceErrorEvent) {
359
- console.log({ message: `An error has occurred: ${cloverDeviceErrorEvent.getMessage()}` });
360
- console.log(`An error has occurred: ${cloverDeviceErrorEvent.getMessage()}`, false);
392
+ onDeviceError: (cloverDeviceErrorEvent) => {
393
+ this.deviceError = cloverDeviceErrorEvent;
394
+ },
395
+ onDeviceDisconnected: () => {
396
+ this.deviceDisconnected = true;
361
397
  },
362
- onDeviceDisconnected: function () {
363
- console.log({ message: "You have been disconnected from the Clover device." });
364
- console.log("The connection to your Clover Device has been dropped.", false);
398
+ onRetrieveDeviceStatusResponse: (response) => {
399
+ this.retrieveDeviceStatusResponse = response;
365
400
  }
366
401
  });
367
402
  }
368
403
  getDeviceConfigurationForNetwork() {
369
- // const onPairingCode = (pairingCode) => {
370
- // const pairingCodeMessage = `Please enter pairing code ${pairingCode} on the device`;
371
- // console.log(` > ${pairingCodeMessage}`);
372
- // this.pairingCode = pairingCode;
373
- // };
374
- // const onPairingSuccess = (authTokenFromPairing) => {
375
- // console.log(` > Got Pairing Auth Token: ${authTokenFromPairing}`);
376
- // this.authToken = authTokenFromPairing;
377
- // this.pairingCode = null;
378
- // };
404
+ const onPairingCode = (pairingCode) => {
405
+ const pairingCodeMessage = `Please enter pairing code ${pairingCode} on the device`;
406
+ console.log(` > ${pairingCodeMessage}`);
407
+ };
408
+ const onPairingSuccess = (authTokenFromPairing) => {
409
+ console.log(` > Got Pairing Auth Token: ${authTokenFromPairing}`);
410
+ };
411
+ if (typeof this.pairingCode === 'undefined') {
412
+ this.pairingCode = onPairingCode;
413
+ }
414
+ if (typeof this.onPairingSuccess === 'undefined') {
415
+ this.pairingCode = onPairingSuccess;
416
+ }
379
417
  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
418
  return configBuilder.build();
381
419
  }
@@ -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";