globalpayments-api 3.6.2 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +135 -125
- package/lib/src/Builders/AuthorizationBuilder.d.ts +9 -1
- package/lib/src/Builders/AuthorizationBuilder.js +10 -1
- package/lib/src/Builders/AuthorizationBuilder.js.map +1 -1
- package/lib/src/Builders/BaseBuilder/Validations.d.ts +3 -1
- package/lib/src/Builders/BaseBuilder/Validations.js +5 -5
- package/lib/src/Builders/BaseBuilder/Validations.js.map +1 -1
- package/lib/src/Builders/RequestBuilder/GpApi/GpApiReportRequestBuilder.js +34 -0
- package/lib/src/Builders/RequestBuilder/GpApi/GpApiReportRequestBuilder.js.map +1 -1
- package/lib/src/Builders/TransactionReportBuilder.d.ts +4 -2
- package/lib/src/Builders/TransactionReportBuilder.js +9 -0
- package/lib/src/Builders/TransactionReportBuilder.js.map +1 -1
- package/lib/src/Entities/Enums/DepositSortProperty.d.ts +6 -0
- package/lib/src/Entities/Enums/DepositSortProperty.js +11 -0
- package/lib/src/Entities/Enums/DepositSortProperty.js.map +1 -0
- package/lib/src/Entities/Enums.d.ts +1 -0
- package/lib/src/Entities/Enums.js +1 -0
- package/lib/src/Entities/Enums.js.map +1 -1
- package/lib/src/Entities/Reporting/DepositSummary.d.ts +29 -0
- package/lib/src/Entities/Reporting/DepositSummary.js +34 -0
- package/lib/src/Entities/Reporting/DepositSummary.js.map +1 -0
- package/lib/src/Entities/Reporting/index.d.ts +1 -0
- package/lib/src/Entities/Reporting/index.js +1 -0
- package/lib/src/Entities/Reporting/index.js.map +1 -1
- package/lib/src/Entities/Transaction.d.ts +15 -1
- package/lib/src/Entities/Transaction.js +34 -0
- package/lib/src/Entities/Transaction.js.map +1 -1
- package/lib/src/Entities/index.d.ts +1 -0
- package/lib/src/Entities/index.js +1 -0
- package/lib/src/Entities/index.js.map +1 -1
- package/lib/src/Gateways/PorticoConnector.js +5 -0
- package/lib/src/Gateways/PorticoConnector.js.map +1 -1
- package/lib/src/Mapping/GpApiMapping.d.ts +2 -0
- package/lib/src/Mapping/GpApiMapping.js +55 -13
- package/lib/src/Mapping/GpApiMapping.js.map +1 -1
- package/lib/src/Services/ReportingService.d.ts +3 -1
- package/lib/src/Services/ReportingService.js +6 -0
- package/lib/src/Services/ReportingService.js.map +1 -1
- package/lib/test/Data/BaseGpApiTestConfig.d.ts +14 -0
- package/lib/test/Data/BaseGpApiTestConfig.js +50 -0
- package/lib/test/Data/BaseGpApiTestConfig.js.map +1 -0
- package/lib/test/Data/GpApi3DSTestCards.d.ts +17 -0
- package/lib/test/Data/GpApi3DSTestCards.js +22 -0
- package/lib/test/Data/GpApi3DSTestCards.js.map +1 -0
- package/lib/test/Data/TestCards.d.ts +24 -0
- package/lib/test/Data/TestCards.js +220 -0
- package/lib/test/Data/TestCards.js.map +1 -0
- package/lib/test/Data/TestChecks.d.ts +4 -0
- package/lib/test/Data/TestChecks.js +27 -0
- package/lib/test/Data/TestChecks.js.map +1 -0
- package/lib/test/Data/index.d.ts +4 -0
- package/lib/test/Data/index.js +21 -0
- package/lib/test/Data/index.js.map +1 -0
- package/lib/test/Integration/Gateways/AcsResponse.d.ts +12 -0
- package/lib/test/Integration/Gateways/AcsResponse.js +33 -0
- package/lib/test/Integration/Gateways/AcsResponse.js.map +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/3DS2Test.d.ts +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/3DS2Test.js +1029 -0
- package/lib/test/Integration/Gateways/GpApiConnector/3DS2Test.js.map +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/3DSecureTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/3DSecureTest.js +649 -0
- package/lib/test/Integration/Gateways/GpApiConnector/3DSecureTest.js.map +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/AccessTokenTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/AccessTokenTest.js +109 -0
- package/lib/test/Integration/Gateways/GpApiConnector/AccessTokenTest.js.map +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/CreditCardNotPresentTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/CreditCardNotPresentTest.js +1025 -0
- package/lib/test/Integration/Gateways/GpApiConnector/CreditCardNotPresentTest.js.map +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/CreditCardPresentTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/CreditCardPresentTest.js +439 -0
- package/lib/test/Integration/Gateways/GpApiConnector/CreditCardPresentTest.js.map +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/DebitCardTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/DebitCardTest.js +143 -0
- package/lib/test/Integration/Gateways/GpApiConnector/DebitCardTest.js.map +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/GpApiCertificationTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/GpApiCertificationTest.js +639 -0
- package/lib/test/Integration/Gateways/GpApiConnector/GpApiCertificationTest.js.map +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/GpApiTokenManagementTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/GpApiTokenManagementTest.js +149 -0
- package/lib/test/Integration/Gateways/GpApiConnector/GpApiTokenManagementTest.js.map +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/ReportingDepositsTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/ReportingDepositsTest.js +226 -0
- package/lib/test/Integration/Gateways/GpApiConnector/ReportingDepositsTest.js.map +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/ReportingSettlementTransactionsTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/ReportingSettlementTransactionsTest.js +434 -0
- package/lib/test/Integration/Gateways/GpApiConnector/ReportingSettlementTransactionsTest.js.map +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/ReportingStoredPaymentMethodsTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/ReportingStoredPaymentMethodsTest.js +217 -0
- package/lib/test/Integration/Gateways/GpApiConnector/ReportingStoredPaymentMethodsTest.js.map +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/ReportingTransactionsTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/GpApiConnector/ReportingTransactionsTest.js +338 -0
- package/lib/test/Integration/Gateways/GpApiConnector/ReportingTransactionsTest.js.map +1 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/Certification/AuthTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/Certification/AuthTest.js +2446 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/Certification/AuthTest.js.map +1 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/Certification/AvsTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/Certification/AvsTest.js +506 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/Certification/AvsTest.js.map +1 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/Certification/CreditTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/Certification/CreditTest.js +1296 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/Certification/CreditTest.js.map +1 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/Certification/HoldTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/Certification/HoldTest.js +847 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/Certification/HoldTest.js.map +1 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/CreditTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/CreditTest.js +215 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/CreditTest.js.map +1 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/HppTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/HppTest.js +99 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/HppTest.js.map +1 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/RecurringTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/RecurringTest.js +133 -0
- package/lib/test/Integration/Gateways/GpEcomConnector/RecurringTest.js.map +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/AchTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/AchTest.js +59 -0
- package/lib/test/Integration/Gateways/PorticoConnector/AchTest.js.map +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/CheckTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/CheckTest.js +378 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/CheckTest.js.map +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceCheckTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceCheckTest.js +86 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceCheckTest.js.map +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceTest.js +1723 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/EcommerceTest.js.map +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/MotoCheckTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/MotoCheckTest.js +86 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/MotoCheckTest.js.map +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/MotoTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/MotoTest.js +1760 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/MotoTest.js.map +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/RecurringTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/RecurringTest.js +420 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/RecurringTest.js.map +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/RetailTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/RetailTest.js +2221 -0
- package/lib/test/Integration/Gateways/PorticoConnector/Certifications/RetailTest.js.map +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/CreditTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/CreditTest.js +392 -0
- package/lib/test/Integration/Gateways/PorticoConnector/CreditTest.js.map +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/DebitTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/DebitTest.js +88 -0
- package/lib/test/Integration/Gateways/PorticoConnector/DebitTest.js.map +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/EbtTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/EbtTest.js +72 -0
- package/lib/test/Integration/Gateways/PorticoConnector/EbtTest.js.map +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/EcommerceTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/EcommerceTest.js +143 -0
- package/lib/test/Integration/Gateways/PorticoConnector/EcommerceTest.js.map +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/GiftTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/GiftTest.js +147 -0
- package/lib/test/Integration/Gateways/PorticoConnector/GiftTest.js.map +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/PorticoManagementTokenTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/PorticoManagementTokenTest.js +48 -0
- package/lib/test/Integration/Gateways/PorticoConnector/PorticoManagementTokenTest.js.map +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/RecurringTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/RecurringTest.js +101 -0
- package/lib/test/Integration/Gateways/PorticoConnector/RecurringTest.js.map +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/ReportingTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/PorticoConnector/ReportingTest.js +50 -0
- package/lib/test/Integration/Gateways/PorticoConnector/ReportingTest.js.map +1 -0
- package/lib/test/Integration/Gateways/ProPayConnector/Certifications/GetInformationCertificationTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/ProPayConnector/Certifications/GetInformationCertificationTest.js +44 -0
- package/lib/test/Integration/Gateways/ProPayConnector/Certifications/GetInformationCertificationTest.js.map +1 -0
- package/lib/test/Integration/Gateways/ProPayConnector/Certifications/ProPayAccountCertificationTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/ProPayConnector/Certifications/ProPayAccountCertificationTest.js +221 -0
- package/lib/test/Integration/Gateways/ProPayConnector/Certifications/ProPayAccountCertificationTest.js.map +1 -0
- package/lib/test/Integration/Gateways/ProPayConnector/Certifications/ProPayFundCertificationTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/ProPayConnector/Certifications/ProPayFundCertificationTest.js +60 -0
- package/lib/test/Integration/Gateways/ProPayConnector/Certifications/ProPayFundCertificationTest.js.map +1 -0
- package/lib/test/Integration/Gateways/ProPayConnector/Certifications/ProPayInNetworkTransactionCertificationTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/ProPayConnector/Certifications/ProPayInNetworkTransactionCertificationTest.js +80 -0
- package/lib/test/Integration/Gateways/ProPayConnector/Certifications/ProPayInNetworkTransactionCertificationTest.js.map +1 -0
- package/lib/test/Integration/Gateways/ProPayConnector/Certifications/TestData/TestAccountData.d.ts +39 -0
- package/lib/test/Integration/Gateways/ProPayConnector/Certifications/TestData/TestAccountData.js +393 -0
- package/lib/test/Integration/Gateways/ProPayConnector/Certifications/TestData/TestAccountData.js.map +1 -0
- package/lib/test/Integration/Gateways/ProPayConnector/GetInformationTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/ProPayConnector/GetInformationTest.js +44 -0
- package/lib/test/Integration/Gateways/ProPayConnector/GetInformationTest.js.map +1 -0
- package/lib/test/Integration/Gateways/ProPayConnector/ProPayAccountTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/ProPayConnector/ProPayAccountTest.js +330 -0
- package/lib/test/Integration/Gateways/ProPayConnector/ProPayAccountTest.js.map +1 -0
- package/lib/test/Integration/Gateways/ProPayConnector/ProPayFundsTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/ProPayConnector/ProPayFundsTest.js +60 -0
- package/lib/test/Integration/Gateways/ProPayConnector/ProPayFundsTest.js.map +1 -0
- package/lib/test/Integration/Gateways/ProPayConnector/ProPayInNetworkTransactionTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/ProPayConnector/ProPayInNetworkTransactionTest.js +80 -0
- package/lib/test/Integration/Gateways/ProPayConnector/ProPayInNetworkTransactionTest.js.map +1 -0
- package/lib/test/Integration/Gateways/ProPayConnector/TestData/TestAccountData.d.ts +34 -0
- package/lib/test/Integration/Gateways/ProPayConnector/TestData/TestAccountData.js +322 -0
- package/lib/test/Integration/Gateways/ProPayConnector/TestData/TestAccountData.js.map +1 -0
- package/lib/test/Integration/Gateways/ProPayConnector/TestData/TestFundsData.d.ts +4 -0
- package/lib/test/Integration/Gateways/ProPayConnector/TestData/TestFundsData.js +28 -0
- package/lib/test/Integration/Gateways/ProPayConnector/TestData/TestFundsData.js.map +1 -0
- package/lib/test/Integration/Gateways/Terminals/RequestIdProvider.d.ts +4 -0
- package/lib/test/Integration/Gateways/Terminals/RequestIdProvider.js +10 -0
- package/lib/test/Integration/Gateways/Terminals/RequestIdProvider.js.map +1 -0
- package/lib/test/Integration/Gateways/Terminals/UPA/UpaMicTest.d.ts +1 -0
- package/lib/test/Integration/Gateways/Terminals/UPA/UpaMicTest.js +149 -0
- package/lib/test/Integration/Gateways/Terminals/UPA/UpaMicTest.js.map +1 -0
- package/lib/test/Integration/Gateways/ThreeDSecureAsClient.d.ts +16 -0
- package/lib/test/Integration/Gateways/ThreeDSecureAsClient.js +212 -0
- package/lib/test/Integration/Gateways/ThreeDSecureAsClient.js.map +1 -0
- package/lib/test/Integration/Services/CheckServiceTest.d.ts +1 -0
- package/lib/test/Integration/Services/CheckServiceTest.js +45 -0
- package/lib/test/Integration/Services/CheckServiceTest.js.map +1 -0
- package/lib/test/Integration/Services/CreditServiceTest.d.ts +1 -0
- package/lib/test/Integration/Services/CreditServiceTest.js +174 -0
- package/lib/test/Integration/Services/CreditServiceTest.js.map +1 -0
- package/lib/test/Integration/Services/DebitServiceTest.d.ts +1 -0
- package/lib/test/Integration/Services/DebitServiceTest.js +81 -0
- package/lib/test/Integration/Services/DebitServiceTest.js.map +1 -0
- package/lib/test/Integration/Services/EBTServiceTest.d.ts +1 -0
- package/lib/test/Integration/Services/EBTServiceTest.js +64 -0
- package/lib/test/Integration/Services/EBTServiceTest.js.map +1 -0
- package/lib/test/Unit/Builders/AuthorizationBuilder/ValidationTest.d.ts +1 -0
- package/lib/test/Unit/Builders/AuthorizationBuilder/ValidationTest.js +111 -0
- package/lib/test/Unit/Builders/AuthorizationBuilder/ValidationTest.js.map +1 -0
- package/lib/test/Unit/Builders/ReportBuilder/ValidationTest.d.ts +1 -0
- package/lib/test/Unit/Builders/ReportBuilder/ValidationTest.js +62 -0
- package/lib/test/Unit/Builders/ReportBuilder/ValidationTest.js.map +1 -0
- package/lib/test/Unit/Gateways/GpEcomConnector/CreditTest.d.ts +1 -0
- package/lib/test/Unit/Gateways/GpEcomConnector/CreditTest.js +34 -0
- package/lib/test/Unit/Gateways/GpEcomConnector/CreditTest.js.map +1 -0
- package/lib/test/Unit/Gateways/PorticoConnector/InputValidationTest.d.ts +1 -0
- package/lib/test/Unit/Gateways/PorticoConnector/InputValidationTest.js +125 -0
- package/lib/test/Unit/Gateways/PorticoConnector/InputValidationTest.js.map +1 -0
- package/package.json +72 -71
|
@@ -0,0 +1,1025 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ava_1 = __importDefault(require("ava"));
|
|
7
|
+
const src_1 = require("../../../../src");
|
|
8
|
+
const BaseGpApiTestConfig_1 = require("../../../Data/BaseGpApiTestConfig");
|
|
9
|
+
const DTO_1 = require("../../../../src/Entities/GpApi/DTO");
|
|
10
|
+
const runSerially = true;
|
|
11
|
+
const test = runSerially ? ava_1.default.serial : ava_1.default;
|
|
12
|
+
const date = new Date();
|
|
13
|
+
const currency = "USD";
|
|
14
|
+
const card = new src_1.CreditCardData();
|
|
15
|
+
card.number = "4263970000005262";
|
|
16
|
+
card.expMonth = (date.getMonth() + 1).toString().padStart(2, "0");
|
|
17
|
+
card.expYear = (date.getFullYear() + 1).toString();
|
|
18
|
+
card.cvn = "131";
|
|
19
|
+
card.cardHolderName = "James Mason";
|
|
20
|
+
test.beforeEach(() => {
|
|
21
|
+
src_1.ServicesContainer.configureService(BaseGpApiTestConfig_1.BaseGpApiTestConfig.gpApiSetupConfig(src_1.Channel.CardNotPresent));
|
|
22
|
+
});
|
|
23
|
+
test("credit sale", async (t) => {
|
|
24
|
+
const address = new src_1.Address();
|
|
25
|
+
address.streetAddress1 = "123 Main St.";
|
|
26
|
+
address.city = "Dallas";
|
|
27
|
+
address.state = "TX";
|
|
28
|
+
address.postalCode = "98765";
|
|
29
|
+
address.country = "USA";
|
|
30
|
+
const response = await card
|
|
31
|
+
.charge(69)
|
|
32
|
+
.withCurrency(currency)
|
|
33
|
+
.withAddress(address)
|
|
34
|
+
.execute();
|
|
35
|
+
t.truthy(response);
|
|
36
|
+
t.is("SUCCESS", response.responseCode);
|
|
37
|
+
t.is(src_1.TransactionStatus.CAPTURED, response.responseMessage);
|
|
38
|
+
t.falsy(response.payerDetails);
|
|
39
|
+
t.is("123456", response.authorizationCode);
|
|
40
|
+
});
|
|
41
|
+
test("credit sale with fingerprint", async (t) => {
|
|
42
|
+
const address = new src_1.Address();
|
|
43
|
+
address.streetAddress1 = "123 Main St.";
|
|
44
|
+
address.city = "Dallas";
|
|
45
|
+
address.state = "TX";
|
|
46
|
+
address.postalCode = "98765";
|
|
47
|
+
address.country = "USA";
|
|
48
|
+
const customer = new src_1.Customer();
|
|
49
|
+
customer.deviceFingerPrint = "ALWAYS";
|
|
50
|
+
const response = await card
|
|
51
|
+
.charge(69)
|
|
52
|
+
.withCurrency(currency)
|
|
53
|
+
.withAddress(address)
|
|
54
|
+
.withCustomerData(customer)
|
|
55
|
+
.execute();
|
|
56
|
+
t.truthy(response);
|
|
57
|
+
t.is("SUCCESS", response.responseCode);
|
|
58
|
+
t.is(src_1.TransactionStatus.CAPTURED, response.responseMessage);
|
|
59
|
+
t.truthy(response.fingerprint);
|
|
60
|
+
t.truthy(response.fingerprintIndicator);
|
|
61
|
+
t.is("123456", response.authorizationCode);
|
|
62
|
+
});
|
|
63
|
+
test("credit sale with fingerprint success", async (t) => {
|
|
64
|
+
const customer = new src_1.Customer();
|
|
65
|
+
customer.deviceFingerPrint = "ON_SUCCESS";
|
|
66
|
+
const response = await card
|
|
67
|
+
.charge(69)
|
|
68
|
+
.withCurrency(currency)
|
|
69
|
+
.withCustomerData(customer)
|
|
70
|
+
.execute();
|
|
71
|
+
t.truthy(response);
|
|
72
|
+
t.is("SUCCESS", response.responseCode);
|
|
73
|
+
t.is(src_1.TransactionStatus.CAPTURED, response.responseMessage);
|
|
74
|
+
t.truthy(response.fingerprint);
|
|
75
|
+
t.truthy(response.fingerprintIndicator);
|
|
76
|
+
t.is("00", response.cardIssuerResponse.result);
|
|
77
|
+
});
|
|
78
|
+
test("credit authorization", async (t) => {
|
|
79
|
+
const response = await card
|
|
80
|
+
.authorize(42)
|
|
81
|
+
.withCurrency(currency)
|
|
82
|
+
.withAllowDuplicates(true)
|
|
83
|
+
.execute();
|
|
84
|
+
t.truthy(response);
|
|
85
|
+
t.is("SUCCESS", response.responseCode);
|
|
86
|
+
t.is(src_1.TransactionStatus.PREAUTHORIZED, response.responseMessage);
|
|
87
|
+
t.falsy(response.payerDetails);
|
|
88
|
+
});
|
|
89
|
+
test("credit authorization then capture", async (t) => {
|
|
90
|
+
const transaction = await card
|
|
91
|
+
.authorize(42)
|
|
92
|
+
.withCurrency(currency)
|
|
93
|
+
.withOrderId("123456-78910")
|
|
94
|
+
.withAllowDuplicates(true)
|
|
95
|
+
.execute();
|
|
96
|
+
t.truthy(transaction);
|
|
97
|
+
t.is("SUCCESS", transaction.responseCode);
|
|
98
|
+
t.is(src_1.TransactionStatus.PREAUTHORIZED, transaction.responseMessage);
|
|
99
|
+
t.is("123456", transaction.authorizationCode);
|
|
100
|
+
const capture = await transaction.capture(30).withGratuity(12).execute();
|
|
101
|
+
t.truthy(capture);
|
|
102
|
+
t.is("SUCCESS", capture.responseCode);
|
|
103
|
+
t.is(src_1.TransactionStatus.CAPTURED, capture.responseMessage);
|
|
104
|
+
t.is("000000", capture.authorizationCode);
|
|
105
|
+
});
|
|
106
|
+
test("credit authorization then capture with fingerprint", async (t) => {
|
|
107
|
+
const customer = new src_1.Customer();
|
|
108
|
+
customer.deviceFingerPrint = "ON_SUCCESS";
|
|
109
|
+
const transaction = await card
|
|
110
|
+
.authorize(42)
|
|
111
|
+
.withCurrency(currency)
|
|
112
|
+
.withOrderId("123456-78910")
|
|
113
|
+
.withAllowDuplicates(true)
|
|
114
|
+
.withCustomerData(customer)
|
|
115
|
+
.execute();
|
|
116
|
+
t.truthy(transaction);
|
|
117
|
+
t.is("SUCCESS", transaction.responseCode);
|
|
118
|
+
t.is(src_1.TransactionStatus.PREAUTHORIZED, transaction.responseMessage);
|
|
119
|
+
t.truthy(transaction.fingerprint);
|
|
120
|
+
t.truthy(transaction.fingerprintIndicator);
|
|
121
|
+
const capture = await transaction.capture(30).withGratuity(12).execute();
|
|
122
|
+
t.truthy(capture);
|
|
123
|
+
t.is("SUCCESS", capture.responseCode);
|
|
124
|
+
t.is(src_1.TransactionStatus.CAPTURED, capture.responseMessage);
|
|
125
|
+
});
|
|
126
|
+
test("credit authorization then capture with idempotency", async (t) => {
|
|
127
|
+
const idempotencyKey = src_1.GenerationUtils.getGuuid();
|
|
128
|
+
const transaction = await card
|
|
129
|
+
.authorize(42)
|
|
130
|
+
.withCurrency(currency)
|
|
131
|
+
.withIdempotencyKey(idempotencyKey)
|
|
132
|
+
.withAllowDuplicates(true)
|
|
133
|
+
.execute();
|
|
134
|
+
t.truthy(transaction);
|
|
135
|
+
t.is("SUCCESS", transaction.responseCode);
|
|
136
|
+
t.is(src_1.TransactionStatus.PREAUTHORIZED, transaction.responseMessage);
|
|
137
|
+
const error = await t.throwsAsync(async () => await transaction
|
|
138
|
+
.capture(30)
|
|
139
|
+
.withIdempotencyKey(idempotencyKey)
|
|
140
|
+
.withGratuity(12)
|
|
141
|
+
.execute(), {
|
|
142
|
+
instanceOf: src_1.GatewayError,
|
|
143
|
+
});
|
|
144
|
+
t.truthy(error);
|
|
145
|
+
t.is(error?.responseCode, "40039");
|
|
146
|
+
t.true(error?.message.includes("Idempotency Key seen before"));
|
|
147
|
+
});
|
|
148
|
+
test("credit authorization for multicapture", async (t) => {
|
|
149
|
+
const transaction = await card
|
|
150
|
+
.authorize(42)
|
|
151
|
+
.withCurrency("EUR")
|
|
152
|
+
.withMultiCapture(true)
|
|
153
|
+
.withAllowDuplicates(true)
|
|
154
|
+
.execute();
|
|
155
|
+
t.truthy(transaction);
|
|
156
|
+
t.is("SUCCESS", transaction.responseCode);
|
|
157
|
+
t.is(src_1.TransactionStatus.PREAUTHORIZED, transaction.responseMessage);
|
|
158
|
+
t.truthy(transaction.multiCapture);
|
|
159
|
+
const capture = await transaction.capture(10).execute();
|
|
160
|
+
t.truthy(capture);
|
|
161
|
+
t.is("SUCCESS", capture.responseCode);
|
|
162
|
+
t.is(src_1.TransactionStatus.CAPTURED, capture.responseMessage);
|
|
163
|
+
const capture2 = await transaction.capture(10).execute();
|
|
164
|
+
t.truthy(capture2);
|
|
165
|
+
t.is("SUCCESS", capture2.responseCode);
|
|
166
|
+
t.is(src_1.TransactionStatus.CAPTURED, capture2.responseMessage);
|
|
167
|
+
const capture3 = await transaction.capture(10).execute();
|
|
168
|
+
t.truthy(capture3);
|
|
169
|
+
t.is("SUCCESS", capture3.responseCode);
|
|
170
|
+
t.is(src_1.TransactionStatus.CAPTURED, capture3.responseMessage);
|
|
171
|
+
});
|
|
172
|
+
test("credit charge with same idempotency key", async (t) => {
|
|
173
|
+
const idempotencyKey = src_1.GenerationUtils.getGuuid();
|
|
174
|
+
const transaction = await card
|
|
175
|
+
.charge(69)
|
|
176
|
+
.withCurrency("EUR")
|
|
177
|
+
.withIdempotencyKey(idempotencyKey)
|
|
178
|
+
.execute();
|
|
179
|
+
t.truthy(transaction);
|
|
180
|
+
t.is("SUCCESS", transaction.responseCode);
|
|
181
|
+
t.is(src_1.TransactionStatus.CAPTURED, transaction.responseMessage);
|
|
182
|
+
const error = await t.throwsAsync(async () => await card
|
|
183
|
+
.charge(69)
|
|
184
|
+
.withCurrency("EUR")
|
|
185
|
+
.withIdempotencyKey(idempotencyKey)
|
|
186
|
+
.execute(), {
|
|
187
|
+
instanceOf: src_1.GatewayError,
|
|
188
|
+
});
|
|
189
|
+
t.truthy(error);
|
|
190
|
+
t.is(error?.responseCode, "40039");
|
|
191
|
+
t.true(error?.message.includes("Idempotency Key seen before"));
|
|
192
|
+
t.true(error?.message.includes("DUPLICATE_ACTION"));
|
|
193
|
+
t.true(error?.message.includes(transaction.transactionId));
|
|
194
|
+
});
|
|
195
|
+
test("credit refund", async (t) => {
|
|
196
|
+
const response = await card
|
|
197
|
+
.refund(16)
|
|
198
|
+
.withCurrency(currency)
|
|
199
|
+
.withAllowDuplicates(true)
|
|
200
|
+
.execute();
|
|
201
|
+
t.truthy(response);
|
|
202
|
+
t.is("SUCCESS", response.responseCode);
|
|
203
|
+
t.is(src_1.TransactionStatus.CAPTURED, response.responseMessage);
|
|
204
|
+
});
|
|
205
|
+
test("credit refund with fingerprint", async (t) => {
|
|
206
|
+
const customer = new src_1.Customer();
|
|
207
|
+
customer.deviceFingerPrint = "ON_SUCCESS";
|
|
208
|
+
const response = await card
|
|
209
|
+
.refund(16)
|
|
210
|
+
.withCurrency(currency)
|
|
211
|
+
.withAllowDuplicates(true)
|
|
212
|
+
.withCustomerData(customer)
|
|
213
|
+
.execute();
|
|
214
|
+
t.truthy(response);
|
|
215
|
+
t.is("SUCCESS", response.responseCode);
|
|
216
|
+
t.is(src_1.TransactionStatus.CAPTURED, response.responseMessage);
|
|
217
|
+
t.truthy(response.fingerprint);
|
|
218
|
+
t.truthy(response.fingerprintIndicator);
|
|
219
|
+
});
|
|
220
|
+
test("credit default refund", async (t) => {
|
|
221
|
+
const transaction = await card
|
|
222
|
+
.charge(50)
|
|
223
|
+
.withCurrency(currency)
|
|
224
|
+
.withAllowDuplicates(true)
|
|
225
|
+
.execute();
|
|
226
|
+
t.truthy(transaction);
|
|
227
|
+
t.is("SUCCESS", transaction.responseCode);
|
|
228
|
+
t.is(src_1.TransactionStatus.CAPTURED, transaction.responseMessage);
|
|
229
|
+
const response = await transaction
|
|
230
|
+
.refund()
|
|
231
|
+
.withCurrency(currency)
|
|
232
|
+
.withAllowDuplicates(true)
|
|
233
|
+
.execute();
|
|
234
|
+
t.truthy(response);
|
|
235
|
+
t.is("SUCCESS", response.responseCode);
|
|
236
|
+
t.is(src_1.TransactionStatus.CAPTURED, response.responseMessage);
|
|
237
|
+
});
|
|
238
|
+
test("credit default refund with idempotency key", async (t) => {
|
|
239
|
+
const idempotencyKey = src_1.GenerationUtils.getGuuid();
|
|
240
|
+
const transaction = await card
|
|
241
|
+
.charge(50)
|
|
242
|
+
.withCurrency(currency)
|
|
243
|
+
.withIdempotencyKey(idempotencyKey)
|
|
244
|
+
.withAllowDuplicates(true)
|
|
245
|
+
.execute();
|
|
246
|
+
t.truthy(transaction);
|
|
247
|
+
t.is("SUCCESS", transaction.responseCode);
|
|
248
|
+
t.is(src_1.TransactionStatus.CAPTURED, transaction.responseMessage);
|
|
249
|
+
const error = await t.throwsAsync(async () => await transaction
|
|
250
|
+
.refund(50)
|
|
251
|
+
.withCurrency(currency)
|
|
252
|
+
.withIdempotencyKey(idempotencyKey)
|
|
253
|
+
.withAllowDuplicates(true)
|
|
254
|
+
.execute(), {
|
|
255
|
+
instanceOf: src_1.GatewayError,
|
|
256
|
+
});
|
|
257
|
+
t.truthy(error);
|
|
258
|
+
t.is(error?.responseCode, "40039");
|
|
259
|
+
t.true(error?.message.includes("Idempotency Key seen before"));
|
|
260
|
+
});
|
|
261
|
+
test("credit sale tokenized with stored credentials", async (t) => {
|
|
262
|
+
const storedCredentials = new src_1.StoredCredential();
|
|
263
|
+
storedCredentials.initiator = src_1.StoredCredentialInitiator.Merchant;
|
|
264
|
+
storedCredentials.type = src_1.StoredCredentialType.INSTALLMENT;
|
|
265
|
+
storedCredentials.sequence = src_1.StoredCredentialSequence.SUBSEQUENT;
|
|
266
|
+
storedCredentials.reason = src_1.StoredCredentialReason.INCREMENTAL;
|
|
267
|
+
const tokenizeResponse = await card.tokenize().execute();
|
|
268
|
+
const tokenId = tokenizeResponse.token;
|
|
269
|
+
const tokenizedCard = new src_1.CreditCardData();
|
|
270
|
+
tokenizedCard.token = tokenId;
|
|
271
|
+
tokenizedCard.cardHolderName = "James Mason";
|
|
272
|
+
const response = await tokenizedCard
|
|
273
|
+
.charge(50)
|
|
274
|
+
.withCurrency("EUR")
|
|
275
|
+
.withStoredCredentials(storedCredentials)
|
|
276
|
+
.execute();
|
|
277
|
+
t.truthy(response);
|
|
278
|
+
t.is("SUCCESS", response.responseCode);
|
|
279
|
+
t.is(src_1.TransactionStatus.CAPTURED, response.responseMessage);
|
|
280
|
+
});
|
|
281
|
+
test("credit sale with stored credentials", async (t) => {
|
|
282
|
+
const storedCredentials = new src_1.StoredCredential();
|
|
283
|
+
storedCredentials.initiator = src_1.StoredCredentialInitiator.Merchant;
|
|
284
|
+
storedCredentials.type = src_1.StoredCredentialType.INSTALLMENT;
|
|
285
|
+
storedCredentials.sequence = src_1.StoredCredentialSequence.SUBSEQUENT;
|
|
286
|
+
storedCredentials.reason = src_1.StoredCredentialReason.INCREMENTAL;
|
|
287
|
+
const response = await card
|
|
288
|
+
.charge(50)
|
|
289
|
+
.withCurrency("EUR")
|
|
290
|
+
.withStoredCredentials(storedCredentials)
|
|
291
|
+
.execute();
|
|
292
|
+
t.truthy(response);
|
|
293
|
+
t.is("SUCCESS", response.responseCode);
|
|
294
|
+
t.is(src_1.TransactionStatus.CAPTURED, response.responseMessage);
|
|
295
|
+
});
|
|
296
|
+
test("credit sale with dynamic descriptor", async (t) => {
|
|
297
|
+
const dynamicDescriptor = "My company";
|
|
298
|
+
const response = await card
|
|
299
|
+
.charge(50)
|
|
300
|
+
.withCurrency("EUR")
|
|
301
|
+
.withDynamicDescriptor(dynamicDescriptor)
|
|
302
|
+
.execute();
|
|
303
|
+
t.truthy(response);
|
|
304
|
+
t.is("SUCCESS", response.responseCode);
|
|
305
|
+
t.is(src_1.TransactionStatus.CAPTURED, response.responseMessage);
|
|
306
|
+
});
|
|
307
|
+
test("credit reverse with wrong ID", async (t) => {
|
|
308
|
+
const transaction = new src_1.Transaction();
|
|
309
|
+
transaction.transactionId = src_1.GenerationUtils.getGuuid();
|
|
310
|
+
const error = await t.throwsAsync(async () => {
|
|
311
|
+
await transaction
|
|
312
|
+
.reverse()
|
|
313
|
+
.withCurrency(currency)
|
|
314
|
+
.withAllowDuplicates(true)
|
|
315
|
+
.execute();
|
|
316
|
+
}, {
|
|
317
|
+
instanceOf: src_1.GatewayError,
|
|
318
|
+
});
|
|
319
|
+
t.truthy(error);
|
|
320
|
+
t.is(error?.responseCode, "40008");
|
|
321
|
+
t.true(error?.message.includes(`RESOURCE_NOT_FOUND`));
|
|
322
|
+
});
|
|
323
|
+
test("credit verification", async (t) => {
|
|
324
|
+
const response = await card.verify().withCurrency(currency).execute();
|
|
325
|
+
t.truthy(response);
|
|
326
|
+
t.is("SUCCESS", response.responseCode);
|
|
327
|
+
t.is("VERIFIED", response.responseMessage);
|
|
328
|
+
});
|
|
329
|
+
test("credit verification with stored credentials", async (t) => {
|
|
330
|
+
const storedCredentials = new src_1.StoredCredential();
|
|
331
|
+
storedCredentials.initiator = src_1.StoredCredentialInitiator.Merchant;
|
|
332
|
+
storedCredentials.type = src_1.StoredCredentialType.INSTALLMENT;
|
|
333
|
+
storedCredentials.sequence = src_1.StoredCredentialSequence.SUBSEQUENT;
|
|
334
|
+
storedCredentials.reason = src_1.StoredCredentialReason.INCREMENTAL;
|
|
335
|
+
const response = await card
|
|
336
|
+
.verify()
|
|
337
|
+
.withCurrency(currency)
|
|
338
|
+
.withStoredCredentials(storedCredentials)
|
|
339
|
+
.execute();
|
|
340
|
+
t.truthy(response);
|
|
341
|
+
t.is("SUCCESS", response.responseCode);
|
|
342
|
+
t.is("VERIFIED", response.responseMessage);
|
|
343
|
+
});
|
|
344
|
+
test("credit verification with idempotency key", async (t) => {
|
|
345
|
+
const idempotencyKey = src_1.GenerationUtils.getGuuid();
|
|
346
|
+
const response = await card
|
|
347
|
+
.verify()
|
|
348
|
+
.withCurrency(currency)
|
|
349
|
+
.withIdempotencyKey(idempotencyKey)
|
|
350
|
+
.execute();
|
|
351
|
+
t.truthy(response);
|
|
352
|
+
t.is("SUCCESS", response.responseCode);
|
|
353
|
+
t.is("VERIFIED", response.responseMessage);
|
|
354
|
+
const error = await t.throwsAsync(async () => await card
|
|
355
|
+
.verify()
|
|
356
|
+
.withCurrency(currency)
|
|
357
|
+
.withIdempotencyKey(idempotencyKey)
|
|
358
|
+
.execute(), {
|
|
359
|
+
instanceOf: src_1.GatewayError,
|
|
360
|
+
});
|
|
361
|
+
t.truthy(error);
|
|
362
|
+
t.is(error?.responseCode, "40039");
|
|
363
|
+
t.true(error?.message.includes("Status Code: DUPLICATE_ACTION - Idempotency Key seen before: "));
|
|
364
|
+
});
|
|
365
|
+
test("credit verification with address", async (t) => {
|
|
366
|
+
const address = new src_1.Address();
|
|
367
|
+
address.streetAddress1 = "123 Main St.";
|
|
368
|
+
address.city = "Downtown";
|
|
369
|
+
address.state = "NJ";
|
|
370
|
+
address.country = "US";
|
|
371
|
+
address.postalCode = "12345";
|
|
372
|
+
const response = await card
|
|
373
|
+
.verify()
|
|
374
|
+
.withCurrency(currency)
|
|
375
|
+
.withAddress(address)
|
|
376
|
+
.execute();
|
|
377
|
+
t.truthy(response);
|
|
378
|
+
t.is("SUCCESS", response.responseCode);
|
|
379
|
+
t.is("VERIFIED", response.responseMessage);
|
|
380
|
+
});
|
|
381
|
+
test("credit verification without currency", async (t) => {
|
|
382
|
+
const error = await t.throwsAsync(async () => await card.verify().execute(), {
|
|
383
|
+
instanceOf: src_1.GatewayError,
|
|
384
|
+
});
|
|
385
|
+
t.truthy(error);
|
|
386
|
+
t.is(error?.responseCode, "40005");
|
|
387
|
+
t.true(error?.message.includes("Status Code: MANDATORY_DATA_MISSING - Request expects the following fields currency"));
|
|
388
|
+
});
|
|
389
|
+
test("credit verification - invalid CVV", async (t) => {
|
|
390
|
+
const wrongCard = new src_1.CreditCardData();
|
|
391
|
+
wrongCard.number = "4263970000005262";
|
|
392
|
+
wrongCard.expMonth = (date.getMonth() + 1).toString().padStart(2, "0");
|
|
393
|
+
wrongCard.expYear = (date.getFullYear() + 1).toString();
|
|
394
|
+
wrongCard.cardHolderName = "James Mason";
|
|
395
|
+
wrongCard.cvn = "1234";
|
|
396
|
+
const error = await t.throwsAsync(async () => await wrongCard.verify().withCurrency(currency).execute(), {
|
|
397
|
+
instanceOf: src_1.GatewayError,
|
|
398
|
+
});
|
|
399
|
+
t.truthy(error);
|
|
400
|
+
t.is(error?.responseCode, "40085");
|
|
401
|
+
t.true(error?.message.includes("Status Code: INVALID_REQUEST_DATA - Security Code/CVV2/CVC must be 3 digits"));
|
|
402
|
+
});
|
|
403
|
+
test("credit verification - not numeric CVV", async (t) => {
|
|
404
|
+
const wrongCard = new src_1.CreditCardData();
|
|
405
|
+
wrongCard.number = "4263970000005262";
|
|
406
|
+
wrongCard.expMonth = (date.getMonth() + 1).toString().padStart(2, "0");
|
|
407
|
+
wrongCard.expYear = (date.getFullYear() + 1).toString();
|
|
408
|
+
wrongCard.cardHolderName = "James Mason";
|
|
409
|
+
wrongCard.cvn = "SMA";
|
|
410
|
+
const error = await t.throwsAsync(async () => await wrongCard.verify().withCurrency(currency).execute(), {
|
|
411
|
+
instanceOf: src_1.GatewayError,
|
|
412
|
+
});
|
|
413
|
+
t.truthy(error);
|
|
414
|
+
t.is(error?.responseCode, "50018");
|
|
415
|
+
t.true(error?.message.includes("Status Code: SYSTEM_ERROR_DOWNSTREAM - The line number 12 which contains ' [number] XXX [/number] ' does not conform to the schema"));
|
|
416
|
+
});
|
|
417
|
+
test("capture higher amount", async (t) => {
|
|
418
|
+
const transaction = await card
|
|
419
|
+
.authorize(55)
|
|
420
|
+
.withCurrency(currency)
|
|
421
|
+
.withAllowDuplicates(true)
|
|
422
|
+
.execute();
|
|
423
|
+
t.truthy(transaction);
|
|
424
|
+
t.is("SUCCESS", transaction.responseCode);
|
|
425
|
+
t.is(src_1.TransactionStatus.PREAUTHORIZED, transaction.responseMessage);
|
|
426
|
+
const capture = await transaction.capture("60").execute();
|
|
427
|
+
t.truthy(capture);
|
|
428
|
+
t.is("SUCCESS", capture.responseCode);
|
|
429
|
+
t.is(src_1.TransactionStatus.CAPTURED, capture.responseMessage);
|
|
430
|
+
const transaction2 = await card
|
|
431
|
+
.authorize(30)
|
|
432
|
+
.withCurrency(currency)
|
|
433
|
+
.withAllowDuplicates(true)
|
|
434
|
+
.execute();
|
|
435
|
+
t.truthy(transaction2);
|
|
436
|
+
t.is("SUCCESS", transaction2.responseCode);
|
|
437
|
+
t.is(src_1.TransactionStatus.PREAUTHORIZED, transaction2.responseMessage);
|
|
438
|
+
const error = await t.throwsAsync(async () => await transaction2.capture("40").execute(), {
|
|
439
|
+
instanceOf: src_1.GatewayError,
|
|
440
|
+
});
|
|
441
|
+
t.truthy(error);
|
|
442
|
+
t.is(error?.responseCode, "50020");
|
|
443
|
+
t.true(error?.message.includes("INVALID_REQUEST_DATA - Can't settle for more than 115% of that which you authorised"));
|
|
444
|
+
});
|
|
445
|
+
test("capture lower amount", async (t) => {
|
|
446
|
+
const transaction = await card
|
|
447
|
+
.authorize("55")
|
|
448
|
+
.withCurrency(currency)
|
|
449
|
+
.withAllowDuplicates(true)
|
|
450
|
+
.execute();
|
|
451
|
+
t.truthy(transaction);
|
|
452
|
+
t.is("SUCCESS", transaction.responseCode);
|
|
453
|
+
t.is(src_1.TransactionStatus.PREAUTHORIZED, transaction.responseMessage);
|
|
454
|
+
const capture = await transaction.capture("20").execute();
|
|
455
|
+
t.truthy(capture);
|
|
456
|
+
t.is("SUCCESS", capture.responseCode);
|
|
457
|
+
t.is(src_1.TransactionStatus.CAPTURED, capture.responseMessage);
|
|
458
|
+
});
|
|
459
|
+
test("charge then refund higher amount", async (t) => {
|
|
460
|
+
const transaction = await card
|
|
461
|
+
.charge(50)
|
|
462
|
+
.withCurrency(currency)
|
|
463
|
+
.withAllowDuplicates(true)
|
|
464
|
+
.execute();
|
|
465
|
+
t.truthy(transaction);
|
|
466
|
+
t.is("SUCCESS", transaction.responseCode);
|
|
467
|
+
t.is(src_1.TransactionStatus.CAPTURED, transaction.responseMessage);
|
|
468
|
+
const error = await t.throwsAsync(async () => await transaction
|
|
469
|
+
.refund(60)
|
|
470
|
+
.withCurrency(currency)
|
|
471
|
+
.withAllowDuplicates(true)
|
|
472
|
+
.execute(), {
|
|
473
|
+
instanceOf: src_1.GatewayError,
|
|
474
|
+
});
|
|
475
|
+
t.truthy(error);
|
|
476
|
+
t.is(error?.responseCode, "40087");
|
|
477
|
+
t.true(error?.message.includes("INVALID_REQUEST_DATA - You may only refund up to 115% of the original amount"));
|
|
478
|
+
});
|
|
479
|
+
test("capture then refund higher amount", async (t) => {
|
|
480
|
+
const transaction = await card
|
|
481
|
+
.authorize(55)
|
|
482
|
+
.withCurrency(currency)
|
|
483
|
+
.withAllowDuplicates(true)
|
|
484
|
+
.execute();
|
|
485
|
+
t.truthy(transaction);
|
|
486
|
+
t.is("SUCCESS", transaction.responseCode);
|
|
487
|
+
t.is(src_1.TransactionStatus.PREAUTHORIZED, transaction.responseMessage);
|
|
488
|
+
const capture = await transaction.capture(55).execute();
|
|
489
|
+
t.truthy(capture);
|
|
490
|
+
t.is("SUCCESS", capture.responseCode);
|
|
491
|
+
t.is(src_1.TransactionStatus.CAPTURED, capture.responseMessage);
|
|
492
|
+
const error = await t.throwsAsync(async () => await transaction
|
|
493
|
+
.refund(70)
|
|
494
|
+
.withCurrency(currency)
|
|
495
|
+
.withAllowDuplicates(true)
|
|
496
|
+
.execute(), {
|
|
497
|
+
instanceOf: src_1.GatewayError,
|
|
498
|
+
});
|
|
499
|
+
t.truthy(error);
|
|
500
|
+
t.is(error?.responseCode, "40087");
|
|
501
|
+
t.true(error?.message.includes("INVALID_REQUEST_DATA - You may only refund up to 115% of the original amount"));
|
|
502
|
+
});
|
|
503
|
+
test("manual transaction", async (t) => {
|
|
504
|
+
const entryModes = [
|
|
505
|
+
src_1.ManualEntryMethod.MOTO,
|
|
506
|
+
src_1.ManualEntryMethod.MAIL,
|
|
507
|
+
src_1.ManualEntryMethod.PHONE,
|
|
508
|
+
];
|
|
509
|
+
for (const entryMode of entryModes) {
|
|
510
|
+
const entryModeCard = new src_1.CreditCardData();
|
|
511
|
+
entryModeCard.number = "4263970000005262";
|
|
512
|
+
entryModeCard.expMonth = (date.getMonth() + 1).toString().padStart(2, "0");
|
|
513
|
+
entryModeCard.expYear = (date.getFullYear() + 1).toString();
|
|
514
|
+
entryModeCard.cardHolderName = "James Mason";
|
|
515
|
+
entryModeCard.cvn = "SMA";
|
|
516
|
+
entryModeCard.entryMethod = entryMode;
|
|
517
|
+
const response = await card.charge(69).withCurrency(currency).execute();
|
|
518
|
+
t.truthy(response);
|
|
519
|
+
t.is("SUCCESS", response.responseCode);
|
|
520
|
+
t.is(src_1.TransactionStatus.CAPTURED, response.responseMessage);
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
test("credit sale - expiry card", async (t) => {
|
|
524
|
+
const previousCardExpYear = card.expYear;
|
|
525
|
+
card.expYear = (date.getFullYear() - 1).toString();
|
|
526
|
+
const error = await t.throwsAsync(async () => await card.charge(1).withCurrency("USD").execute(), {
|
|
527
|
+
instanceOf: src_1.GatewayError,
|
|
528
|
+
});
|
|
529
|
+
t.truthy(error);
|
|
530
|
+
t.is(error?.responseCode, "40085");
|
|
531
|
+
t.true(error?.message.includes("Status Code: INVALID_REQUEST_DATA - Expiry date invalid"));
|
|
532
|
+
card.expYear = previousCardExpYear;
|
|
533
|
+
});
|
|
534
|
+
test("verify tokenized payment method with fingerprint", async (t) => {
|
|
535
|
+
const customer = new src_1.Customer();
|
|
536
|
+
customer.deviceFingerPrint = "ALWAYS";
|
|
537
|
+
const response = await card.tokenize().withCustomerData(customer).execute();
|
|
538
|
+
t.truthy(response);
|
|
539
|
+
t.is("SUCCESS", response.responseCode);
|
|
540
|
+
t.truthy(response.fingerprint);
|
|
541
|
+
const tokenizedCard = new src_1.CreditCardData();
|
|
542
|
+
tokenizedCard.token = response.token;
|
|
543
|
+
const verifyResponse = await tokenizedCard
|
|
544
|
+
.verify()
|
|
545
|
+
.withCurrency(currency)
|
|
546
|
+
.withCustomerData(customer)
|
|
547
|
+
.execute();
|
|
548
|
+
t.truthy(verifyResponse);
|
|
549
|
+
t.is("SUCCESS", verifyResponse.responseCode);
|
|
550
|
+
t.is("VERIFIED", verifyResponse.responseMessage);
|
|
551
|
+
t.truthy(verifyResponse.fingerprint);
|
|
552
|
+
});
|
|
553
|
+
test("verify tokenized payment method with invalid fingerprint", async (t) => {
|
|
554
|
+
const customer = new src_1.Customer();
|
|
555
|
+
customer.deviceFingerPrint = "NOT_ALWAYS";
|
|
556
|
+
const error = await t.throwsAsync(async () => await card
|
|
557
|
+
.charge(60)
|
|
558
|
+
.withCurrency(currency)
|
|
559
|
+
.withCustomerData(customer)
|
|
560
|
+
.execute(), {
|
|
561
|
+
instanceOf: src_1.GatewayError,
|
|
562
|
+
});
|
|
563
|
+
t.truthy(error);
|
|
564
|
+
t.is(error?.responseCode, "40213");
|
|
565
|
+
t.true(error?.message.includes("Status Code: INVALID_REQUEST_DATA - fingerprint_mode contains unexpected data"));
|
|
566
|
+
});
|
|
567
|
+
test("credit sale without permissions", async (t) => {
|
|
568
|
+
const config = BaseGpApiTestConfig_1.BaseGpApiTestConfig.gpApiSetupConfig(src_1.Channel.CardNotPresent);
|
|
569
|
+
config.permissions = ["TRN_POST_Capture"];
|
|
570
|
+
src_1.ServicesContainer.configureService(config, "configWithoutSalePermission");
|
|
571
|
+
const error = await t.throwsAsync(async () => await card
|
|
572
|
+
.charge(50)
|
|
573
|
+
.withCurrency(currency)
|
|
574
|
+
.withAllowDuplicates(true)
|
|
575
|
+
.execute("configWithoutSalePermission"), {
|
|
576
|
+
instanceOf: src_1.GatewayError,
|
|
577
|
+
});
|
|
578
|
+
t.truthy(error);
|
|
579
|
+
t.is(error?.responseCode, "40212");
|
|
580
|
+
t.is(error?.message, "Status Code: ACTION_NOT_AUTHORIZED - Permission not enabled to execute action");
|
|
581
|
+
});
|
|
582
|
+
test("transaction then refund", async (t) => {
|
|
583
|
+
const transaction = await card
|
|
584
|
+
.charge(50)
|
|
585
|
+
.withCurrency(currency)
|
|
586
|
+
.withAllowDuplicates(true)
|
|
587
|
+
.execute();
|
|
588
|
+
t.truthy(transaction);
|
|
589
|
+
t.is("SUCCESS", transaction.responseCode);
|
|
590
|
+
t.is(src_1.TransactionStatus.CAPTURED, transaction.responseMessage);
|
|
591
|
+
const partialAmount = "7.51";
|
|
592
|
+
const partialRefund = await transaction
|
|
593
|
+
.refund(partialAmount)
|
|
594
|
+
.withCurrency(currency)
|
|
595
|
+
.execute();
|
|
596
|
+
t.truthy(partialRefund);
|
|
597
|
+
t.is("SUCCESS", partialRefund.responseCode);
|
|
598
|
+
t.is(src_1.TransactionStatus.CAPTURED, partialRefund.responseMessage);
|
|
599
|
+
t.is(partialAmount, partialRefund.balanceAmount);
|
|
600
|
+
const error = await t.throwsAsync(async () => await transaction.refund().withCurrency(currency).execute(), {
|
|
601
|
+
instanceOf: src_1.GatewayError,
|
|
602
|
+
});
|
|
603
|
+
t.truthy(error);
|
|
604
|
+
t.is(error?.responseCode, "40087");
|
|
605
|
+
t.true(error?.message.includes("INVALID_REQUEST_DATA - You may only refund up to 115% of the original amount"));
|
|
606
|
+
});
|
|
607
|
+
test("transaction then reversal", async (t) => {
|
|
608
|
+
const transaction = await card
|
|
609
|
+
.charge(20)
|
|
610
|
+
.withCurrency(currency)
|
|
611
|
+
.withAllowDuplicates(true)
|
|
612
|
+
.execute();
|
|
613
|
+
t.truthy(transaction);
|
|
614
|
+
t.is("SUCCESS", transaction.responseCode);
|
|
615
|
+
t.is(src_1.TransactionStatus.CAPTURED, transaction.responseMessage);
|
|
616
|
+
const reverse = await transaction.reverse(20).execute();
|
|
617
|
+
t.truthy(reverse);
|
|
618
|
+
t.is("SUCCESS", reverse.responseCode);
|
|
619
|
+
t.is(src_1.TransactionStatus.REVERSED, reverse.responseMessage);
|
|
620
|
+
});
|
|
621
|
+
test("transaction then default reversal", async (t) => {
|
|
622
|
+
const transaction = await card
|
|
623
|
+
.charge(20)
|
|
624
|
+
.withCurrency(currency)
|
|
625
|
+
.withAllowDuplicates(true)
|
|
626
|
+
.execute();
|
|
627
|
+
t.truthy(transaction);
|
|
628
|
+
t.is("SUCCESS", transaction.responseCode);
|
|
629
|
+
t.is(src_1.TransactionStatus.CAPTURED, transaction.responseMessage);
|
|
630
|
+
const reverse = await transaction.reverse().execute();
|
|
631
|
+
t.truthy(reverse);
|
|
632
|
+
t.is("SUCCESS", reverse.responseCode);
|
|
633
|
+
t.is(src_1.TransactionStatus.REVERSED, reverse.responseMessage);
|
|
634
|
+
});
|
|
635
|
+
test("transaction then reversal with idempotency key", async (t) => {
|
|
636
|
+
const idempotencyKey = src_1.GenerationUtils.getGuuid();
|
|
637
|
+
const transaction = await card
|
|
638
|
+
.charge(20)
|
|
639
|
+
.withCurrency(currency)
|
|
640
|
+
.withAllowDuplicates(true)
|
|
641
|
+
.withIdempotencyKey(idempotencyKey)
|
|
642
|
+
.execute();
|
|
643
|
+
t.truthy(transaction);
|
|
644
|
+
t.is("SUCCESS", transaction.responseCode);
|
|
645
|
+
t.is(src_1.TransactionStatus.CAPTURED, transaction.responseMessage);
|
|
646
|
+
const error = await t.throwsAsync(async () => await transaction.reverse().withIdempotencyKey(idempotencyKey).execute(), {
|
|
647
|
+
instanceOf: src_1.GatewayError,
|
|
648
|
+
});
|
|
649
|
+
t.truthy(error);
|
|
650
|
+
t.is(error?.responseCode, "40039");
|
|
651
|
+
t.true(error?.message.includes("Idempotency Key seen before"));
|
|
652
|
+
});
|
|
653
|
+
test("transaction then partial reversal", async (t) => {
|
|
654
|
+
const transaction = await card
|
|
655
|
+
.charge(20)
|
|
656
|
+
.withCurrency(currency)
|
|
657
|
+
.withAllowDuplicates(true)
|
|
658
|
+
.execute();
|
|
659
|
+
t.truthy(transaction);
|
|
660
|
+
t.is("SUCCESS", transaction.responseCode);
|
|
661
|
+
t.is(src_1.TransactionStatus.CAPTURED, transaction.responseMessage);
|
|
662
|
+
const error = await t.throwsAsync(async () => await transaction.reverse(10).execute(), {
|
|
663
|
+
instanceOf: src_1.GatewayError,
|
|
664
|
+
});
|
|
665
|
+
t.truthy(error);
|
|
666
|
+
t.is(error?.responseCode, "40214");
|
|
667
|
+
t.is(error?.message, "Status Code: INVALID_REQUEST_DATA - partial reversal not supported");
|
|
668
|
+
});
|
|
669
|
+
test("card tokenization", async (t) => {
|
|
670
|
+
const response = await card.tokenize().execute();
|
|
671
|
+
t.truthy(response);
|
|
672
|
+
t.is("SUCCESS", response.responseCode);
|
|
673
|
+
t.is("ACTIVE", response.responseMessage);
|
|
674
|
+
});
|
|
675
|
+
test("card tokenization then paying with token - Single to Multi-Use", async (t) => {
|
|
676
|
+
const config = BaseGpApiTestConfig_1.BaseGpApiTestConfig.gpApiSetupConfig(src_1.Channel.CardNotPresent);
|
|
677
|
+
config.permissions = ["PMT_POST_Create_Single"];
|
|
678
|
+
src_1.ServicesContainer.configureService(config, "singleUseToken");
|
|
679
|
+
const response = await card
|
|
680
|
+
.tokenize(true, src_1.PaymentMethodUsageMode.SINGLE)
|
|
681
|
+
.execute("singleUseToken");
|
|
682
|
+
const tokenId = response.token;
|
|
683
|
+
const tokenizedCard = new src_1.CreditCardData();
|
|
684
|
+
tokenizedCard.token = tokenId;
|
|
685
|
+
tokenizedCard.cardHolderName = "James Mason";
|
|
686
|
+
const chargeResponse = await tokenizedCard
|
|
687
|
+
.charge(10)
|
|
688
|
+
.withCurrency("USD")
|
|
689
|
+
.withRequestMultiUseToken(true)
|
|
690
|
+
.execute();
|
|
691
|
+
t.truthy(chargeResponse);
|
|
692
|
+
t.is(chargeResponse.responseCode, "SUCCESS");
|
|
693
|
+
t.is(chargeResponse.responseMessage, src_1.TransactionStatus.CAPTURED);
|
|
694
|
+
t.truthy(chargeResponse.token.startsWith(DTO_1.PaymentMethod.PAYMENT_METHOD_TOKEN_PREFIX));
|
|
695
|
+
tokenizedCard.token = chargeResponse.token;
|
|
696
|
+
const secondChargeResponse = await tokenizedCard
|
|
697
|
+
.charge(10)
|
|
698
|
+
.withCurrency("USD")
|
|
699
|
+
.execute();
|
|
700
|
+
t.truthy(secondChargeResponse);
|
|
701
|
+
t.is(secondChargeResponse.responseCode, "SUCCESS");
|
|
702
|
+
t.is(secondChargeResponse.responseMessage, src_1.TransactionStatus.CAPTURED);
|
|
703
|
+
});
|
|
704
|
+
test("card tokenization with idempotency key", async (t) => {
|
|
705
|
+
const idempotencyKey = src_1.GenerationUtils.getGuuid();
|
|
706
|
+
const response = await card
|
|
707
|
+
.tokenize()
|
|
708
|
+
.withIdempotencyKey(idempotencyKey)
|
|
709
|
+
.execute();
|
|
710
|
+
t.truthy(response);
|
|
711
|
+
t.is(response.responseCode, "SUCCESS");
|
|
712
|
+
t.is(response.responseMessage, "ACTIVE");
|
|
713
|
+
let exceptionCaught = false;
|
|
714
|
+
try {
|
|
715
|
+
await card.tokenize().withIdempotencyKey(idempotencyKey).execute();
|
|
716
|
+
}
|
|
717
|
+
catch (e) {
|
|
718
|
+
exceptionCaught = true;
|
|
719
|
+
t.is(e.responseCode, "40039");
|
|
720
|
+
t.true(e.message.includes("Idempotency Key seen before"));
|
|
721
|
+
}
|
|
722
|
+
finally {
|
|
723
|
+
t.true(exceptionCaught);
|
|
724
|
+
}
|
|
725
|
+
});
|
|
726
|
+
test("card tokenization then paying with token", async (t) => {
|
|
727
|
+
const response = await card.tokenize().execute();
|
|
728
|
+
const tokenId = response.token;
|
|
729
|
+
const tokenizedCard = new src_1.CreditCardData();
|
|
730
|
+
tokenizedCard.token = tokenId;
|
|
731
|
+
tokenizedCard.cardHolderName = "James Mason";
|
|
732
|
+
const chargeResponse = await tokenizedCard
|
|
733
|
+
.charge(69)
|
|
734
|
+
.withCurrency("EUR")
|
|
735
|
+
.withOrderId("124214-214221")
|
|
736
|
+
.execute();
|
|
737
|
+
t.truthy(chargeResponse);
|
|
738
|
+
t.is(chargeResponse.responseCode, "SUCCESS");
|
|
739
|
+
t.is(chargeResponse.responseMessage, src_1.TransactionStatus.CAPTURED);
|
|
740
|
+
});
|
|
741
|
+
test("verify tokenized payment method", async (t) => {
|
|
742
|
+
const tokenizeResponse = await card.tokenize().execute();
|
|
743
|
+
t.truthy(tokenizeResponse);
|
|
744
|
+
t.is(tokenizeResponse.responseCode, "SUCCESS");
|
|
745
|
+
t.is(tokenizeResponse.responseMessage, "ACTIVE");
|
|
746
|
+
const tokenizedCard = new src_1.CreditCardData();
|
|
747
|
+
tokenizedCard.token = tokenizeResponse.token;
|
|
748
|
+
const response = await tokenizedCard
|
|
749
|
+
.verify()
|
|
750
|
+
.withCurrency(currency)
|
|
751
|
+
.execute();
|
|
752
|
+
t.truthy(response);
|
|
753
|
+
t.is(response.responseCode, "SUCCESS");
|
|
754
|
+
t.is(response.responseMessage, "VERIFIED");
|
|
755
|
+
});
|
|
756
|
+
test("verify tokenized payment method with idempotency key", async (t) => {
|
|
757
|
+
const idempotencyKey = src_1.GenerationUtils.getGuuid();
|
|
758
|
+
const tokenizeResponse = await card.tokenize().execute();
|
|
759
|
+
t.truthy(tokenizeResponse);
|
|
760
|
+
t.is(tokenizeResponse.responseCode, "SUCCESS");
|
|
761
|
+
t.is(tokenizeResponse.responseMessage, "ACTIVE");
|
|
762
|
+
const tokenizedCard = new src_1.CreditCardData();
|
|
763
|
+
tokenizedCard.token = tokenizeResponse.token;
|
|
764
|
+
const response = await tokenizedCard
|
|
765
|
+
.verify()
|
|
766
|
+
.withCurrency(currency)
|
|
767
|
+
.withIdempotencyKey(idempotencyKey)
|
|
768
|
+
.execute();
|
|
769
|
+
t.truthy(response);
|
|
770
|
+
t.is(response.responseCode, "SUCCESS");
|
|
771
|
+
t.is(response.responseMessage, "VERIFIED");
|
|
772
|
+
const error = await t.throwsAsync(async () => {
|
|
773
|
+
await tokenizedCard.verify().withIdempotencyKey(idempotencyKey).execute();
|
|
774
|
+
}, {
|
|
775
|
+
instanceOf: src_1.GatewayError,
|
|
776
|
+
});
|
|
777
|
+
t.truthy(error);
|
|
778
|
+
t.is(error?.responseCode, "40039");
|
|
779
|
+
t.is(error?.message.includes(`Idempotency Key seen before`), true);
|
|
780
|
+
});
|
|
781
|
+
test("verify tokenized payment method with wrong ID", async (t) => {
|
|
782
|
+
const tokenizedCard = new src_1.CreditCardData();
|
|
783
|
+
tokenizedCard.token = `PMT_${src_1.GenerationUtils.getGuuid()}`;
|
|
784
|
+
const error = await t.throwsAsync(async () => {
|
|
785
|
+
await tokenizedCard.verify().withCurrency(currency).execute();
|
|
786
|
+
}, {
|
|
787
|
+
instanceOf: src_1.GatewayError,
|
|
788
|
+
});
|
|
789
|
+
t.truthy(error);
|
|
790
|
+
t.is(error?.responseCode, "40116");
|
|
791
|
+
t.is(error?.message, `Status Code: RESOURCE_NOT_FOUND - payment_method ${tokenizedCard.token} not found at this location.`);
|
|
792
|
+
});
|
|
793
|
+
test.skip("card tokenization then delete", async (t) => {
|
|
794
|
+
//Permission not enabled to execute action for this appId/appKey
|
|
795
|
+
const response = await card.tokenize().execute();
|
|
796
|
+
const tokenId = response.token;
|
|
797
|
+
const tokenizedCard = new src_1.CreditCardData();
|
|
798
|
+
tokenizedCard.token = tokenId;
|
|
799
|
+
const deleteTokenExpiryRes = await tokenizedCard.deleteToken();
|
|
800
|
+
t.truthy(deleteTokenExpiryRes);
|
|
801
|
+
const deleteTokenExpiryRes2 = await tokenizedCard.deleteToken();
|
|
802
|
+
t.falsy(deleteTokenExpiryRes2);
|
|
803
|
+
});
|
|
804
|
+
test.skip("card tokenization then delete with idempotency key", async (t) => {
|
|
805
|
+
//Permission not enabled to execute action for this appId/appKey
|
|
806
|
+
const response = await card.tokenize().execute();
|
|
807
|
+
const tokenId = response.token;
|
|
808
|
+
const tokenizedCard = new src_1.CreditCardData();
|
|
809
|
+
tokenizedCard.token = tokenId;
|
|
810
|
+
const idempotencyKey = src_1.GenerationUtils.getGuuid();
|
|
811
|
+
const deleteTokenExpiryRes = await new src_1.ManagementBuilder(src_1.TransactionType.TokenDelete)
|
|
812
|
+
.withPaymentMethod(tokenizedCard)
|
|
813
|
+
.withIdempotencyKey(idempotencyKey)
|
|
814
|
+
.execute();
|
|
815
|
+
t.truthy(deleteTokenExpiryRes);
|
|
816
|
+
t.is(deleteTokenExpiryRes.responseCode, "SUCCESS");
|
|
817
|
+
t.is(deleteTokenExpiryRes.responseMessage, "DELETED");
|
|
818
|
+
const error = await t.throwsAsync(async () => {
|
|
819
|
+
await new src_1.ManagementBuilder(src_1.TransactionType.TokenDelete)
|
|
820
|
+
.withPaymentMethod(tokenizedCard)
|
|
821
|
+
.withIdempotencyKey(idempotencyKey)
|
|
822
|
+
.execute();
|
|
823
|
+
}, {
|
|
824
|
+
instanceOf: src_1.GatewayError,
|
|
825
|
+
});
|
|
826
|
+
t.truthy(error);
|
|
827
|
+
t.is(error?.responseCode, "40039");
|
|
828
|
+
if (error?.message) {
|
|
829
|
+
t.regex(error?.message, new RegExp("Idempotency Key seen before"));
|
|
830
|
+
}
|
|
831
|
+
});
|
|
832
|
+
test.skip("card delete wrong id", async (t) => {
|
|
833
|
+
//Permission not enabled to execute action for this appId/appKey
|
|
834
|
+
const tokenizedCard = new src_1.CreditCardData();
|
|
835
|
+
tokenizedCard.token = `PMT_${src_1.GenerationUtils.getGuuid()}`;
|
|
836
|
+
const error = await t.throwsAsync(async () => {
|
|
837
|
+
await tokenizedCard.deleteToken();
|
|
838
|
+
}, {
|
|
839
|
+
instanceOf: src_1.GatewayError,
|
|
840
|
+
});
|
|
841
|
+
t.truthy(error);
|
|
842
|
+
t.is(error?.responseCode, "40116");
|
|
843
|
+
t.is(error?.message, `Status Code: RESOURCE_NOT_FOUND - payment_method ${tokenizedCard.token} not found at this location.`);
|
|
844
|
+
});
|
|
845
|
+
test("card tokenization then update", async (t) => {
|
|
846
|
+
const response = await card.tokenize().execute();
|
|
847
|
+
const tokenId = response.token;
|
|
848
|
+
const tokenizedCard = new src_1.CreditCardData();
|
|
849
|
+
tokenizedCard.token = tokenId;
|
|
850
|
+
const date = new Date();
|
|
851
|
+
tokenizedCard.expMonth = (date.getMonth() + 2).toString().padStart(2, "0");
|
|
852
|
+
tokenizedCard.expYear = (date.getFullYear() + 2).toString();
|
|
853
|
+
const updateTokenExpiryRes = await tokenizedCard.updateTokenExpiry();
|
|
854
|
+
t.truthy(updateTokenExpiryRes);
|
|
855
|
+
});
|
|
856
|
+
test("card update wrong ID", async (t) => {
|
|
857
|
+
const tokenizedCard = new src_1.CreditCardData();
|
|
858
|
+
tokenizedCard.token = "PMT_" + src_1.GenerationUtils.getGuuid();
|
|
859
|
+
const date = new Date();
|
|
860
|
+
tokenizedCard.expMonth = (date.getMonth() + 2).toString().padStart(2, "0");
|
|
861
|
+
tokenizedCard.expYear = (date.getFullYear() + 2).toString();
|
|
862
|
+
const error = await t.throwsAsync(async () => {
|
|
863
|
+
await tokenizedCard.updateTokenExpiry();
|
|
864
|
+
}, {
|
|
865
|
+
instanceOf: src_1.GatewayError,
|
|
866
|
+
});
|
|
867
|
+
t.truthy(error);
|
|
868
|
+
t.is(error?.message, `Status Code: RESOURCE_NOT_FOUND - payment_method ${tokenizedCard.token} not found at this location.`);
|
|
869
|
+
});
|
|
870
|
+
test("card tokenization then update with idempotency key", async (t) => {
|
|
871
|
+
const response = await card.tokenize().execute();
|
|
872
|
+
const tokenId = response.token;
|
|
873
|
+
const tokenizedCard = new src_1.CreditCardData();
|
|
874
|
+
tokenizedCard.token = tokenId;
|
|
875
|
+
const date = new Date();
|
|
876
|
+
tokenizedCard.expMonth = (date.getMonth() + 2).toString().padStart(2, "0");
|
|
877
|
+
tokenizedCard.expYear = (date.getFullYear() + 2).toString();
|
|
878
|
+
const idempotencyKey = src_1.GenerationUtils.getGuuid();
|
|
879
|
+
const updateTokenExpiryRes = await new src_1.ManagementBuilder(src_1.TransactionType.TokenUpdate)
|
|
880
|
+
.withPaymentMethod(tokenizedCard)
|
|
881
|
+
.withIdempotencyKey(idempotencyKey)
|
|
882
|
+
.execute();
|
|
883
|
+
t.truthy(updateTokenExpiryRes);
|
|
884
|
+
t.is(updateTokenExpiryRes.responseCode, "SUCCESS");
|
|
885
|
+
t.is(updateTokenExpiryRes.responseMessage, "ACTIVE");
|
|
886
|
+
const error = await t.throwsAsync(async () => {
|
|
887
|
+
await new src_1.ManagementBuilder(src_1.TransactionType.TokenUpdate)
|
|
888
|
+
.withPaymentMethod(tokenizedCard)
|
|
889
|
+
.withIdempotencyKey(idempotencyKey)
|
|
890
|
+
.execute();
|
|
891
|
+
}, {
|
|
892
|
+
instanceOf: src_1.GatewayError,
|
|
893
|
+
});
|
|
894
|
+
t.truthy(error);
|
|
895
|
+
t.is(error?.responseCode, "40039");
|
|
896
|
+
if (error?.responseMessage) {
|
|
897
|
+
t.regex(error?.responseMessage, new RegExp("Idempotency Key seen before"));
|
|
898
|
+
}
|
|
899
|
+
const verifyResponse = await tokenizedCard
|
|
900
|
+
.verify()
|
|
901
|
+
.withCurrency(currency)
|
|
902
|
+
.withIdempotencyKey(idempotencyKey)
|
|
903
|
+
.execute();
|
|
904
|
+
t.truthy(verifyResponse);
|
|
905
|
+
t.is(verifyResponse.responseCode, "SUCCESS");
|
|
906
|
+
t.is(verifyResponse.responseMessage, "VERIFIED");
|
|
907
|
+
tokenizedCard.expYear = (date.getFullYear() + 3).toString();
|
|
908
|
+
const updateTokenExpiryRes2 = await tokenizedCard.updateTokenExpiry();
|
|
909
|
+
t.truthy(updateTokenExpiryRes2);
|
|
910
|
+
});
|
|
911
|
+
test("credit refund transaction wrong ID", async (t) => {
|
|
912
|
+
const transaction = new src_1.Transaction();
|
|
913
|
+
transaction.transactionId = src_1.GenerationUtils.getGuuid();
|
|
914
|
+
const error = await t.throwsAsync(async () => {
|
|
915
|
+
await transaction
|
|
916
|
+
.refund(10)
|
|
917
|
+
.withCurrency(currency)
|
|
918
|
+
.withAllowDuplicates(true)
|
|
919
|
+
.execute();
|
|
920
|
+
}, {
|
|
921
|
+
instanceOf: src_1.GatewayError,
|
|
922
|
+
});
|
|
923
|
+
t.truthy(error);
|
|
924
|
+
t.true(error?.message.includes(`RESOURCE_NOT_FOUND`));
|
|
925
|
+
});
|
|
926
|
+
test("card tokenization - Missing card number", async (t) => {
|
|
927
|
+
const card = new src_1.CreditCardData();
|
|
928
|
+
const error = await t.throwsAsync(async () => {
|
|
929
|
+
await card.tokenize().execute();
|
|
930
|
+
}, {
|
|
931
|
+
instanceOf: src_1.GatewayError,
|
|
932
|
+
});
|
|
933
|
+
t.truthy(error);
|
|
934
|
+
t.is(error?.message, "Status Code: MANDATORY_DATA_MISSING - Request expects the following fields : number");
|
|
935
|
+
});
|
|
936
|
+
test("update payment token", async (t) => {
|
|
937
|
+
const startDate = new Date();
|
|
938
|
+
startDate.setDate(startDate.getDate() - 30);
|
|
939
|
+
startDate.setHours(0);
|
|
940
|
+
startDate.setMinutes(0);
|
|
941
|
+
startDate.setSeconds(0);
|
|
942
|
+
const response = await src_1.ReportingService.findStoredPaymentMethodsPaged(1, 1)
|
|
943
|
+
.orderBy(src_1.StoredPaymentMethodSortProperty.TimeCreated, src_1.SortDirection.Desc)
|
|
944
|
+
.where(src_1.SearchCriteria.StartDate, `${startDate.getFullYear()}-${(startDate.getMonth() + 1)
|
|
945
|
+
.toString()
|
|
946
|
+
.padStart(2, "0")}-${startDate.getDate().toString().padStart(2, "0")}`)
|
|
947
|
+
.execute();
|
|
948
|
+
t.is(response.result.length, 1);
|
|
949
|
+
const pmtToken = response.result[0];
|
|
950
|
+
t.truthy(pmtToken);
|
|
951
|
+
const tokenizedCard = new src_1.CreditCardData();
|
|
952
|
+
tokenizedCard.token = pmtToken.paymentMethodId;
|
|
953
|
+
const date = new Date();
|
|
954
|
+
tokenizedCard.cardHolderName = "James BondUp";
|
|
955
|
+
tokenizedCard.expMonth = (date.getMonth() + 2).toString().padStart(2, "0");
|
|
956
|
+
tokenizedCard.expYear = (date.getFullYear() + 4).toString();
|
|
957
|
+
tokenizedCard.number = "4263970000005262";
|
|
958
|
+
const responseUpdateToken = await tokenizedCard
|
|
959
|
+
.updateToken()
|
|
960
|
+
.withPaymentMethodUsageMode(src_1.PaymentMethodUsageMode.MULTIPLE)
|
|
961
|
+
.execute();
|
|
962
|
+
t.truthy(responseUpdateToken);
|
|
963
|
+
t.is(responseUpdateToken.responseCode, "SUCCESS");
|
|
964
|
+
t.is(responseUpdateToken.responseMessage, "ACTIVE");
|
|
965
|
+
t.is(responseUpdateToken.token, pmtToken.paymentMethodId);
|
|
966
|
+
t.is(responseUpdateToken.tokenUsageMode, src_1.PaymentMethodUsageMode.MULTIPLE);
|
|
967
|
+
});
|
|
968
|
+
test("card tokenization then update then charge", async (t) => {
|
|
969
|
+
const config = BaseGpApiTestConfig_1.BaseGpApiTestConfig.gpApiSetupConfig(src_1.Channel.CardNotPresent);
|
|
970
|
+
config.permissions = ["PMT_POST_Create_Single"];
|
|
971
|
+
src_1.ServicesContainer.configureService(config, "singleUseToken");
|
|
972
|
+
const response = await card
|
|
973
|
+
.tokenize()
|
|
974
|
+
.withPaymentMethodUsageMode(src_1.PaymentMethodUsageMode.SINGLE)
|
|
975
|
+
.execute("singleUseToken");
|
|
976
|
+
const tokenId = response.token;
|
|
977
|
+
const tokenizedCard = new src_1.CreditCardData();
|
|
978
|
+
tokenizedCard.token = tokenId;
|
|
979
|
+
tokenizedCard.cardHolderName = "GpApi";
|
|
980
|
+
const responseUpdateToken = await tokenizedCard
|
|
981
|
+
.updateToken()
|
|
982
|
+
.withPaymentMethodUsageMode(src_1.PaymentMethodUsageMode.MULTIPLE)
|
|
983
|
+
.execute();
|
|
984
|
+
t.truthy(responseUpdateToken);
|
|
985
|
+
t.is(responseUpdateToken.responseCode, "SUCCESS");
|
|
986
|
+
t.is(responseUpdateToken.responseMessage, "ACTIVE");
|
|
987
|
+
t.is(responseUpdateToken.tokenUsageMode, src_1.PaymentMethodUsageMode.MULTIPLE);
|
|
988
|
+
const chargeResponse = await tokenizedCard
|
|
989
|
+
.charge(1)
|
|
990
|
+
.withCurrency(currency)
|
|
991
|
+
.execute();
|
|
992
|
+
t.truthy(chargeResponse);
|
|
993
|
+
t.is(chargeResponse.responseCode, "SUCCESS");
|
|
994
|
+
t.is(chargeResponse.responseMessage, src_1.TransactionStatus.CAPTURED);
|
|
995
|
+
});
|
|
996
|
+
test("card tokenization then update to single usage", async (t) => {
|
|
997
|
+
const tokenizedCard = new src_1.CreditCardData();
|
|
998
|
+
tokenizedCard.token = `PMT_${src_1.GenerationUtils.getGuuid()}`;
|
|
999
|
+
const error = await t.throwsAsync(async () => {
|
|
1000
|
+
await tokenizedCard
|
|
1001
|
+
.updateToken()
|
|
1002
|
+
.withPaymentMethodUsageMode(src_1.PaymentMethodUsageMode.SINGLE)
|
|
1003
|
+
.execute();
|
|
1004
|
+
}, {
|
|
1005
|
+
instanceOf: src_1.GatewayError,
|
|
1006
|
+
});
|
|
1007
|
+
t.truthy(error);
|
|
1008
|
+
t.is(error?.responseCode, "50020");
|
|
1009
|
+
t.is(error?.message, "Status Code: INVALID_REQUEST_DATA - Tokentype can only be MULTI");
|
|
1010
|
+
});
|
|
1011
|
+
test("card tokenization then update to without usage mode", async (t) => {
|
|
1012
|
+
const tokenizedCard = new src_1.CreditCardData();
|
|
1013
|
+
tokenizedCard.token = `PMT_${src_1.GenerationUtils.getGuuid()}`;
|
|
1014
|
+
const error = await t.throwsAsync(async () => {
|
|
1015
|
+
await tokenizedCard.updateToken().execute();
|
|
1016
|
+
}, {
|
|
1017
|
+
instanceOf: src_1.GatewayError,
|
|
1018
|
+
});
|
|
1019
|
+
t.truthy(error);
|
|
1020
|
+
t.is(error?.responseCode, "50021");
|
|
1021
|
+
t.is(error?.message, "Status Code: MANDATORY_DATA_MISSING - Mandatory Fields missing [card expdate] See Developers Guide");
|
|
1022
|
+
});
|
|
1023
|
+
test.after(() => BaseGpApiTestConfig_1.BaseGpApiTestConfig.resetGpApiConfig());
|
|
1024
|
+
test.afterEach(() => BaseGpApiTestConfig_1.BaseGpApiTestConfig.resetGpApiConfig());
|
|
1025
|
+
//# sourceMappingURL=CreditCardNotPresentTest.js.map
|