├── .eslintignore
├── .eslintrc.cjs
├── .gitignore
├── .npmignore
├── .prettierrc
├── .travis.yml
├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── bin
└── netsuite-post.js
├── config
└── webpack.netsuite.js
├── docker-compose.yml
├── examples
├── Portico
│ └── google-pay
│ │ ├── controllers
│ │ └── transaction.js
│ │ ├── index.html
│ │ ├── package-lock.json
│ │ ├── package.json
│ │ ├── routes
│ │ └── transaction.js
│ │ ├── server.js
│ │ └── yarn.lock
├── end-to-end
│ ├── error.html
│ ├── index.html
│ ├── index.js
│ ├── package.json
│ ├── success.html
│ └── yarn.lock
├── google-pay
│ ├── index.html
│ ├── index.js
│ ├── package.json
│ └── yarn.lock
├── netsuite-suitescript
│ └── authorize.js
└── tokenize
│ └── index.js
├── jest.config.js
├── netsuite
├── errors.ts
├── https.js
└── set-timeout-polyfill.ts
├── package-lock.json
├── package.json
├── src
├── @types
│ └── elementtree
│ │ └── index.d.ts
├── Builders
│ ├── AuthorizationBuilder.ts
│ ├── BaseBuilder.ts
│ ├── BaseBuilder
│ │ ├── ValidationClause.ts
│ │ ├── ValidationTarget.ts
│ │ └── Validations.ts
│ ├── ManagementBuilder.ts
│ ├── PayFacBuilder.ts
│ ├── RecurringBuilder.ts
│ ├── ReportBuilder.ts
│ ├── RequestBuilder
│ │ ├── GpApi
│ │ │ ├── AccessTokenRequest.ts
│ │ │ ├── GpApiAuthorizationRequestBuilder.ts
│ │ │ ├── GpApiManagementRequestBuilder.ts
│ │ │ ├── GpApiMiCRequestBuilder.ts
│ │ │ ├── GpApiReportRequestBuilder.ts
│ │ │ ├── GpApiSecureRequestBuilder.ts
│ │ │ ├── GpApiSessionInfo.ts
│ │ │ └── index.ts
│ │ ├── GpEcom
│ │ │ ├── GpEcomAuthorizationRequestBuilder.ts
│ │ │ ├── GpEcomManagementRequestBuilder.ts
│ │ │ ├── GpEcomRequestBuilder.ts
│ │ │ └── index.ts
│ │ ├── RequestBuilderFactory.ts
│ │ └── index.ts
│ ├── Secure3dBuilder.ts
│ ├── SecureBuilder.ts
│ ├── TransactionBuilder.ts
│ ├── TransactionReportBuilder.ts
│ └── index.ts
├── ConfiguredServices.ts
├── Entities
│ ├── AdditionalTaxDetails.ts
│ ├── Address.ts
│ ├── AlternativePaymentResponse.ts
│ ├── BatchSummary.ts
│ ├── BrowserData.ts
│ ├── Card.ts
│ ├── CardIssuerResponse.ts
│ ├── CommercialData.ts
│ ├── CommercialLineItem.ts
│ ├── Customer.ts
│ ├── CustomerDocument.ts
│ ├── DccRateData.ts
│ ├── DiscountDetails.ts
│ ├── DisputeDocument.ts
│ ├── Document.ts
│ ├── DocumentUploadData.ts
│ ├── EcommerceInfo.ts
│ ├── EncryptionData.ts
│ ├── Enums.ts
│ ├── Enums
│ │ ├── AcquisitionType.ts
│ │ ├── CardTypeFilter.ts
│ │ ├── DccProcessor.ts
│ │ ├── DccRateType.ts
│ │ ├── DepositSortProperty.ts
│ │ ├── DisputeSortProperty.ts
│ │ ├── DisputeStage.ts
│ │ ├── DisputeStatus.ts
│ │ ├── DocumentCategory.ts
│ │ ├── FileType.ts
│ │ ├── IsoCountries.ts
│ │ └── MerchantCategory.ts
│ ├── Errors.ts
│ ├── FraudRule.ts
│ ├── GpApi
│ │ ├── AccessTokenInfo.ts
│ │ ├── DTO
│ │ │ ├── Card.ts
│ │ │ ├── PaymentMethod.ts
│ │ │ └── index.ts
│ │ ├── GpApiAccount.ts
│ │ ├── GpApiRequest.ts
│ │ ├── GpApiTokenResponse.ts
│ │ ├── PageResult.ts
│ │ └── index.ts
│ ├── HostedPaymentData.ts
│ ├── IRequestBuilder.ts
│ ├── IRequestLogger.ts
│ ├── LodgingData.ts
│ ├── LodgingItems.ts
│ ├── MaskedValueCollection.ts
│ ├── MerchantDataCollection.ts
│ ├── MerchantKVP.ts
│ ├── MessageExtension.ts
│ ├── MobileData.ts
│ ├── OrderDetails.ts
│ ├── PayerDetails.ts
│ ├── PhoneNumber.ts
│ ├── ProFac
│ │ ├── AccountBalanceResponseData.ts
│ │ ├── AccountPermissions.ts
│ │ ├── BankAccountData.ts
│ │ ├── BankAccountOwnershipData.ts
│ │ ├── BeneficialOwnerData.ts
│ │ ├── BeneficialOwnerDataResult.ts
│ │ ├── BusinessData.ts
│ │ ├── DeviceAttributeInfo.ts
│ │ ├── DeviceData.ts
│ │ ├── DeviceInfo.ts
│ │ ├── FlashFundsPaymentCardData.ts
│ │ ├── GrossBillingInformation.ts
│ │ ├── OrderDevice.ts
│ │ ├── OwnersData.ts
│ │ ├── PayFacResponseData.ts
│ │ ├── RenewAccountData.ts
│ │ ├── SignificantOwnerData.ts
│ │ ├── ThreatRiskData.ts
│ │ └── UserPersonalData.ts
│ ├── RecurringEntity.ts
│ ├── Reporting
│ │ ├── BaseSummary.ts
│ │ ├── DepositSummary.ts
│ │ ├── DisputeSummary.ts
│ │ ├── SearchCriteriaBuilder.ts
│ │ ├── StoredPaymentMethodSummary.ts
│ │ └── index.ts
│ ├── Request.ts
│ ├── SSORequestData.ts
│ ├── Schedule.ts
│ ├── ServiceEndpoints.ts
│ ├── StoredCredentials.ts
│ ├── ThreeDSecure.ts
│ ├── Transaction.ts
│ ├── TransactionStatus.ts
│ ├── TransactionSummary.ts
│ ├── UPA
│ │ ├── ProcessIndicator.ts
│ │ ├── UpaParam.ts
│ │ ├── UpaTransactionData.ts
│ │ └── index.ts
│ └── index.ts
├── Gateways
│ ├── Gateway.ts
│ ├── GatewayResponse.ts
│ ├── GpApiConnector.ts
│ ├── GpEcomConnector.ts
│ ├── IPayFacProvider.ts
│ ├── IPaymentGateway.ts
│ ├── IRecurringService.ts
│ ├── PayPlanConnector.ts
│ ├── PorticoConnector.ts
│ ├── ProPayConnector.ts
│ ├── RestGateway.ts
│ ├── XmlGateway.ts
│ ├── https-wrapper.ts
│ └── index.ts
├── HostedPaymentConfig.ts
├── Mapping
│ ├── EnumMapping.ts
│ ├── GpApiMapping.ts
│ ├── GpEcomMapping.ts
│ └── index.ts
├── PaymentMethods
│ ├── AlternativePaymentMethod.ts
│ ├── Cash.ts
│ ├── Credit.ts
│ ├── CreditCardData.ts
│ ├── CreditTrackData.ts
│ ├── Debit.ts
│ ├── DebitTrackData.ts
│ ├── EBT.ts
│ ├── EBTCardData.ts
│ ├── EBTTrackData.ts
│ ├── ECheck.ts
│ ├── GiftCard.ts
│ ├── Interfaces.ts
│ ├── PaymentMethod.ts
│ ├── RecurringPaymentMethod.ts
│ ├── TransactionReference.ts
│ └── index.ts
├── ServiceConfigs
│ ├── AcceptorConfig.ts
│ ├── Configuration.ts
│ ├── Gateways
│ │ ├── GatewayConfig.ts
│ │ ├── GpApiConfig.ts
│ │ ├── GpEcomConfig.ts
│ │ ├── PorticoConfig.ts
│ │ └── index.ts
│ ├── ServicesConfigs.ts
│ └── index.ts
├── Services
│ ├── BatchService.ts
│ ├── CheckService.ts
│ ├── CreditService.ts
│ ├── DebitService.ts
│ ├── DeviceService.ts
│ ├── EBTService.ts
│ ├── GiftService.ts
│ ├── GpApiServices.ts
│ ├── HostedService.ts
│ ├── PayFacService.ts
│ ├── RecurringService.ts
│ ├── ReportingService.ts
│ ├── Secure3dService.ts
│ └── index.ts
├── ServicesContainer.ts
├── Terminals
│ ├── Abstractions
│ │ ├── IDeviceCommInterface.ts
│ │ ├── IDeviceInterface.ts
│ │ ├── IDeviceMessage.ts
│ │ ├── IDeviceResponse.ts
│ │ ├── IRequestIdProvider.ts
│ │ ├── IRequestSubGroup.ts
│ │ ├── ITerminalConfiguration.ts
│ │ └── index.ts
│ ├── Builders
│ │ ├── TerminalAuthBuilder.ts
│ │ ├── TerminalBuilder.ts
│ │ ├── TerminalManageBuilder.ts
│ │ └── index.ts
│ ├── ConnectionConfig.ts
│ ├── DeviceController.ts
│ ├── DeviceInterface.ts
│ ├── DeviceMessage.ts
│ ├── DeviceResponse.ts
│ ├── Enums.ts
│ ├── Enums
│ │ ├── ControlCodes.ts
│ │ └── index.ts
│ ├── SummaryResponse.ts
│ ├── TerminalResponse.ts
│ ├── TerminalUtils.ts
│ ├── UPA
│ │ ├── Entities
│ │ │ ├── UpaMessageId.ts
│ │ │ └── index.ts
│ │ ├── Interfaces
│ │ │ ├── UpaMicInterface.ts
│ │ │ └── index.ts
│ │ ├── Reponses
│ │ │ ├── TransactionResponse.ts
│ │ │ └── index.ts
│ │ ├── Request
│ │ │ ├── BaseRequest.ts
│ │ │ ├── GroupRequest.ts
│ │ │ ├── RequestParams.ts
│ │ │ ├── RootRequest.ts
│ │ │ ├── TransactionRequest.ts
│ │ │ └── index.ts
│ │ ├── UpaController.ts
│ │ ├── UpaInterface.ts
│ │ ├── UpaMessageType.ts
│ │ └── index.ts
│ └── index.ts
├── Utils
│ ├── CardUtils.ts
│ ├── CountryUtils.ts
│ ├── GenerationUtils.ts
│ ├── IRawRequestBuilder.ts
│ ├── InputValidation.ts
│ ├── Logging
│ │ ├── Logger.ts
│ │ ├── ProtectSensitiveData.ts
│ │ ├── SampleRequestLogger.ts
│ │ └── index.ts
│ ├── ServerDates.ts
│ ├── Sha1.ts
│ ├── StringUtils.ts
│ └── index.ts
└── index.ts
├── test
├── Data
│ ├── BaseGpApiTestConfig.ts
│ ├── GpApi3DSTestCards.ts
│ ├── TestCards.ts
│ ├── TestChecks.ts
│ └── index.ts
├── Integration
│ ├── Gateways
│ │ ├── AcsResponse.ts
│ │ ├── GpApiConnector
│ │ │ ├── 3DS2.test.ts
│ │ │ ├── 3DSecure.test.ts
│ │ │ ├── AccessToken.test.ts
│ │ │ ├── Ach.test.ts
│ │ │ ├── Apm.test.ts
│ │ │ ├── CreditCardNotPresent.test.ts
│ │ │ ├── DccCardNotPresent.test.ts
│ │ │ ├── DebitCard.test.ts
│ │ │ ├── EbtCard.test.ts
│ │ │ ├── GpApiCertification.test.ts
│ │ │ ├── GpApiTokenManagement.test.ts
│ │ │ ├── ReportingDeposits.test.ts
│ │ │ ├── ReportingDisputes.test.ts
│ │ │ ├── ReportingSettlementTransactions.test.ts
│ │ │ ├── ReportingStoredPaymentMethods.test.ts
│ │ │ └── ReportingTransactions.test.ts
│ │ ├── GpEcomConnector
│ │ │ ├── Certification
│ │ │ │ ├── Auth.test.ts
│ │ │ │ ├── Avs.test.ts
│ │ │ │ ├── Credit.test.ts
│ │ │ │ └── Hold.test.ts
│ │ │ ├── Credit.test.ts
│ │ │ ├── Hpp.test.ts
│ │ │ └── Recurring.test.ts
│ │ ├── PorticoConnector
│ │ │ ├── Ach.test.ts
│ │ │ ├── Certifications
│ │ │ │ ├── Check.test.ts
│ │ │ │ ├── Ecommerce.test.ts
│ │ │ │ ├── EcommerceCheck.test.ts
│ │ │ │ ├── Moto.test.ts
│ │ │ │ ├── MotoCheck.test.ts
│ │ │ │ ├── Recurring.test.ts
│ │ │ │ └── Retail.test.ts
│ │ │ ├── Credit.test.ts
│ │ │ ├── Debit.test.ts
│ │ │ ├── Ebt.test.ts
│ │ │ ├── Ecommerce.test.ts
│ │ │ ├── Gift.test.ts
│ │ │ ├── PorticoManagementToken.test.ts
│ │ │ ├── Recurring.test.ts
│ │ │ └── Reporting.test.ts
│ │ ├── ProPayConnector
│ │ │ ├── Certifications
│ │ │ │ ├── GetInformationCertification.test.ts
│ │ │ │ ├── ProPayAccountCertification.test.ts
│ │ │ │ ├── ProPayFundCertification.test.ts
│ │ │ │ ├── ProPayInNetworkTransactionCertification.test.ts
│ │ │ │ └── TestData
│ │ │ │ │ ├── TestAccountData.ts
│ │ │ │ │ ├── TestDoc.docx
│ │ │ │ │ ├── TestDocChargeback.docx
│ │ │ │ │ └── selfSignedCertificate.crt
│ │ │ ├── GetInformation.test.ts
│ │ │ ├── ProPayAccount.test.ts
│ │ │ ├── ProPayFunds.test.ts
│ │ │ ├── ProPayInNetworkTransaction.test.ts
│ │ │ └── TestData
│ │ │ │ ├── TestAccountData.ts
│ │ │ │ ├── TestDoc.docx
│ │ │ │ ├── TestDocChargeback.docx
│ │ │ │ ├── TestFundsData.ts
│ │ │ │ ├── selfSignedCertificate.crt
│ │ │ │ └── selfSignedCertificateCAN.crt
│ │ ├── Terminals
│ │ │ ├── RequestIdProvider.ts
│ │ │ └── UPA
│ │ │ │ └── UpaMic.test.ts
│ │ └── ThreeDSecureAsClient.ts
│ └── Services
│ │ ├── CheckService.test.ts
│ │ ├── CreditService.test.ts
│ │ ├── DebitService.test.ts
│ │ └── EBTService.test.ts
└── Unit
│ ├── Builders
│ ├── AuthorizationBuilder
│ │ └── Validation.test.ts
│ └── ReportBuilder
│ │ └── Validation.test.ts
│ └── Gateways
│ ├── GpEcomConnector
│ └── Credit.test.ts
│ └── PorticoConnector
│ └── InputValidation.test.ts
├── tsconfig.eslint.json
├── tsconfig.json
├── tslint.json
└── yarn.lock
/.eslintignore:
--------------------------------------------------------------------------------
1 | bin/
2 | config/
3 | examples/
4 | lib/
5 | netsuite/
6 |
7 | /**/node_modules/*
8 | node_modules/
9 | tsconfig.json
--------------------------------------------------------------------------------
/.eslintrc.cjs:
--------------------------------------------------------------------------------
1 | /* eslint-env node */
2 | module.exports = {
3 | extends: [
4 | "plugin:@typescript-eslint/recommended",
5 | "plugin:prettier/recommended",
6 | ],
7 | parser: "@typescript-eslint/parser",
8 | plugins: ["@typescript-eslint"],
9 | parserOptions: {
10 | tsconfigRootDir: __dirname,
11 | },
12 | root: true,
13 | overrides: [
14 | {
15 | files: ["./src/*.ts"],
16 | extends: ["plugin:@typescript-eslint/disable-type-checked"],
17 | rules: {
18 | "@typescript-eslint/tslint/config": ["off"],
19 | },
20 | },
21 | {
22 | files: ["*.js", "*.jsx", "*.ts", "*.tsx", "*.json", "*.css", "*.scss"],
23 | rules: {
24 | "prettier/prettier": [
25 | "error",
26 | {
27 | endOfLine: "auto",
28 | },
29 | ],
30 | },
31 | },
32 | ],
33 | rules: {
34 | "@typescript-eslint/ban-types": "off",
35 | "@typescript-eslint/no-explicit-any": "off",
36 | "@typescript-eslint/no-misused-new": "off",
37 | "@typescript-eslint/ban-ts-comment": "off",
38 | indent: [
39 | "error",
40 | 2,
41 | {
42 | SwitchCase: 1,
43 | ObjectExpression: 1,
44 | MemberExpression: 1,
45 | FunctionDeclaration: { body: 1, parameters: 2 },
46 | ignoredNodes: ["ConditionalExpression"],
47 | },
48 | ],
49 | },
50 | };
51 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 |
6 | # Runtime data
7 | pids
8 | *.pid
9 | *.seed
10 |
11 | # Directory for instrumented libs generated by jscoverage/JSCover
12 | lib-cov
13 |
14 | # Coverage directory used by tools like istanbul
15 | coverage
16 |
17 | # nyc test coverage
18 | .nyc_output
19 |
20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21 | .grunt
22 |
23 | # node-waf configuration
24 | .lock-wscript
25 |
26 | # Compiled binary addons (http://nodejs.org/api/addons.html)
27 | build/Release
28 |
29 | # Dependency directories
30 | node_modules
31 | jspm_packages
32 |
33 | # Optional npm cache directory
34 | .npm
35 |
36 | # Optional REPL history
37 | .node_repl_history
38 |
39 | # Build files
40 | lib
41 | logger.txt
42 |
43 | # VS Code setup
44 | .vscode/
45 |
46 | #local
47 | .DS_Store
48 | .idea/
49 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .vscode/
2 | bin/
3 | config/
4 | examples/
5 | lib/
6 | !lib/src
7 | netsuite/
8 | src/
9 | test/
10 | docker-compose.yml
11 | tsconfig.json
12 | tslint.json
13 | yarn.lock
14 | yarn-error.log
15 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "arrowParens": "always",
3 | "trailingComma": "all",
4 | "indent": [
5 | "error",
6 | 2,
7 | {
8 | "SwitchCase": 1,
9 | "ObjectExpression": 1,
10 | "MemberExpression": 1,
11 | "FunctionDeclaration": { "body": 1, "parameters": 2 }
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 |
3 | sudo: false
4 | branches:
5 | only:
6 | - master
7 |
8 | node_js:
9 | - "node"
10 |
11 | install:
12 | - yarn install
13 |
14 | script:
15 | - yarn run docs
16 |
17 | deploy:
18 | local-dir: docs
19 | provider: pages
20 | skip-cleanup: true
21 | github-token: $GITHUB_TOKEN # Set in the settings page of your repository, as a secure variable
22 | keep-history: true
23 | on:
24 | branch: master
25 |
26 |
--------------------------------------------------------------------------------
/bin/netsuite-post.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 | const path = require("path");
3 |
4 | const fileName = path.resolve(
5 | __dirname,
6 | "..",
7 | "lib",
8 | "netsuite",
9 | "globalpayments.api.js",
10 | );
11 | let script = fs.readFileSync(fileName).toString();
12 |
13 | script = script.replace(
14 | "define(function() { return /******/ (function(modules) { // webpackBootstrap",
15 | 'define(["N/https", "N/log"], function(https, log) { return /******/ (function(modules) { // webpackBootstrap',
16 | );
17 | script = script.replace(
18 | "var setTimeoutFunc = setTimeout;",
19 | "var setTimeoutFunc = Promise._immediateFn;",
20 | );
21 | script = script.replace(
22 | "var globalSetTimeout = setTimeout;",
23 | "var globalSetTimeout = function(callable, any) {\n return callable.apply(global, [].slice.call(arguments, 2));\n };",
24 | );
25 | script = script.replace(/console\.(log|trace|warn)/g, "log.debug");
26 | script = script.replace(/console\.(error)/g, "log.error");
27 |
28 | fs.writeFileSync(fileName, script);
29 |
--------------------------------------------------------------------------------
/config/webpack.netsuite.js:
--------------------------------------------------------------------------------
1 | const path = require("path");
2 | const { TsConfigPathsPlugin } = require("awesome-typescript-loader");
3 |
4 | const resolve = (p) => path.resolve(__dirname, p);
5 |
6 | module.exports = {
7 | entry: resolve("../src/index.ts"),
8 | output: {
9 | filename: "lib/netsuite/globalpayments.api.js",
10 | libraryTarget: "amd",
11 | },
12 | resolve: {
13 | alias: {
14 | "./https-wrapper$": resolve("../netsuite/https.js"),
15 | "./Errors$": resolve("../netsuite/errors.ts"),
16 | },
17 | extensions: [".ts", ".js"],
18 | plugins: [
19 | new TsConfigPathsPlugin({
20 | configFileName: "tsconfig.json",
21 | compliler: "typescript",
22 | }),
23 | ],
24 | },
25 | module: {
26 | loaders: [{ test: /\.ts$/, loader: "awesome-typescript-loader" }],
27 | },
28 | };
29 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "2.1"
2 | services:
3 | node:
4 | image: node:${NODE_VERSION}-alpine
5 | volumes:
6 | - .:/src
7 | working_dir: /src
8 |
9 | setup:
10 | extends:
11 | service: node
12 | command: >
13 | sh -c "node --version &&
14 | npm --version &&
15 | npm install"
16 |
17 | test:
18 | extends:
19 | service: node
20 | command: npm test
21 |
22 |
23 |
--------------------------------------------------------------------------------
/examples/Portico/google-pay/controllers/transaction.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 | const { json } = require("micro");
3 | const { promisify } = require("util");
4 | const bodyParser = require("body-parser");
5 | const {
6 | CreditCardData,
7 | ServicesContainer,
8 | PaymentDataSourceType,
9 | MobilePaymentMethodType,
10 | PorticoConfig,
11 | GatewayError,
12 | } = require("globalpayments-api");
13 |
14 | const configure = () => {
15 | const config = new PorticoConfig();
16 | config.secretApiKey = "skapi_cert_MeHOBQDccnIA8S6ECUes8HNT8v9cuUvQIsJdKZ8pwA";
17 | config.developerId = "000000";
18 | config.versionNumber = "0000";
19 | config.serviceUrl = "https://cert.api2.heartlandportico.com";
20 | ServicesContainer.configureService(config);
21 | };
22 |
23 | exports.processToken = async (req, res) => {
24 | // obtain request data
25 | const data = await json(req);
26 |
27 | // create payment request with gateway
28 | configure();
29 |
30 | const card = new CreditCardData();
31 | card.token = data.token;
32 | card.mobileType = MobilePaymentMethodType.GOOGLEPAY;
33 | card.paymentSource = PaymentDataSourceType.GOOGLEPAYWEB;
34 |
35 | try {
36 | const payment = card
37 | .charge("1.00")
38 | .withCurrency("USD")
39 | .execute()
40 | .then((result) => {
41 | res.send(
42 | JSON.stringify({
43 | message: 'Google Pay token processed succesfully',
44 | error: false,
45 | responseCode: result.responseCode,
46 | authCode: result.transactionReference.authCode,
47 | txnID: result.transactionId
48 |
49 | }),
50 | );
51 | }).catch( e =>{
52 | if (e instanceof GatewayError) {
53 | res.send(
54 | JSON.stringify({
55 | error: true,
56 | message: e.message,
57 | code: e.responseCode
58 | }),
59 | );
60 | }
61 | })
62 |
63 | } catch (e) {
64 | console.log(e);
65 | res.end(
66 | JSON.stringify({
67 | error: true,
68 | exception: {
69 | code: e.code,
70 | message: e.message,
71 | },
72 | }),
73 | );
74 | }
75 | };
76 |
--------------------------------------------------------------------------------
/examples/Portico/google-pay/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "google-pay",
3 | "version": "1.0.0",
4 | "main": "index.js",
5 | "license": "GPL-2.0",
6 | "scripts": {
7 | "deploy": "now",
8 | "develop": "micro",
9 | "start": "micro"
10 | },
11 | "dependencies": {
12 | "body-parser": "^1.20.3",
13 | "express": "^4.16.4",
14 | "globalpayments-api": "^3.10.1",
15 | "micro": "^9.3.4"
16 | },
17 | "devDependencies": {
18 | "nodemon": "^3.1.9",
19 | "now": "^9.3.3"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/examples/Portico/google-pay/routes/transaction.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const router = express.Router();
3 | const bodyParser = require("body-parser")
4 | const transactionController = require('../controllers/transaction');
5 |
6 |
7 | router.use(bodyParser.urlencoded({extended: false}));
8 |
9 |
10 | //POST
11 | router.post('/post', transactionController.processToken);
12 |
13 | module.exports = router;
--------------------------------------------------------------------------------
/examples/Portico/google-pay/server.js:
--------------------------------------------------------------------------------
1 | const http = require("http");
2 | const express = require("express");
3 | const app = express();
4 | const path = require("path");
5 | const bodyParser = require("body-parser");
6 | const transactionRoutes = require("./routes/transaction");
7 |
8 |
9 | app.use(bodyParser.urlencoded({ extended: false }));
10 | app.use(transactionRoutes);
11 |
12 | app.get('/', (req, res, next)=> {
13 | res.sendFile(path.join(__dirname,'index.html'));
14 | });
15 |
16 | app.use((req, res, next) => {
17 | res.status(404).send("
Page not found
");
18 | });
19 |
20 | const PORT = 3000;
21 | app.listen(PORT, ()=> {
22 | console.log(`Server listening on ${PORT}`);
23 | });
24 |
25 |
--------------------------------------------------------------------------------
/examples/end-to-end/error.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | End-to-End Payment Example
7 |
21 |
22 |
23 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/examples/end-to-end/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "end-to-end",
3 | "version": "1.0.0",
4 | "main": "index.js",
5 | "license": "GPL-2.0",
6 | "scripts": {
7 | "deploy": "now",
8 | "develop": "micro",
9 | "start": "micro"
10 | },
11 | "dependencies": {
12 | "globalpayments-api": "^3.3.0",
13 | "micro": "^9.3.2",
14 | "urlencoded-body-parser": "^2.0.1"
15 | },
16 | "devDependencies": {
17 | "now": "^9.2.7"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/examples/end-to-end/success.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | End-to-End Payment Example
7 |
21 |
22 |
23 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/examples/google-pay/index.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs');
2 | const {json} = require('micro');
3 | const {promisify} = require('util');
4 | const {
5 | Address,
6 | CreditCardData,
7 | GpEcomConfig,
8 | ServicesContainer,
9 | TransactionModifier,
10 | SampleRequestLogger,
11 | Logger,
12 | } = require('globalpayments-api');
13 |
14 | const readFileAsync = promisify(fs.readFile);
15 |
16 | const showIndex = async (res) => {
17 | const html = await readFileAsync('index.html');
18 | res.end(html);
19 | };
20 |
21 | const configure = () => {
22 | const config = new GpEcomConfig();
23 |
24 | config.merchantId = 'heartlandgpsandbox';
25 | config.accountId = 'apitest';
26 | config.sharedSecret = 'secret';
27 | config.serviceUrl = 'https://api.sandbox.realexpayments.com/epage-remote.cgi';
28 | config.requestLogger = new SampleRequestLogger(new Logger("logs"));
29 | ServicesContainer.configureService(config);
30 | }
31 |
32 | module.exports = async (req, res) => {
33 | switch (req.method) {
34 | case 'GET':
35 | await showIndex(res);
36 | break;
37 | case 'POST':
38 | // obtain request data
39 | const data = await json(req);
40 |
41 | // create payment request with gateway
42 | configure();
43 |
44 | const card = new CreditCardData();
45 | card.token = data.response.details.paymentMethodToken.token;
46 | card.mobileType = data.mobileType;
47 |
48 | const address = new Address();
49 | address.postalCode = data.response.details.cardInfo.billingAddress.postalCode;
50 |
51 | try {
52 | const payment = await card.charge('20.00')
53 | .withCurrency('USD')
54 | .withAddress(address)
55 | .withModifier(TransactionModifier.EncryptedMobile)
56 | .execute();
57 |
58 | res.end(JSON.stringify({
59 | error: false,
60 | response: payment,
61 | }));
62 | } catch (e) {
63 | console.log(e);
64 | res.end(JSON.stringify({
65 | error: true,
66 | exception: {
67 | code: e.code,
68 | message: e.message,
69 | },
70 | }));
71 | }
72 | break;
73 | default:
74 | res.end();
75 | }
76 | };
--------------------------------------------------------------------------------
/examples/google-pay/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "google-pay",
3 | "version": "1.0.0",
4 | "main": "index.js",
5 | "license": "GPL-2.0",
6 | "scripts": {
7 | "deploy": "now",
8 | "develop": "micro",
9 | "start": "micro"
10 | },
11 | "dependencies": {
12 | "globalpayments-api": "^3.3.0",
13 | "micro": "^9.3.4"
14 | },
15 | "devDependencies": {
16 | "now": "^9.3.3"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/examples/netsuite-suitescript/authorize.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @NApiVersion 2.x
3 | * @NScriptType ScheduledScript
4 | */
5 | define(["SuiteScripts/Honeycomb Mfg/globalpayments.api", "N/log"], function(
6 | GP,
7 | log,
8 | ) {
9 | function execute(context) {
10 | var config = new GP.ServicesConfig();
11 | config.secretApiKey =
12 | "skapi_cert_MTeSAQAfG1UA9qQDrzl-kz4toXvARyieptFwSKP24w";
13 | config.serviceUrl = "https://cert.api2.heartlandportico.com";
14 |
15 | GP.ServicesContainer.configure(config);
16 |
17 | var card = new GP.CreditCardData();
18 | card.number = "4111111111111111";
19 | card.expMonth = "12";
20 | card.expYear = "2025";
21 | card.cvn = "123";
22 | card.cardHolderName = "Joe Smith";
23 |
24 | card
25 | .authorize("14")
26 | .withCurrency("USD")
27 | .withAllowDuplicates(true)
28 | .execute()
29 | .then(function(authorization) {
30 | log.debug(authorization);
31 | return authorization;
32 | });
33 | }
34 |
35 | return {
36 | execute: execute,
37 | };
38 | });
39 |
--------------------------------------------------------------------------------
/examples/tokenize/index.js:
--------------------------------------------------------------------------------
1 | const {
2 | PorticoConfig,
3 | ServicesContainer,
4 | CreditCardData,
5 | Address,
6 | SampleRequestLogger,
7 | Logger
8 | } = require("../../lib/src");
9 |
10 | const config = new PorticoConfig();
11 | config.secretApiKey = "skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A";
12 | config.serviceUrl = "https://cert.api2.heartlandportico.com";
13 | config.requestLogger = new SampleRequestLogger(new Logger("logs"));
14 |
15 | ServicesContainer.configureService(config);
16 |
17 | const card = new CreditCardData();
18 | card.number = "4111111111111111";
19 | card.expMonth = "12";
20 | card.expYear = "2025";
21 | card.cvn = "123";
22 | card.cardHolderName = "Joe Smith";
23 |
24 | const address = new Address();
25 | address.postalCode = "12345";
26 |
27 | card
28 | .tokenize()
29 | .withCurrency("USD")
30 | .withAddress(address)
31 | .execute()
32 | .then((response) => {
33 | console.log(response);
34 |
35 | const token = new CreditCardData();
36 | token.token = response.token;
37 | token.expMonth = "12";
38 | token.expYear = "2025";
39 |
40 | token
41 | .authorize(10)
42 | .withCurrency("USD")
43 | .execute()
44 | .then((authorization) => {
45 | console.log("auth:", authorization);
46 | })
47 | .catch((err) => console.log(err));
48 | })
49 | .catch((error) => console.log(error));
50 |
--------------------------------------------------------------------------------
/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | preset: "ts-jest",
3 | verbose: true,
4 | runner: "jest-runner",
5 | testTimeout: 900000,
6 | testEnvironment: "node",
7 | extensionsToTreatAsEsm: [".ts"],
8 | testMatch: ["**/?(*.)+(spec|test).[jt]s?(x)"],
9 | }
--------------------------------------------------------------------------------
/netsuite/errors.ts:
--------------------------------------------------------------------------------
1 | // tslint:disable:max-classes-per-file
2 |
3 | export class ApiError {
4 | public message: string;
5 | public name: string;
6 | constructor(m?: string, name = "ApiError") {
7 | if (m) {
8 | this.message = m;
9 | } else {
10 | this.message = "Unexpected error";
11 | }
12 | this.name = name;
13 | }
14 | }
15 |
16 | export class ArgumentError extends ApiError {
17 | constructor(m?: string) {
18 | super(m, "ArgumentError");
19 | }
20 | }
21 |
22 | export class BuilderError extends ApiError {
23 | constructor(m?: string) {
24 | super(m, "BuilderError");
25 | }
26 | }
27 |
28 | export class ConfigurationError extends ApiError {
29 | constructor(m?: string) {
30 | super(m, "ConfigurationError");
31 | }
32 | }
33 |
34 | export class GatewayError extends ApiError {
35 | public responseCode: string;
36 | public responseMessage: string;
37 | constructor(m?: string, code?: string, message?: string) {
38 | super(m, "GatewayError");
39 | if (code) {
40 | this.responseCode = code;
41 | }
42 | if (message) {
43 | this.responseMessage = message;
44 | }
45 | }
46 | }
47 |
48 | export class NotImplementedError extends ApiError {
49 | constructor(m?: string) {
50 | super(m, "NotImplementedError");
51 | }
52 | }
53 |
54 | export class UnsupportedTransactionError extends ApiError {
55 | constructor(m?: string) {
56 | if (!m) {
57 | m = "Transaction type not supported for this payment method.";
58 | }
59 | super(m, "UnsupportedTransactionError");
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/netsuite/https.js:
--------------------------------------------------------------------------------
1 | function parseMethod(method) {
2 | switch (method.toUpperCase()) {
3 | case "GET":
4 | return https.Method.GET;
5 | case "POST":
6 | return https.Method.POST;
7 | case "PUT":
8 | return https.Method.PUT;
9 | case "DELETE":
10 | return https.Method.DELETE;
11 | default:
12 | return "";
13 | }
14 | }
15 |
16 | export function request(requestBody, options) {
17 | var requestOptions = {
18 | body: requestBody,
19 | headers: options.headers,
20 | method: parseMethod(options.method),
21 | url: "https://" + options.host + ":" + options.port + options.path,
22 | };
23 | return new Promise(function(resolve, reject) {
24 | try {
25 | var response = https.request(requestOptions);
26 |
27 | if (response.code !== 200) {
28 | reject(
29 | new Error("Unexpected HTTP status code [" + response.code + "]")
30 | );
31 | }
32 |
33 | resolve(response.body);
34 | } catch (e) {
35 | reject(e);
36 | }
37 | });
38 | }
39 |
--------------------------------------------------------------------------------
/netsuite/set-timeout-polyfill.ts:
--------------------------------------------------------------------------------
1 | function definePolyfill(global: any) {
2 | // tslint:disable:only-arrow-functions
3 | global.setTimeout = function(callable: () => {}, _: any) {
4 | return callable.apply(global, [].slice.call(arguments, 2));
5 | };
6 | // tslint:enable:only-arrow-functions
7 | }
8 |
9 | let local: any;
10 |
11 | if (typeof exports !== "undefined") {
12 | local = exports;
13 | } else if (typeof global !== "undefined") {
14 | local = global;
15 | } else if (typeof self !== "undefined") {
16 | local = self;
17 | } else {
18 | try {
19 | local = Function("return this")();
20 | } catch (e) {
21 | throw new Error("setTimeout polyfill failed.");
22 | }
23 | }
24 |
25 | const P = local.Promise;
26 |
27 | if (P) {
28 | let promiseToString: string | null = null;
29 |
30 | try {
31 | promiseToString = Object.prototype.toString.call(local.setTimeout);
32 | } catch (e) {
33 | /** om nom nom */
34 | }
35 |
36 | if (promiseToString !== "[object Function]") {
37 | definePolyfill(local);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "globalpayments-api",
3 | "version" : "3.10.6",
4 | "description": "Global Payments SDK for NodeJS for Heartland and Global Payments eCommerce gateways",
5 | "author": "Heartland Payment Systems",
6 | "license": "GPL-2.0",
7 | "engines": {
8 | "node": ">=16.20.2"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "https://github.com/globalpayments/node-sdk.git"
13 | },
14 | "main": "./lib/src/index.js",
15 | "typings": "./lib/src/index",
16 | "scripts": {
17 | "build": "tsc",
18 | "test:jest": "jest",
19 | "test:serial": "jest --runInBand test/Integration/Gateways/PorticoConnector/Credit.test.ts",
20 | "build:netsuite": "webpack --env.GP_NETSUITE_BUILD --config config/webpack.netsuite.js && node bin/netsuite-post.js",
21 | "build:clean": "rimraf lib",
22 | "docs": "typedoc --mode file --name \"GlobalPayments.Api\" --project tsconfig.json --out docs src",
23 | "format": "prettier --write --config .prettierrc 'src/**/*.ts' 'test/**/*.ts' '*.md'",
24 | "prebuild": "npm-run-all test:lint",
25 | "prepublish": "npm-run-all build",
26 | "prepublishOnly": "npm-run-all build",
27 | "pretest": "npm-run-all build:clean test:lint build",
28 | "test:lint": "eslint \"src/**/*.ts*\" \"test/**/*.ts\" --fix"
29 | },
30 | "dependencies": {
31 | "@azz/elementtree": "^0.1.6",
32 | "es6-promise": "^4.2.8",
33 | "eslint-config-prettier": "^9.0.0",
34 | "sha1": "^1.1.1",
35 | "typedarray": "^0.0.6",
36 | "url": "^0.11.0"
37 | },
38 | "devDependencies": {
39 | "@hitc/netsuite-types": "^2017.2.32",
40 | "@types/jest": "^29.5.12",
41 | "@types/node": "20.6.0",
42 | "@typescript-eslint/eslint-plugin": "^6.7.3",
43 | "@typescript-eslint/parser": "^6.7.3",
44 | "eslint": "^8.50.0",
45 | "eslint-plugin-prettier": "^5.0.0",
46 | "jest": "^29.7.0",
47 | "npm-run-all": "^4.1.5",
48 | "prettier": "3.0.3",
49 | "rimraf": "^2.6.3",
50 | "ts-jest": "^29.1.5",
51 | "tslint": "^6.1.3",
52 | "typedoc": "0.25.1",
53 | "typescript": "5.2.2",
54 | "webpack": "^5.94.0"
55 | },
56 | "files": [
57 | "lib/src/**",
58 | "lib/test/**",
59 | "appsec.properties",
60 | "CHANGELOG.md"
61 | ],
62 | "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
63 | }
64 |
--------------------------------------------------------------------------------
/src/Builders/BaseBuilder.ts:
--------------------------------------------------------------------------------
1 | import { Validations } from "./BaseBuilder/Validations";
2 |
3 | export interface IDictionary {
4 | [key: string]: T;
5 | }
6 |
7 | export abstract class BaseBuilder {
8 | protected validations: Validations;
9 | [key: string]: any;
10 |
11 | public constructor() {
12 | this.validations = new Validations();
13 | this.setupValidations();
14 | }
15 |
16 | public execute(): Promise {
17 | this.validations.validate(this);
18 | return Promise.resolve(undefined);
19 | }
20 |
21 | protected abstract setupValidations(): void;
22 | }
23 |
--------------------------------------------------------------------------------
/src/Builders/BaseBuilder/ValidationTarget.ts:
--------------------------------------------------------------------------------
1 | import { ValidationClause } from "./ValidationClause";
2 | import { Validations } from "./Validations";
3 |
4 | export class ValidationTarget {
5 | public parent: Validations;
6 | public type: number;
7 | public property: string;
8 | public clause: ValidationClause;
9 | public constraint: number;
10 | public constraintProperty: string;
11 | public enumName: string;
12 | public precondition: ValidationClause;
13 |
14 | public constructor(parent: Validations, enumName: string, type: number) {
15 | this.parent = parent;
16 | this.type = type;
17 | this.enumName = enumName;
18 | }
19 |
20 | public with(property: string, constraint: number) {
21 | this.constraintProperty = property;
22 | this.constraint = constraint;
23 | return this;
24 | }
25 |
26 | public check(targetProperty: string): ValidationClause {
27 | this.property = targetProperty;
28 | this.clause = new ValidationClause(this.parent, this);
29 | return this.clause;
30 | }
31 |
32 | public when(targetProperty: string): ValidationClause {
33 | this.property = targetProperty;
34 | this.precondition = new ValidationClause(this.parent, this, true);
35 | return this.precondition;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Builders/BaseBuilder/Validations.ts:
--------------------------------------------------------------------------------
1 | import { BaseBuilder, BuilderError, TransactionBuilder } from "../../";
2 | import { ValidationTarget } from "./ValidationTarget";
3 |
4 | export interface IRuleSet {
5 | [key: string]: {
6 | [key: string]: ValidationTarget[];
7 | };
8 | }
9 |
10 | export class Validations {
11 | public rules: IRuleSet;
12 |
13 | public constructor() {
14 | this.rules = {};
15 | }
16 |
17 | public of(enumProperty: string, type: number): ValidationTarget {
18 | if (!this.rules.hasOwnProperty(enumProperty)) {
19 | this.rules[enumProperty] = {};
20 | }
21 |
22 | if (!this.rules[enumProperty].hasOwnProperty(type.toString())) {
23 | this.rules[enumProperty][type.toString()] = [];
24 | }
25 |
26 | const target = new ValidationTarget(this, enumProperty, type);
27 | this.rules[enumProperty][type].push(target);
28 | return target;
29 | }
30 |
31 | public validate(builder: BaseBuilder): void {
32 | Object.keys(this.rules).forEach((enumName) => {
33 | Object.keys(this.rules[enumName]).forEach((ruleType) => {
34 | let value: number = builder[enumName];
35 |
36 | if (
37 | (value === undefined || value === null) &&
38 | builder instanceof TransactionBuilder &&
39 | builder.paymentMethod
40 | ) {
41 | value = builder.paymentMethod[enumName];
42 | if (value === undefined || value === null) {
43 | return;
44 | }
45 | }
46 |
47 | if ((Number(ruleType) & value) !== value || Number(ruleType) > value) {
48 | return;
49 | }
50 |
51 | for (const validation of this.rules[enumName][ruleType]) {
52 | if (!validation.clause) {
53 | continue;
54 | }
55 |
56 | if (
57 | validation.constraint !== undefined &&
58 | validation.constraint !== null &&
59 | validation.constraint !== builder[validation.constraintProperty]
60 | ) {
61 | continue;
62 | }
63 |
64 | if (!validation.clause.callback(builder)) {
65 | throw new BuilderError(validation.clause.message);
66 | }
67 | }
68 | });
69 | });
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/Builders/RecurringBuilder.ts:
--------------------------------------------------------------------------------
1 | import { IRecurringEntity, ServicesContainer, TransactionType } from "../";
2 | import { TransactionBuilder } from "./TransactionBuilder";
3 | import { IDictionary } from "./BaseBuilder";
4 |
5 | export class RecurringBuilder<
6 | T extends IRecurringEntity,
7 | > extends TransactionBuilder {
8 | public key: string;
9 | public orderId: string;
10 | public entity: IRecurringEntity | Function;
11 | public searchCriteria: IDictionary;
12 |
13 | public constructor(
14 | type: TransactionType,
15 | entity?: IRecurringEntity | Function,
16 | ) {
17 | super(type);
18 | this.searchCriteria = {};
19 | if (entity) {
20 | this.entity = entity;
21 | this.key = (entity as unknown as IRecurringEntity).key;
22 | }
23 | }
24 |
25 | public addSearchCriteria(key: string, value: string) {
26 | this.searchCriteria[key] = value;
27 | return this;
28 | }
29 |
30 | public execute(configName: string = "default"): Promise {
31 | super.execute();
32 | return ServicesContainer.instance()
33 | .getRecurringClient(configName)
34 | .processRecurring(this);
35 | }
36 |
37 | public setupValidations() {
38 | // todo
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/Builders/ReportBuilder.ts:
--------------------------------------------------------------------------------
1 | import {
2 | ReportType,
3 | SearchCriteriaBuilder,
4 | ServicesContainer,
5 | TimeZoneConversion,
6 | } from "../";
7 | import { BaseBuilder } from "./BaseBuilder";
8 |
9 | export abstract class ReportBuilder extends BaseBuilder {
10 | public reportType: ReportType;
11 | public timeZoneConversion: TimeZoneConversion;
12 | public searchBuilder: SearchCriteriaBuilder;
13 |
14 | public constructor(type: ReportType) {
15 | super();
16 | this.reportType = type;
17 | }
18 |
19 | public execute(configName: string = "default"): Promise {
20 | super.execute();
21 | return ServicesContainer.instance()
22 | .getClient(configName)
23 | .processReport(this);
24 | }
25 |
26 | withPaging(page: number, pageSize: number) {
27 | this.page = page;
28 | this.pageSize = pageSize;
29 |
30 | return this;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Builders/RequestBuilder/GpApi/AccessTokenRequest.ts:
--------------------------------------------------------------------------------
1 | import { IntervalToExpire } from "../../../../src";
2 |
3 | export class AccessTokenRequest {
4 | public app_id: string;
5 | public nonce: string;
6 | public secret: string;
7 | public grant_type: string;
8 | public seconds_to_expire: number | undefined;
9 | public interval_to_expire: IntervalToExpire | null | undefined;
10 | public permissions: string[];
11 |
12 | constructor(
13 | app_id: string,
14 | nonce: string,
15 | secret: string,
16 | grant_type: string,
17 | seconds_to_expire: number,
18 | interval_to_expire: IntervalToExpire | null,
19 | permissions: string[],
20 | ) {
21 | this.app_id = app_id;
22 | this.nonce = nonce;
23 | this.secret = secret;
24 | this.grant_type = grant_type;
25 | this.seconds_to_expire = seconds_to_expire || undefined;
26 | this.interval_to_expire = interval_to_expire || undefined;
27 | this.permissions = permissions;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Builders/RequestBuilder/GpApi/GpApiMiCRequestBuilder.ts:
--------------------------------------------------------------------------------
1 | import {
2 | BaseBuilder,
3 | GatewayConfig,
4 | GpApiConfig,
5 | GpApiRequest,
6 | IRequestBuilder,
7 | Transaction,
8 | } from "../../../../src";
9 |
10 | export class GpApiMiCRequestBuilder implements IRequestBuilder {
11 | /***
12 | * @param builder
13 | *
14 | * @return bool
15 | */
16 | public canProcess(builder: BaseBuilder) {
17 | builder;
18 | return true;
19 | }
20 |
21 | /**
22 | * @param BaseBuilder builder
23 | * @param GpApiConfig config
24 | * @return GpApiRequest|string
25 | */
26 | public buildRequest(
27 | builder: BaseBuilder,
28 | config: GatewayConfig,
29 | ): GpApiRequest {
30 | builder;
31 | config;
32 | return null as unknown as GpApiRequest;
33 | // TODO: Implement buildRequest() method.
34 | }
35 |
36 | public buildRequestFromJson(
37 | jsonRequest: string,
38 | config: GpApiConfig,
39 | ): GpApiRequest {
40 | const endpoint = GpApiRequest.DEVICE_ENDPOINT;
41 | const verb = "POST";
42 | config;
43 | return new GpApiRequest(endpoint, verb, jsonRequest);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Builders/RequestBuilder/GpApi/GpApiSessionInfo.ts:
--------------------------------------------------------------------------------
1 | import * as crypto from "crypto";
2 | import { GpApiRequest, IntervalToExpire } from "../../../../src/Entities";
3 | import { AccessTokenRequest } from "./AccessTokenRequest";
4 |
5 | export class GpApiSessionInfo {
6 | private static generateSecret(nonce: string, appKey: string) {
7 | return crypto
8 | .createHash("sha512")
9 | .update(nonce + appKey)
10 | .digest("hex")
11 | .toLowerCase();
12 | }
13 |
14 | private static generateNonce() {
15 | const base = new Date();
16 | return base.toISOString();
17 | }
18 |
19 | public static async signIn(
20 | appId: string,
21 | appKey: string,
22 | secondsToExpire: number = 0,
23 | intervalToExpire: IntervalToExpire | null = null,
24 | permissions: string[],
25 | ) {
26 | const nonce = GpApiSessionInfo.generateNonce();
27 |
28 | const requestBody = new AccessTokenRequest(
29 | appId,
30 | nonce,
31 | GpApiSessionInfo.generateSecret(nonce, appKey),
32 | "client_credentials",
33 | secondsToExpire,
34 | intervalToExpire,
35 | permissions,
36 | );
37 |
38 | return new GpApiRequest(
39 | GpApiRequest.ACCESS_TOKEN_ENDPOINT,
40 | "POST",
41 | JSON.stringify(requestBody),
42 | );
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/Builders/RequestBuilder/GpApi/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./AccessTokenRequest";
2 | export * from "./GpApiAuthorizationRequestBuilder";
3 | export * from "./GpApiMiCRequestBuilder";
4 | export * from "./GpApiSessionInfo";
5 |
--------------------------------------------------------------------------------
/src/Builders/RequestBuilder/GpEcom/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./GpEcomAuthorizationRequestBuilder";
2 | export * from "./GpEcomManagementRequestBuilder";
3 | export * from "./GpEcomRequestBuilder";
4 |
--------------------------------------------------------------------------------
/src/Builders/RequestBuilder/RequestBuilderFactory.ts:
--------------------------------------------------------------------------------
1 | import { ReportBuilder, Secure3dBuilder } from "src";
2 | import { GpApiAuthorizationRequestBuilder } from ".";
3 | import {
4 | GatewayProvider,
5 | IRequestBuilder,
6 | Transaction,
7 | TransactionSummary,
8 | } from "../../Entities/";
9 | import { BaseBuilder } from "../BaseBuilder";
10 | import { GpApiManagementRequestBuilder } from "./GpApi/GpApiManagementRequestBuilder";
11 | import { GpApiMiCRequestBuilder } from "./GpApi/GpApiMiCRequestBuilder";
12 | import { GpEcomAuthorizationRequestBuilder } from "./GpEcom/GpEcomAuthorizationRequestBuilder";
13 | import { GpEcomManagementRequestBuilder } from "./GpEcom/GpEcomManagementRequestBuilder";
14 | import { GpApiReportRequestBuilder } from "./GpApi/GpApiReportRequestBuilder";
15 | import { GpApiSecureRequestBuilder } from "./GpApi/GpApiSecureRequestBuilder";
16 |
17 | export class RequestBuilderFactory {
18 | public supplementaryData: Record;
19 |
20 | private static processes: Record = {
21 | [GatewayProvider.GpApi]: [
22 | new GpApiAuthorizationRequestBuilder(),
23 | new GpApiManagementRequestBuilder(),
24 | new GpApiReportRequestBuilder(),
25 | new GpApiSecureRequestBuilder(),
26 | new GpApiMiCRequestBuilder(),
27 | ],
28 | [GatewayProvider.GpEcom]: [
29 | new GpEcomAuthorizationRequestBuilder(),
30 | new GpEcomManagementRequestBuilder(),
31 | ],
32 | [GatewayProvider.Portico]: [],
33 | };
34 |
35 | public getRequestBuilder(
36 | builder:
37 | | BaseBuilder
38 | | ReportBuilder
39 | | Secure3dBuilder,
40 | gatewayProvider: GatewayProvider,
41 | ) {
42 | if (!RequestBuilderFactory.processes[gatewayProvider]) {
43 | return null;
44 | }
45 |
46 | for (const processName of RequestBuilderFactory.processes[
47 | gatewayProvider
48 | ]) {
49 | if (processName.canProcess(builder)) {
50 | return processName;
51 | }
52 | }
53 |
54 | return null;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/Builders/RequestBuilder/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./GpApi";
2 | export * from "./GpEcom";
3 | export * from "./RequestBuilderFactory";
4 |
--------------------------------------------------------------------------------
/src/Builders/TransactionBuilder.ts:
--------------------------------------------------------------------------------
1 | import {
2 | IPaymentMethod,
3 | PaymentMethod,
4 | TransactionModifier,
5 | TransactionReference,
6 | TransactionType,
7 | } from "../";
8 | import { BaseBuilder } from "./BaseBuilder";
9 |
10 | export abstract class TransactionBuilder extends BaseBuilder {
11 | public paymentMethod: PaymentMethod | TransactionReference;
12 | public transactionType: TransactionType;
13 | public transactionModifier = TransactionModifier.None;
14 | public supplementaryData: Record = {};
15 |
16 | public constructor(type: TransactionType, paymentMethod?: IPaymentMethod) {
17 | super();
18 |
19 | this.transactionType = type;
20 | if (paymentMethod) {
21 | this.paymentMethod = paymentMethod as
22 | | PaymentMethod
23 | | TransactionReference;
24 | }
25 | }
26 |
27 | public withModifier(modifier?: TransactionModifier) {
28 | if (modifier !== undefined) {
29 | this.transactionModifier = modifier;
30 | }
31 | return this;
32 | }
33 |
34 | public withSupplementaryData(
35 | key: Record | string,
36 | value?: string | string[],
37 | ) {
38 | if (key instanceof Object) {
39 | for (const supplementaryDataKey of Object.keys(key)) {
40 | this.withSupplementaryData(
41 | supplementaryDataKey,
42 | key[supplementaryDataKey],
43 | );
44 | }
45 | }
46 |
47 | if (key && typeof key === "string" && !!value) {
48 | this.supplementaryData[key] = value;
49 | }
50 |
51 | return this;
52 | }
53 |
54 | public withAllowDuplicates(allowDuplicates: boolean) {
55 | this.allowDupplicates = allowDuplicates;
56 |
57 | return this;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/Builders/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./BaseBuilder";
2 | export * from "./AuthorizationBuilder";
3 | export * from "./ManagementBuilder";
4 | export * from "./RecurringBuilder";
5 | export * from "./ReportBuilder";
6 | export * from "./RequestBuilder";
7 | export * from "./SecureBuilder";
8 | export * from "./Secure3dBuilder";
9 | export * from "./TransactionBuilder";
10 | export * from "./TransactionReportBuilder";
11 |
--------------------------------------------------------------------------------
/src/ConfiguredServices.ts:
--------------------------------------------------------------------------------
1 | import { Secure3dVersion } from "./Entities";
2 | import { IPaymentGateway, IRecurringService } from "./Gateways";
3 | import { IPayFacProvider } from "./Gateways/IPayFacProvider";
4 | import { ReportingService, Secure3dService } from "./Services";
5 | import { IDeviceInterface } from "./Terminals";
6 | import { DeviceController } from "./Terminals/DeviceController";
7 |
8 | export class ConfiguredServices {
9 | private payFacProvider: IPayFacProvider;
10 |
11 | public gatewayConnector: IPaymentGateway;
12 |
13 | public recurringConnector: IRecurringService;
14 |
15 | public reportingService: ReportingService;
16 |
17 | public deviceInterface: IDeviceInterface;
18 |
19 | private _deviceController: DeviceController;
20 |
21 | private secure3dProviders: Map = new Map();
22 |
23 | constructor() {}
24 |
25 | /**
26 | * @return void
27 | */
28 | public setPayFacProvider(provider: IPayFacProvider) {
29 | this.payFacProvider = provider;
30 | }
31 |
32 | /**
33 | * @return IPayFacProvider
34 | */
35 | public getPayFacProvider() {
36 | return this.payFacProvider || null;
37 | }
38 |
39 | public get deviceController() {
40 | return this._deviceController;
41 | }
42 |
43 | public set deviceController(deviceController: DeviceController) {
44 | this._deviceController = deviceController;
45 | this.deviceInterface = deviceController.configureInterface();
46 | }
47 |
48 | getSecure3dProvider(version: Secure3dVersion) {
49 | if (this.secure3dProviders.get(version)) {
50 | return this.secure3dProviders.get(version);
51 | } else if (version === Secure3dVersion.ANY) {
52 | let provider = this.secure3dProviders.get(Secure3dVersion.TWO);
53 | if (provider === null) {
54 | provider = this.secure3dProviders.get(Secure3dVersion.ONE);
55 | }
56 | return provider;
57 | } else {
58 | return null;
59 | }
60 | }
61 |
62 | setSecure3dProvider(
63 | version: Secure3dVersion,
64 | provider: Secure3dService,
65 | ): void {
66 | this.secure3dProviders.set(version, provider);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/Entities/AdditionalTaxDetails.ts:
--------------------------------------------------------------------------------
1 | export class AdditionalTaxDetails {
2 | public taxAmount: string | number | undefined;
3 | public taxRate: string | number | undefined;
4 | public taxType: string;
5 | }
6 |
--------------------------------------------------------------------------------
/src/Entities/Address.ts:
--------------------------------------------------------------------------------
1 | import { AddressType } from "../Entities";
2 |
3 | export class Address {
4 | // TODO backfill address with missing fields
5 | public type: AddressType;
6 | public streetAddress1: string;
7 | public streetAddress2: string;
8 | public streetAddress3: string;
9 | public city: string;
10 | public province: string;
11 | public postalCode: string;
12 | public country: string;
13 | public countryCode: string;
14 |
15 | get state(): string {
16 | return this.province;
17 | }
18 |
19 | set state(value: string) {
20 | this.province = value;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Entities/AlternativePaymentResponse.ts:
--------------------------------------------------------------------------------
1 | export class AlternativePaymentResponse {
2 | /**
3 | * bank account details
4 | */
5 | public bankAccount: string | null;
6 |
7 | /**
8 | * Account holder name of the customer’s account
9 | */
10 | public accountHolderName: string | null;
11 |
12 | /**
13 | * 2 character ISO country code
14 | */
15 | public country: string;
16 |
17 | /**
18 | * URL to redirect the customer to - only available in PENDING asynchronous transactions.
19 | * Sent there so merchant can redirect consumer to complete an interrupted payment.
20 | */
21 | public redirectUrl: number | string | null;
22 |
23 | /**
24 | * This parameter reflects what the customer will see on the proof of payment
25 | * (for example, bank statement record and similar). Also known as the payment descriptor
26 | */
27 | public paymentPurpose: string;
28 |
29 | /**
30 | *
31 | */
32 | public paymentMethod: string;
33 |
34 | /**
35 | * The provider reference
36 | */
37 | public providerReference: string;
38 |
39 | /**
40 | * The APM provider name
41 | */
42 | public providerName: string;
43 |
44 | public ack: string;
45 | public sessionToken: string;
46 | public correlationReference: string;
47 | public versionReference: string;
48 | public buildReference: string;
49 | public timeCreatedReference: string;
50 | public transactionReference: string;
51 | public secureAccountReference: string;
52 | public reasonCode: string;
53 | public pendingReason: string;
54 | public grossAmount: string;
55 | public paymentTimeReference: string;
56 | public paymentType: string;
57 | public paymentStatus: string;
58 | public type: string;
59 | public protectionEligibilty: string;
60 | public authStatus: string;
61 | public authAmount: string;
62 | public authAck: string;
63 | public authCorrelationReference: string;
64 | public authVersionReference: string;
65 | public authBuildReference: string;
66 | public authPendingReason: string;
67 | public authProtectionEligibilty: string;
68 | public authProtectionEligibiltyType: string;
69 | public authReference: string;
70 | public feeAmount: string;
71 |
72 | /* start region Alipay */
73 | public nextAction: string | null;
74 | public secondsToExpire: string | null;
75 | public qrCodeImage: string | null;
76 | /* end region */
77 | }
78 |
--------------------------------------------------------------------------------
/src/Entities/BatchSummary.ts:
--------------------------------------------------------------------------------
1 | export class BatchSummary {
2 | public id: string;
3 | public transactionCount: number;
4 | public totalAmount: string;
5 | public sequenceNumber: string;
6 | }
7 |
--------------------------------------------------------------------------------
/src/Entities/BrowserData.ts:
--------------------------------------------------------------------------------
1 | export class BrowserData {
2 | public acceptHeader: string;
3 |
4 | public colorDepth: string;
5 |
6 | public ipAddress: string;
7 |
8 | public javaEnabled: boolean;
9 |
10 | public javaScriptEnabled: boolean;
11 |
12 | public language: string;
13 |
14 | public screenHeight: number;
15 |
16 | public screenWidth: number;
17 |
18 | public challengWindowSize: string;
19 |
20 | public timeZone: string;
21 |
22 | public userAgent: string;
23 | }
24 |
--------------------------------------------------------------------------------
/src/Entities/Card.ts:
--------------------------------------------------------------------------------
1 | export class Card {
2 | public cardholderName: string;
3 |
4 | public cardNumber: string;
5 |
6 | public maskedCardNumber: string;
7 |
8 | public cardExpMonth: string;
9 |
10 | public cardExpYear: string;
11 |
12 | public token: string;
13 |
14 | /**
15 | * Masked card number with last 4 digits showing.
16 | */
17 | public maskedNumberLast4: string;
18 |
19 | /**
20 | * Indicates the card brand that issued the card.
21 | */
22 | public brand: string;
23 |
24 | /**
25 | * The unique reference created by the brands/schemes to uniquely identify the transaction.
26 | */
27 | public brandReference: string;
28 |
29 | /**
30 | * Contains the first 6 digits of the card
31 | */
32 | public bin: string;
33 |
34 | /**
35 | * The issuing country that the bin is associated with.
36 | */
37 | public binCountry: string;
38 |
39 | /**
40 | * The card provider's description of their card product.
41 | */
42 | public accountType: string;
43 |
44 | /**
45 | * The label of the issuing bank or financial institution of the bin.
46 | */
47 | public issuer: string;
48 | }
49 |
--------------------------------------------------------------------------------
/src/Entities/CardIssuerResponse.ts:
--------------------------------------------------------------------------------
1 | export class CardIssuerResponse {
2 | /**
3 | * The result code of the AVS check from the card issuer.
4 | */
5 | public avsResult: string;
6 |
7 | /**
8 | * Result code from the card issuer.
9 | */
10 | public result: string;
11 |
12 | /**
13 | * The result code of the CVV check from the card issuer.
14 | */
15 | public cvvResult: string;
16 |
17 | /**
18 | * The result code of the AVS address check from the card issuer.
19 | */
20 | public avsAddressResult: string;
21 |
22 | /**
23 | * The result of the AVS postal code check from the card issuer.
24 | */
25 | public avsPostalCodeResult: string;
26 | }
27 |
--------------------------------------------------------------------------------
/src/Entities/CommercialData.ts:
--------------------------------------------------------------------------------
1 | import { AdditionalTaxDetails } from "./AdditionalTaxDetails";
2 | import { TaxType, TransactionModifier } from "./Enums";
3 | import { CommercialLineItem } from "./CommercialLineItem";
4 |
5 | export class CommercialData {
6 | public additionalTaxDetails?: AdditionalTaxDetails;
7 | public commercialIndicator: TransactionModifier;
8 | public customerVAT_Number?: string;
9 | public customerReferenceId?: string;
10 | public description?: string;
11 | public discountAmount?: string | number;
12 | public dutyAmount?: string | number;
13 | public destinationPostalCode?: string;
14 | public destinationCountryCode?: string;
15 | public freightAmount?: string | number;
16 | public lineItems: CommercialLineItem[];
17 | public orderDate?: Date;
18 | public originPostalCode?: string;
19 | public poNumber?: string;
20 | public supplierReferenceNumber?: string;
21 | public taxAmount?: string | number;
22 | public taxType: TaxType;
23 | public summaryCommodityCode?: string;
24 | public vat_InvoiceNumber?: string;
25 |
26 | constructor(
27 | taxType: TaxType,
28 | level: TransactionModifier = TransactionModifier.LevelII,
29 | ) {
30 | this.taxType = taxType;
31 | this.commercialIndicator = level;
32 | this.lineItems = [];
33 | }
34 |
35 | public addLineItems(items: CommercialLineItem): CommercialData {
36 | this.lineItems.push(items);
37 | return this;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/Entities/CommercialLineItem.ts:
--------------------------------------------------------------------------------
1 | import { DiscountDetails } from "./DiscountDetails";
2 | import { CreditDebitIndicator, NetGrossIndicator } from "./Enums";
3 |
4 | export class CommercialLineItem {
5 | alternateTaxId?: string;
6 | commodityCode?: string;
7 | description?: string;
8 | extendedAmount?: string | number;
9 | creditDebitIndicator?: CreditDebitIndicator;
10 | netGrossIndicator?: NetGrossIndicator;
11 | name?: string;
12 | productCode?: string;
13 | quantity?: string | number;
14 | unitOfMeasure?: string;
15 | unitCost?: string | number;
16 | taxAmount?: string | number;
17 | taxName?: string | number;
18 | upc?: string;
19 | taxPercentage?: string | number;
20 | discountDetails?: DiscountDetails;
21 | totalAmount?: string | number;
22 | }
23 |
--------------------------------------------------------------------------------
/src/Entities/CustomerDocument.ts:
--------------------------------------------------------------------------------
1 | import { CustomerDocumentType } from "./Enums";
2 |
3 | export class CustomerDocument {
4 | public reference: string;
5 |
6 | public issuer: string;
7 |
8 | /** @var CustomerDocumentType */
9 | public type: CustomerDocumentType;
10 |
11 | constructor(reference: string, issuer: string, type: CustomerDocumentType) {
12 | this.reference = reference;
13 | this.issuer = issuer;
14 | this.type = type;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Entities/DccRateData.ts:
--------------------------------------------------------------------------------
1 | import { DccProcessor } from "./Enums/DccProcessor";
2 | import { DccRateType } from "./Enums/DccRateType";
3 |
4 | export class DccRateData {
5 | /**
6 | * The amount
7 | */
8 | cardHolderAmount: number | string | null;
9 |
10 | /**
11 | * The currency
12 | */
13 | cardHolderCurrency: string;
14 |
15 | /**
16 | * The name of the CCP (Currency Conversion Processor) the request is to be sent to
17 | */
18 | dccProcessor: DccProcessor;
19 |
20 | /**
21 | * Rate Offered for the Exchange
22 | */
23 | cardHolderRate: string;
24 |
25 | /**
26 | * Rate type, 'S' for authorisation transactions (Sale). 'R' for Refunds.
27 | */
28 | dccRateType: DccRateType;
29 |
30 | /**
31 | * The type of currency conversion rate obtained. This is usually set to 1 but can contain other values.
32 | * Please consult with your Currency Conversion Processor.
33 | */
34 | dccType: string;
35 |
36 | /**
37 | * The orderId
38 | */
39 | orderId: string;
40 |
41 | /**
42 | * The DCC ID
43 | */
44 | dccId: string;
45 |
46 | /**
47 | * Commission Percentage
48 | */
49 | commissionPercentage: string;
50 |
51 | /**
52 | * Exchange Rate Source Name
53 | */
54 | exchangeRateSourceName: string;
55 |
56 | /**
57 | * Exchange Rate Source Timestamp
58 | */
59 | exchangeRateSourceTimestamp: Date; // Assuming Date is appropriate in TypeScript
60 |
61 | /**
62 | * The merchant amount
63 | */
64 | merchantAmount: number | string | null;
65 |
66 | /**
67 | * The merchant currency
68 | */
69 | merchantCurrency: string;
70 |
71 | /**
72 | * Margin Rate Percentage
73 | */
74 | marginRatePercentage: string;
75 | }
76 |
--------------------------------------------------------------------------------
/src/Entities/DiscountDetails.ts:
--------------------------------------------------------------------------------
1 | export class DiscountDetails {
2 | public discountName?: string;
3 | public discountAmount: string | number | undefined;
4 | public discountPercentage: string | number | undefined;
5 | public discountType?: string;
6 | public discountPriority?: number;
7 | public discountIsStackable?: boolean;
8 | }
9 |
--------------------------------------------------------------------------------
/src/Entities/DisputeDocument.ts:
--------------------------------------------------------------------------------
1 | import { Document } from "./Document";
2 |
3 | export class DisputeDocument extends Document {
4 | public type: string;
5 | public b64_content: string;
6 | }
7 |
--------------------------------------------------------------------------------
/src/Entities/Document.ts:
--------------------------------------------------------------------------------
1 | import { DocumentCategory } from "./Enums/DocumentCategory";
2 | import { FileType } from "./Enums/FileType";
3 |
4 | export class Document {
5 | public id: string;
6 | public name: string;
7 | public status: string;
8 | public timeCreated: string;
9 | public format: FileType;
10 | public category: DocumentCategory;
11 | }
12 |
--------------------------------------------------------------------------------
/src/Entities/DocumentUploadData.ts:
--------------------------------------------------------------------------------
1 | import * as fs from "fs";
2 |
3 | export class DocumentUploadData {
4 | public documentName: string;
5 | public transactionReference: string;
6 | public docType: string;
7 | get DocType(): string {
8 | return this.docType;
9 | }
10 | set DocType(value: string) {
11 | if (this._validDocTypes.includes(value)) {
12 | this.docType = value;
13 | } else {
14 | throw new Error("The provided file type is not supported.");
15 | }
16 | }
17 | public document: string;
18 | public docCategory: string;
19 | public documentPath: string;
20 |
21 | DocumentPath(value: string) {
22 | const docPath = value;
23 | if (docPath != null) {
24 | const documentType = docPath.substring(docPath.lastIndexOf(".") + 1);
25 | if (this._validDocTypes.includes(documentType)) {
26 | this.docType = documentType;
27 | this.document = String(this.getByteArray(docPath));
28 | } else {
29 | throw new Error("The document provided is not a valid file type.");
30 | }
31 | } else {
32 | throw new Error("DocumentPath has not been set");
33 | }
34 | }
35 |
36 | private getByteArray(filePath: string) {
37 | const fileData = fs.readFileSync(filePath);
38 | const buff = Buffer.from(fileData);
39 | const base64data = buff.toString("base64");
40 | return base64data;
41 | }
42 |
43 | _validDocTypes: Array = [
44 | "tif",
45 | "tiff",
46 | "bmp",
47 | "jpg",
48 | "jpeg",
49 | "gif",
50 | "png",
51 | "doc",
52 | "docx",
53 | ];
54 | }
55 |
--------------------------------------------------------------------------------
/src/Entities/EcommerceInfo.ts:
--------------------------------------------------------------------------------
1 | import { EcommerceChannel } from "../Entities";
2 | export class EcommerceInfo {
3 | public cavv: string;
4 | public channel: EcommerceChannel;
5 | public eci: string;
6 | public paymentDataSource: string;
7 | public paymentDataType: string;
8 | public shipDay: string;
9 | public shipMonth: string;
10 | public xid: string;
11 |
12 | public constructor() {
13 | this.channel = EcommerceChannel.Ecom;
14 | this.shipDay = new Date().getUTCDate().toString();
15 | this.shipMonth = (new Date().getUTCMonth() + 1).toString();
16 | this.paymentDataType = "3DSecure";
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Entities/EncryptionData.ts:
--------------------------------------------------------------------------------
1 | export class EncryptionData {
2 | public version: string;
3 | public trackNumber: string;
4 | public ktb: string;
5 | public ksn: string;
6 |
7 | public static version1(): EncryptionData {
8 | const data = new EncryptionData();
9 | data.version = "01";
10 | return data;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/Entities/Enums/AcquisitionType.ts:
--------------------------------------------------------------------------------
1 | export enum AcquisitionType {
2 | None = "None",
3 | Contact = "Contact",
4 | Contactless = "Contactless",
5 | Swipe = "Swipe",
6 | Manual = "Manual",
7 | Scan = "Scan",
8 | Insert = "Insert",
9 | Tap = "Tap",
10 | }
11 |
--------------------------------------------------------------------------------
/src/Entities/Enums/CardTypeFilter.ts:
--------------------------------------------------------------------------------
1 | export enum CardTypeFilter {
2 | GIFT = "GIFT",
3 | VISA = "VISA",
4 | MC = "MC",
5 | AMEX = "AMEX",
6 | DISCOVER = "DISCOVER",
7 | }
8 |
--------------------------------------------------------------------------------
/src/Entities/Enums/DccProcessor.ts:
--------------------------------------------------------------------------------
1 | export enum DccProcessor {
2 | Fexco = "Fexco",
3 | Euroconex = "Euroconex",
4 | }
5 |
--------------------------------------------------------------------------------
/src/Entities/Enums/DccRateType.ts:
--------------------------------------------------------------------------------
1 | export enum DccRateType {
2 | Sale = "S",
3 | Refund = "R",
4 | }
5 |
--------------------------------------------------------------------------------
/src/Entities/Enums/DepositSortProperty.ts:
--------------------------------------------------------------------------------
1 | export enum DepositSortProperty {
2 | TimeCreated = "TIME_CREATED",
3 | Status = "STATUS",
4 | Type = "TYPE",
5 | DepositId = "DEPOSIT_ID",
6 | }
7 |
--------------------------------------------------------------------------------
/src/Entities/Enums/DisputeSortProperty.ts:
--------------------------------------------------------------------------------
1 | export enum DisputeSortProperty {
2 | Id = "id",
3 | Arn = "arn",
4 | Brand = "brand",
5 | Status = "status",
6 | Stage = "stage",
7 | FromStageTimeCreated = "from_stage_time_created",
8 | ToStageTimeCreated = "to_stage_time_created",
9 | AdjustmentFunding = "adjustment_funding",
10 | FromAdjustmentTimeCreated = "from_adjustment_time_created",
11 | ToAdjustmentTimeCreated = "to_adjustment_time_created",
12 | }
13 |
--------------------------------------------------------------------------------
/src/Entities/Enums/DisputeStage.ts:
--------------------------------------------------------------------------------
1 | export enum DisputeStage {
2 | Retrieval = "RETRIEVAL",
3 | Chargeback = "CHARGEBACK",
4 | Reversal = "REVERSAL",
5 | SecondChargeback = "SECOND_CHARGEBACK",
6 | PreArbitration = "PRE_ARBITRATION",
7 | Arbitration = "ARBITRATION",
8 | PreCompliance = "PRE_COMPLIANCE",
9 | Compliance = "COMPLIANCE",
10 | Goodfaith = "GOODFAITH",
11 | }
12 |
--------------------------------------------------------------------------------
/src/Entities/Enums/DisputeStatus.ts:
--------------------------------------------------------------------------------
1 | export enum DisputeStatus {
2 | UnderReview = "UNDER_REVIEW",
3 | WithMerchant = "WITH_MERCHANT",
4 | Closed = "CLOSED",
5 | SettleDisputeFunded = "FUNDED",
6 | SettleDisputeDelayed = "DELAYED",
7 | }
8 |
--------------------------------------------------------------------------------
/src/Entities/Enums/DocumentCategory.ts:
--------------------------------------------------------------------------------
1 | export enum DocumentCategory {
2 | IdentityVerification = "IDENTITY_VERIFICATION",
3 | RiskReview = "RISK_REVIEW",
4 | Underwriting = "UNDERWRITING",
5 | }
6 |
--------------------------------------------------------------------------------
/src/Entities/Enums/FileType.ts:
--------------------------------------------------------------------------------
1 | export enum FileType {
2 | TIF = "TIF",
3 | TIFF = "TIFF",
4 | PDF = "PDF",
5 | BMP = "BMP",
6 | JPEG = "JPEG",
7 | GIF = "GIF",
8 | PNG = "PNG",
9 | DOC = "DOC",
10 | DOCX = "DOCX",
11 | }
12 |
--------------------------------------------------------------------------------
/src/Entities/Enums/MerchantCategory.ts:
--------------------------------------------------------------------------------
1 | export enum MerchantCategory {
2 | Hotel = "HOTEL",
3 | Airline = "AIRLINE",
4 | Retail = "RETAIL",
5 | TopUp = "TOP_UP",
6 | Player = "PLAYER",
7 | CdKey = "CD_KEY",
8 | Other = "OTHER",
9 | }
10 |
--------------------------------------------------------------------------------
/src/Entities/Errors.ts:
--------------------------------------------------------------------------------
1 | // tslint:disable:max-classes-per-file
2 |
3 | export class ApiError extends Error {
4 | constructor(m?: string) {
5 | super(m);
6 | Object.setPrototypeOf(this, ApiError.prototype);
7 | this.name = this.constructor.name;
8 | }
9 | }
10 |
11 | export class ArgumentError extends ApiError {
12 | constructor(m?: string) {
13 | super(m);
14 | Object.setPrototypeOf(this, ArgumentError.prototype);
15 | this.name = this.constructor.name;
16 | }
17 | }
18 |
19 | export class BuilderError extends ApiError {
20 | constructor(m?: string) {
21 | super(m);
22 | Object.setPrototypeOf(this, BuilderError.prototype);
23 | this.name = this.constructor.name;
24 | }
25 | }
26 |
27 | export class ConfigurationError extends ApiError {
28 | constructor(m?: string) {
29 | super(m);
30 | Object.setPrototypeOf(this, ConfigurationError.prototype);
31 | this.name = this.constructor.name;
32 | }
33 | }
34 |
35 | export class GatewayError extends ApiError {
36 | public responseCode: string;
37 | public responseMessage: string;
38 | constructor(m?: string, code?: string, message?: string) {
39 | super(m);
40 | Object.setPrototypeOf(this, GatewayError.prototype);
41 | this.name = this.constructor.name;
42 | if (code) {
43 | this.responseCode = code;
44 | }
45 | if (message) {
46 | this.responseMessage = message;
47 | }
48 | }
49 | }
50 |
51 | export class NotImplementedError extends ApiError {
52 | constructor(m?: string) {
53 | super(m);
54 | Object.setPrototypeOf(this, NotImplementedError.prototype);
55 | this.name = this.constructor.name;
56 | }
57 | }
58 |
59 | export class UnsupportedTransactionError extends ApiError {
60 | constructor(m?: string) {
61 | if (!m) {
62 | m = "Transaction type not supported for this payment method.";
63 | }
64 | super(m);
65 | Object.setPrototypeOf(this, UnsupportedTransactionError.prototype);
66 | this.name = this.constructor.name;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/Entities/FraudRule.ts:
--------------------------------------------------------------------------------
1 | import { FraudFilterMode } from ".";
2 |
3 | export class FraudRule {
4 | key: string;
5 | mode: FraudFilterMode;
6 | description: string;
7 | result: string;
8 |
9 | constructor(
10 | key: string,
11 | mode: FraudFilterMode,
12 | description: string,
13 | result: string,
14 | ) {
15 | this.key = key;
16 | this.mode = mode;
17 | this.description = description;
18 | this.result = result;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Entities/GpApi/AccessTokenInfo.ts:
--------------------------------------------------------------------------------
1 | export class AccessTokenInfo {
2 | public accessToken: string;
3 |
4 | public merchantId: string;
5 |
6 | public dataAccountName: string;
7 |
8 | public disputeManagementAccountName: string;
9 |
10 | public tokenizationAccountName: string;
11 |
12 | public transactionProcessingAccountName: string;
13 |
14 | public riskAssessmentAccountName: string;
15 |
16 | public dataAccountID: string;
17 |
18 | public disputeManagementAccountID: string;
19 |
20 | public tokenizationAccountID: string;
21 |
22 | public transactionProcessingAccountID: string;
23 |
24 | public riskAssessmentAccountID: string;
25 |
26 | public merchantManagementAccountName: string;
27 |
28 | public merchantManagementAccountID: string;
29 | }
30 |
--------------------------------------------------------------------------------
/src/Entities/GpApi/DTO/Card.ts:
--------------------------------------------------------------------------------
1 | export class Card {
2 | public number: string;
3 | public expiry_month: string;
4 | public expiry_year: string;
5 | public cvv: string;
6 | public cvv_indicator?: string;
7 | public avs_address?: string;
8 | public avs_postal_code?: string;
9 | public track?: string;
10 | public tag?: string;
11 | public funding?: string;
12 | public chip_condition?: string | null;
13 | public pin_block?: string;
14 | public brand_reference?: string;
15 | public authcode?: string;
16 | }
17 |
--------------------------------------------------------------------------------
/src/Entities/GpApi/DTO/PaymentMethod.ts:
--------------------------------------------------------------------------------
1 | import { Card } from ".";
2 |
3 | export class PaymentMethod {
4 | id: any;
5 | entry_mode: any;
6 | authentication: any;
7 | encryption: any;
8 | name: any;
9 | storage_mode: any;
10 | card: Card | null;
11 | digital_wallet: any;
12 | bank_transfer: any;
13 | apm: any[];
14 | fingerprint_mode: any;
15 | narrative: any;
16 | bnpl: any;
17 |
18 | static PAYMENT_METHOD_TOKEN_PREFIX = "PMT_";
19 | }
20 |
--------------------------------------------------------------------------------
/src/Entities/GpApi/DTO/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./Card";
2 | export * from "./PaymentMethod";
3 |
--------------------------------------------------------------------------------
/src/Entities/GpApi/GpApiAccount.ts:
--------------------------------------------------------------------------------
1 | export class GpApiAccount {
2 | public id: string;
3 | public name: string;
4 |
5 | constructor(id: string, name: string) {
6 | this.id = id;
7 | this.name = name;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/Entities/GpApi/GpApiRequest.ts:
--------------------------------------------------------------------------------
1 | import { Request } from "../Request";
2 |
3 | export class GpApiRequest extends Request {
4 | public static ACCESS_TOKEN_ENDPOINT = "/accesstoken";
5 | public static TRANSACTION_ENDPOINT = "/transactions";
6 | public static PAYMENT_METHODS_ENDPOINT = "/payment-methods";
7 | public static VERIFICATIONS_ENDPOINT = "/verifications";
8 | public static DEPOSITS_ENDPOINT = "/settlement/deposits";
9 | public static DISPUTES_ENDPOINT = "/disputes";
10 | public static SETTLEMENT_DISPUTES_ENDPOINT = "/settlement/disputes";
11 | public static SETTLEMENT_TRANSACTIONS_ENDPOINT = "/settlement/transactions";
12 | public static AUTHENTICATIONS_ENDPOINT = "/authentications";
13 | public static BATCHES_ENDPOINT = "/batches";
14 | public static ACTIONS_ENDPOINT = "/actions";
15 | public static MERCHANT_MANAGEMENT_ENDPOINT = "/merchants";
16 | public static DCC_ENDPOINT = "/currency-conversions";
17 | public static PAYBYLINK_ENDPOINT = "/links";
18 | public static RISK_ASSESSMENTS = "/risk-assessments";
19 | public static ACCOUNTS_ENDPOINT = "/accounts";
20 | public static TRANSFER_ENDPOINT = "/transfers";
21 | public static DEVICE_ENDPOINT = "/devices";
22 | }
23 |
--------------------------------------------------------------------------------
/src/Entities/GpApi/PageResult.ts:
--------------------------------------------------------------------------------
1 | export class PagedResult {
2 | totalRecordCount: number | null;
3 | pageSize: number | null;
4 | page: number | null;
5 | order: string | null;
6 | orderBy: string | null;
7 | result: any[] = [];
8 | }
9 |
--------------------------------------------------------------------------------
/src/Entities/GpApi/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./AccessTokenInfo";
2 | export * from "./GpApiAccount";
3 | export * from "./GpApiRequest";
4 | export * from "./GpApiTokenResponse";
5 | export * from "./PageResult";
6 |
--------------------------------------------------------------------------------
/src/Entities/HostedPaymentData.ts:
--------------------------------------------------------------------------------
1 | export class HostedPaymentData {
2 | public customerExists: boolean;
3 | public customerKey: string;
4 | public customerNumber: string;
5 | public offerToSaveCard: boolean;
6 | public paymentKey: string;
7 | public productId: string;
8 | public supplementaryData: object;
9 | public addressCapture?: boolean = false;
10 | public notReturnAddress?: boolean = false;
11 | public removeShipping?: boolean = false;
12 |
13 | public constructor() {
14 | this.supplementaryData = {};
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Entities/IRequestBuilder.ts:
--------------------------------------------------------------------------------
1 | import {
2 | BaseBuilder,
3 | GatewayConfig,
4 | ReportBuilder,
5 | Request,
6 | Secure3dBuilder,
7 | Transaction,
8 | TransactionSummary,
9 | } from "../../src";
10 |
11 | export interface IRequestBuilder {
12 | buildRequest(
13 | builder:
14 | | BaseBuilder
15 | | ReportBuilder
16 | | Secure3dBuilder,
17 | config: GatewayConfig,
18 | ): Request;
19 |
20 | buildRequestFromJson(jsonRequest: any, config: GatewayConfig): void;
21 |
22 | canProcess(
23 | builder:
24 | | BaseBuilder
25 | | ReportBuilder
26 | | Secure3dBuilder,
27 | ): boolean;
28 | }
29 |
--------------------------------------------------------------------------------
/src/Entities/IRequestLogger.ts:
--------------------------------------------------------------------------------
1 | import { ClientRequestArgs, IncomingHttpHeaders } from "http";
2 | import { GatewayResponse } from "../Gateways/GatewayResponse";
3 |
4 | export interface IRequestLogger {
5 | requestSent(
6 | verb: string,
7 | endpoint: string,
8 | requestId: number,
9 | headers: ClientRequestArgs["headers"],
10 | data: any,
11 | ): void;
12 |
13 | responseReceived(
14 | response: GatewayResponse,
15 | requestId?: number,
16 | ): Promise;
17 |
18 | responseError(
19 | e: Error,
20 | requestId: number,
21 | headers?: IncomingHttpHeaders,
22 | ): Promise;
23 | }
24 |
--------------------------------------------------------------------------------
/src/Entities/LodgingData.ts:
--------------------------------------------------------------------------------
1 | import { LodgingItems } from ".";
2 |
3 | export class LodgingData {
4 | prestigiousPropertyLimit: string;
5 | noShow: boolean;
6 | advancedDepositType: string;
7 | lodgingDataEdit: string;
8 | preferredCustomer: boolean;
9 | bookingReference: string;
10 | durationDays: number;
11 | checkedInDate: string;
12 | checkedOutDate: string;
13 | dailyRateAmount: string;
14 | items: LodgingItems[] = [];
15 | }
16 |
--------------------------------------------------------------------------------
/src/Entities/LodgingItems.ts:
--------------------------------------------------------------------------------
1 | export class LodgingItems {
2 | types: any[];
3 | reference: string;
4 | totalAmount: string;
5 | paymentMethodProgramCodes: any[];
6 | }
7 |
--------------------------------------------------------------------------------
/src/Entities/MaskedValueCollection.ts:
--------------------------------------------------------------------------------
1 | export class MaskedValueCollection {
2 | protected maskValues: { [key: string]: string } = {};
3 |
4 | private getValues(): { [key: string]: string } {
5 | return this.maskValues;
6 | }
7 |
8 | public hideValue(
9 | key: string,
10 | value: string | null,
11 | unmaskedLastChars: number = 0,
12 | unmaskedFirstChars: number = 0,
13 | ): { [key: string]: string } {
14 | this.addValue(key, value, unmaskedLastChars, unmaskedFirstChars);
15 |
16 | return this.getValues();
17 | }
18 |
19 | protected addValue(
20 | key: string,
21 | value: string | null,
22 | unmaskedLastChars: number = 0,
23 | unmaskedFirstChars: number = 0,
24 | ): boolean {
25 | if (!this.validateValue(value) || this.maskValues[key] === value) {
26 | return false;
27 | }
28 | this.maskValues[key] = this.disguise(
29 | value,
30 | unmaskedLastChars,
31 | unmaskedFirstChars,
32 | );
33 |
34 | return true;
35 | }
36 |
37 | protected validateValue(value: string | null): boolean {
38 | if (!value || Array.isArray(value) || typeof value === "object") {
39 | return false;
40 | }
41 |
42 | return true;
43 | }
44 |
45 | private disguise(
46 | value: string | null,
47 | unmaskedLastChars: number = 0,
48 | unmaskedFirstChars: number = 0,
49 | maskSymbol: string = "X",
50 | ): string {
51 | value = String(value);
52 | unmaskedLastChars = Math.abs(Math.floor(unmaskedLastChars));
53 | maskSymbol = String(maskSymbol);
54 |
55 | // not enough chars to unmask?
56 | if (unmaskedLastChars >= value.length) {
57 | unmaskedLastChars = 0;
58 | }
59 |
60 | // at least half must be masked?
61 | if (unmaskedLastChars > value.length / 2) {
62 | unmaskedLastChars = Math.round(unmaskedLastChars / 2);
63 | }
64 |
65 | // leading unmasked chars
66 | if (unmaskedLastChars < 0) {
67 | const unmasked = value.slice(0, unmaskedLastChars);
68 | return unmasked + maskSymbol.repeat(value.length - unmasked.length);
69 | }
70 |
71 | const unmaskedFirstValue = value.slice(0, unmaskedFirstChars);
72 | const unmaskedLastValue = unmaskedLastChars
73 | ? value.slice(-unmaskedLastChars)
74 | : "";
75 |
76 | return (
77 | unmaskedFirstValue +
78 | maskSymbol.repeat(value.length - unmaskedFirstChars - unmaskedLastChars) +
79 | unmaskedLastValue
80 | );
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/src/Entities/MerchantKVP.ts:
--------------------------------------------------------------------------------
1 | export class MerchantKVP {
2 | private key: string;
3 | private value: string;
4 | private visible: boolean;
5 |
6 | getKey(): string {
7 | return this.key;
8 | }
9 |
10 | setKey(key: string): void {
11 | this.key = key;
12 | }
13 |
14 | getValue(): string {
15 | return this.value;
16 | }
17 |
18 | setValue(value: string): void {
19 | this.value = value;
20 | }
21 |
22 | isVisible(): boolean {
23 | return this.visible;
24 | }
25 |
26 | setVisible(visible: boolean): void {
27 | this.visible = visible;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Entities/MessageExtension.ts:
--------------------------------------------------------------------------------
1 | export class MessageExtension {
2 | criticalityIndicator: boolean;
3 | messageExtensionData: string;
4 | messageExtensionId: string;
5 | messageExtensionName: string;
6 | }
7 |
--------------------------------------------------------------------------------
/src/Entities/MobileData.ts:
--------------------------------------------------------------------------------
1 | import { SdkInterface, SdkUiType } from "./Enums";
2 |
3 | export class MobileData {
4 | encodedData: string;
5 | applicationReference: string;
6 | sdkInterface: SdkInterface;
7 | sdkUiTypes: SdkUiType[];
8 | ephemeralPublicKey: string;
9 | maximumTimeout: number;
10 | referenceNumber: string;
11 | sdkTransReference: string;
12 | }
13 |
--------------------------------------------------------------------------------
/src/Entities/OrderDetails.ts:
--------------------------------------------------------------------------------
1 | export class OrderDetails {
2 | insuranceAmount: string | number;
3 | hasInsurance: boolean;
4 | handlingAmount: string | number;
5 | description: string;
6 | }
7 |
--------------------------------------------------------------------------------
/src/Entities/PayerDetails.ts:
--------------------------------------------------------------------------------
1 | import { Address } from ".";
2 |
3 | export class PayerDetails {
4 | firstName: string = "";
5 | lastName: string = "";
6 | email: string = "";
7 | billingAddress: Address;
8 | shippingAddress: Address;
9 | }
10 |
--------------------------------------------------------------------------------
/src/Entities/PhoneNumber.ts:
--------------------------------------------------------------------------------
1 | export class PhoneNumber {
2 | countryCode: string;
3 | number: string;
4 | type: string;
5 |
6 | constructor(countryCode: string, number: string, type: string) {
7 | this.countryCode = countryCode;
8 | this.number = number;
9 | this.type = type;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Entities/ProFac/AccountBalanceResponseData.ts:
--------------------------------------------------------------------------------
1 | export class AccountBalanceResponseData {
2 | public enabled: string;
3 | public limitRemaining: string;
4 | public transferFee: string;
5 | public feeType: string;
6 | public accountLastFour: string;
7 | }
8 |
--------------------------------------------------------------------------------
/src/Entities/ProFac/AccountPermissions.ts:
--------------------------------------------------------------------------------
1 | import { ProPayAccountStatus } from "../../Entities";
2 |
3 | export class AccountPermissions {
4 | public aCHIn: boolean;
5 | public aCHOut: boolean;
6 | public cCProcessing: boolean;
7 | public proPayIn: boolean;
8 | public proPayOut: boolean;
9 | public creditCardMonthLimit: string;
10 | public creditCardTransactionLimit: string;
11 | public merchantOverallStatus: ProPayAccountStatus;
12 | public softLimitEnabled: boolean;
13 | public aCHPaymentSoftLimitEnabled: boolean;
14 | public softLimitACHOffPercent: string;
15 | public aCHPaymentACHOffPercent: string;
16 | }
17 |
--------------------------------------------------------------------------------
/src/Entities/ProFac/BankAccountData.ts:
--------------------------------------------------------------------------------
1 | export class BankAccountData {
2 | ///
3 | /// ISO 3166 standard 3-character country code
4 | ///
5 | public accountCountryCode: string;
6 | ///
7 | /// Merchant/Individual Name
8 | ///
9 | public accountName: string;
10 | ///
11 | /// Financial Institution account number
12 | ///
13 | public accountNumber: string;
14 | ///
15 | /// Valid values are: Personal and Business
16 | ///
17 | public accountOwnershipType: string;
18 | ///
19 | /// Valid Values are:
20 | /// C - Checking
21 | /// S - Savings
22 | /// G - General Ledger
23 | ///
24 | public accountType: string;
25 | ///
26 | /// Name of financial institution
27 | ///
28 | public bankName: string;
29 | ///
30 | /// Financial institution routing number. Must be a valid ACH routing number.
31 | ///
32 | public routingNumber: string;
33 |
34 | ///
35 | /// The account holder's name. This is required if payment method is a bank account.
36 | ///
37 | public accountHolderName: string;
38 | }
39 |
--------------------------------------------------------------------------------
/src/Entities/ProFac/BankAccountOwnershipData.ts:
--------------------------------------------------------------------------------
1 | import { Address } from "../../Entities";
2 | export class BankAccountOwnershipData {
3 | public firstName: string;
4 | public lastName: string;
5 | public ownerAddress: Address;
6 | public phoneNumber: string;
7 |
8 | constructor() {
9 | this.ownerAddress = new Address();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Entities/ProFac/BeneficialOwnerData.ts:
--------------------------------------------------------------------------------
1 | import { OwnersData } from "./OwnersData";
2 |
3 | export class BeneficialOwnerData {
4 | public ownersCount: string;
5 | public ownersList: Array;
6 |
7 | public constructor() {
8 | this.ownersList = new Array();
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/Entities/ProFac/BeneficialOwnerDataResult.ts:
--------------------------------------------------------------------------------
1 | export class BeneficialOwnerDataResult {
2 | public firstName: string;
3 | public lastName: string;
4 | public status: string;
5 | }
6 |
--------------------------------------------------------------------------------
/src/Entities/ProFac/BusinessData.ts:
--------------------------------------------------------------------------------
1 | import { Address } from "../../Entities";
2 |
3 | export class BusinessData {
4 | ///
5 | /// The legal name of the business as registered
6 | ///
7 | public businessLegalName: string;
8 | ///
9 | /// This field can be used to provide DBA information on an account. ProPay accounts can be configured to display DBA on cc statements. (Note most banks' CC statements allow for 29 characters)
10 | ///
11 | public doingBusinessAs: string;
12 | ///
13 | /// EIN - 9 characters without dashes
14 | ///
15 | public employerIdentificationNumber: string;
16 |
17 | ///
18 | /// Merchant Category Code
19 | ///
20 | public merchantCategoryCode: string;
21 |
22 | ///
23 | /// The business' website URL
24 | ///
25 | public websiteURL: string;
26 | ///
27 | /// The business' description
28 | ///
29 | public businessDescription: string;
30 | ///
31 | /// The monthly colume of bank card transactions; Value representing the number of pennies in USD, or the number of [currency] without decimals. Defaults to $1000.00 if not sent.
32 | ///
33 | public monthlyBankCardVolume: string;
34 | ///
35 | /// The average amount of an individual transaction; Value representing the number of pennies in USD, or the number of [currency] without decimals. Defaults to $300.00 if not sent.
36 | ///
37 | public averageTicket: string;
38 | ///
39 | /// The highest transaction amount; Value representing the number of pennies in USD, or the number of [currency] without decimals. Defaults to $300.00 if not sent.
40 | ///
41 | public highestTicket: string;
42 | // The business' address
43 | public businessAddress: Address;
44 |
45 | public businessType: string;
46 |
47 | constructor() {
48 | this.businessAddress = new Address();
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/Entities/ProFac/DeviceAttributeInfo.ts:
--------------------------------------------------------------------------------
1 | export class DeviceAttributeInfo {
2 | ///
3 | /// Name of the attribute item. For example "Heartland.AMD.OfficeKey" which is specific to Portico devices for AMD. The avlue of this item is passed to Heartland for equipment boarding
4 | /// AttributeName and AttributeValue are optional as a pair. But if one is specified, both must be specified.
5 | ///
6 | public name: string;
7 | ///
8 | /// Value of the attribute item. In the above example, the value for the attribute named "Heartland.AMD.OfficeKey"
9 | /// AttributeName and AttributeValue are optional as a pair. But if one is specified, both must be specified.
10 | ///
11 | public value: string;
12 | }
13 |
--------------------------------------------------------------------------------
/src/Entities/ProFac/DeviceData.ts:
--------------------------------------------------------------------------------
1 | import { DeviceInfo } from "./DeviceInfo";
2 |
3 | export class DeviceData {
4 | public devices: Array;
5 |
6 | constructor() {
7 | this.devices = new Array();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/Entities/ProFac/DeviceInfo.ts:
--------------------------------------------------------------------------------
1 | import { DeviceAttributeInfo } from "../ProFac/DeviceAttributeInfo";
2 |
3 | export class DeviceInfo {
4 | ///
5 | /// Unique name of the device being ordered
6 | ///
7 | public name: string;
8 | ///
9 | /// Number of devices ordered. Defaults to 0
10 | ///
11 | public quantity: number;
12 |
13 | ///
14 | /// A list of attributes for the specific device. This will be null if no attributes are set
15 | ///
16 | public attributes: Array;
17 | }
18 |
--------------------------------------------------------------------------------
/src/Entities/ProFac/FlashFundsPaymentCardData.ts:
--------------------------------------------------------------------------------
1 | import { CreditCardData } from "../../PaymentMethods/CreditCardData";
2 | import { Address } from "../Address";
3 |
4 | export class FlashFundsPaymentCardData {
5 | public creditCard: CreditCardData;
6 | public cardholderAddress: Address;
7 |
8 | constructor() {
9 | this.creditCard = new CreditCardData();
10 | this.cardholderAddress = new Address();
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/Entities/ProFac/GrossBillingInformation.ts:
--------------------------------------------------------------------------------
1 | import { Address } from "../Address";
2 | import { BankAccountData } from "./BankAccountData";
3 | import { CreditCardData } from "../../PaymentMethods";
4 |
5 | export class GrossBillingInformation {
6 | public grossSettleAddress: Address;
7 | public grossSettleBankData: BankAccountData;
8 | public grossSettleCreditCardData: CreditCardData;
9 | }
10 |
--------------------------------------------------------------------------------
/src/Entities/ProFac/OrderDevice.ts:
--------------------------------------------------------------------------------
1 | export class OrderDevice {
2 | public accountNum: number;
3 | public shipTo: string;
4 | public shipToContact: string;
5 | public shipToAddress: string;
6 | public shipToAddress2: string;
7 | public shipToCity: string;
8 | public shipToState: string;
9 | public shipToZip: string;
10 | public shipToPhone: string;
11 | public cardholderName: string;
12 | public ccNum: string;
13 | public expDate: string;
14 | public cVV2: string;
15 | public billingZip: string;
16 | public name: string;
17 | public quantity: string;
18 | }
19 |
--------------------------------------------------------------------------------
/src/Entities/ProFac/OwnersData.ts:
--------------------------------------------------------------------------------
1 | import { Address } from "../../Entities";
2 |
3 | export class OwnersData {
4 | ///
5 | /// Owner title
6 | ///
7 | public title: string;
8 | ///
9 | /// Owner first name
10 | ///
11 | public firstName: string;
12 | ///
13 | /// Owner last name
14 | ///
15 | public lastName: string;
16 | ///
17 | /// Owner email ID
18 | ///
19 | public email: string;
20 | ///
21 | /// Date of birth of the owner. Must be in 'mm-dd-yyyy' format.
22 | ///
23 | public DateOfBirth: string;
24 | ///
25 | /// Social Security Number of the owner. Should be 9 digits.
26 | ///
27 | public sSN: string;
28 | ///
29 | /// Percentage stake in company by owner. Must be whole number between 0 and 100.
30 | ///
31 | public percentage: string;
32 | ///
33 | /// Address of the owner
34 | ///
35 | public ownerAddress: Address;
36 |
37 | constructor() {
38 | this.ownerAddress = new Address();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/Entities/ProFac/RenewAccountData.ts:
--------------------------------------------------------------------------------
1 | import { CreditCardData } from "../../PaymentMethods";
2 |
3 | export class RenewAccountData {
4 | ///
5 | /// Supplying a value will change the account's tier under the affiliation upon renewal
6 | /// If not passed, the tier will not be changed
7 | ///
8 | public tier: string;
9 |
10 | ///
11 | /// Credit Card details
12 | ///
13 | public creditCard: CreditCardData;
14 |
15 | ///
16 | /// The US zip code of the credit card. 5 or 9 digits without a dash for US cards. Omit for internation credit cards.
17 | ///
18 | public zipCode: string;
19 |
20 | ///
21 | /// User to pay for an account via ACH and monthly renewal. Financial institution account number.
22 | /// *Required if using ACH to pay renewal fee
23 | ///
24 | public paymentBankAccountNumber: string;
25 |
26 | ///
27 | /// Used to pay for an account via ACH and monthly renewal. Financial institution account number.
28 | /// *Required if using ACH to pay renewal fee
29 | ///
30 | public paymentBankRoutingNumber: string;
31 |
32 | ///
33 | /// Used to pay for an account via ACH and monthly renewal. Valid values are: Checking and Savings
34 | ///
35 | public paymentBankAccountType: string;
36 |
37 | constructor() {
38 | this.creditCard = new CreditCardData();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/Entities/ProFac/SignificantOwnerData.ts:
--------------------------------------------------------------------------------
1 | import { OwnersData } from "./OwnersData";
2 |
3 | export class SignificantOwnerData {
4 | ///
5 | /// Seller's authorized Signer First Name. By default Merchant's First name is saved.
6 | ///
7 | public authorizedSignerFirstName: string;
8 | ///
9 | /// Seller's Authorized Signer Last Name. By default Merchant's Last name is saved.
10 | ///
11 | public authorizedSignerLastName: string;
12 | ///
13 | /// This field contains the Seller's Authorized Signer Title
14 | ///
15 | public authorizedSignerTitle: string;
16 | ///
17 | /// Seller's Authorized Signer owner information
18 | ///
19 | public significantOwner: OwnersData;
20 |
21 | constructor() {
22 | this.significantOwner = new OwnersData();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Entities/ProFac/ThreatRiskData.ts:
--------------------------------------------------------------------------------
1 | export class ThreatRiskData {
2 | ///
3 | /// SourceIp of Merchant, see ProPay Fraud Detection Solutions Manual
4 | ///
5 | public merchantSourceIP: string;
6 | ///
7 | /// Threat Metrix Policy, see ProPay Fraud Detection Solutions Manual
8 | ///
9 | public threatMetrixPolicy: string;
10 | ///
11 | /// SessionId for Threat Metrix, see ProPay Fraud Detection Solutions Manual
12 | ///
13 | public threatMetrixSessionID: string;
14 | }
15 |
--------------------------------------------------------------------------------
/src/Entities/Reporting/BaseSummary.ts:
--------------------------------------------------------------------------------
1 | export abstract class BaseSummary {
2 | amount: string;
3 | currency: string;
4 | merchantId: string;
5 | merchantHierarchy: string;
6 | merchantName: string;
7 | merchantDbaName: string;
8 | }
9 |
--------------------------------------------------------------------------------
/src/Entities/Reporting/DepositSummary.ts:
--------------------------------------------------------------------------------
1 | import { BaseSummary } from "./BaseSummary";
2 |
3 | export class DepositSummary extends BaseSummary {
4 | depositId: string;
5 | depositDate: Date;
6 | reference: string;
7 | type: string;
8 | routingNumber: string;
9 | accountNumber: string;
10 | mode: string;
11 | summaryModel: string;
12 | salesTotalCount: number;
13 | salesTotalAmount: string;
14 | salesTotalCurrency: string;
15 | refundsTotalCount: number;
16 | refundsTotalAmount: string;
17 | refundsTotalCurrency: string;
18 | chargebackTotalCount: number;
19 | chargebackTotalAmount: string;
20 | chargebackTotalCurrency: string;
21 | representmentTotalCount: number;
22 | representmentTotalAmount: number;
23 | representmentTotalCurrency: string;
24 | feesTotalAmount: string;
25 | feesTotalCurrency: string;
26 | adjustmentTotalCount: number;
27 | adjustmentTotalAmount: string;
28 | adjustmentTotalCurrency: string;
29 | status: string;
30 | }
31 |
--------------------------------------------------------------------------------
/src/Entities/Reporting/DisputeSummary.ts:
--------------------------------------------------------------------------------
1 | import { ManagementBuilder } from "../../Builders";
2 | import { TransactionType } from "../Enums";
3 | import { DisputeDocument } from "../DisputeDocument";
4 |
5 | export class DisputeSummary {
6 | public merchantHierarchy: string;
7 | public merchantName: string;
8 | public merchantDbaName: string;
9 | public merchantNumber: string;
10 | public merchantCategory: string;
11 | public depositDate: Date | null;
12 | public depositReference: string;
13 | public depositType: string;
14 | public type: string;
15 | public caseAmount: string;
16 | public caseCurrency: string;
17 | public caseStage: string;
18 | public caseStatus: string;
19 | public caseDescription: string;
20 | public transactionOrderId: string;
21 | public transactionLocalTime: Date;
22 | public transactionTime: Date;
23 | public transactionType: string;
24 | public transactionAmount: string;
25 | public transactionCurrency: string;
26 | public caseNumber: string;
27 | public caseTime: Date;
28 | public caseId: string;
29 | public caseIdTime: Date | string;
30 | public caseMerchantId: string;
31 | public caseTerminalId: string;
32 | public transactionARN: string;
33 | public transactionReferenceNumber: string;
34 | public transactionSRD: string;
35 | public transactionAuthCode: string;
36 | public transactionCardType: string;
37 | public transactionMaskedCardNumber: string;
38 | public reason: string;
39 | public reasonCode: string;
40 | public result: string;
41 | public issuerComment: string;
42 | public issuerCaseNumber: string;
43 | public disputeAmount: number;
44 | public disputeCurrency: string;
45 | public disputeCustomerAmount: number;
46 | public disputeCustomerCurrency: string;
47 | public respondByDate: Date;
48 | public caseOriginalReference: string;
49 | public lastAdjustmentAmount: string;
50 | public lastAdjustmentCurrency: string;
51 | public lastAdjustmentFunding: string;
52 | public documents: DisputeDocument[];
53 |
54 | accept(): ManagementBuilder {
55 | return new ManagementBuilder(
56 | TransactionType.DisputeAcceptance,
57 | ).withDisputeId(this.caseId);
58 | }
59 |
60 | challenge(documents: DisputeDocument[]): ManagementBuilder {
61 | return new ManagementBuilder(TransactionType.DisputeChallenge)
62 | .withDisputeId(this.caseId)
63 | .withDisputeDocuments(documents);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/Entities/Reporting/StoredPaymentMethodSummary.ts:
--------------------------------------------------------------------------------
1 | export class StoredPaymentMethodSummary {
2 | paymentMethodId: string;
3 | timeCreated: Date;
4 | status: string;
5 | reference: string;
6 | cardHolderName: string;
7 | cardType: string;
8 | cardNumberLastFour: string;
9 | cardExpMonth: number;
10 | cardExpYear: number;
11 | }
12 |
--------------------------------------------------------------------------------
/src/Entities/Reporting/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./BaseSummary";
2 | export * from "./DepositSummary";
3 | export * from "./DisputeSummary";
4 | export * from "./SearchCriteriaBuilder";
5 | export * from "./StoredPaymentMethodSummary";
6 |
--------------------------------------------------------------------------------
/src/Entities/Request.ts:
--------------------------------------------------------------------------------
1 | import { ParsedUrlQuery } from "querystring";
2 |
3 | export class Request {
4 | public endpoint: string;
5 |
6 | public httpVerb: string;
7 |
8 | public requestBody: string;
9 |
10 | public queryParams: ParsedUrlQuery | undefined;
11 |
12 | static maskedValues: Record = {};
13 |
14 | constructor(
15 | endpoint: string,
16 | httpVerb: string,
17 | requestBody: string = "",
18 | queryParams?: ParsedUrlQuery,
19 | ) {
20 | this.endpoint = endpoint;
21 | this.httpVerb = httpVerb;
22 | this.requestBody = requestBody;
23 | this.queryParams = queryParams;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Entities/SSORequestData.ts:
--------------------------------------------------------------------------------
1 | export class SSORequestData {
2 | ///
3 | /// The ProPay system requires that your single-sign-on originate from the URL originally provided here
4 | ///
5 | public referrerURL: string;
6 | ///
7 | /// The ProPay system requires that your single-sign-on originate from the URL originally provided here. Can supply a range of class c or more restrictive
8 | ///
9 | public iPAddress: string;
10 | ///
11 | /// The ProPay system requires that your single-sign-on originate from the URL originally provided here. Can supply a range of class c or more restrictive
12 | ///
13 | public iPSubnetMask: string;
14 | }
15 |
--------------------------------------------------------------------------------
/src/Entities/ServiceEndpoints.ts:
--------------------------------------------------------------------------------
1 | export enum ServiceEndpoints {
2 | GLOBAL_ECOM_PRODUCTION = "https://api.realexpayments.com/epage-remote.cgi",
3 | GLOBAL_ECOM_TEST = "https://api.sandbox.realexpayments.com/epage-remote.cgi",
4 | GP_API_PRODUCTION = "https://apis.globalpay.com/ucp",
5 | GP_API_TEST = "https://apis.sandbox.globalpay.com/ucp",
6 | PORTICO_PRODUCTION = "https://api2.heartlandportico.com",
7 | PORTICO_TEST = "https://cert.api2.heartlandportico.com",
8 | PROPAY_TEST = "https://xmltest.propay.com/API/PropayAPI.aspx",
9 | PROPAY_TEST_CANADIAN = "https://xmltestcanada.propay.com/API/PropayAPI.aspx",
10 | PROPAY_PRODUCTION = "https://epay.propay.com/API/PropayAPI.aspx",
11 | PROPAY_PRODUCTION_CANADIAN = "https://www.propaycanada.ca/API/PropayAPI.aspx",
12 | }
13 |
--------------------------------------------------------------------------------
/src/Entities/StoredCredentials.ts:
--------------------------------------------------------------------------------
1 | import {
2 | StoredCredentialInitiator,
3 | StoredCredentialReason,
4 | StoredCredentialSequence,
5 | StoredCredentialType,
6 | } from ".";
7 |
8 | export class StoredCredential {
9 | public type: StoredCredentialType;
10 | public initiator: StoredCredentialInitiator;
11 | public sequence: StoredCredentialSequence;
12 | public schemeId: string;
13 | public reason: StoredCredentialReason;
14 | public cardBrandTransactionId: string;
15 | }
16 |
--------------------------------------------------------------------------------
/src/Entities/TransactionStatus.ts:
--------------------------------------------------------------------------------
1 | export class TransactionStatus {
2 | static INITIATED = "INITIATED";
3 | static AUTHENTICATED = "AUTHENTICATED";
4 | static PENDING = "PENDING";
5 | static DECLINED = "DECLINED";
6 | static PREAUTHORIZED = "PREAUTHORIZED";
7 | static CAPTURED = "CAPTURED";
8 | static BATCHED = "BATCHED";
9 | static REVERSED = "REVERSED";
10 | static FUNDED = "FUNDED";
11 | static REJECTED = "REJECTED";
12 |
13 | static mapTransactionStatusResponse: Record = {
14 | [TransactionStatus.INITIATED]: TransactionStatus.INITIATED,
15 | [TransactionStatus.AUTHENTICATED]: "SUCCESS_AUTHENTICATED",
16 | [TransactionStatus.PENDING]: TransactionStatus.PENDING,
17 | [TransactionStatus.DECLINED]: TransactionStatus.DECLINED,
18 | [TransactionStatus.PREAUTHORIZED]: TransactionStatus.PREAUTHORIZED,
19 | [TransactionStatus.CAPTURED]: TransactionStatus.CAPTURED,
20 | [TransactionStatus.BATCHED]: TransactionStatus.BATCHED,
21 | [TransactionStatus.REVERSED]: TransactionStatus.REVERSED,
22 | [TransactionStatus.FUNDED]: TransactionStatus.FUNDED,
23 | [TransactionStatus.REJECTED]: TransactionStatus.REJECTED,
24 | };
25 | }
26 |
--------------------------------------------------------------------------------
/src/Entities/UPA/ProcessIndicator.ts:
--------------------------------------------------------------------------------
1 | import { CardTypeFilter } from "../Enums/CardTypeFilter";
2 |
3 | export class ProcessingIndicator {
4 | public QuickChip: string;
5 | public CheckLuhn: string;
6 | public SecurityCode: string;
7 | public CardTypeFilter: CardTypeFilter;
8 | }
9 |
--------------------------------------------------------------------------------
/src/Entities/UPA/UpaParam.ts:
--------------------------------------------------------------------------------
1 | import { AcquisitionType } from "../Enums/AcquisitionType";
2 |
3 | export class UpaParam {
4 | public timeout: number;
5 | public acquisitionTypes: AcquisitionType;
6 | public header: string;
7 | public displayTotalAmount: string;
8 | public promptForManual: boolean;
9 | public brandIcon1: number;
10 | public brandIcon2: number;
11 | }
12 |
--------------------------------------------------------------------------------
/src/Entities/UPA/UpaTransactionData.ts:
--------------------------------------------------------------------------------
1 | import { TransactionType } from "..";
2 |
3 | export class UpaTransactionData {
4 | public totalAmount: number;
5 | public cashBackAmount: number;
6 | public tranDate: string;
7 | public tranTime: string;
8 | public transType: TransactionType;
9 | }
10 |
--------------------------------------------------------------------------------
/src/Entities/UPA/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./ProcessIndicator";
2 | export * from "./UpaParam";
3 | export * from "./UpaTransactionData";
4 |
--------------------------------------------------------------------------------
/src/Entities/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./AdditionalTaxDetails";
2 | export * from "./Address";
3 | export * from "./AlternativePaymentResponse";
4 | export * from "./BatchSummary";
5 | export * from "./BrowserData";
6 | export * from "./Card";
7 | export * from "./CardIssuerResponse";
8 | export * from "./CommercialData";
9 | export * from "./CommercialLineItem";
10 | export * from "./Customer";
11 | export * from "./CustomerDocument";
12 | export * from "./DccRateData";
13 | export * from "./DiscountDetails";
14 | export * from "./DisputeDocument";
15 | export * from "./Document";
16 | export * from "./EcommerceInfo";
17 | export * from "./EncryptionData";
18 | export * from "./Enums";
19 | export * from "./Enums/FileType";
20 | export * from "./Enums/DccProcessor";
21 | export * from "./Enums/DccRateType";
22 | export * from "./Enums/DepositSortProperty";
23 | export * from "./Enums/DisputeSortProperty";
24 | export * from "./Enums/DisputeStage";
25 | export * from "./Enums/DisputeStatus";
26 | export * from "./Enums/DocumentCategory";
27 | export * from "./Enums/IsoCountries";
28 | export * from "./Enums/MerchantCategory";
29 | export * from "./Errors";
30 | export * from "./FraudRule";
31 | export * from "./GpApi";
32 | export * from "./HostedPaymentData";
33 | export * from "./IRequestBuilder";
34 | export * from "./IRequestLogger";
35 | export * from "./LodgingData";
36 | export * from "./LodgingItems";
37 | export * from "./LodgingData";
38 | export * from "./MaskedValueCollection";
39 | export * from "./MessageExtension";
40 | export * from "./MerchantDataCollection";
41 | export * from "./MerchantKVP";
42 | export * from "./MobileData";
43 | export * from "./OrderDetails";
44 | export * from "./PayerDetails";
45 | export * from "./PhoneNumber";
46 | export * from "./RecurringEntity";
47 | export * from "./Reporting";
48 | export * from "./Request";
49 | export * from "./Schedule";
50 | export * from "./ServiceEndpoints";
51 | export * from "./StoredCredentials";
52 | export * from "./ThreeDSecure";
53 | export * from "./Transaction";
54 | export * from "./TransactionStatus";
55 | export * from "./TransactionSummary";
56 | export * from "./UPA";
57 |
--------------------------------------------------------------------------------
/src/Gateways/GatewayResponse.ts:
--------------------------------------------------------------------------------
1 | import { IncomingHttpHeaders } from "http";
2 |
3 | export class GatewayResponse {
4 | public statusCode: number;
5 |
6 | public rawResponse: string;
7 |
8 | public headers: IncomingHttpHeaders;
9 |
10 | constructor(
11 | headers: IncomingHttpHeaders,
12 | rawResponse: string,
13 | statusCode: number | undefined,
14 | ) {
15 | this.headers = headers;
16 | this.rawResponse = rawResponse;
17 | this.statusCode = statusCode || 0;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Gateways/IPayFacProvider.ts:
--------------------------------------------------------------------------------
1 | import { Transaction } from "../Entities/Transaction";
2 | import { PayFacBuilder } from "../Builders/PayFacBuilder";
3 |
4 | export interface IPayFacProvider {
5 | processPayFac(builder: PayFacBuilder): Promise;
6 | }
7 |
--------------------------------------------------------------------------------
/src/Gateways/IPaymentGateway.ts:
--------------------------------------------------------------------------------
1 | import {
2 | AuthorizationBuilder,
3 | ManagementBuilder,
4 | ReportBuilder,
5 | Transaction,
6 | } from "../";
7 |
8 | export interface IPaymentGateway {
9 | supportsHostedPayments: boolean;
10 | processAuthorization(builder: AuthorizationBuilder): Promise;
11 | manageTransaction(builder: ManagementBuilder): Promise;
12 | processReport(builder: ReportBuilder): Promise;
13 | serializeRequest(builder: AuthorizationBuilder): string;
14 | }
15 |
--------------------------------------------------------------------------------
/src/Gateways/IRecurringService.ts:
--------------------------------------------------------------------------------
1 | import { IRecurringEntity, RecurringBuilder } from "../";
2 |
3 | export interface IRecurringService {
4 | supportsRetrieval: boolean;
5 | supportsUpdatePaymentDetails: boolean;
6 | processRecurring(
7 | builder: RecurringBuilder,
8 | ): Promise;
9 | }
10 |
--------------------------------------------------------------------------------
/src/Gateways/XmlGateway.ts:
--------------------------------------------------------------------------------
1 | import { RequestIdProvider } from "../../test/Integration/Gateways/Terminals/RequestIdProvider";
2 | import { Gateway } from "./Gateway";
3 | import { GatewayResponse } from "./GatewayResponse";
4 | import { ElementTree, XML as xml } from "@azz/elementtree";
5 | export abstract class XmlGateway extends Gateway {
6 | public constructor() {
7 | super("text/xml");
8 | }
9 |
10 | public doTransaction(requestData: string): Promise {
11 | const requestId = new RequestIdProvider().getRequestId();
12 |
13 | return this.sendRequest("POST", "", requestId, requestData).then(
14 | (response: GatewayResponse) => {
15 | if (this.requestLogger) {
16 | this.requestLogger.responseReceived(response, requestId);
17 | }
18 | return response.rawResponse;
19 | },
20 | );
21 | }
22 |
23 | public override maskSensitiveData(data: string) {
24 | const root = xml(data);
25 |
26 | Object.keys(this.maskedRequestData).forEach((key) => {
27 | const splittedKeys = key.split(".");
28 | if (splittedKeys.length) {
29 | const element = root.find(splittedKeys[0]);
30 | if (element) {
31 | if (splittedKeys[1]) {
32 | const subElement = element.find(splittedKeys[1]);
33 | if (splittedKeys[2]) {
34 | subElement.find(splittedKeys[2]).text =
35 | this.maskedRequestData[key];
36 | } else {
37 | subElement.text = this.maskedRequestData[key];
38 | }
39 | } else {
40 | element.text = this.maskedRequestData[key];
41 | }
42 | }
43 | } else {
44 | root.find(key) && (root.find(key).text = this.maskedRequestData[key]);
45 | }
46 | });
47 |
48 | return new ElementTree(root)
49 | .write({
50 | indent: " ",
51 | })
52 | .replaceAll(" 1", " ");
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/Gateways/https-wrapper.ts:
--------------------------------------------------------------------------------
1 | import * as https from "https";
2 | import { Socket } from "net";
3 |
4 | import { ApiError, GatewayError } from "../Entities/Errors";
5 | import { createGunzip } from "zlib";
6 | import { GatewayResponse } from "./GatewayResponse";
7 |
8 | export const request = (
9 | data?: string,
10 | options?: https.RequestOptions,
11 | ): Promise =>
12 | new Promise((resolve, reject) => {
13 | if (options === undefined) {
14 | options = {};
15 | }
16 |
17 | const req = https.request(options, (res) => {
18 | let responseData = "";
19 | const buffer: string[] = [];
20 | const successCodes: string[] = ["200", "204"];
21 |
22 | if (res.headers["content-encoding"] == "gzip") {
23 | const gunzip = createGunzip();
24 |
25 | res.pipe(gunzip);
26 |
27 | gunzip
28 | .on("data", function (data) {
29 | // decompression chunk ready, add it to the buffer
30 | buffer.push(data.toString());
31 | })
32 | .on("end", function () {
33 | // response and decompression complete, join the buffer and return
34 | resolve(
35 | new GatewayResponse(res.headers, buffer.join(""), res.statusCode),
36 | );
37 | })
38 | .on("error", function (e) {
39 | reject(e);
40 | });
41 | return;
42 | }
43 |
44 | res.on("data", (d: string) => (responseData += d));
45 | res.on("end", () => {
46 | if (
47 | res.statusCode != null &&
48 | !successCodes.includes(res.statusCode.toString())
49 | ) {
50 | const er = JSON.stringify(responseData);
51 | const parsedError = JSON.parse(er);
52 |
53 | reject(
54 | new GatewayError(
55 | `Unexpected HTTP status code [${res.statusCode}]`,
56 | res.statusMessage,
57 | parsedError,
58 | ),
59 | );
60 | }
61 | resolve(new GatewayResponse(res.headers, responseData, res.statusCode));
62 | });
63 | res.on("error", reject);
64 | });
65 | req.on("socket", (socket: Socket) => {
66 | socket.on("timeout", () => {
67 | req.abort();
68 | reject(new ApiError("Socket timeout occurred."));
69 | });
70 | });
71 | req.on("error", reject);
72 | if (data !== undefined) {
73 | req.write(data);
74 | }
75 | req.end();
76 | });
77 |
--------------------------------------------------------------------------------
/src/Gateways/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./Gateway";
2 | export * from "./GpApiConnector";
3 | export * from "./GpEcomConnector";
4 | export * from "./IPaymentGateway";
5 | export * from "./IRecurringService";
6 | export * from "./PayPlanConnector";
7 | export * from "./PorticoConnector";
8 | export * from "./ProPayConnector";
9 | export * from "./XmlGateway";
10 |
--------------------------------------------------------------------------------
/src/HostedPaymentConfig.ts:
--------------------------------------------------------------------------------
1 | import { FraudFilterMode, HppVersion } from "./";
2 |
3 | export class HostedPaymentConfig {
4 | public cardStorageEnabled: boolean;
5 | public directCurrencyConversionEnabled: boolean;
6 | public displaySavedCards: boolean;
7 | public fraudFilterMode: FraudFilterMode;
8 | public language: string;
9 | public paymentButtonText: string;
10 | public responseUrl: string;
11 | public requestTransactionStabilityScore: string;
12 | public version: HppVersion;
13 | }
14 |
--------------------------------------------------------------------------------
/src/Mapping/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./EnumMapping";
2 | export * from "./GpApiMapping";
3 | export * from "./GpEcomMapping";
4 |
--------------------------------------------------------------------------------
/src/PaymentMethods/AlternativePaymentMethod.ts:
--------------------------------------------------------------------------------
1 | import {
2 | AuthorizationBuilder,
3 | EncryptionData,
4 | NotImplementedError,
5 | PaymentMethodType,
6 | TransactionModifier,
7 | TransactionType,
8 | } from "../../src";
9 | import {
10 | IChargable,
11 | IEncryptable,
12 | IPaymentMethod,
13 | IPinProtected,
14 | IPrePayable,
15 | IRefundable,
16 | IReversable,
17 | } from ".";
18 |
19 | /* eslint-disable indent */
20 | export class AlternativePaymentMethod
21 | implements
22 | IPaymentMethod,
23 | IPrePayable,
24 | IRefundable,
25 | IReversable,
26 | IChargable,
27 | IEncryptable,
28 | IPinProtected
29 | {
30 | paymentMethodType = PaymentMethodType.APM;
31 | alternativePaymentMethodType: string;
32 | returnUrl: string;
33 | statusUpdateUrl: string;
34 | cancelUrl: string;
35 | descriptor: string;
36 | country: string;
37 | accountHolderName: string;
38 | providerReference: string;
39 | addressOverrideMode: string;
40 | pinBlock: string;
41 | encryptionData: EncryptionData;
42 | /* eslint-enable indent */
43 |
44 | constructor(alternativePaymentMethodType: string) {
45 | this.alternativePaymentMethodType = alternativePaymentMethodType;
46 | }
47 |
48 | charge(amount: string | number): AuthorizationBuilder {
49 | return new AuthorizationBuilder(TransactionType.Sale, this)
50 | .withModifier(TransactionModifier.AlternativePaymentMethod)
51 | .withAmount(amount);
52 | }
53 |
54 | authorize(amount: string | number): AuthorizationBuilder {
55 | return new AuthorizationBuilder(TransactionType.Auth, this)
56 | .withModifier(TransactionModifier.AlternativePaymentMethod)
57 | .withAmount(amount);
58 | }
59 |
60 | addValue(amount: string | number): AuthorizationBuilder {
61 | amount;
62 | throw new NotImplementedError();
63 | }
64 |
65 | refund(amount: string | number): AuthorizationBuilder {
66 | amount;
67 | throw new NotImplementedError();
68 | }
69 |
70 | reverse(amount: string | number): AuthorizationBuilder {
71 | amount;
72 | throw new NotImplementedError();
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/PaymentMethods/Cash.ts:
--------------------------------------------------------------------------------
1 | import {
2 | AuthorizationBuilder,
3 | NotImplementedError,
4 | PaymentMethodType,
5 | } from "../";
6 | import { IChargable, IRefundable } from "./Interfaces";
7 | import { PaymentMethod } from "./PaymentMethod";
8 |
9 | export class Cash extends PaymentMethod implements IChargable, IRefundable {
10 | public paymentMethodType = PaymentMethodType.Cash;
11 |
12 | public charge(): AuthorizationBuilder {
13 | throw new NotImplementedError();
14 | }
15 |
16 | public refund(): AuthorizationBuilder {
17 | throw new NotImplementedError();
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/PaymentMethods/CreditCardData.ts:
--------------------------------------------------------------------------------
1 | import { CvnPresenceIndicator } from "../";
2 | import { Credit } from "./Credit";
3 | import { ICardData } from "./Interfaces";
4 |
5 | export class CreditCardData extends Credit implements ICardData {
6 | public static cardTypes = [
7 | { name: "Visa", regex: /^4/ },
8 | { name: "MC", regex: /^(5[1-5]|2[2-7])/ },
9 | { name: "Amex", regex: /^3[47]/ },
10 | { name: "Diners", regex: /^3[0689]/ },
11 | { name: "EnRoute", regex: /^2(014|149)/ },
12 | { name: "Discover", regex: /^6([045]|22)/ },
13 | { name: "Jcb", regex: /^35/ },
14 | ];
15 |
16 | public number: string;
17 | public expMonth: string;
18 | public expYear: string;
19 | public cvn: string;
20 | public cvnPresenceIndicator: CvnPresenceIndicator;
21 | public cardHolderName: string;
22 | public cardPresent: boolean;
23 | public readerPresent: boolean;
24 |
25 | public constructor() {
26 | super();
27 | this.cardPresent = false;
28 | this.readerPresent = false;
29 | this.cvnPresenceIndicator = CvnPresenceIndicator.NotRequested;
30 | }
31 |
32 | public getCardType(): string {
33 | const number = this.number.replace(" ", "").replace("-", "");
34 |
35 | for (const type of CreditCardData.cardTypes) {
36 | if (type.regex.test(number)) {
37 | return type.name;
38 | }
39 | }
40 |
41 | return "Unknown";
42 | }
43 |
44 | public getShortExpiry(): string {
45 | if (this.expMonth != null && this.expYear != null) {
46 | return this.expMonth + this.expYear.slice(-2);
47 | }
48 |
49 | return "";
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/PaymentMethods/CreditTrackData.ts:
--------------------------------------------------------------------------------
1 | import { CardUtils, EntryMethod } from "../";
2 | import { Credit } from "./Credit";
3 | import { ITrackData } from "./Interfaces";
4 |
5 | export class CreditTrackData extends Credit implements ITrackData {
6 | public entryMethod: EntryMethod;
7 | public value: string;
8 | public discretionaryData: string;
9 | public expiry: string;
10 | public pan: string;
11 | public purchaseDeviceSequenceNumber: string;
12 | public trackNumber: string;
13 | public trackData: string;
14 |
15 | public setTrackData(value: string) {
16 | if (!this.value) {
17 | this.setValue(value);
18 | } else {
19 | this.trackData = value;
20 | }
21 | }
22 |
23 | setValue(value: string): void {
24 | this.value = value;
25 | CardUtils.parseTrackData(this);
26 | this.cardType = CardUtils.getCardType(this.pan);
27 | this.isFleet = CardUtils.isFleet(this.cardType, this.pan);
28 |
29 | if (
30 | this.cardType === "WexFleet" &&
31 | this.discretionaryData !== null &&
32 | this.discretionaryData.length >= 8
33 | ) {
34 | this.purchaseDeviceSequenceNumber = this.discretionaryData.substring(
35 | 3,
36 | 11,
37 | );
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/PaymentMethods/Debit.ts:
--------------------------------------------------------------------------------
1 | import {
2 | AuthorizationBuilder,
3 | EncryptionData,
4 | PaymentMethodType,
5 | TransactionType,
6 | } from "../";
7 | import {
8 | IChargable,
9 | IEncryptable,
10 | IPinProtected,
11 | IPrePayable,
12 | IRefundable,
13 | IReversable,
14 | } from "./Interfaces";
15 | import { PaymentMethod } from "./PaymentMethod";
16 |
17 | export abstract class Debit
18 | extends PaymentMethod
19 | implements
20 | IChargable,
21 | IEncryptable,
22 | IRefundable,
23 | IReversable,
24 | IPrePayable,
25 | IPinProtected
26 | {
27 | public encryptionData: EncryptionData;
28 | public paymentMethodType: PaymentMethodType = PaymentMethodType.Debit;
29 | public pinBlock: string;
30 |
31 | /**
32 | * Authorizes the payment method and captures the entire authorized amount
33 | *
34 | * @param string|number amount Amount to authorize
35 | *
36 | * @return AuthorizationBuilder
37 | */
38 | public charge(amount?: string | number) {
39 | return new AuthorizationBuilder(TransactionType.Sale, this).withAmount(
40 | amount,
41 | );
42 | }
43 |
44 | /**
45 | * Adds value to the payment method
46 | *
47 | * @param string|number amount Amount to add
48 | *
49 | * @return AuthorizationBuilder
50 | */
51 | public addValue(amount?: string | number) {
52 | return new AuthorizationBuilder(TransactionType.AddValue, this).withAmount(
53 | amount,
54 | );
55 | }
56 |
57 | /**
58 | * Refunds the payment method
59 | *
60 | * @param string|number amount Amount to refund
61 | *
62 | * @return AuthorizationBuilder
63 | */
64 | public refund(amount?: string | number) {
65 | return new AuthorizationBuilder(TransactionType.Refund, this).withAmount(
66 | amount,
67 | );
68 | }
69 |
70 | /**
71 | * Reverses the payment method
72 | *
73 | * @param string|number amount Amount to reverse
74 | *
75 | * @return AuthorizationBuilder
76 | */
77 | public reverse(amount?: string | number) {
78 | return new AuthorizationBuilder(TransactionType.Reversal, this).withAmount(
79 | amount,
80 | );
81 | }
82 | /**
83 | * Authorizes the payment method
84 | *
85 | * @param string|number amount Amount to reverse
86 | *
87 | * @return AuthorizationBuilder
88 | */
89 | public authorize(amount?: string | number) {
90 | return new AuthorizationBuilder(TransactionType.Auth, this)
91 | .withAmount(amount)
92 | .withAmountEstimated(true);
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/src/PaymentMethods/DebitTrackData.ts:
--------------------------------------------------------------------------------
1 | import { CardUtils, EntryMethod } from "../";
2 | import { Debit } from "./Debit";
3 | import { ITrackData } from "./Interfaces";
4 |
5 | export class DebitTrackData extends Debit implements ITrackData {
6 | public entryMethod: EntryMethod;
7 | public value: string;
8 |
9 | public setTrackData(value: string) {
10 | if (!this.value) {
11 | this.setValue(value);
12 | } else {
13 | this.trackData = value;
14 | }
15 | }
16 |
17 | public setValue(value: string): void {
18 | this.value = value;
19 | CardUtils.parseTrackData(this);
20 | this.cardType = CardUtils.getCardType(this.pan);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/PaymentMethods/EBTCardData.ts:
--------------------------------------------------------------------------------
1 | import { CvnPresenceIndicator } from "../";
2 | import { EBT } from "./EBT";
3 | import { ICardData } from "./Interfaces";
4 |
5 | export class EBTCardData extends EBT implements ICardData {
6 | public approvalCode: string;
7 | public number: string;
8 | public expMonth: string;
9 | public expYear: string;
10 | public cvn: string;
11 | public cvnPresenceIndicator: CvnPresenceIndicator;
12 | public cardHolderName: string;
13 | public cardPresent: boolean;
14 | public readerPresent: boolean;
15 | public serialNumber: string;
16 |
17 | public constructor() {
18 | super();
19 | this.cardPresent = false;
20 | this.readerPresent = false;
21 | this.cvnPresenceIndicator = CvnPresenceIndicator.NotRequested;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/PaymentMethods/EBTTrackData.ts:
--------------------------------------------------------------------------------
1 | import { EncryptionData, EntryMethod } from "../";
2 | import { EBT } from "./EBT";
3 | import { IEncryptable, ITrackData } from "./Interfaces";
4 |
5 | export class EBTTrackData extends EBT implements ITrackData, IEncryptable {
6 | public encryptionData: EncryptionData;
7 | public entryMethod: EntryMethod;
8 | public value: string;
9 | }
10 |
--------------------------------------------------------------------------------
/src/PaymentMethods/ECheck.ts:
--------------------------------------------------------------------------------
1 | import {
2 | AccountType,
3 | Address,
4 | AuthorizationBuilder,
5 | CheckType,
6 | EntryMethod,
7 | PaymentMethodType,
8 | SecCode,
9 | TransactionType,
10 | } from "../";
11 | import { IChargable } from "./Interfaces";
12 | import { PaymentMethod } from "./PaymentMethod";
13 |
14 | export class ECheck extends PaymentMethod implements IChargable {
15 | public accountNumber: string;
16 | public accountType: AccountType;
17 | public achVerify: boolean;
18 | public birthYear: string;
19 | public bankAddress: Address;
20 | public checkHolderName: string;
21 | public checkName: string;
22 | public checkNumber: string;
23 | public checkType: CheckType;
24 | public checkVerify: boolean;
25 | public driversLicenseNumber: string;
26 | public driversLicenseState: string;
27 | public entryMode: EntryMethod;
28 | public micrNumber: string;
29 | public paymentMethodType = PaymentMethodType.ACH;
30 | public phoneNumber: string;
31 | public routingNumber: string;
32 | public secCode: SecCode;
33 | public ssnLast4: string;
34 | public token: string;
35 |
36 | /**
37 | * Authorizes the payment method and captures the entire authorized amount
38 | *
39 | * @param string|number amount Amount to authorize
40 | *
41 | * @return AuthorizationBuilder
42 | */
43 | public charge(amount?: string | number) {
44 | return new AuthorizationBuilder(TransactionType.Sale, this).withAmount(
45 | amount,
46 | );
47 | }
48 |
49 | /**
50 | * Refunds the payment method
51 | *
52 | * @param string|number amount Amount to authorize
53 | *
54 | * @return AuthorizationBuilder
55 | */
56 | public refund(amount?: string | number) {
57 | return new AuthorizationBuilder(TransactionType.Refund, this).withAmount(
58 | amount,
59 | );
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/PaymentMethods/Interfaces.ts:
--------------------------------------------------------------------------------
1 | import {
2 | AuthorizationBuilder,
3 | CvnPresenceIndicator,
4 | EncryptionData,
5 | EntryMethod,
6 | InquiryType,
7 | ManagementBuilder,
8 | PaymentMethodType,
9 | Transaction,
10 | } from "../";
11 |
12 | export interface IAuthable {
13 | authorize(amount?: string | number): AuthorizationBuilder;
14 | }
15 |
16 | export interface IBalanceable {
17 | balanceInquiry(inquiry?: InquiryType): AuthorizationBuilder;
18 | }
19 |
20 | export interface ICardData {
21 | number: string;
22 | expMonth: string;
23 | expYear: string;
24 | cvn: string;
25 | cvnPresenceIndicator: CvnPresenceIndicator;
26 | cardHolderName: string;
27 | cardPresent: boolean;
28 | readerPresent: boolean;
29 | }
30 |
31 | export interface IChargable {
32 | charge(amount?: string | number): AuthorizationBuilder;
33 | }
34 |
35 | export interface IEditable {
36 | edit(amount?: string | number): AuthorizationBuilder;
37 | }
38 |
39 | export interface IEncryptable {
40 | encryptionData: EncryptionData;
41 | }
42 |
43 | export interface IPaymentMethod {
44 | paymentMethodType: PaymentMethodType;
45 | }
46 |
47 | export interface IPinProtected {
48 | pinBlock: string;
49 | }
50 |
51 | export interface IPrePayable {
52 | addValue(amount?: string | number): AuthorizationBuilder;
53 | }
54 |
55 | export interface IRefundable {
56 | refund(amount?: string | number): AuthorizationBuilder;
57 | }
58 |
59 | export interface IReversable {
60 | reverse(amount?: string | number): AuthorizationBuilder;
61 | }
62 |
63 | export interface ITokenizable {
64 | token: string;
65 | tokenize(): AuthorizationBuilder;
66 | updateTokenExpiry(): Promise;
67 | deleteToken(): Promise;
68 | detokenize(): Promise;
69 | updateToken(): ManagementBuilder;
70 | }
71 |
72 | export interface ITrackData {
73 | value: string;
74 | entryMethod: EntryMethod;
75 | }
76 |
77 | export interface IVerifyable {
78 | verify(): AuthorizationBuilder;
79 | }
80 |
81 | export interface IVoidable {
82 | void(): ManagementBuilder;
83 | }
84 |
85 | export interface ISecure3d {}
86 |
87 | export interface ISecureCheck {}
88 |
--------------------------------------------------------------------------------
/src/PaymentMethods/TransactionReference.ts:
--------------------------------------------------------------------------------
1 | import {
2 | AlternativePaymentResponse,
3 | IPaymentMethod,
4 | PaymentMethodType,
5 | } from "../";
6 |
7 | export class TransactionReference implements IPaymentMethod {
8 | public authCode: string;
9 | public orderId: string;
10 | public transactionId: string;
11 | public declare paymentMethodType: PaymentMethodType;
12 | public clientTransactionId: string;
13 | public alternativePaymentResponse: AlternativePaymentResponse;
14 | [key: string]: any;
15 |
16 | public constructor(transactionId?: string) {
17 | if (transactionId) {
18 | this.transactionId = transactionId;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/PaymentMethods/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./AlternativePaymentMethod";
2 | export * from "./Cash";
3 | export * from "./Credit";
4 | export * from "./CreditCardData";
5 | export * from "./CreditTrackData";
6 | export * from "./Debit";
7 | export * from "./DebitTrackData";
8 | export * from "./EBT";
9 | export * from "./EBTCardData";
10 | export * from "./EBTTrackData";
11 | export * from "./ECheck";
12 | export * from "./GiftCard";
13 | export * from "./Interfaces";
14 | export * from "./PaymentMethod";
15 | export * from "./RecurringPaymentMethod";
16 | export * from "./Interfaces";
17 | export * from "./TransactionReference";
18 |
--------------------------------------------------------------------------------
/src/ServiceConfigs/AcceptorConfig.ts:
--------------------------------------------------------------------------------
1 | import {
2 | CardDataInputCapability,
3 | CardDataOutputCapability,
4 | CardHolderAuthenticationCapability,
5 | CardHolderAuthenticationEntity,
6 | } from "../../src/Entities";
7 |
8 | export class AcceptorConfig {
9 | /**
10 | * Used w/TransIT
11 | */
12 | public cardCaptureCapability: boolean;
13 |
14 | /**
15 | * Used w/TransIT
16 | */
17 | public cardDataInputCapability: CardDataInputCapability;
18 |
19 | /**
20 | * Used w/TransIT
21 | */
22 | public cardDataOutputCapability: CardDataOutputCapability;
23 |
24 | /**
25 | * Used w/TransIT; corresponding tag will default to eComm or Manual if this isn't used
26 | */
27 | public cardDataSource: unknown;
28 |
29 | /**
30 | * Used w/TransIT
31 | */
32 | public cardHolderAuthenticationCapability: CardHolderAuthenticationCapability;
33 |
34 | /**
35 | * Used w/TransIT
36 | */
37 | public cardHolderAuthenticationEntity: CardHolderAuthenticationEntity;
38 |
39 | constructor(
40 | cardCaptureCapability = false,
41 | cardDataInputCapability = CardDataInputCapability.KeyedEntryOnly,
42 | cardDataOutputCapability = CardDataOutputCapability.None,
43 | cardHolderAuthenticationCapability = CardHolderAuthenticationCapability.NoCapability,
44 | cardHolderAuthenticationEntity = CardHolderAuthenticationEntity.NotAuthenticated,
45 | ) {
46 | this.cardCaptureCapability = cardCaptureCapability;
47 | this.cardDataInputCapability = cardDataInputCapability;
48 | this.cardDataOutputCapability = cardDataOutputCapability;
49 | this.cardHolderAuthenticationCapability =
50 | cardHolderAuthenticationCapability;
51 | this.cardHolderAuthenticationEntity = cardHolderAuthenticationEntity;
52 | }
53 |
54 | public validate() {
55 | // for use in future gateway integrations
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/ServiceConfigs/Configuration.ts:
--------------------------------------------------------------------------------
1 | import { ConfiguredServices } from "src/ConfiguredServices";
2 | import { Environment, IRequestLogger } from "../../src/Entities/";
3 |
4 | export abstract class Configuration {
5 | public timeout: number = 65000;
6 |
7 | public environment: Environment = Environment.Test;
8 |
9 | public requestLogger: IRequestLogger;
10 |
11 | public serviceUrl: string;
12 |
13 | public validated: boolean;
14 |
15 | public webProxy: unknown;
16 |
17 | public enableLogging: boolean;
18 |
19 | public forceGatewayTimeout: boolean;
20 |
21 | public dynamicHeaders: Record;
22 |
23 | public abstract configureContainer(services: ConfiguredServices): void;
24 |
25 | public validate() {
26 | this.validated = true;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/ServiceConfigs/Gateways/GatewayConfig.ts:
--------------------------------------------------------------------------------
1 | import { GatewayProvider } from "../../../src/Entities";
2 | import { AcceptorConfig } from "../AcceptorConfig";
3 | import { Configuration } from "../Configuration";
4 |
5 | export abstract class GatewayConfig extends Configuration {
6 | public acceptorConfig: AcceptorConfig;
7 |
8 | protected _gatewayProvider: GatewayProvider;
9 |
10 | public dataClientId: string;
11 |
12 | public dataClientSecret: string;
13 |
14 | public dataClientUserId: string;
15 |
16 | public dataClientSeviceUrl: string;
17 |
18 | constructor(provider: GatewayProvider) {
19 | super();
20 | this._gatewayProvider = provider;
21 | }
22 |
23 | // public configureContainer(services)
24 | // {
25 | // // need to implement dataServicesConnector
26 | // }
27 |
28 | public validate() {
29 | super.validate();
30 |
31 | return;
32 | // data client validations go here when enabled
33 | }
34 |
35 | get gatewayProvider() {
36 | return this._gatewayProvider;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/ServiceConfigs/Gateways/GpApiConfig.ts:
--------------------------------------------------------------------------------
1 | import {
2 | AccessTokenInfo,
3 | Channel,
4 | ConfigurationError,
5 | Environment,
6 | GatewayProvider,
7 | IntervalToExpire,
8 | ServiceEndpoints,
9 | } from "../../../src/Entities";
10 | import { GatewayConfig } from "./GatewayConfig";
11 | import { ConfiguredServices } from "../../../src/ConfiguredServices";
12 | import { GpApiConnector, Secure3dVersion } from "../../../src";
13 |
14 | export class GpApiConfig extends GatewayConfig {
15 | public appId: string;
16 |
17 | public appKey: string;
18 |
19 | public accessTokenInfo: AccessTokenInfo;
20 |
21 | public country: string = "US";
22 |
23 | public channel: Channel;
24 |
25 | public secondsToExpire: number;
26 |
27 | public intervalToExpire: IntervalToExpire;
28 |
29 | public methodNotificationUrl: string;
30 |
31 | public challengeNotificationUrl: string;
32 |
33 | public merchantContactUrl: string;
34 |
35 | public permissions: string[];
36 |
37 | public merchantId: string;
38 |
39 | public deviceCurrency: string;
40 |
41 | constructor() {
42 | super(GatewayProvider.GpApi);
43 | }
44 |
45 | public configureContainer(services: ConfiguredServices) {
46 | if (!this.serviceUrl) {
47 | this.serviceUrl =
48 | this.environment == Environment.Production
49 | ? ServiceEndpoints.GP_API_PRODUCTION
50 | : ServiceEndpoints.GP_API_TEST;
51 | }
52 |
53 | const gateway = new GpApiConnector(this);
54 | gateway.serviceUrl = this.serviceUrl;
55 | gateway.requestLogger = this.requestLogger;
56 |
57 | services.gatewayConnector = gateway;
58 | services.reportingService = gateway;
59 | services.setSecure3dProvider(Secure3dVersion.ONE, gateway);
60 | services.setSecure3dProvider(Secure3dVersion.TWO, gateway);
61 | }
62 |
63 | public validate() {
64 | super.validate();
65 |
66 | if (!this.accessTokenInfo && (!this.appId || !this.appKey)) {
67 | throw new ConfigurationError(
68 | "AccessTokenInfo or AppId and AppKey cannot be null",
69 | );
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/ServiceConfigs/Gateways/GpEcomConfig.ts:
--------------------------------------------------------------------------------
1 | import {
2 | ConfigurationError,
3 | Environment,
4 | GatewayProvider,
5 | ServiceEndpoints,
6 | ShaHashType,
7 | } from "../../../src/Entities";
8 | import { GatewayConfig } from "./GatewayConfig";
9 | import { GpEcomConnector } from "../../../src/Gateways/";
10 | import { HostedPaymentConfig } from "../../../src";
11 | import { ConfiguredServices } from "../../../src/ConfiguredServices";
12 |
13 | export class GpEcomConfig extends GatewayConfig {
14 | public accountId: string;
15 | public merchantId: string;
16 | public rebatePassword: string;
17 | public refundPassword: string;
18 | public sharedSecret: string;
19 | public channel: string;
20 | public hostedPaymentConfig: HostedPaymentConfig;
21 | public shaHashType = ShaHashType.SHA1;
22 |
23 | // Secure 3D
24 | public challengeNotificationUrl: string;
25 | public methodNotificationUrl: string;
26 | public merchantContactUrl: string;
27 | public merchantNotificationUrl: string;
28 |
29 | constructor() {
30 | super(GatewayProvider.GpEcom);
31 | }
32 |
33 | public configureContainer(services: ConfiguredServices) {
34 | // parent::configureContainer(services); // must implement data services first
35 |
36 | if (!this.serviceUrl) {
37 | this.serviceUrl =
38 | this.environment == Environment.Test
39 | ? ServiceEndpoints.GLOBAL_ECOM_TEST
40 | : ServiceEndpoints.GLOBAL_ECOM_PRODUCTION;
41 | }
42 |
43 | const gateway = new GpEcomConnector(this);
44 | gateway.timeout = this.timeout;
45 | gateway.hostedPaymentConfig = this.hostedPaymentConfig;
46 |
47 | gateway.serviceUrl = this.serviceUrl;
48 | gateway.requestLogger = this.requestLogger;
49 |
50 | services.gatewayConnector = gateway;
51 | services.recurringConnector = gateway;
52 | }
53 |
54 | public validate() {
55 | super.validate();
56 |
57 | if (!this.merchantId) {
58 | throw new ConfigurationError("MerchantId is required for this gateway.");
59 | }
60 |
61 | if (!this.sharedSecret) {
62 | throw new ConfigurationError(
63 | "SharedSecret is required for this gateway.",
64 | );
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/ServiceConfigs/Gateways/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./GatewayConfig";
2 | export * from "./GpApiConfig";
3 | export * from "./GpEcomConfig";
4 | export * from "./PorticoConfig";
5 |
--------------------------------------------------------------------------------
/src/ServiceConfigs/ServicesConfigs.ts:
--------------------------------------------------------------------------------
1 | import { ConnectionConfig } from "src";
2 | import { GatewayConfig } from "./Gateways/GatewayConfig";
3 |
4 | export class ServicesConfigs {
5 | public gatewayConfig: GatewayConfig;
6 |
7 | public deviceConnectionConfig: ConnectionConfig;
8 |
9 | public timeout: number;
10 |
11 | public validate() {
12 | if (this.gatewayConfig !== undefined) {
13 | this.gatewayConfig.validate();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/ServiceConfigs/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./AcceptorConfig";
2 | export * from "./Configuration";
3 | export * from "./Gateways";
4 | export * from "./ServicesConfigs";
5 |
--------------------------------------------------------------------------------
/src/Services/BatchService.ts:
--------------------------------------------------------------------------------
1 | import { BatchSummary, ManagementBuilder, TransactionType } from "../";
2 |
3 | export class BatchService {
4 | public static closeBatch(): Promise {
5 | return new ManagementBuilder(TransactionType.BatchClose)
6 | .execute()
7 | .then(() => {
8 | return new BatchSummary();
9 | });
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Services/CheckService.ts:
--------------------------------------------------------------------------------
1 | import { GatewayConfig } from "src/ServiceConfigs";
2 | import {
3 | AuthorizationBuilder,
4 | ManagementBuilder,
5 | PaymentMethodType,
6 | ServicesContainer,
7 | TransactionReference,
8 | TransactionType,
9 | } from "../";
10 |
11 | export class CheckService {
12 | constructor(config: GatewayConfig, configName: string = "default") {
13 | ServicesContainer.configureService(config, configName);
14 | }
15 |
16 | public charge(amount?: number | string) {
17 | return new AuthorizationBuilder(TransactionType.Sale).withAmount(amount);
18 | }
19 |
20 | public void(transactionId: string) {
21 | const ref = new TransactionReference();
22 | ref.paymentMethodType = PaymentMethodType.ACH;
23 | ref.transactionId = transactionId;
24 | return new ManagementBuilder(TransactionType.Void).withPaymentMethod(ref);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Services/CreditService.ts:
--------------------------------------------------------------------------------
1 | import { GatewayConfig } from "src/ServiceConfigs";
2 | import {
3 | AuthorizationBuilder,
4 | ManagementBuilder,
5 | PaymentMethodType,
6 | ServicesContainer,
7 | TransactionReference,
8 | TransactionType,
9 | } from "../";
10 |
11 | export class CreditService {
12 | constructor(config: GatewayConfig, configName: string = "default") {
13 | ServicesContainer.configureService(config, configName);
14 | }
15 |
16 | public authorize(amount?: number | string) {
17 | return new AuthorizationBuilder(TransactionType.Auth).withAmount(amount);
18 | }
19 |
20 | public capture(transactionId: string) {
21 | const ref = new TransactionReference();
22 | ref.paymentMethodType = PaymentMethodType.Credit;
23 | ref.transactionId = transactionId;
24 | return new ManagementBuilder(TransactionType.Capture).withPaymentMethod(
25 | ref,
26 | );
27 | }
28 |
29 | public charge(amount?: number | string) {
30 | return new AuthorizationBuilder(TransactionType.Sale).withAmount(amount);
31 | }
32 |
33 | public edit(transactionId?: string) {
34 | const ref = new TransactionReference();
35 | ref.paymentMethodType = PaymentMethodType.Credit;
36 | if (transactionId) {
37 | ref.transactionId = transactionId;
38 | }
39 | return new ManagementBuilder(TransactionType.Edit).withPaymentMethod(ref);
40 | }
41 |
42 | public refund(amount?: number | string) {
43 | const ref = new TransactionReference();
44 | ref.paymentMethodType = PaymentMethodType.Credit;
45 | return new AuthorizationBuilder(TransactionType.Refund)
46 | .withAmount(amount)
47 | .withPaymentMethod(ref);
48 | }
49 |
50 | public reverse(amount?: number | string) {
51 | const ref = new TransactionReference();
52 | ref.paymentMethodType = PaymentMethodType.Credit;
53 | return new AuthorizationBuilder(TransactionType.Reversal)
54 | .withAmount(amount)
55 | .withPaymentMethod(ref);
56 | }
57 |
58 | public verify() {
59 | return new AuthorizationBuilder(TransactionType.Verify);
60 | }
61 |
62 | public void(transactionId: string) {
63 | const ref = new TransactionReference();
64 | ref.paymentMethodType = PaymentMethodType.Credit;
65 | ref.transactionId = transactionId;
66 | return new ManagementBuilder(TransactionType.Void).withPaymentMethod(ref);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/Services/DebitService.ts:
--------------------------------------------------------------------------------
1 | import { GatewayConfig } from "src/ServiceConfigs";
2 | import {
3 | AuthorizationBuilder,
4 | PaymentMethodType,
5 | ServicesContainer,
6 | TransactionReference,
7 | TransactionType,
8 | } from "../";
9 |
10 | export class DebitService {
11 | constructor(config: GatewayConfig, configName: string = "default") {
12 | ServicesContainer.configureService(config, configName);
13 | }
14 |
15 | public charge(amount?: number | string) {
16 | return new AuthorizationBuilder(TransactionType.Sale).withAmount(amount);
17 | }
18 |
19 | public refund(amount?: number | string) {
20 | const ref = new TransactionReference();
21 | ref.paymentMethodType = PaymentMethodType.Debit;
22 | return new AuthorizationBuilder(TransactionType.Refund)
23 | .withAmount(amount)
24 | .withPaymentMethod(ref);
25 | }
26 |
27 | public reverse(amount?: number | string) {
28 | const ref = new TransactionReference();
29 | ref.paymentMethodType = PaymentMethodType.Debit;
30 | return new AuthorizationBuilder(TransactionType.Reversal)
31 | .withAmount(amount)
32 | .withPaymentMethod(ref);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Services/DeviceService.ts:
--------------------------------------------------------------------------------
1 | import {
2 | ConnectionConfig,
3 | IDeviceInterface,
4 | ServicesContainer,
5 | } from "../../src";
6 |
7 | export class DeviceService {
8 | public static create(
9 | config: ConnectionConfig,
10 | configName: string = "default",
11 | ): IDeviceInterface {
12 | ServicesContainer.configureService(config, configName);
13 | if (config.gatewayConfig != null) {
14 | config.setConfigName(configName);
15 | ServicesContainer.configureService(config.gatewayConfig, configName);
16 | }
17 | return ServicesContainer.instance().getDeviceInterface(configName);
18 | }
19 |
20 | public static findDeviceController(
21 | configName: string = "default",
22 | ): IDeviceInterface {
23 | return ServicesContainer.instance().getDeviceInterface(configName);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Services/EBTService.ts:
--------------------------------------------------------------------------------
1 | import { GatewayConfig } from "src/ServiceConfigs";
2 | import {
3 | AuthorizationBuilder,
4 | InquiryType,
5 | PaymentMethodType,
6 | ServicesContainer,
7 | TransactionReference,
8 | TransactionType,
9 | } from "../";
10 |
11 | export class EBTService {
12 | constructor(config: GatewayConfig, configName: string = "default") {
13 | ServicesContainer.configureService(config, configName);
14 | }
15 |
16 | public balanceInquiry(type = InquiryType.Foodstamp) {
17 | return new AuthorizationBuilder(TransactionType.Balance)
18 | .withBalanceInquiryType(type)
19 | .withAmount(0);
20 | }
21 |
22 | public benefitWithdrawal(amount?: number | string) {
23 | return new AuthorizationBuilder(TransactionType.BenefitWithDrawal)
24 | .withAmount(amount)
25 | .withCashBack(0);
26 | }
27 |
28 | public charge(amount?: number | string) {
29 | return new AuthorizationBuilder(TransactionType.Sale).withAmount(amount);
30 | }
31 |
32 | public refund(amount?: number | string) {
33 | const ref = new TransactionReference();
34 | ref.paymentMethodType = PaymentMethodType.EBT;
35 | return new AuthorizationBuilder(TransactionType.Refund)
36 | .withAmount(amount)
37 | .withPaymentMethod(ref);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/Services/GiftService.ts:
--------------------------------------------------------------------------------
1 | import { GatewayConfig } from "src/ServiceConfigs";
2 | import {
3 | AliasAction,
4 | AuthorizationBuilder,
5 | GiftCard,
6 | InquiryType,
7 | ManagementBuilder,
8 | PaymentMethodType,
9 | ServicesContainer,
10 | TransactionReference,
11 | TransactionType,
12 | } from "../";
13 |
14 | export class GiftService {
15 | constructor(config: GatewayConfig, configName: string = "default") {
16 | ServicesContainer.configureService(config, configName);
17 | }
18 |
19 | public activate(amount?: number | string) {
20 | return new AuthorizationBuilder(TransactionType.Activate).withAmount(
21 | amount,
22 | );
23 | }
24 |
25 | public addValue(amount?: number | string) {
26 | return new AuthorizationBuilder(TransactionType.AddValue).withAmount(
27 | amount,
28 | );
29 | }
30 |
31 | public addAlias(phoneNumber: string) {
32 | return new AuthorizationBuilder(TransactionType.Alias).withAlias(
33 | AliasAction.Add,
34 | phoneNumber,
35 | );
36 | }
37 |
38 | public balanceInquiry(type?: InquiryType) {
39 | return new AuthorizationBuilder(
40 | TransactionType.Balance,
41 | ).withBalanceInquiryType(type);
42 | }
43 |
44 | public charge(amount?: number | string) {
45 | return new AuthorizationBuilder(TransactionType.Sale).withAmount(amount);
46 | }
47 |
48 | public create(phoneNumber: string) {
49 | return GiftCard.create(phoneNumber);
50 | }
51 |
52 | public deactivate() {
53 | return new AuthorizationBuilder(TransactionType.Deactivate);
54 | }
55 |
56 | public removeAlias(phoneNumber: string) {
57 | return new AuthorizationBuilder(TransactionType.Alias).withAlias(
58 | AliasAction.Delete,
59 | phoneNumber,
60 | );
61 | }
62 |
63 | public replaceWith(newCard: GiftCard) {
64 | return new AuthorizationBuilder(
65 | TransactionType.Replace,
66 | ).withReplacementCard(newCard);
67 | }
68 |
69 | public reverse(amount?: number | string) {
70 | const ref = new TransactionReference();
71 | ref.paymentMethodType = PaymentMethodType.Gift;
72 | return new AuthorizationBuilder(TransactionType.Reversal)
73 | .withAmount(amount)
74 | .withPaymentMethod(ref);
75 | }
76 |
77 | public rewards(amount?: number | string) {
78 | return new AuthorizationBuilder(TransactionType.Reward).withAmount(amount);
79 | }
80 |
81 | public void(transactionId: string) {
82 | const ref = new TransactionReference();
83 | ref.paymentMethodType = PaymentMethodType.Gift;
84 | ref.transactionId = transactionId;
85 | return new ManagementBuilder(TransactionType.Void).withPaymentMethod(ref);
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/Services/GpApiServices.ts:
--------------------------------------------------------------------------------
1 | import {
2 | AccessTokenInfo,
3 | Environment,
4 | GpApiConfig,
5 | GpApiConnector,
6 | ServiceEndpoints,
7 | } from "../../src";
8 |
9 | export class GpApiService {
10 | public static async generateTransactionKey(config: GpApiConfig) {
11 | const gateway = new GpApiConnector(config);
12 | if (!gateway.serviceUrl) {
13 | gateway.serviceUrl =
14 | config.environment == Environment.Production
15 | ? ServiceEndpoints.GP_API_PRODUCTION
16 | : ServiceEndpoints.GP_API_TEST;
17 | }
18 |
19 | gateway.requestLogger = config.requestLogger;
20 |
21 | // TODO to be backfilled when implemented
22 | // gateway.webProxy = config.webProxy;
23 | // gateway.dynamicHeaders = config.dynamicHeaders;
24 |
25 | const data = await gateway.getAccessToken();
26 |
27 | const accessTokenInfo = new AccessTokenInfo();
28 | accessTokenInfo.accessToken = data.token;
29 | accessTokenInfo.dataAccountName = data.getDataAccountName();
30 | accessTokenInfo.disputeManagementAccountName =
31 | data.getDisputeManagementAccountName();
32 | accessTokenInfo.transactionProcessingAccountName =
33 | data.getTransactionProcessingAccountName();
34 | accessTokenInfo.tokenizationAccountName = data.getTokenizationAccountName();
35 | accessTokenInfo.riskAssessmentAccountName =
36 | data.getRiskAssessmentAccountName();
37 | accessTokenInfo.merchantManagementAccountName =
38 | data.getMerchantManagementAccountName();
39 | accessTokenInfo.dataAccountID = data.getDataAccountID();
40 | accessTokenInfo.disputeManagementAccountID =
41 | data.getDisputeManagementAccountID();
42 | accessTokenInfo.transactionProcessingAccountID =
43 | data.getTransactionProcessingAccountID();
44 | accessTokenInfo.tokenizationAccountID = data.getTokenizationAccountID();
45 | accessTokenInfo.riskAssessmentAccountID = data.getRiskAssessmentAccountID();
46 | accessTokenInfo.merchantManagementAccountID =
47 | data.getMerchantManagementAccountID();
48 |
49 | return accessTokenInfo;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/Services/RecurringService.ts:
--------------------------------------------------------------------------------
1 | import { IRecurringEntity, RecurringBuilder, TransactionType } from "../";
2 |
3 | export class RecurringService {
4 | public static create(
5 | entity: T,
6 | configName: string = "default",
7 | ) {
8 | return new RecurringBuilder(TransactionType.Create, entity).execute(
9 | configName,
10 | );
11 | }
12 |
13 | public static delete(
14 | entity: T,
15 | configName: string = "default",
16 | ) {
17 | return new RecurringBuilder(TransactionType.Delete, entity).execute(
18 | configName,
19 | );
20 | }
21 |
22 | public static edit(
23 | entity: T,
24 | configName: string = "default",
25 | ) {
26 | return new RecurringBuilder(TransactionType.Edit, entity).execute(
27 | configName,
28 | );
29 | }
30 |
31 | public static get(
32 | key: string,
33 | configName: string = "default",
34 | ) {
35 | const entity = key;
36 | return new RecurringBuilder(
37 | TransactionType.Fetch,
38 | entity as any as T,
39 | ).execute(configName);
40 | }
41 |
42 | public static search(
43 | enity: IRecurringEntity | Function,
44 | ) {
45 | return new RecurringBuilder(TransactionType.Search, enity);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/Services/Secure3dService.ts:
--------------------------------------------------------------------------------
1 | import { Secure3dBuilder } from "../";
2 | import { ThreeDSecure, TransactionType } from "../Entities";
3 | import { PaymentMethod } from "../PaymentMethods";
4 |
5 | export class Secure3dService {
6 | static checkEnrollment(paymentMethod: PaymentMethod): Secure3dBuilder {
7 | return new Secure3dBuilder(
8 | TransactionType.VerifyEnrolled,
9 | ).withPaymentMethod(paymentMethod);
10 | }
11 |
12 | static initiateAuthentication(
13 | paymentMethod: PaymentMethod,
14 | secureEcom: ThreeDSecure,
15 | ): Secure3dBuilder {
16 | if (paymentMethod.isSecure3d) {
17 | paymentMethod.threeDSecure = secureEcom;
18 | }
19 | return new Secure3dBuilder(
20 | TransactionType.InitiateAuthentication,
21 | ).withPaymentMethod(paymentMethod);
22 | }
23 |
24 | static getAuthenticationData(): Secure3dBuilder {
25 | return new Secure3dBuilder(TransactionType.VerifySignature);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Services/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./BatchService";
2 | export * from "./CheckService";
3 | export * from "./CreditService";
4 | export * from "./DebitService";
5 | export * from "./EBTService";
6 | export * from "./GiftService";
7 | export * from "./GpApiServices";
8 | export * from "./HostedService";
9 | export * from "./RecurringService";
10 | export * from "./ReportingService";
11 | export * from "./Secure3dService";
12 |
--------------------------------------------------------------------------------
/src/Terminals/Abstractions/IDeviceCommInterface.ts:
--------------------------------------------------------------------------------
1 | export interface IDeviceCommInterface {
2 | connect(): unknown;
3 |
4 | disconnect(): unknown;
5 |
6 | send(message: any, requestType?: string): unknown;
7 |
8 | parseResponse(gatewayResponse: any): unknown;
9 | }
10 |
--------------------------------------------------------------------------------
/src/Terminals/Abstractions/IDeviceInterface.ts:
--------------------------------------------------------------------------------
1 | import { IDeviceResponse } from ".";
2 | import { TerminalAuthBuilder, TerminalManageBuilder } from "../Builders";
3 |
4 | export interface IDeviceInterface {
5 | ecrId: string;
6 |
7 | lineItem(
8 | leftText: string,
9 | rightText?: string,
10 | runningLeftText?: string,
11 | runningRightText?: string,
12 | ): Promise;
13 |
14 | //region Generic Calls
15 | authorize(amount?: number): TerminalAuthBuilder;
16 | capture(amount?: number): TerminalManageBuilder;
17 | refund(amount?: number): TerminalAuthBuilder;
18 | refundById(amount: number): TerminalManageBuilder;
19 | sale(amount?: number): TerminalAuthBuilder;
20 | verify(): TerminalAuthBuilder;
21 | void(): TerminalManageBuilder;
22 | //endregion
23 | }
24 |
--------------------------------------------------------------------------------
/src/Terminals/Abstractions/IDeviceMessage.ts:
--------------------------------------------------------------------------------
1 | export interface IDeviceMessage {
2 | getSendBuffer(): Buffer;
3 | }
4 |
--------------------------------------------------------------------------------
/src/Terminals/Abstractions/IDeviceResponse.ts:
--------------------------------------------------------------------------------
1 | import { ApplicationCryptogramType } from "../../../src";
2 |
3 | export interface IDeviceResponse {
4 | status: string;
5 | command: string;
6 | version: string;
7 | deviceResponseCode: string;
8 | deviceResponseText: string;
9 | referenceNumber: string;
10 | toString(): string;
11 | }
12 |
13 | export interface ITerminalResponse extends IDeviceResponse {
14 | responseCode: string;
15 | responseText: string;
16 | transactionId: string;
17 | terminalRefNumber: string;
18 | token: string;
19 | signatureStatus: string;
20 | signatureData: Buffer;
21 | transactionType: string;
22 | maskedCardNumber: string;
23 | entryMethod: string;
24 | authorizationCode: string;
25 | approvalCode: string;
26 | transactionAmount: number;
27 | amountDue: number;
28 | balanceAmount: number;
29 | cardHolderName: string;
30 | cardBIN: string;
31 | cardPresent: boolean;
32 | expirationDate: string;
33 | tipAmount?: number;
34 | cashBackAmount?: number;
35 | avsResponseCode: string;
36 | avsResponseText: string;
37 | cvvResponseCode: string;
38 | cvvResponseText: string;
39 | taxExempt: boolean;
40 | taxExemptId: string;
41 | ticketNumber: string;
42 | paymentType: string;
43 | applicationPreferredName: string;
44 | applicationLabel: string;
45 | applicationId: string;
46 | applicationCryptogramType: ApplicationCryptogramType;
47 | applicationCryptogram: string;
48 | cardHolderVerificationMethod: string;
49 | terminalVerificationResults: string;
50 | merchantFee?: number;
51 | }
52 |
53 | export interface ITerminalReport extends IDeviceResponse {}
54 |
--------------------------------------------------------------------------------
/src/Terminals/Abstractions/IRequestIdProvider.ts:
--------------------------------------------------------------------------------
1 | export interface IRequestIdProvider {
2 | getRequestId(): number;
3 | }
4 |
--------------------------------------------------------------------------------
/src/Terminals/Abstractions/IRequestSubGroup.ts:
--------------------------------------------------------------------------------
1 | export interface IRequestSubGroup {
2 | getElementString(): Record;
3 | }
4 |
--------------------------------------------------------------------------------
/src/Terminals/Abstractions/ITerminalConfiguration.ts:
--------------------------------------------------------------------------------
1 | import { DeviceType, GatewayConfig } from "../../../src";
2 | import { ConnectionModes, Parity } from "../Enums";
3 | import { IRequestIdProvider } from ".";
4 |
5 | export interface ITerminalConfiguration {
6 | connectionMode: ConnectionModes;
7 | deviceType: DeviceType;
8 | requestIdProvider: IRequestIdProvider;
9 |
10 | // Ethernet
11 | ipAddress: string;
12 | port: string;
13 |
14 | // Serial
15 | parity: Parity;
16 |
17 | // Timeout
18 | timeout: number;
19 |
20 | // Associated Gateway
21 | gatewayConfig: GatewayConfig;
22 |
23 | getGatewayConfig(): GatewayConfig;
24 |
25 | setConfigName(configName: string): void;
26 |
27 | getConfigName(): string;
28 | }
29 |
--------------------------------------------------------------------------------
/src/Terminals/Abstractions/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./IDeviceCommInterface";
2 | export * from "./IDeviceInterface";
3 | export * from "./IDeviceMessage";
4 | export * from "./IDeviceResponse";
5 | export * from "./IRequestIdProvider";
6 | export * from "./IRequestSubGroup";
7 | export * from "./ITerminalConfiguration";
8 |
--------------------------------------------------------------------------------
/src/Terminals/Builders/TerminalBuilder.ts:
--------------------------------------------------------------------------------
1 | import {
2 | ITerminalResponse,
3 | PaymentMethodType,
4 | TransactionBuilder,
5 | TransactionType,
6 | } from "../../../src";
7 |
8 | export abstract class TerminalBuilder extends TransactionBuilder {
9 | paymentMethodType?: PaymentMethodType;
10 | referenceNumber: number;
11 | ecrId: number;
12 | clerkNumber: string;
13 |
14 | public withPaymentMethodType(value: PaymentMethodType) {
15 | this.paymentMethodType = value;
16 | return this;
17 | }
18 | public withReferenceNumber(value: number) {
19 | this.referenceNumber = value;
20 | return this;
21 | }
22 | public withRequestId(value: number) {
23 | this.referenceNumber = value;
24 | return this;
25 | }
26 | public withClerkNumber(value: string) {
27 | this.clerkNumber = value;
28 | return this;
29 | }
30 |
31 | constructor(type: TransactionType, paymentType?: PaymentMethodType) {
32 | super(type);
33 | this.paymentMethodType = paymentType;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/Terminals/Builders/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./TerminalAuthBuilder";
2 | export * from "./TerminalManageBuilder";
3 |
--------------------------------------------------------------------------------
/src/Terminals/ConnectionConfig.ts:
--------------------------------------------------------------------------------
1 | import { ApiError, Configuration, DeviceType, GatewayConfig } from "../../src";
2 | import { IRequestIdProvider, ITerminalConfiguration } from "./Abstractions";
3 | import { ConnectionModes, Parity } from "./Enums";
4 | import { ConfiguredServices } from "../../src/ConfiguredServices";
5 | import { UpaController } from "./UPA";
6 |
7 | export class ConnectionConfig
8 | extends Configuration
9 | implements ITerminalConfiguration
10 | {
11 | public deviceType: DeviceType;
12 | public connectionMode: ConnectionModes;
13 | public parity: Parity;
14 | public ipAddress: string;
15 | public port: string;
16 | public requestIdProvider: IRequestIdProvider;
17 | public gatewayConfig: GatewayConfig;
18 | public configName: string;
19 |
20 | public connectionConfig() {
21 | this.timeout = -1;
22 | }
23 |
24 | public configureContainer(services: ConfiguredServices) {
25 | switch (this.deviceType) {
26 | case DeviceType.UPA_DEVICE:
27 | services.deviceController = new UpaController(this);
28 | break;
29 | default:
30 | break;
31 | }
32 | }
33 | getGatewayConfig(): GatewayConfig {
34 | return this.gatewayConfig;
35 | }
36 |
37 | setConfigName(configName: string) {
38 | this.configName = configName;
39 | }
40 |
41 | getConfigName(): string {
42 | return this.configName;
43 | }
44 |
45 | public validate() {
46 | super.validate();
47 |
48 | if (
49 | this.connectionMode == ConnectionModes.TCP_IP ||
50 | this.connectionMode == ConnectionModes.HTTP
51 | ) {
52 | if (!this.ipAddress)
53 | throw new ApiError(
54 | "IpAddress is required for TCP or HTTP communication modes.",
55 | );
56 | if (!this.port)
57 | throw new ApiError(
58 | "Port is required for TCP or HTTP communication modes.",
59 | );
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/Terminals/DeviceController.ts:
--------------------------------------------------------------------------------
1 | import { DeviceType } from "../../src";
2 | import {
3 | IDeviceCommInterface,
4 | IDeviceInterface,
5 | IRequestIdProvider,
6 | ITerminalConfiguration,
7 | ITerminalResponse,
8 | UpaMessageId,
9 | } from ".";
10 | import { ConnectionModes } from "./Enums";
11 | import { TerminalAuthBuilder } from "./Builders/TerminalAuthBuilder";
12 | import { TerminalManageBuilder } from "./Builders";
13 | import { DeviceMessage } from "./DeviceMessage";
14 |
15 | export abstract class DeviceController {
16 | protected _interface: IDeviceInterface;
17 | protected _settings: ITerminalConfiguration;
18 | public connector: IDeviceCommInterface;
19 |
20 | public connectionMode: ConnectionModes;
21 | public deviceType: DeviceType;
22 | public requestIdProvider: IRequestIdProvider;
23 |
24 | constructor(settings: ITerminalConfiguration) {
25 | this._settings = settings;
26 | this.connector = this.configureConnector();
27 | }
28 |
29 | public getConnectionMode() {
30 | if (this._settings != null) {
31 | return this._settings.connectionMode;
32 | }
33 | return null;
34 | }
35 |
36 | public getDeviceType() {
37 | if (this._settings != null) {
38 | return this._settings.deviceType;
39 | }
40 | return null;
41 | }
42 |
43 | public getRequestIdProvider() {
44 | if (this._settings != null) {
45 | return this._settings.requestIdProvider;
46 | }
47 | return null;
48 | }
49 |
50 | public send(message: DeviceMessage, requestType?: UpaMessageId): any {
51 | message.awaitResponse = true;
52 | if (this.connector) {
53 | return this.connector.send(message);
54 | }
55 | requestType;
56 | }
57 |
58 | abstract configureConnector(): IDeviceCommInterface;
59 | abstract configureInterface(): IDeviceInterface;
60 |
61 | abstract processTransaction(
62 | builder: TerminalAuthBuilder,
63 | ): Promise;
64 | abstract manageTransaction(
65 | builder: TerminalManageBuilder,
66 | ): Promise;
67 | }
68 |
--------------------------------------------------------------------------------
/src/Terminals/DeviceMessage.ts:
--------------------------------------------------------------------------------
1 | import { IDeviceMessage } from ".";
2 |
3 | export class DeviceMessage implements IDeviceMessage {
4 | public keepAlive: boolean;
5 | public awaitResponse: boolean;
6 | private buffer: Buffer;
7 | private jsonRequest: Record;
8 |
9 | constructor(buffer: Buffer) {
10 | this.buffer = buffer;
11 | }
12 |
13 | public getSendBuffer(): Buffer {
14 | return this.buffer;
15 | }
16 |
17 | public setJsonRequest(jsonRequest: any[]): void {
18 | this.jsonRequest = jsonRequest;
19 | }
20 |
21 | public getJsonRequest(): Record {
22 | return this.jsonRequest;
23 | }
24 |
25 | public toString(): string {
26 | return this.buffer.toString();
27 | }
28 |
29 | public getRequestField(key: string): any {
30 | return this.iterateDeep(this.jsonRequest, key);
31 | }
32 |
33 | private iterateDeep(obj: Record, key: string): any {
34 | if (!this.jsonRequest || typeof this.jsonRequest !== "object") {
35 | return undefined;
36 | }
37 |
38 | if (obj[key]) {
39 | return obj[key];
40 | }
41 |
42 | for (const objectKey in obj) {
43 | if (typeof obj[objectKey] === "object" && obj[objectKey] !== null) {
44 | return this.iterateDeep(obj[objectKey], key);
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/Terminals/DeviceResponse.ts:
--------------------------------------------------------------------------------
1 | import { IDeviceResponse } from ".";
2 |
3 | export abstract class DeviceResponse implements IDeviceResponse {
4 | status: string;
5 | command: string;
6 | version: string;
7 | deviceResponseCode: string;
8 | deviceResponseText: string;
9 | referenceNumber: string;
10 |
11 | constructor() {
12 | this.status = "";
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/Terminals/Enums.ts:
--------------------------------------------------------------------------------
1 | export enum ConnectionModes {
2 | SERIAL,
3 | TCP_IP,
4 | SSL_TCP,
5 | HTTP,
6 | MEET_IN_THE_CLOUD,
7 | }
8 |
9 | export enum Parity {
10 | None = 0,
11 | Odd,
12 | Even,
13 | }
14 |
--------------------------------------------------------------------------------
/src/Terminals/Enums/ControlCodes.ts:
--------------------------------------------------------------------------------
1 | export enum ControlCodes {
2 | STX = 0x02,
3 | ETX = 0x03,
4 | LF = 0x0a,
5 | }
6 |
--------------------------------------------------------------------------------
/src/Terminals/Enums/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./ControlCodes";
2 |
--------------------------------------------------------------------------------
/src/Terminals/SummaryResponse.ts:
--------------------------------------------------------------------------------
1 | import { TransactionSummary } from "../../src";
2 |
3 | export enum SummaryType {
4 | Approved,
5 | PartiallyApproved,
6 | VoidApproved,
7 | Pending,
8 | VoidPending,
9 | Declined,
10 | VoidDeclined,
11 | OfflineApproved,
12 | Provsional,
13 | Discarded,
14 | VoidProvisional,
15 | VoidDiscarded,
16 | Reversal,
17 | EmvDeclined,
18 | Attachment,
19 | Unknown,
20 | }
21 |
22 | export class SummaryResponse {
23 | public amount: number;
24 | public amountDue: number;
25 | public authorizedAmount: number;
26 | public count: number;
27 | public summaryType: SummaryType;
28 | public totalAmountCount: number;
29 | public transactions: TransactionSummary;
30 | }
31 |
--------------------------------------------------------------------------------
/src/Terminals/TerminalResponse.ts:
--------------------------------------------------------------------------------
1 | import { ApplicationCryptogramType } from "src";
2 | import { DeviceResponse } from "./DeviceResponse";
3 |
4 | export class TerminalResponse extends DeviceResponse {
5 | responseCode: string;
6 | responseText: string;
7 | transactionId: string;
8 | terminalRefNumber: string;
9 | token: string;
10 | signatureStatus: string;
11 | signatureData: any;
12 | transactionType: string;
13 | maskedCardNumber: string;
14 | entryMethod: string;
15 | authorizationCode: string;
16 | approvalCode: string;
17 | transactionAmount: number;
18 | amountDue: number;
19 | balanceAmount: number;
20 | cardHolderName: string;
21 | cardBIN: string;
22 | cardPresent: boolean;
23 | expirationDate: string;
24 | tipAmount: number;
25 | cashBackAmount: number;
26 | avsResponseCode: string;
27 | avsResponseText: string;
28 | cvvResponseCode: string;
29 | cvvResponseText: string;
30 | taxExempt: boolean;
31 | taxExemptId: string;
32 | ticketNumber: string;
33 | paymentType: string;
34 | applicationPreferredName: string;
35 | applicationLabel: string;
36 | applicationId: string;
37 | applicationCryptogramType: ApplicationCryptogramType;
38 | applicationCryptogram: string;
39 | cardHolderVerificationMethod: string;
40 | terminalVerificationResults: string;
41 | merchantFee: number;
42 |
43 | constructor() {
44 | super();
45 | this.responseCode = "";
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/Terminals/TerminalUtils.ts:
--------------------------------------------------------------------------------
1 | import { DeviceMessage } from "./DeviceMessage";
2 | import { ControlCodes } from "./Enums/ControlCodes";
3 |
4 | export class TerminalUtils {
5 | public static buildUpaRequest(
6 | requestParams: Record,
7 | ): DeviceMessage {
8 | const buffer: number[] = [];
9 |
10 | // Begin Message
11 | buffer.push(ControlCodes.STX);
12 | buffer.push(ControlCodes.LF);
13 |
14 | // Add the Message
15 | buffer.push(...Array.from(Buffer.from(JSON.stringify(requestParams))));
16 |
17 | // End the Message
18 | buffer.push(ControlCodes.LF);
19 | buffer.push(ControlCodes.ETX);
20 | buffer.push(ControlCodes.LF);
21 |
22 | const deviceMessage = new DeviceMessage(Buffer.from(buffer));
23 | deviceMessage.setJsonRequest(requestParams as any[]);
24 | return deviceMessage;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Terminals/UPA/Entities/UpaMessageId.ts:
--------------------------------------------------------------------------------
1 | export enum UpaMessageId {
2 | SALE = "Sale",
3 | VOID = "Void",
4 | REFUND = "Refund",
5 | EOD = "EODProcessing",
6 | SENDSAF = "SendSAF",
7 | TIPADJUST = "TipAdjust",
8 | CARD_VERIFY = "CardVerify",
9 | GET_SAF_REPORT = "GetSAFReport",
10 | CANCEL = "CancelTransaction",
11 | REBOOT = "Reboot",
12 | LINEITEM = "LineItemDisplay",
13 | REVERSAL = "Reversal",
14 | GET_BATCH_REPORT = "GetBatchReport",
15 | BALANCE_INQUIRY = "BalanceInquiry",
16 | PRE_AUTH = "PreAuth",
17 | AUTH_COMPLETION = "AuthCompletion",
18 | TOKENIZE = "Tokenize",
19 | GET_OPEN_TAB_DETAILS = "GetOpenTabDetails",
20 | }
21 |
--------------------------------------------------------------------------------
/src/Terminals/UPA/Entities/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./UpaMessageId";
2 |
--------------------------------------------------------------------------------
/src/Terminals/UPA/Interfaces/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./UpaMicInterface";
2 |
--------------------------------------------------------------------------------
/src/Terminals/UPA/Reponses/TransactionResponse.ts:
--------------------------------------------------------------------------------
1 | import {
2 | ApplicationCryptogramType,
3 | GatewayProvider,
4 | ITerminalResponse,
5 | NotImplementedError,
6 | } from "../../../../src";
7 |
8 | export class TransactionResponse implements ITerminalResponse {
9 | public availableBalance?: number;
10 | public transactionId: string;
11 | public terminalRefNumber: string;
12 | public token: string;
13 | public cardBrandTransId: string;
14 | public signatureStatus: string;
15 | public signatureData: Buffer;
16 | public transactionType: string;
17 | public maskedCardNumber: string;
18 | public entryMethod: string;
19 | public authorizationCode: string;
20 | public transactionAmount: number;
21 | public amountDue: number;
22 | public balanceAmount: number;
23 | public cardBIN: string;
24 | public cardPresent: boolean;
25 | public expirationDate: string;
26 | public avsResponseCode: string;
27 | public avsResponseText: string;
28 | public cvvResponseCode: string;
29 | public cvvResponseText: string;
30 | public taxExempt: boolean;
31 | public taxExemptId: string;
32 | public ticketNumber: string;
33 | public paymentType: string;
34 | public applicationPreferredName: string;
35 | public applicationLabel: string;
36 | public applicationId: string;
37 | public applicationCryptogramType: ApplicationCryptogramType;
38 | public applicationCryptogram: string;
39 | public cardHolderVerificationMethod: string;
40 | public terminalVerificationResults: string;
41 | public merchantFee?: number;
42 | public status: string;
43 | public command: string;
44 | public version: string;
45 | public deviceResponseCode: string;
46 | public deviceResponseText: string;
47 | public responseCode: string;
48 | public responseText: string;
49 | public approvalCode: string;
50 | public tipAmount?: number;
51 | public baseAmount?: number;
52 | public cashBackAmount?: number;
53 | public referenceNumber: string;
54 | public cardHolderName: string;
55 | public requestId: string;
56 |
57 | constructor(jsonResponse: any) {
58 | if (this.isGpApiResponse(jsonResponse)) {
59 | this.requestId = this.transactionId = jsonResponse.id;
60 | this.deviceResponseText = jsonResponse.status;
61 | this.responseText = this.deviceResponseCode =
62 | jsonResponse.action.result_code;
63 | this.deviceResponseText = jsonResponse.status;
64 | } else {
65 | throw new NotImplementedError();
66 | }
67 | }
68 |
69 | private isGpApiResponse(jsonResponse: any): boolean {
70 | return !!(
71 | jsonResponse.provider && jsonResponse.provider === GatewayProvider.GpApi
72 | );
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/Terminals/UPA/Reponses/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./TransactionResponse";
2 |
--------------------------------------------------------------------------------
/src/Terminals/UPA/Request/BaseRequest.ts:
--------------------------------------------------------------------------------
1 | import { GroupRequest } from ".";
2 |
3 | export class BaseRequest {
4 | command: string;
5 | EcrId: string;
6 | requestId: number;
7 | data: GroupRequest;
8 | }
9 |
--------------------------------------------------------------------------------
/src/Terminals/UPA/Request/GroupRequest.ts:
--------------------------------------------------------------------------------
1 | import { RequestParams, TransactionRequest } from ".";
2 |
3 | export class GroupRequest {
4 | params: RequestParams;
5 | transaction: TransactionRequest;
6 | }
7 |
--------------------------------------------------------------------------------
/src/Terminals/UPA/Request/RequestParams.ts:
--------------------------------------------------------------------------------
1 | export class RequestParams {
2 | clerkId: string | null = null;
3 | tokenRequest: number | null = null;
4 | tokenValue: string | null = null;
5 | displayOption?: number | null = null;
6 | lineItemLeft: string | null;
7 | lineItemRight: string | null;
8 | batch?: number | null = null;
9 | }
10 |
--------------------------------------------------------------------------------
/src/Terminals/UPA/Request/RootRequest.ts:
--------------------------------------------------------------------------------
1 | import { BaseRequest } from ".";
2 |
3 | export class RootRequest {
4 | message: string;
5 | data: BaseRequest;
6 | }
7 |
--------------------------------------------------------------------------------
/src/Terminals/UPA/Request/TransactionRequest.ts:
--------------------------------------------------------------------------------
1 | export class TransactionRequest {
2 | baseAmount: string;
3 | taxAmount: number;
4 | tipAmount: number;
5 | taxIndicator: number;
6 | cashbackAmount: number;
7 | invoiceNbr: number;
8 | tranNo: number;
9 | totalAmount: number;
10 | }
11 |
--------------------------------------------------------------------------------
/src/Terminals/UPA/Request/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./BaseRequest";
2 | export * from "./GroupRequest";
3 | export * from "./RequestParams";
4 | export * from "./RootRequest";
5 | export * from "./TransactionRequest";
6 |
--------------------------------------------------------------------------------
/src/Terminals/UPA/UpaInterface.ts:
--------------------------------------------------------------------------------
1 | import {
2 | ApiError,
3 | IDeviceResponse,
4 | PaymentMethodType,
5 | TransactionType,
6 | } from "../../../src";
7 | import {
8 | TransactionResponse,
9 | UpaController,
10 | UpaMessageId,
11 | UpaMessageType,
12 | } from ".";
13 | import { TerminalManageBuilder } from "../Builders";
14 | import { DeviceInterface } from "../DeviceInterface";
15 | import { TerminalUtils } from "../TerminalUtils";
16 |
17 | export class UpaInterface
18 | extends DeviceInterface
19 | implements DeviceInterface
20 | {
21 | constructor(private readonly upaController: T) {
22 | super(upaController);
23 | }
24 |
25 | tipAdjust(amount: number): TerminalManageBuilder {
26 | return new TerminalManageBuilder(
27 | TransactionType.Edit,
28 | PaymentMethodType.Credit,
29 | ).WithGratuity(amount);
30 | }
31 |
32 | public async lineItem(
33 | leftText: string,
34 | rightText?: string,
35 | ): Promise {
36 | if (!leftText) {
37 | throw new ApiError("Line item left text cannot be null");
38 | }
39 |
40 | const requestId = this.upaController.requestIdProvider.getRequestId();
41 | const data = {
42 | params: {
43 | lineItemLeft: leftText,
44 | lineItemRight: rightText || undefined,
45 | },
46 | };
47 |
48 | const requestMessage = {
49 | message: UpaMessageType.MSG,
50 | data: {
51 | command: UpaMessageId.LINEITEM,
52 | requestId: requestId,
53 | ecrId: /** builder.ecrId || 12 */ 12,
54 | data,
55 | },
56 | };
57 |
58 | const message = TerminalUtils.buildUpaRequest(requestMessage);
59 | const rawResponse = await this.upaController.send(
60 | message,
61 | UpaMessageId.LINEITEM,
62 | );
63 | return new TransactionResponse(rawResponse);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/Terminals/UPA/UpaMessageType.ts:
--------------------------------------------------------------------------------
1 | export enum UpaMessageType {
2 | ACK = "ACK",
3 | NAK = "NAK",
4 | READY = "READY",
5 | BUSY = "BUSY",
6 | TO = "TO",
7 | MSG = "MSG",
8 | }
9 |
--------------------------------------------------------------------------------
/src/Terminals/UPA/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./Entities";
2 | export * from "./Interfaces";
3 | export * from "./Reponses";
4 | export * from "./Request";
5 | export * from "./UpaController";
6 | export * from "./UpaInterface";
7 | export * from "./UpaMessageType";
8 |
--------------------------------------------------------------------------------
/src/Terminals/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./Abstractions";
2 | export * from "./ConnectionConfig";
3 | export * from "./DeviceInterface";
4 | export * from "./DeviceResponse";
5 | export * from "./DeviceMessage";
6 | export * from "./SummaryResponse";
7 | export * from "./TerminalResponse";
8 | export * from "./UPA";
9 |
--------------------------------------------------------------------------------
/src/Utils/GenerationUtils.ts:
--------------------------------------------------------------------------------
1 | import { hex_sha1 as sha1 } from "./Sha1";
2 | import * as crypto from "crypto";
3 |
4 | import { StringUtils } from "../";
5 |
6 | export class GenerationUtils {
7 | public static generateHash(toHash: string, secret?: string): string {
8 | const toHashFirstPass = sha1(toHash);
9 | if (!secret) {
10 | return toHashFirstPass;
11 | }
12 | const toHashSecondPass = `${toHashFirstPass}.${secret}`;
13 | return sha1(toHashSecondPass);
14 | }
15 |
16 | public static generateTimestamp(): string {
17 | const date = new Date();
18 | return (
19 | date.getUTCFullYear().toString() +
20 | StringUtils.leftPad((date.getUTCMonth() + 1).toString(), 2, "0") +
21 | StringUtils.leftPad(date.getUTCDate().toString(), 2, "0") +
22 | StringUtils.leftPad(date.getUTCHours().toString(), 2, "0") +
23 | StringUtils.leftPad(date.getUTCMinutes().toString(), 2, "0") +
24 | StringUtils.leftPad(date.getUTCSeconds().toString(), 2, "0")
25 | );
26 | }
27 |
28 | public static generateOrderId(): string {
29 | const id = StringUtils.uuid();
30 | return Buffer.from(id, "ascii")
31 | .toString("base64")
32 | .replace("=", "")
33 | .replace("+", "-")
34 | .replace("/", "_");
35 | }
36 |
37 | public static getGuuid() {
38 | function bin2hex(buffer: Uint8Array): string {
39 | return Array.prototype.map
40 | .call(buffer, (byte: number) => {
41 | return ("0" + (byte & 0xff).toString(16)).slice(-2);
42 | })
43 | .join("");
44 | }
45 |
46 | const data = crypto.getRandomValues(new Uint8Array(16));
47 | data[6] = (data[6] & 0x0f) | 0x40; // set version to 0100
48 | data[8] = (data[8] & 0x3f) | 0x80; // set bits 6-7 to 10
49 |
50 | const hexString = bin2hex(data);
51 |
52 | const formattedUUID = [
53 | hexString.slice(0, 8),
54 | hexString.slice(8, 12),
55 | hexString.slice(12, 16),
56 | hexString.slice(16, 20),
57 | hexString.slice(20),
58 | ].join("-");
59 |
60 | return formattedUUID;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/Utils/IRawRequestBuilder.ts:
--------------------------------------------------------------------------------
1 | export interface IRawRequestBuilder {
2 | getValue(names: string[]): T;
3 | }
4 |
--------------------------------------------------------------------------------
/src/Utils/Logging/ProtectSensitiveData.ts:
--------------------------------------------------------------------------------
1 | import { MaskedValueCollection } from "../../../src";
2 |
3 | export class ProtectSensitiveData {
4 | private static hideValueCollection: MaskedValueCollection;
5 |
6 | public static hideValue(
7 | key: string,
8 | value: string | null,
9 | unmaskedLastChars: number = 0,
10 | unmaskedFirstChars: number = 0,
11 | ): { [key: string]: string } {
12 | return (
13 | this.hideValueCollection ??
14 | (this.hideValueCollection = new MaskedValueCollection())
15 | ).hideValue(key, value, unmaskedLastChars, unmaskedFirstChars);
16 | }
17 |
18 | public static hideValues(
19 | list: { [key: string]: string },
20 | unmaskedLastChars: number = 0,
21 | unmaskedFirstChars: number = 0,
22 | ): { [key: string]: string } {
23 | if (!this.hideValueCollection) {
24 | this.hideValueCollection = new MaskedValueCollection();
25 | }
26 |
27 | let maskedList: { [key: string]: string } = {};
28 | for (const [key, value] of Object.entries(list)) {
29 | maskedList = this.hideValueCollection.hideValue(
30 | key,
31 | value,
32 | unmaskedLastChars,
33 | unmaskedFirstChars,
34 | );
35 | }
36 |
37 | return maskedList;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/Utils/Logging/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./Logger";
2 | export * from "./ProtectSensitiveData";
3 | export * from "./SampleRequestLogger";
4 |
--------------------------------------------------------------------------------
/src/Utils/ServerDates.ts:
--------------------------------------------------------------------------------
1 | export const processServerDate = (s: string) => {
2 | if (!s || s.length !== 8) {
3 | throw new Error("Invalid date format. Expected 'MMDDYYYY'");
4 | }
5 |
6 | const month = parseInt(s.substring(0, 2), 10) - 1;
7 | const day = parseInt(s.substring(2, 4), 10);
8 | const year = parseInt(s.substring(4, 8), 10);
9 |
10 | return new Date(year, month, day);
11 | };
12 |
--------------------------------------------------------------------------------
/src/Utils/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./CardUtils";
2 | export * from "./CountryUtils";
3 | export * from "./GenerationUtils";
4 | export * from "./IRawRequestBuilder";
5 | export * from "./Logging";
6 | export * from "./StringUtils";
7 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | if (process.env.GP_NETSUITE_BUILD) {
2 | // tslint:disable-next-line
3 | require("../netsuite/set-timeout-polyfill");
4 | }
5 |
6 | import "es6-promise/auto";
7 | import "typedarray";
8 |
9 | export * from "./HostedPaymentConfig";
10 | export * from "./ServicesContainer";
11 |
12 | export * from "./Builders";
13 | export * from "./Entities";
14 | export * from "./Gateways";
15 | export * from "./Mapping";
16 | export * from "./PaymentMethods";
17 | export * from "./Services";
18 | export * from "./ServiceConfigs";
19 | export * from "./Terminals";
20 | export * from "./Utils";
21 |
--------------------------------------------------------------------------------
/test/Data/BaseGpApiTestConfig.ts:
--------------------------------------------------------------------------------
1 | import {
2 | AccessTokenInfo,
3 | Channel,
4 | Environment,
5 | GpApiConfig,
6 | Logger,
7 | SampleRequestLogger,
8 | ServicesContainer,
9 | } from "../../src";
10 |
11 | export class BaseGpApiTestConfig {
12 | public static PARTNER_SOLUTION_APP_ID: string =
13 | "A1feRdMmEB6m0Y1aQ65H0bDi9ZeAEB2t";
14 | public static PARTNER_SOLUTION_APP_KEY: string = "5jPt1OpB6LLitgi7";
15 |
16 | public static appId: string = "4gPqnGBkppGYvoE5UX9EWQlotTxGUDbs";
17 | public static appKey: string = "FQyJA5VuEQfcji2M";
18 |
19 | public static UPA_MIC_DEVICE_APP_ID: string =
20 | "83cdNQ0YBmzxzkLpFHpDGn2ir0WKTW0N";
21 | public static UPA_MIC_DEVICE_APP_KEY: string = "1ASrcQZb0AEqR6ZT";
22 |
23 | private static dynamicHeaderEnabled: boolean = false;
24 | private static permissionsEnabled: boolean = false;
25 |
26 | private static logEnabled: boolean = true;
27 |
28 | public static gpApiSetupConfig(channel: Channel): GpApiConfig {
29 | const config = new GpApiConfig();
30 | config.appId = BaseGpApiTestConfig.appId;
31 | config.appKey = BaseGpApiTestConfig.appKey;
32 | config.environment = Environment.Test;
33 | config.channel = channel;
34 | config.country = "US";
35 | config.accessTokenInfo = new AccessTokenInfo();
36 | config.accessTokenInfo.transactionProcessingAccountName =
37 | "transaction_processing";
38 | config.accessTokenInfo.transactionProcessingAccountID =
39 | "TRA_c9967ad7d8ec4b46b6dd44a61cde9a91";
40 | config.accessTokenInfo.riskAssessmentAccountName = "EOS_RiskAssessment";
41 |
42 | config.challengeNotificationUrl = "https://ensi808o85za.x.pipedream.net/";
43 | config.methodNotificationUrl = "https://ensi808o85za.x.pipedream.net/";
44 | config.merchantContactUrl = "https://ensi808o85za.x.pipedream.net/";
45 |
46 | if (BaseGpApiTestConfig.dynamicHeaderEnabled) {
47 | config.dynamicHeaders = {
48 | "x-gp-platform": "prestashop;version=1.7.2",
49 | "x-gp-extension": "coccinet;version=2.4.1",
50 | };
51 | }
52 |
53 | if (BaseGpApiTestConfig.permissionsEnabled) {
54 | config.permissions = ["TRN_POST_Authorize"];
55 | }
56 |
57 | if (BaseGpApiTestConfig.logEnabled) {
58 | config.requestLogger = new SampleRequestLogger(new Logger("logs"));
59 | }
60 |
61 | return config;
62 | }
63 |
64 | static resetGpApiConfig() {
65 | ServicesContainer.removeConfiguration();
66 | BaseGpApiTestConfig.appId = BaseGpApiTestConfig.appId;
67 | BaseGpApiTestConfig.appKey = BaseGpApiTestConfig.appKey;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/test/Data/GpApi3DSTestCards.ts:
--------------------------------------------------------------------------------
1 | export class GpApi3DSTestCards {
2 | static CARDHOLDER_ENROLLED_V1: string = "4012001037141112";
3 |
4 | static CARD_AUTH_SUCCESSFUL_V2_1: string = "4263970000005262";
5 | static CARD_AUTH_SUCCESSFUL_NO_METHOD_URL_V2_1: string = "4222000006724235";
6 | static CARD_AUTH_ATTEMPTED_BUT_NOT_SUCCESSFUL_V2_1: string =
7 | "4012001037167778";
8 | static CARD_AUTH_FAILED_V2_1: string = "4012001037461114";
9 | static CARD_AUTH_ISSUER_REJECTED_V2_1: string = "4012001038443335";
10 | static CARD_AUTH_COULD_NOT_BE_PREFORMED_V2_1: string = "4012001037484447";
11 | static CARD_CHALLENGE_REQUIRED_V2_1: string = "4012001038488884";
12 |
13 | static CARD_AUTH_SUCCESSFUL_V2_2: string = "4222000006285344";
14 | static CARD_AUTH_SUCCESSFUL_NO_METHOD_URL_V2_2: string = "4222000009719489";
15 | static CARD_AUTH_ATTEMPTED_BUT_NOT_SUCCESSFUL_V2_2: string =
16 | "4222000005218627";
17 | static CARD_AUTH_FAILED_V2_2: string = "4222000002144131";
18 | static CARD_AUTH_ISSUER_REJECTED_V2_2: string = "4222000007275799";
19 | static CARD_AUTH_COULD_NOT_BE_PREFORMED_V2_2: string = "4222000008880910";
20 | static CARD_CHALLENGE_REQUIRED_V2_2: string = "4222000001227408";
21 | }
22 |
--------------------------------------------------------------------------------
/test/Data/TestChecks.ts:
--------------------------------------------------------------------------------
1 | import {
2 | AccountType,
3 | CheckType,
4 | ECheck,
5 | EntryMethod,
6 | SecCode,
7 | } from "../../src";
8 |
9 | export class TestChecks {
10 | public static certification(
11 | secCode = SecCode.PPD,
12 | checkType = CheckType.Personal,
13 | accountType = AccountType.Checking,
14 | checkName?: string,
15 | ) {
16 | const check = new ECheck();
17 | check.accountNumber = "1357902468";
18 | check.routingNumber = "122000030";
19 | check.checkType = checkType;
20 | check.accountType = accountType;
21 | check.secCode = secCode;
22 | check.entryMode = EntryMethod.Manual;
23 | check.checkHolderName = "John Doe";
24 | check.driversLicenseNumber = "09876543210";
25 | check.driversLicenseState = "TX";
26 | check.phoneNumber = "8003214567";
27 | check.birthYear = "1997";
28 | check.ssnLast4 = "4321";
29 | if (checkName) {
30 | check.checkName = checkName;
31 | }
32 | return check;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/test/Data/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./BaseGpApiTestConfig";
2 | export * from "./GpApi3DSTestCards";
3 | export * from "./TestCards";
4 | export * from "./TestChecks";
5 |
--------------------------------------------------------------------------------
/test/Integration/Gateways/AcsResponse.ts:
--------------------------------------------------------------------------------
1 | export class AcsResponse {
2 | private authResponse: string;
3 | private merchantData: string;
4 | private status: boolean;
5 |
6 | constructor() {
7 | this.authResponse = "";
8 | this.merchantData = "";
9 | this.status = false;
10 | }
11 |
12 | public getAuthResponse(): string {
13 | return this.authResponse;
14 | }
15 |
16 | public setAuthResponse(authResponse: string): void {
17 | this.authResponse = authResponse;
18 | }
19 |
20 | public getMerchantData(): string {
21 | return this.merchantData;
22 | }
23 |
24 | public setMerchantData(merchantData: string): void {
25 | this.merchantData = merchantData;
26 | }
27 |
28 | public getStatus(): boolean {
29 | return this.status;
30 | }
31 |
32 | public setStatus(status: boolean): void {
33 | this.status = status;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/test/Integration/Gateways/PorticoConnector/Ach.test.ts:
--------------------------------------------------------------------------------
1 | import {
2 | AccountType,
3 | Address,
4 | CheckType,
5 | ECheck,
6 | EntryMethod,
7 | PaymentMethodType,
8 | PorticoConfig,
9 | SecCode,
10 | ServicesContainer,
11 | Transaction,
12 | } from "../../../../src";
13 |
14 | const address = new Address();
15 | const check = new ECheck();
16 | const config = new PorticoConfig();
17 |
18 | beforeAll(() => {
19 | address.streetAddress1 = "123 Main St.";
20 | address.city = "Downtown";
21 | address.province = "NJ";
22 | address.postalCode = "12345";
23 |
24 | check.accountNumber = "1357902468";
25 | check.routingNumber = "122000030";
26 | check.checkType = CheckType.Personal;
27 | check.secCode = SecCode.PPD;
28 | check.accountType = AccountType.Checking;
29 | check.entryMode = EntryMethod.Manual;
30 | check.checkHolderName = "John Doe";
31 | check.driversLicenseNumber = "09876543210";
32 | check.driversLicenseState = "TX";
33 | check.phoneNumber = "8003214567";
34 | check.birthYear = "1997";
35 | check.ssnLast4 = "4321";
36 | check.checkName = "Genysis Chamber";
37 | });
38 |
39 | beforeEach(() => {
40 | config.secretApiKey = "skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A";
41 | config.serviceUrl = "https://cert.api2.heartlandportico.com";
42 | ServicesContainer.configureService(config);
43 | });
44 |
45 | test("check sale", async () => {
46 | const response = await check
47 | .charge(11)
48 | .withCurrency("USD")
49 | .withAddress(address)
50 | .execute();
51 |
52 | expect(response).toBeTruthy();
53 | expect(response.responseCode).toBe("00");
54 | });
55 |
56 | test("check void from transaction id", async () => {
57 | const response = await check
58 | .charge(10)
59 | .withCurrency("USD")
60 | .withAddress(address)
61 | .execute();
62 |
63 | expect(response).toBeTruthy();
64 | expect(response.responseCode).toBe("00");
65 |
66 | const voidResponse = await Transaction.fromId(
67 | response.transactionId,
68 | PaymentMethodType.ACH,
69 | )
70 | .void()
71 | .execute();
72 |
73 | expect(voidResponse).toBeTruthy();
74 | expect(voidResponse.responseCode).toBe("00");
75 | });
76 |
--------------------------------------------------------------------------------
/test/Integration/Gateways/PorticoConnector/PorticoManagementToken.test.ts:
--------------------------------------------------------------------------------
1 | import {
2 | CreditCardData,
3 | PorticoConfig,
4 | ServicesContainer,
5 | } from "../../../../src";
6 |
7 | const config = new PorticoConfig();
8 |
9 | beforeAll(() => {
10 | config.secretApiKey = "skapi_cert_MXDMBQDwa3IAA4GV7NGMqQA_wFR3_TNeamFWoNUu_Q";
11 | ServicesContainer.configureService(config);
12 | });
13 |
14 | test("card tokenization then update expiry date", async () => {
15 | const card = new CreditCardData();
16 | card.number = "4263970000005262";
17 | card.expMonth = "10";
18 | card.expYear = "2020";
19 | card.cvn = "131";
20 | card.cardHolderName = "Megatron";
21 | const response = await card.tokenize().execute();
22 | const tokenId = response.token;
23 |
24 | const tokenizedCard = new CreditCardData();
25 | tokenizedCard.token = tokenId;
26 | const mdate = new Date();
27 | tokenizedCard.expMonth = (mdate.getMonth() + 2).toString().padStart(2, "0");
28 | tokenizedCard.expYear = (mdate.getFullYear() + 2).toString();
29 |
30 | const isTokenUpdated = await tokenizedCard.updateTokenExpiry();
31 |
32 | expect(isTokenUpdated).toBeTruthy();
33 | });
34 |
35 | test("Should delete tokenized card token", async () => {
36 | const card = new CreditCardData();
37 | card.number = "4263970000005262";
38 | card.expMonth = "10";
39 | card.expYear = "2020";
40 | card.cvn = "131";
41 | card.cardHolderName = "Tron";
42 | const response = await card.tokenize().execute();
43 | const tokenId = response.token;
44 |
45 | const tokenizedCard = new CreditCardData();
46 | tokenizedCard.token = tokenId;
47 |
48 | const isTokenDeleted = await tokenizedCard.deleteToken();
49 |
50 | expect(isTokenDeleted).toBe(true);
51 | });
52 |
--------------------------------------------------------------------------------
/test/Integration/Gateways/PorticoConnector/Reporting.test.ts:
--------------------------------------------------------------------------------
1 | import {
2 | PorticoConfig,
3 | ReportingService,
4 | ServicesContainer,
5 | } from "../../../../src";
6 |
7 | const config = new PorticoConfig();
8 |
9 | beforeAll(() => {
10 | config.secretApiKey = "skapi_cert_MXDMBQDwa3IAA4GV7NGMqQA_wFR3_TNeamFWoNUu_Q";
11 | ServicesContainer.configureService(config);
12 | });
13 |
14 | test("report activity", () => {
15 | const start = new Date(Date.now());
16 | start.setDate(start.getDate() - 7);
17 | const end = new Date(Date.now());
18 |
19 | return ReportingService.activity()
20 | .withStartDate(start)
21 | .withEndDate(end)
22 | .execute()
23 | .then((activity) => {
24 | expect(activity).toBeTruthy();
25 | expect(activity.length > 0).toBe(true);
26 | });
27 | });
28 |
29 | test("report transaction detail", () => {
30 | const start = new Date(Date.now());
31 | start.setDate(start.getDate() - 7);
32 | const end = new Date(Date.now());
33 |
34 | return ReportingService.activity()
35 | .withStartDate(start)
36 | .withEndDate(end)
37 | .execute()
38 | .then((activity) => {
39 | expect(activity).toBeTruthy();
40 |
41 | if (activity.length > 0) {
42 | return ReportingService.transactionDetail(activity[0].transactionId)
43 | .execute()
44 | .then((detail) => {
45 | expect(detail).toBeTruthy();
46 | expect(detail.gatewayResponseCode).toBe("00");
47 | });
48 | }
49 |
50 | expect.assertions(1);
51 | return Promise.resolve();
52 | });
53 | });
54 |
--------------------------------------------------------------------------------
/test/Integration/Gateways/ProPayConnector/Certifications/GetInformationCertification.test.ts:
--------------------------------------------------------------------------------
1 | import { PayFacService } from "../../../../../src/Services/PayFacService";
2 | import { PorticoConfig, ServicesContainer } from "../../../../../src";
3 |
4 | const config = new PorticoConfig();
5 | config.serviceUrl = "https://xmltest.propay.com/API/PropayAPI.aspx";
6 | config.certificationStr = "d17d770d4734341aaedab32b7a7763";
7 | config.terminalId = "7a7763";
8 | const _service = new PayFacService();
9 |
10 | beforeAll(() => {
11 | ServicesContainer.configureService(config);
12 | });
13 |
14 | test("get account info", async () => {
15 | const response = await _service
16 | .getAccountDetails()
17 | .withAccountNumber("718570752")
18 | .execute();
19 |
20 | expect(response).toBeTruthy();
21 | expect("00").toBe(response.responseCode);
22 | });
23 |
24 | test("get account balance", async () => {
25 | const response = await _service
26 | .getAccountBalance()
27 | .withAccountNumber("718570752")
28 | .execute();
29 |
30 | expect(response).toBeTruthy();
31 | expect("00").toBe(response.responseCode);
32 | });
33 |
34 | test("get account info enchance", async () => {
35 | expect.assertions(2);
36 | const response = await _service
37 | .getAccountDetailsEnhanced()
38 | .withAccountNumber("718570752")
39 | .execute();
40 |
41 | expect(response).toBeTruthy();
42 | expect("00").toBe(response.responseCode);
43 | });
44 |
--------------------------------------------------------------------------------
/test/Integration/Gateways/ProPayConnector/Certifications/ProPayFundCertification.test.ts:
--------------------------------------------------------------------------------
1 | import { PayFacService } from "../../../../../src/Services/PayFacService";
2 | import { PorticoConfig, ServicesContainer } from "../../../../../src";
3 | import { TestFundsData } from "../TestData/TestFundsData";
4 |
5 | const config = new PorticoConfig();
6 | config.serviceUrl = "https://xmltest.propay.com/API/PropayAPI.aspx";
7 | config.certificationStr = "d17d770d4734341aaedab32b7a7763";
8 | config.terminalId = "7a7763";
9 | config.selfSignedCertLocation =
10 | "test/Integration/Gateways/ProPayConnector/Certifications/TestData/selfSignedCertificate.crt";
11 | const _service = new PayFacService();
12 |
13 | beforeAll(() => {
14 | ServicesContainer.configureService(config);
15 | });
16 |
17 | test("add funds", async () => {
18 | const response = await _service
19 | .addFunds()
20 | .withAccountNumber("718571343") //718571145")
21 | .withAmount("100")
22 | .execute();
23 |
24 | expect(response).toBeTruthy();
25 | expect("00").toBe(response.responseCode);
26 | });
27 |
28 | test("sweep funds", async () => {
29 | const response = await _service
30 | .sweepFunds()
31 | .withAccountNumber("718571343") //718571146")
32 | .withAmount("10")
33 | .execute();
34 |
35 | expect(response).toBeTruthy();
36 | expect("00").toBe(response.responseCode);
37 | });
38 |
39 | test.skip("add flash funds payment card", async () => {
40 | const response = await _service
41 | .addCardFlashFunds()
42 | .withAccountNumber("718571147")
43 | .withFlashFundsPaymentCardData(TestFundsData.GetFlashFundsPaymentCardData())
44 | .execute();
45 |
46 | expect(response).toBeTruthy();
47 | expect("00").toBe(response.responseCode);
48 | });
49 |
50 | test.skip("push money to flash funds card", async () => {
51 | const response = await _service
52 | .pushMoneyToFlashFundsCard()
53 | .withAccountNumber("718571148")
54 | .withAmount("100")
55 | .execute();
56 |
57 | expect(response).toBeTruthy();
58 | expect("00").toBe(response.responseCode);
59 | });
60 |
--------------------------------------------------------------------------------
/test/Integration/Gateways/ProPayConnector/Certifications/TestData/TestDoc.docx:
--------------------------------------------------------------------------------
1 | A test document
--------------------------------------------------------------------------------
/test/Integration/Gateways/ProPayConnector/Certifications/TestData/TestDocChargeback.docx:
--------------------------------------------------------------------------------
1 | Test document chargeback
--------------------------------------------------------------------------------
/test/Integration/Gateways/ProPayConnector/Certifications/TestData/selfSignedCertificate.crt:
--------------------------------------------------------------------------------
1 | MIICpDCCAYygAwIBAgIIduJH9PTV4gMwDQYJKoZIhvcNAQENBQAwETEPMA0GA1UE
2 | AwwGUFJPUEFZMB4XDTIzMDEyMzAwMDAwMFoXDTMzMDEyMzAwMDAwMFowEzERMA8GA1UEAwwIMTI3LjAuMDEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDM
3 | dUs6EyxEYjy4Z5KipeNHpYV62sy47EpXXluqgkf+kitay4TfXXV1hArkwfHQsgd/
4 | 6ybP9MWDN96RyDHtcOGklExZATBf7t79M4Ve9E/bf7eDg8ey6vXph1SwMh5mbEov
5 | qINxZzpq2jKpjUecMNS/DG3rnYYmn5Mpf2DV/WwB4SisPjuIjxe9ADIFj3ugy812
6 | Wz1XeMJLlQNLbDGI6wRASweDvGCg81yEn47Vam67Fo5mOAYSmdZlTC18FqT8Aps8
7 | zd5MLbCP8/JTO5poA9kMh5Ag75gpfq/zCHMWYsHXDX0eIqgVSm+/94Yoe/g0P1sd
8 | B1wxesVCuyAvebun4M5BAgMBAAEwDQYJKoZIhvcNAQENBQADggEBALzYT2LiamT7
9 | cO+ihn9GcXbwyS3uJPQY6G/fKU3w+sdppCHuokQ46O6oFmgnZEPSLJenJxt6aD2g
10 | t3JhPWg5JJEtRa+7TcQ5dUzsaLrqkmVG0c/uvxJwrikOLqw8HS70FFU6GrSwGGO4
11 | FkTa5/xltB3G5BAjmsqzWBadZ4WENyhq/BmzrL2ceMBaw/mP+grD1ZUOtgkED3io
12 | E54m0tJNFcviETNY+gyJ60JtOKrH84v3DXnibtLQ+Mtg6nK8/8eqDB8QnLCbvOXg
13 | jycmF1hqJVs+knTa1t95ZeXrPCdvCS3IF29AewVf1YRi43OOwsHqPGNqZIM7g8cV
14 | hjjJNp4ksV8=
--------------------------------------------------------------------------------
/test/Integration/Gateways/ProPayConnector/GetInformation.test.ts:
--------------------------------------------------------------------------------
1 | import { PayFacService } from "../../../../src/Services/PayFacService";
2 | import { PorticoConfig, ServicesContainer } from "../../../../src";
3 |
4 | const config = new PorticoConfig();
5 | config.serviceUrl = "https://xmltest.propay.com/API/PropayAPI.aspx";
6 | config.certificationStr = "5dbacb0fc504dd7bdc2eadeb7039dd";
7 | config.terminalId = "7039dd";
8 | const _service = new PayFacService();
9 |
10 | beforeAll(() => {
11 | ServicesContainer.configureService(config);
12 | });
13 |
14 | test("get account balance", async () => {
15 | const response = await _service
16 | .getAccountBalance()
17 | .withAccountNumber("718135687")
18 | .execute();
19 |
20 | expect(response).toBeTruthy();
21 | expect("00").toBe(response.responseCode);
22 | });
23 |
24 | test("get account info", async () => {
25 | const response = await _service
26 | .getAccountDetails()
27 | .withAccountNumber("718135687")
28 | .execute();
29 |
30 | expect(response).toBeTruthy();
31 | expect("00").toBe(response.responseCode);
32 | });
33 |
34 | test("get account info enchance", async () => {
35 | const response = await _service
36 | .getAccountDetailsEnhanced()
37 | .withAccountNumber("718135687")
38 | .execute();
39 |
40 | expect(response).toBeTruthy();
41 | expect("00").toBe(response.responseCode);
42 | });
43 |
--------------------------------------------------------------------------------
/test/Integration/Gateways/ProPayConnector/ProPayFunds.test.ts:
--------------------------------------------------------------------------------
1 | import { PayFacService } from "../../../../src/Services/PayFacService";
2 | import { PorticoConfig, ServicesContainer } from "../../../../src";
3 | import { TestFundsData } from "./TestData/TestFundsData";
4 |
5 | const config = new PorticoConfig();
6 | config.serviceUrl = "https://xmltest.propay.com/API/PropayAPI.aspx";
7 | config.certificationStr = "4ee64cbd706400fb4a34e65aab6f48";
8 | config.terminalId = "ab6f48";
9 | config.selfSignedCertLocation =
10 | "test/Integration/Gateways/ProPayConnector/TestData/selfSignedCertificate.crt";
11 | const _service = new PayFacService();
12 |
13 | beforeAll(() => {
14 | ServicesContainer.configureService(config);
15 | });
16 |
17 | test("add funds", async () => {
18 | const response = await _service
19 | .addFunds()
20 | .withAccountNumber("718134204")
21 | .withAmount("10")
22 | .execute();
23 |
24 | expect(response).toBeTruthy();
25 | expect("00").toBe(response.responseCode);
26 | });
27 |
28 | test("sweep funds", async () => {
29 | const response = await _service
30 | .sweepFunds()
31 | .withAccountNumber("718570822")
32 | .withAmount("10")
33 | .execute();
34 |
35 | expect(response).toBeTruthy();
36 | expect("00").toBe(response.responseCode);
37 | });
38 |
39 | test.failing("add flash funds payment card", async () => {
40 | const response = await _service
41 | .addCardFlashFunds()
42 | .withAccountNumber("718136438")
43 | .withFlashFundsPaymentCardData(TestFundsData.GetFlashFundsPaymentCardData())
44 | .execute();
45 |
46 | expect(response).toBeTruthy();
47 | expect("00").toBe(response.responseCode);
48 | });
49 |
50 | test.skip("push money to flash funds card", async () => {
51 | expect.assertions(2);
52 | const response = await _service
53 | .pushMoneyToFlashFundsCard()
54 | .withAccountNumber("718136438")
55 | .withAmount("100")
56 | .execute();
57 |
58 | expect(response).toBeTruthy();
59 | expect("00").toBe(response.responseCode);
60 | });
61 |
--------------------------------------------------------------------------------
/test/Integration/Gateways/ProPayConnector/TestData/TestDoc.docx:
--------------------------------------------------------------------------------
1 | A test document
--------------------------------------------------------------------------------
/test/Integration/Gateways/ProPayConnector/TestData/TestDocChargeback.docx:
--------------------------------------------------------------------------------
1 | Test document chargeback
--------------------------------------------------------------------------------
/test/Integration/Gateways/ProPayConnector/TestData/TestFundsData.ts:
--------------------------------------------------------------------------------
1 | import { CreditCardData } from "../../../../../src/PaymentMethods";
2 | import { Address } from "../../../../../src/Entities/Address";
3 | import { FlashFundsPaymentCardData } from "../../../../../src/Entities/ProFac/FlashFundsPaymentCardData";
4 |
5 | export class TestFundsData {
6 | public static GetFlashFundsPaymentCardData(): FlashFundsPaymentCardData {
7 | const cardData = new FlashFundsPaymentCardData();
8 | const creditCard = new CreditCardData();
9 | creditCard.number = "4895142232120006";
10 | creditCard.expMonth = "10";
11 | creditCard.expYear = "2025";
12 | creditCard.cvn = "022";
13 | creditCard.cardHolderName = "Clint Eastwood";
14 | cardData.creditCard = creditCard;
15 | const cardholderAddress = new Address();
16 | cardholderAddress.streetAddress1 = "900 Metro Center Blv";
17 | cardholderAddress.city = "San Fransisco";
18 | cardholderAddress.state = "CA";
19 | cardholderAddress.postalCode = "94404";
20 | cardholderAddress.country = "USA";
21 | cardData.cardholderAddress = cardholderAddress;
22 | return cardData;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/test/Integration/Gateways/ProPayConnector/TestData/selfSignedCertificate.crt:
--------------------------------------------------------------------------------
1 | MIICpDCCAYygAwIBAgIIS7Y5fijJytIwDQYJKoZIhvcNAQENBQAwETEPMA0GA1UE
2 | AwwGUFJPUEFZMB4XDTE5MDkxOTAwMDAwMFoXDTI5MDkxOTAwMDAwMFowEzERMA8G
3 | A1UEAwwIMTI3LjAuMDEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCC
4 | wvq2ho43oeeGX3L9+2aD7bna7qjdLwWumeIpwhPZLa44MeQ5100wy4W2hKk3pOb5
5 | yaHqyhzoHDriveQnq/EpZJk9m7sizXsxZtBHtt+wghSZjdNhnon3R54SH5J7oEPy
6 | bRSAKXSEzHjN+kCu7W3TmXSLve6YuODnjUpbOcAsHG2wE+zpCoEbe8toH5Tt7g8H
7 | zEc5mJYkkILTq6j9pwDE50r2NVbV3SXwmQ1ifxf54Z9EFB5bQv5cI3+GL/VwlQeJ
8 | diKMGj1rs8zTR8TjbAjVlJbz6bBkFItUsqexgwAHIJZAaU7an8ZamGRlPjf6dp3m
9 | OEu4B47igNj5KOSgCNdRAgMBAAEwDQYJKoZIhvcNAQENBQADggEBAF88u367yrdu
10 | qd3PfEIo2ClaI2QPRIIWKKACMcZDl3z1BzVzNFOZNG2vLcSuKnGRH89tJPCjyxdJ
11 | a0RyDTkXMSLqb5FgUseEjmj3ULAvFqLZNW35PY9mmlmCY+S3CC/bQR4iyPLo8lsR
12 | q0Nl6hlvB440+9zS8UQjtc2957QgcXfD427UJb698gXzsfQcNeaQWy8pNm7FzDfH
13 | TJbo/t6FOpmfR+RMZky9FrlWabInkrkf3w2XJL0uUAYU9jGQa+l/vnZD2KNzs1mO
14 | 1EqkS6yB/fsn85mkgGe4Vfbo9GQ/S+KmDujewFA0ma7O03fy1W5v6Amn/nAcFTCd
15 | dVL3BDNEtOM=
--------------------------------------------------------------------------------
/test/Integration/Gateways/ProPayConnector/TestData/selfSignedCertificateCAN.crt:
--------------------------------------------------------------------------------
1 | MIICpDCCAYygAwIBAgIIfzbbTvSWYSEwDQYJKoZIhvcNAQENBQAwETEPMA0GA1UEAwwGUFJPUEFZMB4XDTIxMDgyMzAwMDAwMFoXDTMxMDgyMzAwMDAwMFowEzERMA8GA1UEAwwIMTI3LjAuMDEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCpKFpE1GY7YtcFuDFlUbdrHRaAFQWPt+XKFQ8oSpjhHRueL2JRsN0Rq1+eJjx0TYCLNVrmNSSEfYfiVdns2qo7JrZD1XJp7tafomY5t/SK7Q8m5KiEfR3ae+VFD1JpJC8ExZiguBvHITU5ltIAshnqM/GyCwSj6GyLkEMaH8ehRu4rPCpOGuI3YoaB/1gEDsWNhkjyL7B2Wxe+InwVqaI1idfgTUOHMXvrH90DpbWGr6E7GHsha7zh2mdORhy2lVKtO0u7cTQqqIXFFDzxDhfCM+Vx4eT22u4hlfquAi3n3ihqQ2AWgFga+MiJBUWg1J+3OiUZYwCBvNFysCIsBtL5AgMBAAEwDQYJKoZIhvcNAQENBQADggEBAHNGhfegh2Tfjy9/hVcTzDHszdu980M8+nWGGxC+RHkSf8AYtwXLDgX7BTwUVkrs99qAV7U3tTBpIQMBWZBsHiQWYFNgwtmDdEsAsO9A6o4u1XJdlA/ggMkoYD57OcTdhds+77QnUUOVGKVn5pJN0E2OPE2xbBp+KOsavCYmd7NNm/I3d73maGKqNjQqoc6KHVgdtuE+YE4MRTVclAtalbvi7s4mFSi7d3Q+P2LTWKqS5vJWBHSiDCx6bt8htbD+jR1nb+upOecTy4+IN/LzKXJBGTANd4Q4qQQCU8sPp0piC5ZNvnokAgq4SiE0ycZwnU8A5P/OfDetTEK62YLcn8I=
--------------------------------------------------------------------------------
/test/Integration/Gateways/Terminals/RequestIdProvider.ts:
--------------------------------------------------------------------------------
1 | import { IRequestIdProvider } from "../../../../src";
2 |
3 | export class RequestIdProvider implements IRequestIdProvider {
4 | public getRequestId() {
5 | return 10000 + Math.round(10000 * Math.random());
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/test/Integration/Services/CheckService.test.ts:
--------------------------------------------------------------------------------
1 | import { Address, CheckService, PorticoConfig } from "../../../src";
2 | import { TestChecks } from "../../Data";
3 |
4 | const config = new PorticoConfig();
5 | config.secretApiKey = "skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A";
6 | const service = new CheckService(config);
7 |
8 | const check = TestChecks.certification();
9 | const address = new Address();
10 | address.streetAddress1 = "123 Main St.";
11 | address.city = "Downtown";
12 | address.state = "NJ";
13 | address.postalCode = "12345";
14 |
15 | test.failing("sale", async () => {
16 | const response = await service
17 | .charge(10)
18 | .withCurrency("USD")
19 | .withPaymentMethod(check)
20 | .withAddress(address)
21 | .execute();
22 |
23 | expect(response).toBeTruthy();
24 | expect(response.responseCode).toBe("00");
25 | });
26 |
27 | test.failing("void", async () => {
28 | expect.assertions(4);
29 |
30 | const response = await service
31 | .charge(10)
32 | .withCurrency("USD")
33 | .withPaymentMethod(check)
34 | .withAddress(address)
35 | .execute();
36 |
37 | expect(response).toBeTruthy();
38 | expect(response.responseCode).toBe("00");
39 |
40 | const voidResponse = await service.void(response.transactionId).execute();
41 |
42 | expect(voidResponse).toBeTruthy();
43 | expect(voidResponse.responseCode).toBe("00");
44 | });
45 |
--------------------------------------------------------------------------------
/test/Integration/Services/DebitService.test.ts:
--------------------------------------------------------------------------------
1 | import {
2 | DebitService,
3 | PorticoConfig,
4 | UnsupportedTransactionError,
5 | } from "../../../src";
6 | import { TestCards } from "../../Data";
7 |
8 | const config = new PorticoConfig();
9 | config.secretApiKey = "skapi_cert_MaePAQBr-1QAqjfckFC8FTbRTT120bVQUlfVOjgCBw";
10 | const service = new DebitService(config);
11 |
12 | const card = TestCards.asDebit(
13 | TestCards.visaSwipe(),
14 | "32539F50C245A6A93D123412324000AA",
15 | );
16 |
17 | test("sale", async () => {
18 | expect.assertions(2);
19 |
20 | const response = await service
21 | .charge(14)
22 | .withCurrency("USD")
23 | .withPaymentMethod(card)
24 | .withAllowDuplicates(true)
25 | .execute();
26 |
27 | expect(response).toBeTruthy();
28 | expect(response.responseCode).toBe("00");
29 | });
30 |
31 | test.skip("refund by card", async () => {
32 | expect.assertions(4);
33 |
34 | const response = await service
35 | .charge(15)
36 | .withCurrency("USD")
37 | .withPaymentMethod(card)
38 | .withAllowDuplicates(true)
39 | .execute();
40 |
41 | expect(response).toBeTruthy();
42 | expect(response.responseCode).toBe("00");
43 |
44 | const refund = await service
45 | .refund(15)
46 | .withCurrency("USD")
47 | .withPaymentMethod(card)
48 | .execute();
49 |
50 | expect(refund).toBeTruthy();
51 | expect(refund.responseCode).toBe("00");
52 | });
53 |
54 | test("reverse by card", async () => {
55 | expect.assertions(4);
56 |
57 | const response = await service
58 | .charge(16)
59 | .withCurrency("USD")
60 | .withPaymentMethod(card)
61 | .withAllowDuplicates(true)
62 | .execute();
63 |
64 | expect(response).toBeTruthy();
65 | expect(response.responseCode).toBe("00");
66 |
67 | const reverse = await service
68 | .reverse(16)
69 | .withCurrency("USD")
70 | .withPaymentMethod(card)
71 | .execute();
72 |
73 | expect(reverse).toBeTruthy();
74 | expect(reverse.responseCode).toBe("00");
75 | });
76 |
77 | test("reverse by transaction id fails", async () => {
78 | const response = await service
79 | .charge(17)
80 | .withCurrency("USD")
81 | .withPaymentMethod(card)
82 | .withAllowDuplicates(true)
83 | .execute();
84 |
85 | expect(response).toBeTruthy();
86 | expect(response.responseCode).toBe("00");
87 |
88 | try {
89 | await service
90 | .reverse(17)
91 | .withCurrency("USD")
92 | .withTransactionId(response.transactionId)
93 | .execute();
94 | } catch (error) {
95 | expect(error?.message).toBeTruthy();
96 | expect(error).toBeInstanceOf(UnsupportedTransactionError);
97 | }
98 | });
99 |
--------------------------------------------------------------------------------
/test/Integration/Services/EBTService.test.ts:
--------------------------------------------------------------------------------
1 | import { EBTService, PorticoConfig } from "../../../src";
2 | import { TestCards } from "../../Data";
3 |
4 | const config = new PorticoConfig();
5 | config.secretApiKey = "skapi_cert_MaePAQBr-1QAqjfckFC8FTbRTT120bVQUlfVOjgCBw";
6 | const service = new EBTService(config);
7 |
8 | const card = TestCards.asEBTTrack(
9 | TestCards.visaSwipe(),
10 | "32539F50C245A6A93D123412324000AA",
11 | );
12 |
13 | test("balance inquiry", async () => {
14 | const response = await service
15 | .balanceInquiry()
16 | .withPaymentMethod(card)
17 | .execute();
18 |
19 | expect(response).toBeTruthy();
20 | expect(response.responseCode).toBe("00");
21 | });
22 |
23 | test.failing("benefits withdrawal", async () => {
24 | const response = await service
25 | .benefitWithdrawal(10)
26 | .withCurrency("USD")
27 | .withPaymentMethod(card)
28 | .withAllowDuplicates(true)
29 | .execute();
30 |
31 | expect(response).toBeTruthy();
32 | expect(response.responseCode).toBe("00");
33 | });
34 |
35 | test("sale", async () => {
36 | const response = await service
37 | .charge(11)
38 | .withCurrency("USD")
39 | .withPaymentMethod(card)
40 | .withAllowDuplicates(true)
41 | .execute();
42 |
43 | expect(response).toBeTruthy();
44 | expect(response.responseCode).toBe("00");
45 | });
46 |
47 | test("refund by card", async () => {
48 | const response = await service
49 | .charge(12)
50 | .withCurrency("USD")
51 | .withPaymentMethod(card)
52 | .withAllowDuplicates(true)
53 | .execute();
54 |
55 | expect(response).toBeTruthy();
56 | expect(response.responseCode).toBe("00");
57 |
58 | const refund = await service
59 | .refund(12)
60 | .withCurrency("USD")
61 | .withPaymentMethod(card)
62 | .execute();
63 |
64 | expect(refund).toBeTruthy();
65 | expect(refund.responseCode).toBe("00");
66 | });
67 |
--------------------------------------------------------------------------------
/test/Unit/Builders/ReportBuilder/Validation.test.ts:
--------------------------------------------------------------------------------
1 | import {
2 | BuilderError,
3 | PorticoConfig,
4 | ReportingService,
5 | ServicesContainer,
6 | } from "../../../../src";
7 |
8 | const config = new PorticoConfig();
9 | config.secretApiKey = "skapi_cert_MTeSAQAfG1UA9qQDrzl-kz4toXvARyieptFwSKP24w";
10 | config.serviceUrl = "https://cert.api2-c.heartlandportico.com";
11 |
12 | beforeAll(() => {
13 | ServicesContainer.configureService(config);
14 | });
15 |
16 | test("report transaction details no transaction id", async () => {
17 | try {
18 | await ReportingService.transactionDetail("").execute();
19 | } catch (error) {
20 | expect(error).toBeInstanceOf(BuilderError);
21 | expect(error?.name).toBe("BuilderError");
22 | expect(-1 !== error?.message.indexOf("transactionId cannot be empty")).toBe(
23 | true,
24 | );
25 | }
26 | });
27 |
28 | test("report transaction details with device id", async () => {
29 | try {
30 | await ReportingService.transactionDetail("1234567890")
31 | .withDeviceId("123456")
32 | .execute();
33 | } catch (error) {
34 | expect(error).toBeInstanceOf(BuilderError);
35 | expect(error?.name).toBe("BuilderError");
36 | expect(-1 !== error?.message.indexOf("deviceId cannot be set")).toBe(true);
37 | }
38 | });
39 |
40 | test("report transaction details with start date", async () => {
41 | try {
42 | await ReportingService.transactionDetail("1234567890")
43 | .withStartDate(new Date())
44 | .execute();
45 | } catch (error) {
46 | expect(error).toBeInstanceOf(BuilderError);
47 | expect(error?.name).toBe("BuilderError");
48 | expect(-1 !== error?.message.indexOf("startDate cannot be set")).toBe(true);
49 | }
50 | });
51 |
52 | test("report transaction details with end date", async () => {
53 | try {
54 | await ReportingService.transactionDetail("1234567890")
55 | .withEndDate(new Date())
56 | .execute();
57 | } catch (error) {
58 | expect(error).toBeInstanceOf(BuilderError);
59 |
60 | expect(error?.name).toBe("BuilderError");
61 | expect(-1 !== error?.message.indexOf("endDate cannot be set")).toBe(true);
62 | }
63 | });
64 |
65 | test("report activity with transaction id", async () => {
66 | try {
67 | await ReportingService.activity().withTransactionId("1234567890").execute();
68 | } catch (error) {
69 | expect(error).toBeInstanceOf(BuilderError);
70 | expect(error?.name).toBe("BuilderError");
71 | expect(-1 !== error?.message.indexOf("transactionId cannot be set")).toBe(
72 | true,
73 | );
74 | }
75 | });
76 |
--------------------------------------------------------------------------------
/test/Unit/Gateways/GpEcomConnector/Credit.test.ts:
--------------------------------------------------------------------------------
1 | import {
2 | CreditCardData,
3 | ServicesContainer,
4 | UnsupportedTransactionError,
5 | } from "../../../../src";
6 | import { GpEcomConfig } from "../../../../src/ServiceConfigs";
7 |
8 | const config = new GpEcomConfig();
9 | config.merchantId = "heartlandgpsandbox";
10 | config.accountId = "api";
11 | config.sharedSecret = "secret";
12 | config.serviceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi";
13 | config.rebatePassword = "rebate";
14 | config.refundPassword = "refund";
15 |
16 | const card = new CreditCardData();
17 | card.number = "4111111111111111";
18 | card.expMonth = "12";
19 | card.expYear = "2025";
20 | card.cvn = "123";
21 | card.cardHolderName = "Joe Smith";
22 |
23 | beforeAll(() => {
24 | ServicesContainer.configureService(config);
25 | });
26 |
27 | test("credit reverse", async () => {
28 | try {
29 | await card.reverse(15).withAllowDuplicates(true).execute();
30 | } catch (error) {
31 | expect(error).toBeInstanceOf(UnsupportedTransactionError);
32 | expect(error?.name).toBe("UnsupportedTransactionError");
33 | expect(
34 | -1 !==
35 | error?.message.indexOf(
36 | "selected gateway does not support this transaction type",
37 | ),
38 | ).toBe(true);
39 | }
40 | });
41 |
--------------------------------------------------------------------------------
/tsconfig.eslint.json:
--------------------------------------------------------------------------------
1 | {
2 | // extend your base config to share compilerOptions, etc
3 | "extends": "./tsconfig.json",
4 | "compilerOptions": {
5 | // ensure that nobody can accidentally use this config for a build
6 | "noEmit": true
7 | },
8 | "include": [
9 | // whatever paths you intend to lint
10 | "src",
11 | "test",
12 | "tools"
13 | ]
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "Node16",
4 | "target": "ES2022",
5 | "lib": ["ES2022"],
6 | "noImplicitAny": true,
7 | "noImplicitReturns": true,
8 | "noUnusedLocals": true,
9 | "noUnusedParameters": true,
10 | "skipLibCheck": true,
11 | "strictNullChecks": true,
12 | "sourceMap": true,
13 | "esModuleInterop": true,
14 | "declaration": true,
15 | "outDir": "./lib",
16 | "baseUrl": ".",
17 | "paths": {
18 | "N/*": ["node_modules/@hitc/netsuite-types/N/*"]
19 | }
20 | },
21 | "include": [
22 | "src/**/*",
23 | "test/**/*"
24 | ],
25 | "exclude": [
26 | "node_modules",
27 | "lib",
28 | "netsuite"
29 | ]
30 | }
31 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "tslint:latest",
3 | "rules": {
4 | "class-name": true,
5 | "comment-format": [true, "check-lowercase", "check-space"],
6 | "curly": true,
7 | "eofline": true,
8 | "indent": [true, "spaces"],
9 | "label-position": true,
10 | "max-line-length": [true, 140],
11 | "member-ordering": [true,
12 | "public-before-private",
13 | "static-before-instance",
14 | "variables-before-functions"
15 | ],
16 | "no-arg": true,
17 | "no-bitwise": false,
18 | "no-console": [true,
19 | "debug",
20 | "info",
21 | "time",
22 | "timeEnd",
23 | "trace"
24 | ],
25 | "no-construct": true,
26 | "no-debugger": true,
27 | "no-duplicate-variable": true,
28 | "no-empty": true,
29 | "no-empty-interface": true,
30 | "no-eval": true,
31 | "no-shadowed-variable": true,
32 | "no-string-literal": true,
33 | "no-switch-case-fall-through": true,
34 | "no-trailing-whitespace": true,
35 | "no-unused-expression": true,
36 | "no-use-before-declare": true,
37 | "one-line": [true,
38 | "check-open-brace",
39 | "check-catch",
40 | "check-else",
41 | "check-whitespace"
42 | ],
43 | "radix": true,
44 | "semicolon":[
45 | true
46 | ],
47 | "triple-equals": [true, "allow-null-check"],
48 | "variable-name": false,
49 | "whitespace": [true,
50 | "check-branch",
51 | "check-decl",
52 | "check-operator",
53 | "check-separator",
54 | "check-type"
55 | ]
56 | }
57 | }
58 |
--------------------------------------------------------------------------------