globalpayments-api 3.10.2 → 3.10.3

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.
Files changed (109) hide show
  1. package/CHANGELOG.md +191 -184
  2. package/LICENSE.md +257 -257
  3. package/README.md +141 -141
  4. package/lib/src/Gateways/PorticoConnector.js +3 -2
  5. package/lib/src/Gateways/PorticoConnector.js.map +1 -1
  6. package/lib/test/Integration/Gateways/GpApiConnector/3DS2.test.js +15 -15
  7. package/lib/test/Integration/Gateways/GpApiConnector/3DSecure.test.js +5 -5
  8. package/lib/test/Integration/Gateways/GpEcomConnector/Credit.test.js +4 -4
  9. package/lib/test/Integration/Gateways/PorticoConnector/Credit.test.js +26 -0
  10. package/lib/test/Integration/Gateways/PorticoConnector/Credit.test.js.map +1 -1
  11. package/lib/test/Integration/Gateways/PorticoConnector/Ecommerce.test.js +8 -8
  12. package/package.json +62 -62
  13. package/appsec.properties +0 -8
  14. package/lib/src/Gateways/RealexConnector.d.ts +0 -30
  15. package/lib/src/Gateways/RealexConnector.js +0 -523
  16. package/lib/src/ServicesConfig.d.ts +0 -27
  17. package/lib/src/ServicesConfig.js +0 -50
  18. package/lib/test/Integration/Gateways/PorticoConnector/AchTest.d.ts +0 -1
  19. package/lib/test/Integration/Gateways/PorticoConnector/AchTest.js +0 -112
  20. package/lib/test/Integration/Gateways/PorticoConnector/Certifications/CheckTest.d.ts +0 -1
  21. package/lib/test/Integration/Gateways/PorticoConnector/Certifications/CheckTest.js +0 -483
  22. package/lib/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceCheckTest.d.ts +0 -1
  23. package/lib/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceCheckTest.js +0 -83
  24. package/lib/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceTest.d.ts +0 -1
  25. package/lib/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceTest.js +0 -1720
  26. package/lib/test/Integration/Gateways/PorticoConnector/Certifications/MotoCheckTest.d.ts +0 -1
  27. package/lib/test/Integration/Gateways/PorticoConnector/Certifications/MotoCheckTest.js +0 -83
  28. package/lib/test/Integration/Gateways/PorticoConnector/Certifications/MotoTest.d.ts +0 -1
  29. package/lib/test/Integration/Gateways/PorticoConnector/Certifications/MotoTest.js +0 -1757
  30. package/lib/test/Integration/Gateways/PorticoConnector/Certifications/RecurringTest.d.ts +0 -1
  31. package/lib/test/Integration/Gateways/PorticoConnector/Certifications/RecurringTest.js +0 -682
  32. package/lib/test/Integration/Gateways/PorticoConnector/Certifications/RetailTest.d.ts +0 -1
  33. package/lib/test/Integration/Gateways/PorticoConnector/Certifications/RetailTest.js +0 -2218
  34. package/lib/test/Integration/Gateways/PorticoConnector/CreditTest.d.ts +0 -1
  35. package/lib/test/Integration/Gateways/PorticoConnector/CreditTest.js +0 -707
  36. package/lib/test/Integration/Gateways/PorticoConnector/DebitTest.d.ts +0 -1
  37. package/lib/test/Integration/Gateways/PorticoConnector/DebitTest.js +0 -151
  38. package/lib/test/Integration/Gateways/PorticoConnector/EbtTest.d.ts +0 -1
  39. package/lib/test/Integration/Gateways/PorticoConnector/EbtTest.js +0 -171
  40. package/lib/test/Integration/Gateways/PorticoConnector/EcommerceTest.d.ts +0 -1
  41. package/lib/test/Integration/Gateways/PorticoConnector/EcommerceTest.js +0 -192
  42. package/lib/test/Integration/Gateways/PorticoConnector/GiftTest.d.ts +0 -1
  43. package/lib/test/Integration/Gateways/PorticoConnector/GiftTest.js +0 -377
  44. package/lib/test/Integration/Gateways/PorticoConnector/RecurringTest.d.ts +0 -1
  45. package/lib/test/Integration/Gateways/PorticoConnector/RecurringTest.js +0 -196
  46. package/lib/test/Integration/Gateways/PorticoConnector/ReportingTest.d.ts +0 -1
  47. package/lib/test/Integration/Gateways/PorticoConnector/ReportingTest.js +0 -53
  48. package/lib/test/Integration/Gateways/ProPayConnector/Certifications/GetInformationCertificationTests.d.ts +0 -1
  49. package/lib/test/Integration/Gateways/ProPayConnector/Certifications/GetInformationCertificationTests.js +0 -100
  50. package/lib/test/Integration/Gateways/ProPayConnector/Certifications/ProPayAccountCertificationTests.d.ts +0 -1
  51. package/lib/test/Integration/Gateways/ProPayConnector/Certifications/ProPayAccountCertificationTests.js +0 -352
  52. package/lib/test/Integration/Gateways/ProPayConnector/Certifications/ProPayFundCertificationTests.d.ts +0 -1
  53. package/lib/test/Integration/Gateways/ProPayConnector/Certifications/ProPayFundCertificationTests.js +0 -123
  54. package/lib/test/Integration/Gateways/ProPayConnector/Certifications/ProPayInNetworkTransactionCertificationTests.d.ts +0 -1
  55. package/lib/test/Integration/Gateways/ProPayConnector/Certifications/ProPayInNetworkTransactionCertificationTests.js +0 -142
  56. package/lib/test/Integration/Gateways/ProPayConnector/GetInformationTests.d.ts +0 -1
  57. package/lib/test/Integration/Gateways/ProPayConnector/GetInformationTests.js +0 -100
  58. package/lib/test/Integration/Gateways/ProPayConnector/ProPayAccountTests.d.ts +0 -1
  59. package/lib/test/Integration/Gateways/ProPayConnector/ProPayAccountTests.js +0 -535
  60. package/lib/test/Integration/Gateways/ProPayConnector/ProPayFundsTests.d.ts +0 -1
  61. package/lib/test/Integration/Gateways/ProPayConnector/ProPayFundsTests.js +0 -124
  62. package/lib/test/Integration/Gateways/ProPayConnector/ProPayInNetworkTransactionTests.d.ts +0 -1
  63. package/lib/test/Integration/Gateways/ProPayConnector/ProPayInNetworkTransactionTests.js +0 -144
  64. package/lib/test/Integration/Gateways/RealexConnector/Certification/AuthTest.d.ts +0 -1
  65. package/lib/test/Integration/Gateways/RealexConnector/Certification/AuthTest.js +0 -4373
  66. package/lib/test/Integration/Gateways/RealexConnector/Certification/AvsTest.d.ts +0 -1
  67. package/lib/test/Integration/Gateways/RealexConnector/Certification/AvsTest.js +0 -758
  68. package/lib/test/Integration/Gateways/RealexConnector/Certification/CreditTest.d.ts +0 -1
  69. package/lib/test/Integration/Gateways/RealexConnector/Certification/CreditTest.js +0 -2399
  70. package/lib/test/Integration/Gateways/RealexConnector/Certification/HoldTest.d.ts +0 -1
  71. package/lib/test/Integration/Gateways/RealexConnector/Certification/HoldTest.js +0 -1656
  72. package/lib/test/Integration/Gateways/RealexConnector/Certification/ManualTest.d.ts +0 -1
  73. package/lib/test/Integration/Gateways/RealexConnector/Certification/ManualTest.js +0 -5650
  74. package/lib/test/Integration/Gateways/RealexConnector/Certification/OtbTest.d.ts +0 -1
  75. package/lib/test/Integration/Gateways/RealexConnector/Certification/OtbTest.js +0 -1985
  76. package/lib/test/Integration/Gateways/RealexConnector/Certification/RebateTest.d.ts +0 -1
  77. package/lib/test/Integration/Gateways/RealexConnector/Certification/RebateTest.js +0 -2369
  78. package/lib/test/Integration/Gateways/RealexConnector/Certification/ReleaseTest.d.ts +0 -1
  79. package/lib/test/Integration/Gateways/RealexConnector/Certification/ReleaseTest.js +0 -1703
  80. package/lib/test/Integration/Gateways/RealexConnector/Certification/SettleTest.d.ts +0 -1
  81. package/lib/test/Integration/Gateways/RealexConnector/Certification/SettleTest.js +0 -2053
  82. package/lib/test/Integration/Gateways/RealexConnector/Certification/ValidationTest.d.ts +0 -1
  83. package/lib/test/Integration/Gateways/RealexConnector/Certification/ValidationTest.js +0 -2469
  84. package/lib/test/Integration/Gateways/RealexConnector/Certification/VerifyEnrolledTest.d.ts +0 -1
  85. package/lib/test/Integration/Gateways/RealexConnector/Certification/VerifyEnrolledTest.js +0 -3116
  86. package/lib/test/Integration/Gateways/RealexConnector/Certification/VoidTest.d.ts +0 -1
  87. package/lib/test/Integration/Gateways/RealexConnector/Certification/VoidTest.js +0 -2031
  88. package/lib/test/Integration/Gateways/RealexConnector/CreditTest.d.ts +0 -1
  89. package/lib/test/Integration/Gateways/RealexConnector/CreditTest.js +0 -322
  90. package/lib/test/Integration/Gateways/RealexConnector/HppTest.d.ts +0 -1
  91. package/lib/test/Integration/Gateways/RealexConnector/HppTest.js +0 -98
  92. package/lib/test/Integration/Gateways/RealexConnector/RecurringTest.d.ts +0 -1
  93. package/lib/test/Integration/Gateways/RealexConnector/RecurringTest.js +0 -263
  94. package/lib/test/Integration/Services/CheckServiceTest.d.ts +0 -1
  95. package/lib/test/Integration/Services/CheckServiceTest.js +0 -98
  96. package/lib/test/Integration/Services/CreditServiceTest.d.ts +0 -1
  97. package/lib/test/Integration/Services/CreditServiceTest.js +0 -313
  98. package/lib/test/Integration/Services/DebitServiceTest.d.ts +0 -1
  99. package/lib/test/Integration/Services/DebitServiceTest.js +0 -154
  100. package/lib/test/Integration/Services/EBTServiceTest.d.ts +0 -1
  101. package/lib/test/Integration/Services/EBTServiceTest.js +0 -135
  102. package/lib/test/Unit/Builders/AuthorizationBuilder/ValidationTest.d.ts +0 -1
  103. package/lib/test/Unit/Builders/AuthorizationBuilder/ValidationTest.js +0 -161
  104. package/lib/test/Unit/Builders/ReportBuilder/ValidationTest.d.ts +0 -1
  105. package/lib/test/Unit/Builders/ReportBuilder/ValidationTest.js +0 -139
  106. package/lib/test/Unit/Gateways/PorticoConnector/InputValidationTest.d.ts +0 -1
  107. package/lib/test/Unit/Gateways/PorticoConnector/InputValidationTest.js +0 -202
  108. package/lib/test/Unit/Gateways/RealexConnector/CreditTest.d.ts +0 -1
  109. package/lib/test/Unit/Gateways/RealexConnector/CreditTest.js +0 -29
@@ -1,523 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.RealexConnector = void 0;
19
- var elementtree_1 = require("@azz/elementtree");
20
- var __1 = require("../");
21
- var XmlGateway_1 = require("./XmlGateway");
22
- var RealexConnector = /** @class */ (function (_super) {
23
- __extends(RealexConnector, _super);
24
- function RealexConnector() {
25
- var _this = _super !== null && _super.apply(this, arguments) || this;
26
- _this.supportsHostedPayments = true;
27
- _this.supportsRetrieval = false;
28
- _this.supportsUpdatePaymentDetails = true;
29
- return _this;
30
- }
31
- RealexConnector.prototype.processAuthorization = function (builder) {
32
- var _this = this;
33
- var timestamp = __1.GenerationUtils.generateTimestamp();
34
- var orderId = builder.orderId
35
- ? builder.orderId
36
- : __1.GenerationUtils.generateOrderId();
37
- // build Request
38
- var request = elementtree_1.Element("request", {
39
- timestamp: timestamp,
40
- type: this.mapAuthRequestType(builder),
41
- });
42
- if (this.merchantId) {
43
- elementtree_1.SubElement(request, "merchantid").append(elementtree_1.CData(this.merchantId));
44
- }
45
- if (this.accountId) {
46
- elementtree_1.SubElement(request, "account").append(elementtree_1.CData(this.accountId));
47
- }
48
- if (this.channel) {
49
- elementtree_1.SubElement(request, "channel").append(elementtree_1.CData(this.channel));
50
- }
51
- elementtree_1.SubElement(request, "orderid").append(elementtree_1.CData(orderId));
52
- if (builder.amount) {
53
- var amountAttrs = builder.currency
54
- ? { currency: builder.currency }
55
- : {};
56
- elementtree_1.SubElement(request, "amount", amountAttrs).append(elementtree_1.CData(this.numberFormat(builder.amount)));
57
- }
58
- // hydrate the payment data fields
59
- if (builder.paymentMethod instanceof __1.CreditCardData) {
60
- var card = builder.paymentMethod;
61
- if (builder.transactionModifier === __1.TransactionModifier.EncryptedMobile) {
62
- elementtree_1.SubElement(request, "token").append(elementtree_1.CData(card.token));
63
- elementtree_1.SubElement(request, "mobile").append(elementtree_1.CData(card.mobileType));
64
- }
65
- else {
66
- var cardElement = elementtree_1.SubElement(request, "card");
67
- elementtree_1.SubElement(cardElement, "number").append(elementtree_1.CData(card.number));
68
- var date = __1.StringUtils.leftPad(card.expMonth, 2, "0") +
69
- __1.StringUtils.leftPad((card.expYear || "").substr(2, 2), 2, "0");
70
- elementtree_1.SubElement(cardElement, "expdate").append(elementtree_1.CData(date));
71
- elementtree_1.SubElement(cardElement, "type").append(elementtree_1.CData(card.getCardType().toUpperCase()));
72
- elementtree_1.SubElement(cardElement, "chname").append(elementtree_1.CData(card.cardHolderName));
73
- if (card.cvn) {
74
- var cvnElement = elementtree_1.SubElement(cardElement, "cvn");
75
- elementtree_1.SubElement(cvnElement, "number").append(elementtree_1.CData(card.cvn));
76
- elementtree_1.SubElement(cvnElement, "presind").append(elementtree_1.CData(card.cvnPresenceIndicator.toString()));
77
- }
78
- // issueno
79
- }
80
- var isVerify = builder.transactionType === __1.TransactionType.Verify;
81
- elementtree_1.SubElement(request, "sha1hash").append(elementtree_1.CData(this.generateHash(timestamp, orderId, builder.amount ? this.numberFormat(builder.amount) : "", builder.currency, builder.transactionModifier === __1.TransactionModifier.EncryptedMobile
82
- ? card.token
83
- : card.number, isVerify)));
84
- }
85
- if (builder.paymentMethod instanceof __1.RecurringPaymentMethod) {
86
- var recurring = builder.paymentMethod;
87
- elementtree_1.SubElement(request, "payerref").append(elementtree_1.CData(recurring.customerKey));
88
- elementtree_1.SubElement(request, "paymentmethod").append(elementtree_1.CData(recurring.key || recurring.id));
89
- if (builder.cvn) {
90
- var paymentData = elementtree_1.SubElement(request, "paymentdata");
91
- var cvn = elementtree_1.SubElement(paymentData, "cvn");
92
- elementtree_1.SubElement(cvn, "number").append(elementtree_1.CData(builder.cvn));
93
- }
94
- var isVerify = builder.transactionType === __1.TransactionType.Verify;
95
- elementtree_1.SubElement(request, "sha1hash").append(elementtree_1.CData(this.generateHash(timestamp, orderId, builder.amount ? this.numberFormat(builder.amount) : "", builder.currency, recurring.customerKey, isVerify)));
96
- }
97
- // refund hash
98
- if (builder.transactionType === __1.TransactionType.Refund) {
99
- elementtree_1.SubElement(request, "refundhash").append(elementtree_1.CData(__1.GenerationUtils.generateHash(this.refundPassword) || ""));
100
- }
101
- // this needs to be figured out based on txn type and set to 0, 1 or MULTI
102
- if (builder.transactionType === __1.TransactionType.Sale ||
103
- builder.transactionType === __1.TransactionType.Auth) {
104
- var autoSettle = builder.transactionType === __1.TransactionType.Sale ? "1" : "0";
105
- elementtree_1.SubElement(request, "autosettle", { flag: autoSettle });
106
- }
107
- if (builder.description) {
108
- var comments = elementtree_1.SubElement(request, "comments");
109
- elementtree_1.SubElement(comments, "comment", { id: 1 }).append(elementtree_1.CData(builder.description));
110
- }
111
- if (builder.customerId ||
112
- builder.productId ||
113
- builder.customerIpAddress ||
114
- builder.clientTransactionId) {
115
- var tssInfo = elementtree_1.SubElement(request, "tssinfo");
116
- elementtree_1.SubElement(tssInfo, "custnum").append(elementtree_1.CData(builder.customerId));
117
- elementtree_1.SubElement(tssInfo, "prodid").append(elementtree_1.CData(builder.productId));
118
- elementtree_1.SubElement(tssInfo, "varref").append(elementtree_1.CData(builder.clientTransactionId));
119
- elementtree_1.SubElement(tssInfo, "custipaddress").append(elementtree_1.CData(builder.customerIpAddress));
120
- }
121
- if (builder.ecommerceInfo) {
122
- var mpi = elementtree_1.SubElement(request, "mpi");
123
- elementtree_1.SubElement(mpi, "cavv").append(elementtree_1.CData(builder.ecommerceInfo.cavv));
124
- elementtree_1.SubElement(mpi, "xid").append(elementtree_1.CData(builder.ecommerceInfo.xid));
125
- elementtree_1.SubElement(mpi, "eci").append(elementtree_1.CData(builder.ecommerceInfo.eci));
126
- }
127
- return this.doTransaction(this.buildEnvelope(request)).then(function (response) {
128
- return _this.mapResponse(response);
129
- });
130
- };
131
- RealexConnector.prototype.serializeRequest = function (builder) {
132
- if (!this.hostedPaymentConfig) {
133
- throw new __1.ApiError("Hosted configuration missing. Please check your configuration");
134
- }
135
- var encoder = this.hostedPaymentConfig.version === __1.HppVersion.Version2
136
- ? function (t) { return t; }
137
- : __1.StringUtils.btoa;
138
- var request = {};
139
- var orderId = builder.orderId || __1.GenerationUtils.generateOrderId();
140
- var timestamp = builder.timestamp || __1.GenerationUtils.generateTimestamp();
141
- if (builder.transactionType !== __1.TransactionType.Sale &&
142
- builder.transactionType !== __1.TransactionType.Auth &&
143
- builder.transactionType !== __1.TransactionType.Verify) {
144
- throw new __1.UnsupportedTransactionError();
145
- }
146
- request.MERCHANT_ID = encoder(this.merchantId || "");
147
- request.ACCOUNT = encoder(this.accountId || "");
148
- request.CHANNEL = encoder(this.channel || "");
149
- request.ORDER_ID = encoder(orderId || "");
150
- if (builder.amount) {
151
- request.AMOUNT = encoder(this.numberFormat(builder.amount) || "");
152
- }
153
- request.CURRENCY = encoder(builder.currency || "");
154
- request.TIMESTAMP = encoder(timestamp || "");
155
- request.AUTO_SETTLE_FLAG = encoder(builder.transactionType === __1.TransactionType.Sale ? "1" : "0" || "");
156
- request.COMMENT1 = encoder(builder.Description || "");
157
- // request.COMMENT2 = encoder( || "");
158
- if (this.hostedPaymentConfig.requestTransactionStabilityScore) {
159
- request.RETURN_TSS = encoder(this.hostedPaymentConfig.requestTransactionStabilityScore
160
- ? "1"
161
- : "0" || "");
162
- }
163
- if (this.hostedPaymentConfig.directCurrencyConversionEnabled) {
164
- request.DCC_ENABLE = encoder(this.hostedPaymentConfig.directCurrencyConversionEnabled
165
- ? "1"
166
- : "0" || "");
167
- }
168
- if (builder.hostedPaymentData) {
169
- request.CUST_NUM = encoder(builder.hostedPaymentData.customerNumber || "");
170
- if (this.hostedPaymentConfig.displaySavedCards &&
171
- builder.hostedPaymentData.customerKey) {
172
- request.HPP_SELECT_STORED_CARD = encoder(builder.hostedPaymentData.customerKey || "");
173
- }
174
- if (builder.hostedPaymentData.offerToSaveCard) {
175
- request.OFFER_SAVE_CARD = encoder(builder.hostedPaymentData.offerToSaveCard ? "1" : "0" || "");
176
- }
177
- if (builder.hostedPaymentData.customerExists) {
178
- request.PAYER_EXIST = encoder(builder.hostedPaymentData.customerExists ? "1" : "0" || "");
179
- }
180
- request.PAYER_REF = encoder(builder.hostedPaymentData.customerKey || "");
181
- request.PMT_REF = encoder(builder.hostedPaymentData.paymentKey || "");
182
- request.PROD_ID = encoder(builder.hostedPaymentData.productId || "");
183
- }
184
- if (builder.shippingAddress) {
185
- request.SHIPPING_CODE = encoder(builder.shippingAddress.postalCode || "");
186
- request.SHIPPING_CO = encoder(builder.shippingAddress.country || "");
187
- }
188
- if (builder.sillingAddress) {
189
- request.BILLING_CODE = encoder(builder.billingAddress.postalCode || "");
190
- request.BILLING_CO = encoder(builder.billingAddress.country || "");
191
- }
192
- request.CUST_NUM = encoder(builder.customerId || "");
193
- request.VAR_REF = encoder(builder.clientTransactionId || "");
194
- request.HPP_LANG = encoder(this.hostedPaymentConfig.language || "");
195
- request.MERCHANT_RESPONSE_URL = encoder(this.hostedPaymentConfig.responseUrl || "");
196
- request.CARD_PAYMENT_BUTTON = encoder(this.hostedPaymentConfig.paymentButtonText || "");
197
- if (this.hostedPaymentConfig.cardStorageEnabled) {
198
- request.CARD_STORAGE_ENABLE = encoder(this.hostedPaymentConfig.cardStorageEnabled ? "1" : "0" || "");
199
- }
200
- if (builder.transactionType === __1.TransactionType.Verify) {
201
- request.VALIDATE_CARD_ONLY = encoder("1" || "");
202
- }
203
- if (this.hostedPaymentConfig.fraudFilterMode) {
204
- request.HPP_FRAUD_FILTER_MODE = encoder(this.hostedPaymentConfig.fraudFilterMode.toString() || "");
205
- }
206
- if (builder.recurringType || builder.recurringSequence) {
207
- if (builder.recurringType) {
208
- request.RECURRING_TYPE = encoder(builder.recurringType.toString().toLowerCase() || "");
209
- }
210
- if (builder.recurringSequence) {
211
- request.RECURRING_SEQUENCE = encoder(builder.recurringSequence.toString().toLowerCase() || "");
212
- }
213
- }
214
- if (this.hostedPaymentConfig.version) {
215
- request.HPP_VERSION = encoder(this.hostedPaymentConfig.version.toString() || "");
216
- }
217
- var toHash = [
218
- timestamp,
219
- this.merchantId,
220
- orderId,
221
- builder.amount ? this.numberFormat(builder.amount) : null,
222
- builder.currency,
223
- ];
224
- if (this.hostedPaymentConfig.cardStorageEnabled ||
225
- (builder.hostedPaymentData && builder.hostedPaymentData.offerToSaveCard)) {
226
- toHash.push(builder.hostedPaymentData.customerKey
227
- ? builder.hostedPaymentData.customerKey
228
- : null);
229
- toHash.push(builder.hostedPaymentData.paymentKey
230
- ? builder.hostedPaymentData.paymentKey
231
- : null);
232
- }
233
- if (this.hostedPaymentConfig.fraudFilterMode &&
234
- this.hostedPaymentConfig.fraudFilterMode !== __1.FraudFilterMode.None) {
235
- toHash.push(this.hostedPaymentConfig.fraudFilterMode.toString());
236
- }
237
- request.SHA1HASH = encoder(__1.GenerationUtils.generateHash(toHash.join("."), this.sharedSecret) || "");
238
- return JSON.stringify(request);
239
- };
240
- RealexConnector.prototype.manageTransaction = function (builder) {
241
- var _this = this;
242
- var timestamp = __1.GenerationUtils.generateTimestamp();
243
- var orderId = builder.orderId || __1.GenerationUtils.generateOrderId();
244
- // build Request
245
- var request = elementtree_1.Element("request", {
246
- timestamp: timestamp,
247
- type: this.mapManageRequestType(builder.transactionType),
248
- });
249
- if (this.merchantId) {
250
- elementtree_1.SubElement(request, "merchantid").append(elementtree_1.CData(this.merchantId));
251
- }
252
- if (this.accountId) {
253
- elementtree_1.SubElement(request, "account").append(elementtree_1.CData(this.accountId));
254
- }
255
- if (this.channel) {
256
- elementtree_1.SubElement(request, "channel").append(elementtree_1.CData(this.channel));
257
- }
258
- elementtree_1.SubElement(request, "orderid").append(elementtree_1.CData(orderId));
259
- if (builder.paymentMethod) {
260
- var ref = builder.paymentMethod;
261
- elementtree_1.SubElement(request, "pasref").append(elementtree_1.CData(ref.transactionId));
262
- }
263
- if (builder.amount) {
264
- var amountAttrs = builder.currency
265
- ? { currency: builder.currency }
266
- : {};
267
- elementtree_1.SubElement(request, "amount", amountAttrs).append(elementtree_1.CData(this.numberFormat(builder.amount)));
268
- }
269
- else if (builder.transactionType === __1.TransactionType.Capture) {
270
- throw new __1.BuilderError("Amount cannot be null for capture");
271
- }
272
- if (builder.transactionType === __1.TransactionType.Refund) {
273
- if (builder.authorizationCode) {
274
- elementtree_1.SubElement(request, "authcode").append(elementtree_1.CData(builder.authorizationCode));
275
- }
276
- elementtree_1.SubElement(request, "refundhash").append(elementtree_1.CData(__1.GenerationUtils.generateHash(this.rebatePassword)));
277
- }
278
- if (builder.reasonCode) {
279
- elementtree_1.SubElement(request, "reasoncode").append(elementtree_1.CData(builder.reasonCode.toString()));
280
- }
281
- if (builder.description) {
282
- var comments = elementtree_1.SubElement(request, "comments");
283
- elementtree_1.SubElement(comments, "comment", { id: 1 }).append(elementtree_1.CData(builder.description));
284
- }
285
- elementtree_1.SubElement(request, "sha1hash").append(elementtree_1.CData(this.generateHash(timestamp, orderId, builder.amount ? this.numberFormat(builder.amount) : "", builder.currency, "")));
286
- return this.doTransaction(this.buildEnvelope(request)).then(function (response) {
287
- return _this.mapResponse(response);
288
- });
289
- };
290
- RealexConnector.prototype.processReport = function (_builder) {
291
- throw new __1.UnsupportedTransactionError("Reporting functionality is not supported through this gateway.");
292
- };
293
- RealexConnector.prototype.processRecurring = function (builder) {
294
- var _this = this;
295
- var timestamp = __1.GenerationUtils.generateTimestamp();
296
- var orderId = builder.orderId || __1.GenerationUtils.generateOrderId();
297
- // build Request
298
- var request = elementtree_1.Element("request", {
299
- timestamp: timestamp,
300
- type: this.mapRecurringRequestType(builder),
301
- });
302
- if (this.merchantId) {
303
- elementtree_1.SubElement(request, "merchantid").append(elementtree_1.CData(this.merchantId));
304
- }
305
- if (this.accountId) {
306
- elementtree_1.SubElement(request, "account").append(elementtree_1.CData(this.accountId));
307
- }
308
- elementtree_1.SubElement(request, "orderid").append(elementtree_1.CData(orderId));
309
- if (builder.transactionType === __1.TransactionType.Create ||
310
- builder.transactionType === __1.TransactionType.Edit) {
311
- if (builder.entity instanceof __1.Customer) {
312
- var customer = builder.entity;
313
- request.append(this.buildCustomer(customer));
314
- elementtree_1.SubElement(request, "sha1hash").append(elementtree_1.CData(__1.GenerationUtils.generateHash([timestamp, this.merchantId, orderId, "", "", customer.key].join("."), this.sharedSecret)));
315
- }
316
- else if (builder.entity instanceof __1.RecurringPaymentMethod) {
317
- var payment = builder.entity;
318
- var cardElement = elementtree_1.SubElement(request, "card");
319
- elementtree_1.SubElement(cardElement, "ref").append(elementtree_1.CData(payment.key || payment.id));
320
- elementtree_1.SubElement(cardElement, "payerref").append(elementtree_1.CData(payment.customerKey));
321
- if (payment.paymentMethod) {
322
- var card = payment.paymentMethod;
323
- var expiry = __1.StringUtils.leftPad(card.expMonth, 2, "0") +
324
- __1.StringUtils.leftPad((card.expYear || "").substr(2, 2), 2, "0");
325
- elementtree_1.SubElement(cardElement, "number").append(elementtree_1.CData(card.number));
326
- elementtree_1.SubElement(cardElement, "expdate").append(elementtree_1.CData(expiry));
327
- elementtree_1.SubElement(cardElement, "chname").append(elementtree_1.CData(card.cardHolderName));
328
- elementtree_1.SubElement(cardElement, "type").append(elementtree_1.CData(card.getCardType().toUpperCase()));
329
- var sha1hash = "";
330
- if (builder.transactionType === __1.TransactionType.Create) {
331
- sha1hash = __1.GenerationUtils.generateHash([
332
- timestamp,
333
- this.merchantId,
334
- orderId,
335
- "",
336
- "",
337
- payment.customerKey,
338
- card.cardHolderName,
339
- card.number,
340
- ].join("."), this.sharedSecret);
341
- }
342
- else {
343
- sha1hash = __1.GenerationUtils.generateHash([
344
- timestamp,
345
- this.merchantId,
346
- payment.customerKey,
347
- payment.key || payment.id,
348
- expiry,
349
- card.number,
350
- ].join("."), this.sharedSecret);
351
- }
352
- elementtree_1.SubElement(request, "sha1hash").append(elementtree_1.CData(sha1hash));
353
- }
354
- }
355
- }
356
- else if (builder.transactionType === __1.TransactionType.Delete) {
357
- if (builder.entity instanceof __1.RecurringPaymentMethod) {
358
- var payment = builder.entity;
359
- var cardElement = elementtree_1.SubElement(request, "card");
360
- elementtree_1.SubElement(cardElement, "ref").append(elementtree_1.CData(payment.key || payment.id));
361
- elementtree_1.SubElement(cardElement, "payerref").append(elementtree_1.CData(payment.customerKey));
362
- }
363
- }
364
- return this.doTransaction(this.buildEnvelope(request)).then(function (response) {
365
- return _this.mapRecurringResponse(response, builder);
366
- });
367
- };
368
- RealexConnector.prototype.buildEnvelope = function (transaction) {
369
- return new elementtree_1.ElementTree(transaction).write();
370
- };
371
- RealexConnector.prototype.buildCustomer = function (customer) {
372
- var payer = elementtree_1.Element("payer", {
373
- ref: customer.key || __1.StringUtils.uuid(),
374
- type: "Retail",
375
- });
376
- elementtree_1.SubElement(payer, "title").append(elementtree_1.CData(customer.title));
377
- elementtree_1.SubElement(payer, "firstname").append(elementtree_1.CData(customer.firstName));
378
- elementtree_1.SubElement(payer, "surname").append(elementtree_1.CData(customer.lastName));
379
- elementtree_1.SubElement(payer, "company").append(elementtree_1.CData(customer.company));
380
- if (customer.address) {
381
- var address = elementtree_1.SubElement(payer, "address");
382
- elementtree_1.SubElement(address, "line1").append(elementtree_1.CData(customer.address.streetAddress1));
383
- elementtree_1.SubElement(address, "line2").append(elementtree_1.CData(customer.address.streetAddress2));
384
- elementtree_1.SubElement(address, "line3").append(elementtree_1.CData(customer.address.streetAddress3));
385
- elementtree_1.SubElement(address, "city").append(elementtree_1.CData(customer.address.city));
386
- elementtree_1.SubElement(address, "county").append(elementtree_1.CData(customer.address.province));
387
- elementtree_1.SubElement(address, "postcode").append(elementtree_1.CData(customer.address.postalCode));
388
- if (customer.address.country) {
389
- elementtree_1.SubElement(address, "country", { code: "GB" }).append(elementtree_1.CData(customer.address.country));
390
- }
391
- }
392
- var phone = elementtree_1.SubElement(payer, "phonenumbers");
393
- elementtree_1.SubElement(phone, "home").append(elementtree_1.CData(customer.homePhone));
394
- elementtree_1.SubElement(phone, "work").append(elementtree_1.CData(customer.workPhone));
395
- elementtree_1.SubElement(phone, "fax").append(elementtree_1.CData(customer.fax));
396
- elementtree_1.SubElement(phone, "mobile").append(elementtree_1.CData(customer.mobilePhone));
397
- elementtree_1.SubElement(payer, "email").append(elementtree_1.CData(customer.email));
398
- return payer;
399
- };
400
- RealexConnector.prototype.mapResponse = function (rawResponse) {
401
- var result = new __1.Transaction();
402
- var root = elementtree_1.XML(rawResponse);
403
- this.checkResponse(root);
404
- result.responseCode = root.findtext(".//result");
405
- result.responseMessage = root.findtext(".//message");
406
- result.cvnResponseCode = root.findtext(".//cvnresult");
407
- result.avsResponseCode = root.findtext(".//avspostcoderesponse");
408
- result.timestamp = root.findtext(".//timestamp");
409
- result.transactionReference = new __1.TransactionReference();
410
- result.transactionReference.authCode = root.findtext(".//authcode");
411
- result.transactionReference.orderId = root.findtext(".//orderid");
412
- result.transactionReference.paymentMethodType = __1.PaymentMethodType.Credit;
413
- result.transactionReference.transactionId = root.findtext(".//pasref");
414
- return result;
415
- };
416
- RealexConnector.prototype.mapRecurringResponse = function (rawResponse, builder) {
417
- var root = elementtree_1.XML(rawResponse);
418
- this.checkResponse(root);
419
- return builder.entity;
420
- };
421
- RealexConnector.prototype.checkResponse = function (root, acceptedCodes) {
422
- if (!acceptedCodes) {
423
- acceptedCodes = ["00"];
424
- }
425
- var responseCode = root.findtext(".//result");
426
- var responseMessage = root.findtext(".//message");
427
- if (acceptedCodes.indexOf(responseCode) === -1) {
428
- throw new __1.GatewayError("Unexpected Gateway Response: " + responseCode + " - " + responseMessage, responseCode, responseMessage);
429
- }
430
- };
431
- RealexConnector.prototype.generateHash = function (timestamp, orderId, amount, currency, paymentData, verify) {
432
- if (verify === void 0) { verify = false; }
433
- var data = [timestamp, this.merchantId, orderId];
434
- if (false === verify) {
435
- data.push(amount);
436
- data.push(currency);
437
- }
438
- data.push(paymentData);
439
- return __1.GenerationUtils.generateHash(data.join("."), this.sharedSecret);
440
- };
441
- RealexConnector.prototype.mapAuthRequestType = function (builder) {
442
- switch (builder.transactionType) {
443
- case __1.TransactionType.Sale:
444
- case __1.TransactionType.Auth:
445
- if (builder.paymentMethod.paymentMethodType === __1.PaymentMethodType.Credit) {
446
- if (builder.transactionModifier === __1.TransactionModifier.Offline) {
447
- return "offline";
448
- }
449
- if (builder.transactionModifier === __1.TransactionModifier.EncryptedMobile) {
450
- return "auth-mobile";
451
- }
452
- return "auth";
453
- }
454
- return "receipt-in";
455
- case __1.TransactionType.Capture:
456
- return "settle";
457
- case __1.TransactionType.Verify:
458
- if (builder.paymentMethod.paymentMethodType === __1.PaymentMethodType.Credit) {
459
- return "otb";
460
- }
461
- return "receipt-in-otb";
462
- case __1.TransactionType.Refund:
463
- if (builder.paymentMethod.paymentMethodType === __1.PaymentMethodType.Credit) {
464
- return "credit";
465
- }
466
- return "payment-out";
467
- case __1.TransactionType.Reversal:
468
- default:
469
- throw new __1.UnsupportedTransactionError("The selected gateway does not support this transaction type.");
470
- }
471
- };
472
- RealexConnector.prototype.mapManageRequestType = function (type) {
473
- switch (type) {
474
- case __1.TransactionType.Capture:
475
- return "settle";
476
- case __1.TransactionType.Hold:
477
- return "hold";
478
- case __1.TransactionType.Refund:
479
- return "rebate";
480
- case __1.TransactionType.Release:
481
- return "release";
482
- case __1.TransactionType.Void:
483
- case __1.TransactionType.Reversal:
484
- return "void";
485
- default:
486
- return "unknown";
487
- }
488
- };
489
- RealexConnector.prototype.mapRecurringRequestType = function (builder) {
490
- var entity = builder.entity;
491
- switch (builder.transactionType) {
492
- case __1.TransactionType.Create:
493
- if (entity instanceof __1.Customer) {
494
- return "payer-new";
495
- }
496
- if (entity instanceof __1.Schedule) {
497
- throw new __1.UnsupportedTransactionError();
498
- }
499
- return "card-new";
500
- case __1.TransactionType.Edit:
501
- if (entity instanceof __1.Customer) {
502
- return "payer-edit";
503
- }
504
- if (entity instanceof __1.Schedule) {
505
- throw new __1.UnsupportedTransactionError();
506
- }
507
- return "card-update-card";
508
- case __1.TransactionType.Delete:
509
- if (entity instanceof __1.Customer || entity instanceof __1.Schedule) {
510
- throw new __1.UnsupportedTransactionError();
511
- }
512
- return "card-cancel-card";
513
- default:
514
- throw new __1.UnsupportedTransactionError();
515
- }
516
- };
517
- RealexConnector.prototype.numberFormat = function (amount) {
518
- var f = parseFloat(amount.toString()) * 100;
519
- return parseFloat(f.toFixed(2)).toString();
520
- };
521
- return RealexConnector;
522
- }(XmlGateway_1.XmlGateway));
523
- exports.RealexConnector = RealexConnector;
@@ -1,27 +0,0 @@
1
- import { HostedPaymentConfig } from "./";
2
- export declare class ServicesConfig {
3
- siteId: string;
4
- licenseId: string;
5
- deviceId: string;
6
- username: string;
7
- password: string;
8
- developerId: string;
9
- versionNumber: string;
10
- secretApiKey: string;
11
- sdkNameVersion: string;
12
- accountId: string;
13
- merchantId: string;
14
- sharedSecret: string;
15
- channel: string;
16
- rebatePassword: string;
17
- refundPassword: string;
18
- hostedPaymentConfig: HostedPaymentConfig;
19
- certificationStr: string;
20
- terminalID: string;
21
- x509CertificateString: string;
22
- x509CertificationPath: string;
23
- serviceUrl: string;
24
- timeout: number;
25
- constructor();
26
- validate(): void;
27
- }
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ServicesConfig = void 0;
4
- var _1 = require("./");
5
- var ServicesConfig = /** @class */ (function () {
6
- function ServicesConfig() {
7
- this.timeout = 65000;
8
- }
9
- ServicesConfig.prototype.validate = function () {
10
- // portico api key
11
- if (this.secretApiKey) {
12
- if (this.siteId ||
13
- this.licenseId ||
14
- this.deviceId ||
15
- this.username ||
16
- this.password) {
17
- throw new _1.ConfigurationError("Configuration contains both secret api key and legacy credentials. These are mutually exclusive.");
18
- }
19
- }
20
- // portico legacy
21
- if (this.siteId ||
22
- this.licenseId ||
23
- this.deviceId ||
24
- this.username ||
25
- this.password) {
26
- if (!(this.siteId &&
27
- this.licenseId &&
28
- this.deviceId &&
29
- this.username &&
30
- this.password)) {
31
- throw new _1.ConfigurationError("Site, License, Device, Username and Password should all have a values for this configuration.");
32
- }
33
- }
34
- // realex
35
- if (this.merchantId || this.sharedSecret) {
36
- if (!this.merchantId) {
37
- throw new _1.ConfigurationError("MerchantId is required for this configuration.");
38
- }
39
- if (!this.sharedSecret) {
40
- throw new _1.ConfigurationError("SharedSecret is required for this configuration.");
41
- }
42
- }
43
- // service url
44
- if (!this.serviceUrl) {
45
- throw new _1.ConfigurationError("Service URL could not be determined from the credentials provided. Please specify an endpoint.");
46
- }
47
- };
48
- return ServicesConfig;
49
- }());
50
- exports.ServicesConfig = ServicesConfig;