├── .gitignore ├── CHANGELOG.md ├── README.md ├── lerna.json ├── package.json ├── packages ├── globalpayments-3ds │ ├── .gitignore │ ├── .npmignore │ ├── .prettierrc │ ├── LICENSE.md │ ├── README.md │ ├── config │ │ └── rollup.js │ ├── package.json │ ├── src │ │ ├── enums.ts │ │ ├── index.ts │ │ ├── interfaces.ts │ │ └── lib │ │ │ ├── gp-error.ts │ │ │ ├── handle-notification-message-event.ts │ │ │ ├── lightbox.ts │ │ │ ├── make-request.ts │ │ │ └── post-to-iframe.ts │ ├── test │ │ ├── acceptance │ │ │ ├── test-challenge.ts │ │ │ ├── test-frictionless.ts │ │ │ └── test-make-request.ts │ │ ├── fixtures │ │ │ ├── mocks │ │ │ │ ├── challenge-acs.ts │ │ │ │ ├── challenge-notification-complete.ts │ │ │ │ ├── check-3ds-version-success.ts │ │ │ │ ├── initiate-authentication-challenge.ts │ │ │ │ ├── initiate-authentication-frictionless-authentication-failed.ts │ │ │ │ ├── initiate-authentication-frictionless-authentication-successful.ts │ │ │ │ └── method-notification-complete.ts │ │ │ └── test-site │ │ │ │ ├── make-request-client-error.html │ │ │ │ ├── make-request-server-error.html │ │ │ │ ├── make-request-success-enrolled.html │ │ │ │ ├── make-request-success-not-enrolled.html │ │ │ │ ├── minimal-payment-page-embedded-dom-target-missing.html │ │ │ │ ├── minimal-payment-page-embedded-dom-target.html │ │ │ │ ├── minimal-payment-page-embedded-string-target-missing.html │ │ │ │ ├── minimal-payment-page-embedded-string-target.html │ │ │ │ ├── minimal-payment-page-lightbox.html │ │ │ │ ├── simple-payment-page-embedded-dom-target-missing.html │ │ │ │ ├── simple-payment-page-embedded-dom-target.html │ │ │ │ ├── simple-payment-page-embedded-string-target-missing.html │ │ │ │ ├── simple-payment-page-embedded-string-target.html │ │ │ │ ├── simple-payment-page-lightbox-cross-origin.html │ │ │ │ └── simple-payment-page-lightbox.html │ │ ├── helpers │ │ │ ├── data.ts │ │ │ └── mocking.ts │ │ └── mocks │ │ │ ├── challenge-complete.ts │ │ │ ├── frictionless-authentication-failed.ts │ │ │ ├── frictionless-authentication-successful-cross-origin.ts │ │ │ ├── frictionless-authentication-successful.ts │ │ │ └── make-request.ts │ ├── tsconfig.json │ └── tslint.json ├── globalpayments-js-loader │ ├── .gitignore │ ├── .npmignore │ ├── LICENSE.md │ ├── index.ts │ ├── package.json │ ├── tsconfig.json │ └── tslint.json ├── globalpayments-js-web-components │ ├── .gitignore │ ├── LICENSE.md │ ├── config │ │ └── rollup.js │ ├── custom-elements.md │ ├── examples │ │ ├── gp-api.html │ │ └── heartland.html │ ├── package.json │ ├── src │ │ ├── components │ │ │ ├── index.ts │ │ │ ├── secure-card-cvv-field.ts │ │ │ ├── secure-card-expiration-field.ts │ │ │ ├── secure-card-number-field.ts │ │ │ ├── secure-payment-element.ts │ │ │ ├── secure-payment-form.ts │ │ │ └── secure-submit-button.ts │ │ └── index.ts │ ├── tsconfig.json │ └── tslint.json ├── globalpayments-js │ ├── .gitignore │ ├── .npmignore │ ├── .prettierrc │ ├── LICENSE.md │ ├── README.md │ ├── TODO │ ├── bin │ │ ├── replace-gp-ref.js │ │ └── update-version.js │ ├── config │ │ └── rollup.js │ ├── cypress.json │ ├── docs │ │ └── images │ │ │ ├── example-drop-in-blank-credit-card.png │ │ │ ├── example-drop-in-blank-echeck.png │ │ │ ├── example-drop-in-blank-gift.png │ │ │ ├── example-drop-in-blank-track.png │ │ │ ├── example-drop-in-credit-card.png │ │ │ ├── example-drop-in-echeck.png │ │ │ ├── example-drop-in-gift.png │ │ │ ├── example-drop-in-track.png │ │ │ ├── example-raw-credit-card.png │ │ │ ├── example-raw-echeck.png │ │ │ ├── example-raw-gift.png │ │ │ ├── example-raw-payment-request-review.png │ │ │ ├── example-raw-payment-request.png │ │ │ └── example-raw-track.png │ ├── examples │ │ ├── accessibility.html │ │ ├── billpay.html │ │ ├── custom-styles │ │ │ └── gp-api-ab.php │ │ ├── genius.html │ │ ├── globalpayments.html │ │ ├── globalpayments │ │ │ └── hash.php │ │ ├── gpApi │ │ │ ├── all-apms.php │ │ │ ├── custom-form.php │ │ │ ├── dcc.php │ │ │ ├── gp-api.php │ │ │ ├── open-banking.php │ │ │ ├── paypal.php │ │ │ ├── qr-code-payments.php │ │ │ └── tsys-bnpl.php │ │ ├── heartland.html │ │ ├── index.html │ │ ├── openedge.html │ │ └── transit │ │ │ ├── create-manifest.php │ │ │ ├── curl.php │ │ │ └── index.php │ ├── package.json │ ├── src │ │ ├── apm │ │ │ ├── enums.ts │ │ │ ├── index.ts │ │ │ ├── non-card-payments │ │ │ │ ├── components │ │ │ │ │ ├── common.ts │ │ │ │ │ ├── constants.ts │ │ │ │ │ └── redirect-action-handler.ts │ │ │ │ └── contracts.ts │ │ │ └── qr-code-payments │ │ │ │ ├── components │ │ │ │ ├── common.ts │ │ │ │ ├── generate-qr-code.ts │ │ │ │ ├── present-qr-code-action-handler.ts │ │ │ │ ├── qr-code-expired-handler.ts │ │ │ │ └── redirect-in-frame-action-handler.ts │ │ │ │ ├── contracts.ts │ │ │ │ ├── helpers.ts │ │ │ │ └── requests │ │ │ │ └── get-qr-code-payment-methods.ts │ │ ├── assets │ │ │ ├── artifactVersion.txt │ │ │ ├── field.html │ │ │ ├── fonts │ │ │ │ ├── DMSans-Regular.ttf │ │ │ │ ├── GPCommerce-Regular.woff2 │ │ │ │ └── OpenSans-Regular.ttf │ │ │ ├── images │ │ │ │ ├── Bankova_Platba_Logo.svg │ │ │ │ ├── Bankovni_Platba_Logo.svg │ │ │ │ ├── BrandFooterLogo_BOIPA_Desktop.svg │ │ │ │ ├── BrandFooterLogo_BOIPA_Desktop_UK.svg │ │ │ │ ├── BrandFooterLogo_BOIPA_Tablet_Mobile.svg │ │ │ │ ├── BrandFooterLogo_BOIPA_Tablet_Mobile_UK.svg │ │ │ │ ├── BrandFooterLogo_COMMERZBANK_Desktop.svg │ │ │ │ ├── BrandFooterLogo_COMMERZBANK_Tablet_Mobile.svg │ │ │ │ ├── BrandFooterLogo_ESERVICE_Desktop.svg │ │ │ │ ├── BrandFooterLogo_ESERVICE_Tablet_Mobile.svg │ │ │ │ ├── BrandFooterLogo_NBGPAY_Desktop.svg │ │ │ │ ├── BrandFooterLogo_NBGPAY_Tablet_Mobile.svg │ │ │ │ ├── BrandSecurityIcon_BOIPA.svg │ │ │ │ ├── BrandSecurityIcon_Commerzbank.svg │ │ │ │ ├── BrandSecurityIcon_EService.svg │ │ │ │ ├── BrandSecurityIcon_NBGPay.svg │ │ │ │ ├── Cashpresso30Days.svg │ │ │ │ ├── Cashpresso3Installments.svg │ │ │ │ ├── CashpressoInstallments.svg │ │ │ │ ├── Przelew_Online_Logo.svg │ │ │ │ ├── alert-icon.svg │ │ │ │ ├── amex.svg │ │ │ │ ├── bank-logos │ │ │ │ │ ├── 365 bank.svg │ │ │ │ │ ├── BCAI_AirBank.svg │ │ │ │ │ ├── BCCS_CeskaSporitlena2023Blue.svg │ │ │ │ │ ├── BCKB_KomercniBanka.svg │ │ │ │ │ ├── BCMO_MonetaMoneyBank.svg │ │ │ │ │ ├── BCOB_CSOB.svg │ │ │ │ │ ├── BCRB_RaiffeisenBank2023.svg │ │ │ │ │ ├── BPUA_PayU_AliorBank.svg │ │ │ │ │ ├── BPUB_PayU_BankNowySA.svg │ │ │ │ │ ├── BPUC_PayU_BankiSpoldzielcze.svg │ │ │ │ │ ├── BPUD_PayU_BNPParibas.svg │ │ │ │ │ ├── BPUE_PayU_BOSBank.svg │ │ │ │ │ ├── BPUF_PayU_Citi.svg │ │ │ │ │ ├── BPUG_PayU_CreditAgricole.svg │ │ │ │ │ ├── BPUH_PayU_ING.svg │ │ │ │ │ ├── BPUI_PayU_Inteligo.svg │ │ │ │ │ ├── BPUJ_PayU_IPKO_BankPolski.svg │ │ │ │ │ ├── BPUK_PayU_mBank.svg │ │ │ │ │ ├── BPUL_PayU_MilleniumBank.svg │ │ │ │ │ ├── BPUM_PayU_NestBank.svg │ │ │ │ │ ├── BPUN_PayU_NobleBank.svg │ │ │ │ │ ├── BPUO_PayU_BankPekaoSA.svg │ │ │ │ │ ├── BPUP_PayU_PlusBank.svg │ │ │ │ │ ├── BPUQ_PayU_Santander.svg │ │ │ │ │ ├── BSFI_FioBanka.svg │ │ │ │ │ ├── BSTB_TatraBanka.svg │ │ │ │ │ ├── BSUB_UniCreditBank.svg │ │ │ │ │ ├── BSVB_VUBBanka.svg │ │ │ │ │ ├── Banka Creditas.svg │ │ │ │ │ ├── Ceska posta.svg │ │ │ │ │ ├── J&T BANKA.svg │ │ │ │ │ ├── QR_Platba_Logo.svg │ │ │ │ │ ├── bank-pocztowy-logo.svg │ │ │ │ │ ├── logo-slovenska-sporitelna 1.svg │ │ │ │ │ ├── velo_bank_logo.svg │ │ │ │ │ └── viamo.svg │ │ │ │ ├── blik.svg │ │ │ │ ├── card-brands.svg │ │ │ │ ├── clock-timer.svg │ │ │ │ ├── cross-grey.svg │ │ │ │ ├── ctp-check.svg │ │ │ │ ├── ctp-coloured-cards.svg │ │ │ │ ├── ctp-lock.svg │ │ │ │ ├── ctp-shopping-cart.svg │ │ │ │ ├── ctp.svg │ │ │ │ ├── cvv-amex.png │ │ │ │ ├── cvv.png │ │ │ │ ├── discover.svg │ │ │ │ ├── external-link.svg │ │ │ │ ├── gp-cc-amex.svg │ │ │ │ ├── gp-cc-carnet.svg │ │ │ │ ├── gp-cc-diners.svg │ │ │ │ ├── gp-cc-dinnersclub.svg │ │ │ │ ├── gp-cc-discover.svg │ │ │ │ ├── gp-cc-generic.svg │ │ │ │ ├── gp-cc-jcb.svg │ │ │ │ ├── gp-cc-maestro.svg │ │ │ │ ├── gp-cc-mastercard.svg │ │ │ │ ├── gp-cc-visa.svg │ │ │ │ ├── gp-fa-question-circle.svg │ │ │ │ ├── gp-lock-alt.svg │ │ │ │ ├── gp-lock.svg │ │ │ │ ├── gp-secure-logo.svg │ │ │ │ ├── gp-secure-ssl-logo.svg │ │ │ │ ├── info-circle.svg │ │ │ │ ├── info.svg │ │ │ │ ├── jcb.svg │ │ │ │ ├── logo-amex@2x.png │ │ │ │ ├── logo-discover@2x.png │ │ │ │ ├── logo-jcb@2x.png │ │ │ │ ├── logo-mastercard@2x.png │ │ │ │ ├── logo-unknown@2x.png │ │ │ │ ├── logo-visa@2x.png │ │ │ │ ├── mastercard.svg │ │ │ │ ├── open-banking.svg │ │ │ │ ├── paypal.svg │ │ │ │ ├── qr-code-expired.png │ │ │ │ ├── qr-code-redirect-logo.png │ │ │ │ ├── realex-grey.png │ │ │ │ ├── shield-and-logos@2x.png │ │ │ │ ├── ssl_logo_ico.svg │ │ │ │ ├── virgin-money-logo.png │ │ │ │ └── visa.svg │ │ │ └── vendor │ │ │ │ └── qrcode.js │ │ ├── common │ │ │ ├── browser-helpers.ts │ │ │ ├── constants.ts │ │ │ ├── currency.ts │ │ │ ├── enums.ts │ │ │ ├── helpers.ts │ │ │ └── html-element.ts │ │ ├── credit-card │ │ │ └── index.ts │ │ ├── echeck │ │ │ └── index.ts │ │ ├── gift-and-loyalty │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── internal │ │ │ ├── built-in-validations │ │ │ │ ├── constants.ts │ │ │ │ ├── english-characters-validation.ts │ │ │ │ ├── field-validator.ts │ │ │ │ ├── helpers.ts │ │ │ │ └── messages.ts │ │ │ ├── formatters │ │ │ │ ├── card-number.ts │ │ │ │ ├── expiration.ts │ │ │ │ └── formatter.ts │ │ │ ├── gateways │ │ │ │ ├── billpay │ │ │ │ │ ├── action-normalize-response.ts │ │ │ │ │ ├── action-tokenize.ts │ │ │ │ │ ├── action-validate-data.ts │ │ │ │ │ └── index.ts │ │ │ │ ├── genius │ │ │ │ │ ├── action-normalize-response.ts │ │ │ │ │ ├── action-tokenize.ts │ │ │ │ │ ├── action-validate-data.ts │ │ │ │ │ └── index.ts │ │ │ │ ├── globalpayments │ │ │ │ │ ├── action-normalize-response.ts │ │ │ │ │ ├── action-onload.ts │ │ │ │ │ ├── action-setup.ts │ │ │ │ │ ├── action-tokenize.ts │ │ │ │ │ ├── action-validate-data.ts │ │ │ │ │ └── index.ts │ │ │ │ ├── gp-api │ │ │ │ │ ├── action-normalize-response.ts │ │ │ │ │ ├── action-query-currency-conversion.ts │ │ │ │ │ ├── action-query-installment-plans.ts │ │ │ │ │ ├── action-tokenize.ts │ │ │ │ │ ├── action-validate-data.ts │ │ │ │ │ ├── get-apm-payment-methods.ts │ │ │ │ │ ├── get-asset-base-url.ts │ │ │ │ │ ├── get-env.ts │ │ │ │ │ └── index.ts │ │ │ │ ├── heartland │ │ │ │ │ ├── action-normalize-response.ts │ │ │ │ │ ├── action-tokenize.ts │ │ │ │ │ ├── action-validate-data.ts │ │ │ │ │ └── index.ts │ │ │ │ ├── index.ts │ │ │ │ ├── openedge │ │ │ │ │ ├── action-normalize-response.ts │ │ │ │ │ ├── action-tokenize.ts │ │ │ │ │ ├── action-validate-data.ts │ │ │ │ │ ├── get-asset-base-url.ts │ │ │ │ │ ├── get-env.ts │ │ │ │ │ └── index.ts │ │ │ │ └── transit │ │ │ │ │ ├── action-normalize-response.ts │ │ │ │ │ ├── action-tokenize.ts │ │ │ │ │ ├── action-validate-data.ts │ │ │ │ │ └── index.ts │ │ │ ├── index.ts │ │ │ ├── lib │ │ │ │ ├── add-footer-branded-icons.ts │ │ │ │ ├── add-footer-icons.ts │ │ │ │ ├── add-sandbox-alert.ts │ │ │ │ ├── asset-base-url.ts │ │ │ │ ├── bank-selection │ │ │ │ │ ├── available-banks-data.ts │ │ │ │ │ ├── contracts.ts │ │ │ │ │ └── helpers.ts │ │ │ │ ├── build-tokenization-url.ts │ │ │ │ ├── card-types.ts │ │ │ │ ├── card.ts │ │ │ │ ├── currency-conversion │ │ │ │ │ ├── components │ │ │ │ │ │ ├── enums.ts │ │ │ │ │ │ ├── events.ts │ │ │ │ │ │ └── template.ts │ │ │ │ │ ├── contracts │ │ │ │ │ │ ├── constants.ts │ │ │ │ │ │ ├── enums.ts │ │ │ │ │ │ └── interfaces.ts │ │ │ │ │ ├── requests │ │ │ │ │ │ └── query-currency-conversion.ts │ │ │ │ │ └── utils │ │ │ │ │ │ ├── helpers.ts │ │ │ │ │ │ └── reset-currency-conversion.ts │ │ │ │ ├── detectLanguage.ts │ │ │ │ ├── dot-placeholders.ts │ │ │ │ ├── encode-entities.ts │ │ │ │ ├── enums.ts │ │ │ │ ├── ev.ts │ │ │ │ ├── events.ts │ │ │ │ ├── get-gateway.ts │ │ │ │ ├── installments │ │ │ │ │ ├── components │ │ │ │ │ │ ├── add-issuer-banner.ts │ │ │ │ │ │ └── modal │ │ │ │ │ │ │ ├── create-modal-component.ts │ │ │ │ │ │ │ └── styles.ts │ │ │ │ │ ├── contracts │ │ │ │ │ │ ├── constants.ts │ │ │ │ │ │ ├── enums.ts │ │ │ │ │ │ ├── installment-action.ts │ │ │ │ │ │ ├── installment-payment-method.ts │ │ │ │ │ │ ├── installment-plans-data.ts │ │ │ │ │ │ ├── installment-term-fees.ts │ │ │ │ │ │ └── installment-term.ts │ │ │ │ │ ├── helpers │ │ │ │ │ │ ├── currency.ts │ │ │ │ │ │ └── html-element.ts │ │ │ │ │ ├── installments-handler.ts │ │ │ │ │ ├── requests │ │ │ │ │ │ └── query-installment-plans.ts │ │ │ │ │ └── templates │ │ │ │ │ │ ├── common.ts │ │ │ │ │ │ ├── create-step-0.ts │ │ │ │ │ │ ├── create-step-1.ts │ │ │ │ │ │ └── modals.ts │ │ │ │ ├── loaded-frames.ts │ │ │ │ ├── object-assign.ts │ │ │ │ ├── options.ts │ │ │ │ ├── order-information │ │ │ │ │ ├── constants.ts │ │ │ │ │ └── contracts.ts │ │ │ │ ├── payment-field-id.ts │ │ │ │ ├── post-message.ts │ │ │ │ ├── set-headers.ts │ │ │ │ ├── styles.ts │ │ │ │ ├── styles │ │ │ │ │ ├── apple-pay │ │ │ │ │ │ └── common.ts │ │ │ │ │ ├── bank-selection │ │ │ │ │ │ └── common.ts │ │ │ │ │ ├── built-in-validations │ │ │ │ │ │ ├── common.ts │ │ │ │ │ │ ├── default.ts │ │ │ │ │ │ ├── gp-default.ts │ │ │ │ │ │ └── simple.ts │ │ │ │ │ ├── click-to-pay │ │ │ │ │ │ ├── default.ts │ │ │ │ │ │ ├── gp-default.ts │ │ │ │ │ │ └── simple.ts │ │ │ │ │ ├── currency-conversion │ │ │ │ │ │ ├── common.ts │ │ │ │ │ │ ├── default.ts │ │ │ │ │ │ ├── gp-default.ts │ │ │ │ │ │ └── simple.ts │ │ │ │ │ ├── default.ts │ │ │ │ │ ├── google-pay │ │ │ │ │ │ └── common.ts │ │ │ │ │ ├── gp-default.ts │ │ │ │ │ ├── installments │ │ │ │ │ │ ├── common.ts │ │ │ │ │ │ ├── default.ts │ │ │ │ │ │ ├── gp-default.ts │ │ │ │ │ │ └── simple.ts │ │ │ │ │ ├── order-information │ │ │ │ │ │ └── common.ts │ │ │ │ │ ├── payment-methods │ │ │ │ │ │ ├── common.ts │ │ │ │ │ │ ├── open-banking.ts │ │ │ │ │ │ ├── paypal.ts │ │ │ │ │ │ └── qr-code-payments.ts │ │ │ │ │ ├── simple.ts │ │ │ │ │ ├── themes │ │ │ │ │ │ ├── brand-themes │ │ │ │ │ │ │ ├── base │ │ │ │ │ │ │ │ ├── base-theme-preset.ts │ │ │ │ │ │ │ │ ├── base-theme.ts │ │ │ │ │ │ │ │ ├── base-token-definition.ts │ │ │ │ │ │ │ │ └── contracts.ts │ │ │ │ │ │ │ ├── brand-theme-boipa-uk.ts │ │ │ │ │ │ │ ├── brand-theme-boipa.ts │ │ │ │ │ │ │ ├── brand-theme-commerzbank.ts │ │ │ │ │ │ │ ├── brand-theme-e-service.ts │ │ │ │ │ │ │ ├── brand-theme-nbg-pay.ts │ │ │ │ │ │ │ └── brand-themes.ts │ │ │ │ │ │ └── helpers.ts │ │ │ │ │ └── tooltip │ │ │ │ │ │ └── common.ts │ │ │ │ ├── translate.ts │ │ │ │ ├── translations │ │ │ │ │ ├── cs.ts │ │ │ │ │ ├── de.ts │ │ │ │ │ ├── el.ts │ │ │ │ │ ├── en.ts │ │ │ │ │ ├── es.ts │ │ │ │ │ ├── et.ts │ │ │ │ │ ├── fr.ts │ │ │ │ │ ├── ga.ts │ │ │ │ │ ├── hr.ts │ │ │ │ │ ├── hu.ts │ │ │ │ │ ├── it.ts │ │ │ │ │ ├── ja.ts │ │ │ │ │ ├── lv.ts │ │ │ │ │ ├── mt.ts │ │ │ │ │ ├── nl.ts │ │ │ │ │ ├── pl.ts │ │ │ │ │ ├── pt.ts │ │ │ │ │ ├── ro.ts │ │ │ │ │ ├── ru.ts │ │ │ │ │ ├── sk.ts │ │ │ │ │ ├── sl.ts │ │ │ │ │ ├── sv.ts │ │ │ │ │ ├── tr.ts │ │ │ │ │ ├── translations.ts │ │ │ │ │ ├── uk.ts │ │ │ │ │ ├── vi.ts │ │ │ │ │ └── zh.ts │ │ │ │ └── util.ts │ │ │ ├── requests │ │ │ │ └── tokenize.ts │ │ │ └── validators │ │ │ │ ├── card-number.ts │ │ │ │ ├── cvv.ts │ │ │ │ ├── expiration.ts │ │ │ │ └── validator.ts │ │ ├── lib │ │ │ └── version.ts │ │ ├── payment-request │ │ │ ├── complete.ts │ │ │ ├── defaults.ts │ │ │ ├── index.ts │ │ │ └── setup.ts │ │ ├── tools │ │ │ └── configure.ts │ │ └── ui │ │ │ ├── components │ │ │ ├── bank-selection │ │ │ │ └── action-add-bank-selection.ts │ │ │ └── order-information │ │ │ │ └── action-add-order-information.ts │ │ │ ├── form │ │ │ └── index.ts │ │ │ ├── iframe-field │ │ │ ├── action-accumulate-data-and-tokenize.ts │ │ │ ├── action-add-stylesheet.ts │ │ │ ├── action-card-track-button-click.ts │ │ │ ├── action-get-cvv.ts │ │ │ ├── action-hide-validation.ts │ │ │ ├── action-payment-request-complete.ts │ │ │ ├── action-payment-request-start.ts │ │ │ ├── action-request-data.ts │ │ │ ├── action-set-card-type.ts │ │ │ ├── action-set-custom-message.ts │ │ │ ├── action-set-focus.ts │ │ │ ├── action-set-label.ts │ │ │ ├── action-set-placeholder.ts │ │ │ ├── action-set-text.ts │ │ │ ├── action-set-type-cvv.ts │ │ │ ├── action-set-value.ts │ │ │ ├── action-show-validation.ts │ │ │ ├── action-validate-form.ts │ │ │ ├── action-validate-value.ts │ │ │ ├── apple-pay │ │ │ │ └── action-add.ts │ │ │ ├── click-to-pay │ │ │ │ └── action-add.ts │ │ │ ├── currency-conversion │ │ │ │ ├── action-add.ts │ │ │ │ ├── action-get-value.ts │ │ │ │ ├── action-request-accumulate-data.ts │ │ │ │ ├── action-request-data.ts │ │ │ │ └── action-request-start.ts │ │ │ ├── google-pay │ │ │ │ └── action-add.ts │ │ │ ├── index.ts │ │ │ ├── installments │ │ │ │ ├── action-add.ts │ │ │ │ ├── action-request-accumulate-data.ts │ │ │ │ ├── action-request-data.ts │ │ │ │ └── action-request-start.ts │ │ │ ├── payment-methods │ │ │ │ └── action-add.ts │ │ │ └── qr-code-payment-methods │ │ │ │ ├── action-add.ts │ │ │ │ └── action-request-start.ts │ │ │ └── index.ts │ ├── test │ │ ├── fixtures │ │ │ ├── accessibility │ │ │ │ └── runner.html │ │ │ ├── billpay │ │ │ │ ├── ach │ │ │ │ │ └── runner.html │ │ │ │ └── card │ │ │ │ │ └── runner.html │ │ │ ├── genius │ │ │ │ └── card │ │ │ │ │ └── runner.html │ │ │ ├── globalpayments │ │ │ │ ├── card-dropin │ │ │ │ │ └── runner.html │ │ │ │ ├── card │ │ │ │ │ └── runner.html │ │ │ │ └── sha1.min.js │ │ │ ├── gp-api │ │ │ │ ├── card-dropin │ │ │ │ │ └── runner.html │ │ │ │ ├── card │ │ │ │ │ └── runner.html │ │ │ │ └── sha512.js │ │ │ ├── heartland │ │ │ │ ├── ach-dropin │ │ │ │ │ └── runner.html │ │ │ │ ├── ach │ │ │ │ │ └── runner.html │ │ │ │ ├── card-attributes │ │ │ │ │ └── runner.html │ │ │ │ ├── card-bin-checks │ │ │ │ │ └── runner.html │ │ │ │ ├── card-disposal │ │ │ │ │ └── runner.html │ │ │ │ ├── card-dropin │ │ │ │ │ └── runner.html │ │ │ │ ├── card-styled │ │ │ │ │ └── runner.html │ │ │ │ ├── card-track │ │ │ │ │ └── runner.html │ │ │ │ ├── card │ │ │ │ │ └── runner.html │ │ │ │ ├── gift-dropin │ │ │ │ │ └── runner.html │ │ │ │ ├── gift │ │ │ │ │ └── runner.html │ │ │ │ ├── sandbox-alert-non-prod │ │ │ │ │ └── runner.html │ │ │ │ └── sandbox-alert-prod │ │ │ │ │ └── runner.html │ │ │ ├── openedge │ │ │ │ └── card │ │ │ │ │ └── runner.html │ │ │ └── transit │ │ │ │ └── card │ │ │ │ └── runner.html │ │ ├── integration │ │ │ ├── billpay │ │ │ │ └── tokenization_spec.js │ │ │ ├── experience │ │ │ │ ├── accessibility_spec.js │ │ │ │ ├── attributes_spec.js │ │ │ │ ├── disposal_spec.js │ │ │ │ ├── formatting_spec.js │ │ │ │ ├── sandbox-alert_spec.js │ │ │ │ ├── styles_spec.js │ │ │ │ ├── type-detection_spec.js │ │ │ │ └── validation_spec.js │ │ │ ├── genius │ │ │ │ └── tokenization_spec.js │ │ │ ├── globalpayments │ │ │ │ └── tokenization_spec.js │ │ │ ├── gp-api │ │ │ │ ├── fields-behave_spec.js │ │ │ │ └── tokenization_spec.js │ │ │ ├── heartland │ │ │ │ └── tokenization_spec.js │ │ │ ├── openedge │ │ │ │ └── tokenization_spec.js │ │ │ └── transit │ │ │ │ └── tokenization_spec.js │ │ ├── plugins │ │ │ └── index.js │ │ ├── run.ps1 │ │ ├── run.sh │ │ └── support │ │ │ ├── helpers.js │ │ │ └── index.js │ ├── tsconfig.json │ ├── tslint.json │ └── types │ │ └── global-type.d.ts └── globalpayments-lib │ ├── .gitignore │ ├── .npmignore │ ├── .prettierrc │ ├── LICENSE.md │ ├── package.json │ ├── polyfills.js │ ├── src │ ├── event-emitter.ts │ ├── generate-guid.ts │ ├── index.ts │ └── polyfills │ │ ├── array-foreach.ts │ │ ├── base64.ts │ │ ├── index.ts │ │ ├── json.ts │ │ ├── json2.ts │ │ ├── object-freeze.ts │ │ ├── object-getownpropertynames.ts │ │ ├── parentnode-prepend.ts │ │ ├── promise.ts │ │ └── string-repeat.ts │ ├── tsconfig.json │ └── tslint.json ├── tsconfig.json └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Global Payments 2 | 3 | ## Packages 4 | 5 | - [`@globalpayments/js`](packages/globalpayments-js) - JavaScript library for web applications to connect to Heartland eCommerce & Global Payments eCommerce tokenization services 6 | - [`@globalpayments/js-loader`](packages/globalpayments-js-loader) - IN PROGRESS - Helper library for dynamically loading `@globalpayments/js` within web applications 7 | - [`@globalpayments/js-web-components`](packages/globalpayments-js-web-components) - IN PROGRESS - Exposes web components / custom elements around `@globalpayments/js` 8 | - [`globalpayments-3ds`](packages/globalpayments-3ds) - Helper library for leveraging 3DSecure 2 for Strong Customer Authentication (SCA) 9 | - [`globalpayments-lib`](packages/globalpayments-lib) - Helper library for Global Payments JavaScript libraries 10 | 11 | ## Development 12 | 13 | This monorepo uses [`lerna`](https://github.com/lerna/lerna). Run the below to get started within a new environment: 14 | 15 | ``` 16 | yarn install 17 | yarn lerna bootstrap 18 | ``` 19 | 20 | This will install all dependencies as well as a local copy of `lerna`. 21 | 22 | Common scripts can be ran across packages, e.g.: 23 | 24 | ``` 25 | yarn lerna run build 26 | ``` 27 | 28 | Scripts can be ran against individual packages as well, e.g.: 29 | 30 | ``` 31 | yarn lerna run --scope=@globalpayments/js test 32 | ``` 33 | 34 | ## Supported Browsers 35 | 36 | The library is supported on the following browsers: 37 | * Google Chrome 38 | * Safari 39 | * Microsoft Edge 40 | * Opera 41 | * Mozilla Firefox -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages": [ 3 | "packages/*" 4 | ], 5 | "npmClient": "yarn", 6 | "useWorkspaces": true, 7 | "version": "4.1.10", 8 | "command": { 9 | "run": { 10 | "stream": true 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "root", 3 | "version": "4.1.10", 4 | "private": true, 5 | "devDependencies": { 6 | "@rollup/plugin-commonjs": "^16.0.0", 7 | "@rollup/plugin-node-resolve": "^10.0.0", 8 | "@types/base64-js": "^1.3.0", 9 | "@types/promise-polyfill": "^6.0.3", 10 | "cypress": "^6.0.0", 11 | "cypress-axe": "^0.11.0", 12 | "lerna": "^3.22.1", 13 | "prettier": "^2.2.0", 14 | "replace-in-file": "^6.1.0", 15 | "rimraf": "^3.0.2", 16 | "rollup": "^2.33.3", 17 | "rollup-plugin-node-builtins": "^2.1.2", 18 | "rollup-plugin-terser": "^7.0.2", 19 | "rollup-plugin-typescript2": "^0.29.0", 20 | "serve": "^11.3.2", 21 | "start-server-and-test": "^1.11.6", 22 | "testcafe": "^1.9.4", 23 | "tslint": "^6.1.3", 24 | "typescript": "^4.1.2", 25 | "web-component-analyzer": "^1.1.6", 26 | "cross-os": "^1.4.0" 27 | }, 28 | "dependencies": { 29 | "@globalpayments/js": "file:packages/globalpayments-js", 30 | "@globalpayments/js-loader": "file:packages/globalpayments-js-loader", 31 | "@globalpayments/js-web-components": "file:packages/globalpayments-js-web-components", 32 | "globalpayments-3ds": "file:packages/globalpayments-3ds", 33 | "globalpayments-lib": "file:packages/globalpayments-lib" 34 | }, 35 | "workspaces": [ 36 | "packages/*" 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/.gitignore: -------------------------------------------------------------------------------- 1 | .rpt2_cache/ 2 | dist/ 3 | node_modules/ 4 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/.npmignore: -------------------------------------------------------------------------------- 1 | .rpt2_cache/ 2 | config/ 3 | !dist/ 4 | node_modules/ 5 | src/ 6 | test/ 7 | .prettierrc 8 | tsconfig.json 9 | tslint.json 10 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "always", 3 | "trailingComma": "all" 4 | } 5 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/src/lib/gp-error.ts: -------------------------------------------------------------------------------- 1 | export interface IGPErrorReason { 2 | code: string; 3 | message: string; 4 | } 5 | 6 | export class GPError extends Error { 7 | public error = true; 8 | public reasons: IGPErrorReason[]; 9 | 10 | constructor(reasons: IGPErrorReason[], message?: string) { 11 | super(message || "Error: see `reasons` property"); 12 | this.reasons = reasons; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/src/lib/handle-notification-message-event.ts: -------------------------------------------------------------------------------- 1 | import { 2 | IChallengeNotificationData, 3 | IMethodNotificationData, 4 | } from "../interfaces"; 5 | 6 | export function handleNotificationMessageEvent( 7 | event: string, 8 | data: IChallengeNotificationData | IMethodNotificationData, 9 | origin?: string, 10 | ) { 11 | if (window.parent !== window) { 12 | window.parent.postMessage( 13 | { data, event }, 14 | origin || window.location.origin, 15 | ); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/src/lib/make-request.ts: -------------------------------------------------------------------------------- 1 | import { GPError } from "./gp-error"; 2 | 3 | // tslint:disable-next-line:no-empty-interface 4 | export interface IRequestData {} 5 | 6 | // tslint:disable-next-line:no-empty-interface 7 | export interface IResponseData {} 8 | 9 | export async function makeRequest( 10 | endpoint: string, 11 | data: IRequestData, 12 | headers: Record, 13 | ): Promise { 14 | const defaultHeaders = { 15 | "Content-Type": "application/json", 16 | }; 17 | const requestHeaders = Object.assign({}, defaultHeaders, headers); 18 | 19 | try { 20 | const rawResponse = await fetch(endpoint, { 21 | body: JSON.stringify(data), 22 | credentials: "omit", 23 | headers: typeof Headers !== "undefined" ? new Headers(requestHeaders) : requestHeaders, 24 | method: "POST", 25 | }); 26 | 27 | if (!rawResponse.ok) { 28 | throw new GPError( 29 | [ 30 | { 31 | code: rawResponse.status.toString(), 32 | message: await rawResponse.text(), 33 | }, 34 | ], 35 | rawResponse.statusText, 36 | ); 37 | } 38 | 39 | return await rawResponse.json(); 40 | } catch (e) { 41 | let reasons = [{ code: e.name, message: e.message }]; 42 | if (e.reasons) { 43 | reasons = reasons.concat(e.reasons); 44 | } 45 | throw new GPError(reasons); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/fixtures/mocks/challenge-notification-complete.ts: -------------------------------------------------------------------------------- 1 | export default ``; 16 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/fixtures/mocks/check-3ds-version-success.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | enrolled: true, 3 | // tslint:disable-next-line:max-line-length 4 | methodData: 5 | "ewogICJ0aHJlZURTU2VydmVyVHJhbnNJRCIgOiAiMzMyMjE5YTQtNWMzYS00Yjc4LTg3ZWItY2EwYzBhNzRhMzM4IiwKICAidGhyZWVEU01ldGhvZE5vdGlmaWNhdGlvblVSTCIgOiAiaHR0cDovLzNkczIubG9jYWxob3N0L21ldGhvZC1ub3RpZmljYXRpb24ucGhwIgp9", 6 | methodUrl: "http://localhost:7778/acs/methodData?delay=1000", 7 | serverTransactionId: "332219a4-5c3a-4b78-87eb-ca0c0a74a338", 8 | versions: { 9 | accessControlServer: { 10 | end: "2.1.0", 11 | start: "2.1.0", 12 | }, 13 | directoryServer: { 14 | end: "2.1.0", 15 | start: "2.1.0", 16 | }, 17 | }, 18 | }; 19 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/fixtures/mocks/initiate-authentication-challenge.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable:max-line-length 2 | 3 | export default { 4 | acsTransactionId: "3ad375c8-4380-4ba5-bda1-7cc9cc1a2cf1", 5 | authenticationRequestType: "MERCHANT_SYSTEM_AUTHENTICATION", 6 | authenticationSource: "BROWSER", 7 | cardholderResponseInfo: null, 8 | challenge: { 9 | encodedChallengeRequest: 10 | "eyJ0aHJlZURTU2VydmVyVHJhbnNJRCI6IjZkMGUzM2Y0LTAwODQtNDA2Yy1iN2E5LTc2NWI1ZjA1MjkzNiIsImFjc1RyYW5zSUQiOiIzYWQzNzVjOC00MzgwLTRiYTUtYmRhMS03Y2M5Y2MxYTJjZjEiLCJtZXNzYWdlRXh0ZW5zaW9uIjpbeyJjcml0aWNhbGl0eUluZGljYXRvciI6dHJ1ZSwiZGF0YSI6InNvbWUgc2FtcGxlIGRhdGEiLCJpZCI6ImV4dC0wMDEiLCJuYW1lIjoic2FtcGxlIn1dLCJtZXNzYWdlVHlwZSI6IkNSZXEiLCJtZXNzYWdlVmVyc2lvbiI6IjIuMS4wIiwiY2hhbGxlbmdlV2luZG93U2l6ZSI6IjA1In0=", 11 | requestUrl: "http://localhost:8190/acs/challenge", 12 | windowSize: null, 13 | }, 14 | challengeMandated: true, 15 | deviceRenderOptions: { 16 | sdk_interface: "BROWSER", 17 | sdk_ui_type: ["MULTI_SELECT"], 18 | }, 19 | dsTransactionId: "e09822e9-a08b-4139-9aac-d0b3e95f504b", 20 | messageCategory: "PAYMENT_AUTHENTICATION", 21 | messageExtension: [ 22 | { 23 | criticality_indicator: true, 24 | data: "some sample data", 25 | id: "ext-001", 26 | name: "sample", 27 | }, 28 | ], 29 | messageVersion: "2.1.0", 30 | mpi: { 31 | authenticationValue: null, 32 | eci: null, 33 | }, 34 | serverTransactionId: "6d0e33f4-0084-406c-b7a9-765b5f052936", 35 | status: "CHALLENGE_REQUIRED", 36 | statusReason: null, 37 | }; 38 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/fixtures/mocks/initiate-authentication-frictionless-authentication-failed.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable:max-line-length 2 | 3 | export default { 4 | acsTransactionId: "13c701a3-5a88-4c45-89e9-ef65e50a8bf9", 5 | authenticationRequestType: "PAYMENT_TRANSACTION", 6 | authenticationSource: "BROWSER", 7 | cardholderResponseInfo: 8 | "Additional authentication is needed for this transaction, please contact [Issuer Name] at 123-456-7890", 9 | dsTransactionId: "c272b04f-6e7b-43a2-bb78-90f4fb94aa25", 10 | messageCategory: "PAYMENT_AUTHENTICATION", 11 | messageVersion: "2.1.0", 12 | mpi: { 13 | authenticationValue: "ODQzNjgwNjU0ZjM3N2JmYTg0NTM=", 14 | eci: "7", 15 | }, 16 | serverTransactionId: "af65c369-59b9-4f8d-b2f6-7d7d5f5c69d5", 17 | status: "AUTHENTICATION_FAILED", 18 | statusReason: "CARD_AUTHENTICATION_FAILED", 19 | }; 20 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/fixtures/mocks/initiate-authentication-frictionless-authentication-successful.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | acsTransactionId: "dcb27803-7f90-4610-977f-97557dab0fb8", 3 | authenticationRequestType: "NOT_AUTHENTICATED", 4 | authenticationSource: "BROWSER", 5 | cardholderResponseInfo: "Please contact (Issuer Name) at xxx-xxx-xxxx.", 6 | dsTransactionId: "5d641478-658b-489e-8c58-beb96c4a7cd0", 7 | messageCategory: "PAYMENT_AUTHENTICATION", 8 | messageVersion: "2.1.0", 9 | mpi: { 10 | authenticationValue: "MTIzNDU2Nzg5MDA5ODc2NTQzMjE=", 11 | eci: "05", 12 | }, 13 | serverTransactionId: "2d8641ec-7242-400b-9807-47c2ffe3195f", 14 | status: "AUTHENTICATION_SUCCESSFUL", 15 | }; 16 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/fixtures/mocks/method-notification-complete.ts: -------------------------------------------------------------------------------- 1 | export default ``; 11 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/fixtures/test-site/make-request-client-error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 35 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/fixtures/test-site/make-request-server-error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 35 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/fixtures/test-site/make-request-success-enrolled.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 35 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/fixtures/test-site/make-request-success-not-enrolled.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 35 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/fixtures/test-site/minimal-payment-page-embedded-dom-target-missing.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 53 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/fixtures/test-site/minimal-payment-page-embedded-dom-target.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 53 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/fixtures/test-site/minimal-payment-page-embedded-string-target-missing.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 53 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/fixtures/test-site/minimal-payment-page-embedded-string-target.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 53 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/fixtures/test-site/minimal-payment-page-lightbox.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 51 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/helpers/data.ts: -------------------------------------------------------------------------------- 1 | import { ClientFunction, Selector } from "testcafe"; 2 | 3 | export const getVersionCheckData = ClientFunction( 4 | () => (window as any).__versionCheckData, 5 | ); 6 | export const getInitiateAuthenticationData = ClientFunction( 7 | () => (window as any).__initiateAuthenticationData, 8 | ); 9 | export const getCurrentDocument = () => Selector("body"); 10 | export const getIframe = () => 11 | Selector('iframe[id*="GlobalPayments-3DSecure"]'); 12 | export const getOverlay = () => Selector('div[id*="GlobalPayments-overlay"]'); 13 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/helpers/mocking.ts: -------------------------------------------------------------------------------- 1 | import { RequestMock } from "testcafe"; 2 | 3 | export const successfulHtmlResponse = ( 4 | requestMock: RequestMock, 5 | request: RegExp, 6 | data: string, 7 | ) => 8 | requestMock 9 | .onRequestTo(request) 10 | .respond(data, 200, { 11 | "Content-Type": "text/html", 12 | "Access-Control-Allow-Origin": "*", 13 | }); 14 | 15 | export const successfulJsonResponse = ( 16 | requestMock: RequestMock, 17 | request: RegExp, 18 | data: any, 19 | ) => 20 | requestMock 21 | .onRequestTo(request) 22 | .respond(JSON.stringify(data), 200, { 23 | "Content-Type": "application/json", 24 | "Access-Control-Allow-Origin": "*", 25 | }); 26 | 27 | export const successfulRedirectResponse = ( 28 | requestMock: RequestMock, 29 | request: RegExp, 30 | data: string, 31 | ) => requestMock.onRequestTo(request).respond("", 302, { Location: data }); 32 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/mocks/challenge-complete.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable:max-line-length 2 | import { RequestMock } from "testcafe"; 3 | 4 | import challengeAcs from "../fixtures/mocks/challenge-acs"; 5 | import challengeNotificationComplete from "../fixtures/mocks/challenge-notification-complete"; 6 | import check3dsVersionSuccess from "../fixtures/mocks/check-3ds-version-success"; 7 | import initiateAuthenticationChallenge from "../fixtures/mocks/initiate-authentication-challenge"; 8 | import methodNotificationComplete from "../fixtures/mocks/method-notification-complete"; 9 | import { 10 | successfulHtmlResponse, 11 | successfulJsonResponse, 12 | // successfulRedirectResponse, 13 | } from "../helpers/mocking"; 14 | 15 | const mocks = RequestMock(); 16 | successfulJsonResponse( 17 | mocks, 18 | /\/check-3ds-version.php/, 19 | check3dsVersionSuccess, 20 | ); 21 | successfulHtmlResponse(mocks, /\/acs\/methodData/, methodNotificationComplete); 22 | successfulJsonResponse( 23 | mocks, 24 | /\/initiate-authentication.php/, 25 | initiateAuthenticationChallenge, 26 | ); 27 | successfulHtmlResponse(mocks, /\/acs\/challenge/, challengeAcs); 28 | successfulHtmlResponse( 29 | mocks, 30 | /\/3ds2\/challengeNotification/, 31 | challengeNotificationComplete, 32 | ); 33 | 34 | export default mocks; 35 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/mocks/frictionless-authentication-failed.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable:max-line-length 2 | import { RequestMock } from "testcafe"; 3 | 4 | import check3dsVersionSuccess from "../fixtures/mocks/check-3ds-version-success"; 5 | import initiateAuthenticationFrictionlessAuthenticationFailed from "../fixtures/mocks/initiate-authentication-frictionless-authentication-failed"; 6 | import methodNotificationComplete from "../fixtures/mocks/method-notification-complete"; 7 | import { 8 | successfulHtmlResponse, 9 | successfulJsonResponse, 10 | } from "../helpers/mocking"; 11 | 12 | const mocks = RequestMock(); 13 | successfulJsonResponse( 14 | mocks, 15 | /\/check-3ds-version.php/, 16 | check3dsVersionSuccess, 17 | ); 18 | successfulHtmlResponse(mocks, /\/acs\/methodData/, methodNotificationComplete); 19 | successfulJsonResponse( 20 | mocks, 21 | /\/initiate-authentication.php/, 22 | initiateAuthenticationFrictionlessAuthenticationFailed, 23 | ); 24 | 25 | export default mocks; 26 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/mocks/frictionless-authentication-successful-cross-origin.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable:max-line-length 2 | import { RequestMock } from "testcafe"; 3 | 4 | import check3dsVersionSuccess from "../fixtures/mocks/check-3ds-version-success"; 5 | import initiateAuthenticationFrictionlessAuthenticationSuccessful from "../fixtures/mocks/initiate-authentication-frictionless-authentication-successful"; 6 | import methodNotificationComplete from "../fixtures/mocks/method-notification-complete"; 7 | import { successfulJsonResponse } from "../helpers/mocking"; 8 | 9 | const mocks = RequestMock(); 10 | successfulJsonResponse( 11 | mocks, 12 | /http:\/\/3ds2\.localhost\/check-3ds-version\.php/, 13 | check3dsVersionSuccess, 14 | ); 15 | mocks 16 | .onRequestTo(/\/acs\/methodData/) 17 | .respond(methodNotificationComplete, 200, { "Content-Type": "text/html" }); 18 | successfulJsonResponse( 19 | mocks, 20 | /http:\/\/3ds2\.localhost\/initiate-authentication\.php/, 21 | initiateAuthenticationFrictionlessAuthenticationSuccessful, 22 | ); 23 | 24 | export default mocks; 25 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/mocks/frictionless-authentication-successful.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable:max-line-length 2 | import { RequestMock } from "testcafe"; 3 | 4 | import check3dsVersionSuccess from "../fixtures/mocks/check-3ds-version-success"; 5 | import initiateAuthenticationFrictionlessAuthenticationSuccessful from "../fixtures/mocks/initiate-authentication-frictionless-authentication-successful"; 6 | import methodNotificationComplete from "../fixtures/mocks/method-notification-complete"; 7 | import { 8 | successfulHtmlResponse, 9 | successfulJsonResponse, 10 | } from "../helpers/mocking"; 11 | 12 | const mocks = RequestMock(); 13 | successfulJsonResponse( 14 | mocks, 15 | /\/check-3ds-version.php/, 16 | check3dsVersionSuccess, 17 | ); 18 | successfulHtmlResponse(mocks, /\/acs\/methodData/, methodNotificationComplete); 19 | successfulJsonResponse( 20 | mocks, 21 | /\/initiate-authentication.php/, 22 | initiateAuthenticationFrictionlessAuthenticationSuccessful, 23 | ); 24 | 25 | export default mocks; 26 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/test/mocks/make-request.ts: -------------------------------------------------------------------------------- 1 | import { RequestMock } from "testcafe"; 2 | 3 | const mocks = RequestMock(); 4 | 5 | mocks 6 | .onRequestTo(/\/foo\/bar\/success-enrolled/) 7 | .respond({ enrolled: true }, 200, { 8 | "Content-Type": "text/json", 9 | "Access-Control-Allow-Origin": "*", 10 | }); 11 | mocks 12 | .onRequestTo(/\/foo\/bar\/success-not-enrolled/) 13 | .respond({ enrolled: false }, 200, { 14 | "Content-Type": "text/json", 15 | "Access-Control-Allow-Origin": "*", 16 | }); 17 | mocks 18 | .onRequestTo(/\/foo\/bar\/client-error/) 19 | .respond({ error: "error" }, 400, { 20 | "Content-Type": "text/json", 21 | "Access-Control-Allow-Origin": "*", 22 | }); 23 | mocks 24 | .onRequestTo(/\/foo\/bar\/server-error/) 25 | .respond({ error: "error" }, 500, { 26 | "Content-Type": "text/json", 27 | "Access-Control-Allow-Origin": "*", 28 | }); 29 | 30 | export default mocks; 31 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "declaration": true, 4 | "declarationDir": "./dist/types", 5 | "importHelpers": true, 6 | "lib": ["dom", "esnext"], 7 | "removeComments": false, 8 | "sourceMap": true, 9 | "strict": true, 10 | "target": "es3" 11 | }, 12 | "include": [ 13 | "src/**/*" 14 | ], 15 | "exclude": [ 16 | "node_modules", 17 | "lib" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /packages/globalpayments-3ds/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rules": { 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /packages/globalpayments-js-loader/.gitignore: -------------------------------------------------------------------------------- 1 | index.d.ts 2 | index.js 3 | globalpayments-js/ 4 | -------------------------------------------------------------------------------- /packages/globalpayments-js-loader/.npmignore: -------------------------------------------------------------------------------- 1 | index.ts 2 | tsconfig.json 3 | !index.js 4 | !index.d.ts 5 | -------------------------------------------------------------------------------- /packages/globalpayments-js-loader/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import version from "@globalpayments/js/src/lib/version"; 3 | 4 | /** 5 | * Prevent multiple copies of the Global Payments JavaScript 6 | * library from being loaded by only using a single Promise. 7 | */ 8 | let libraryLoaded: Promise; 9 | 10 | /** 11 | * Loads the Global Payments JavaScript library asynchronously, using a 12 | * resolved `Promise` to signal that the library has loaded. 13 | * 14 | * @param url 15 | * 16 | * @returns The resolved library 17 | */ 18 | export function loadLibrary( 19 | url?: string 20 | ): Promise { 21 | if (libraryLoaded) { 22 | return libraryLoaded; 23 | } 24 | 25 | if (window.GlobalPayments) { 26 | return (libraryLoaded = Promise.resolve(window.GlobalPayments)); 27 | } 28 | 29 | if (!url) { 30 | url = `https://js.globalpay.com/${version}/globalpayments.js`; 31 | } 32 | 33 | return (libraryLoaded = new Promise((resolve) => { 34 | try { 35 | const script = document.createElement("script"); 36 | script.defer = true; 37 | script.src = url || ""; 38 | script.onload = () => { 39 | resolve(window.GlobalPayments); 40 | }; 41 | document.body.appendChild(script); 42 | } catch (e) { 43 | /** */ 44 | } 45 | })); 46 | } 47 | -------------------------------------------------------------------------------- /packages/globalpayments-js-loader/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@globalpayments/js-loader", 3 | "version": "1.8.5", 4 | "main": "./index.js", 5 | "module": "./index.js", 6 | "types": "./index.d.ts", 7 | "typings": "./index.d.ts", 8 | "author": "Heartland Developer Portal ", 9 | "license": "GPL-2.0", 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/globalpayments/globalpayments-js.git" 13 | }, 14 | "publishConfig": { 15 | "access": "public" 16 | }, 17 | "files": [ 18 | "./index.d.ts", 19 | "./index.js" 20 | ], 21 | "scripts": { 22 | "build": "tsc", 23 | "clean": "rimraf index.d.ts index.js", 24 | "format": "prettier --write **/* !examples/**/*.html", 25 | "prebuild": "yarn test:lint", 26 | "prepublish": "yarn build", 27 | "test:lint": "tslint --project tsconfig.json", 28 | "test:serve": "serve -p 7777" 29 | }, 30 | "dependencies": { 31 | "@globalpayments/js": "^1.8.5" 32 | }, 33 | "devDependencies": { 34 | "rimraf": "*", 35 | "typescript": "*" 36 | }, 37 | "gitHead": "09776fcfe6140ce5b1ea8fc55fb4867b15565f1d" 38 | } 39 | -------------------------------------------------------------------------------- /packages/globalpayments-js-loader/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | 4 | "compilerOptions": { 5 | "declaration": true, 6 | "lib": ["DOM", "ES2015", "ESNext"], 7 | "moduleResolution": "node", 8 | "strict": true, 9 | "target": "ES2015" 10 | }, 11 | "include": ["**/*"] 12 | } 13 | -------------------------------------------------------------------------------- /packages/globalpayments-js-loader/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rules": {} 4 | } 5 | -------------------------------------------------------------------------------- /packages/globalpayments-js-web-components/.gitignore: -------------------------------------------------------------------------------- 1 | lib/ 2 | -------------------------------------------------------------------------------- /packages/globalpayments-js-web-components/config/rollup.js: -------------------------------------------------------------------------------- 1 | import commonjs from "@rollup/plugin-commonjs"; 2 | import resolve from "@rollup/plugin-node-resolve"; 3 | import typescript from "rollup-plugin-typescript2"; 4 | 5 | const input = "./src/index.ts"; 6 | 7 | const plugins = [ 8 | resolve({ 9 | "globalpayments-js-loader": true, 10 | }), 11 | commonjs(), 12 | typescript({ 13 | check: true, 14 | typescript: require("typescript"), 15 | useTsconfigDeclarationDir: true, 16 | }), 17 | ]; 18 | 19 | const onwarn = (warning) => { 20 | // Suppress this error message... there are hundreds of them. Angular team says to ignore it. 21 | // https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined 22 | if (warning.code === "THIS_IS_UNDEFINED") { 23 | return; 24 | } 25 | console.error(warning.message); 26 | }; 27 | 28 | export default [ 29 | // Dev 30 | { 31 | input, 32 | output: { 33 | file: "./lib/globalpayments-js-web-components.js", 34 | format: "esm", 35 | name: "GlobalPayments", 36 | sourcemap: true, 37 | }, 38 | 39 | plugins, 40 | onwarn, 41 | }, 42 | ]; 43 | -------------------------------------------------------------------------------- /packages/globalpayments-js-web-components/examples/gp-api.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 17 | -------------------------------------------------------------------------------- /packages/globalpayments-js-web-components/src/components/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./secure-payment-element"; 2 | export * from "./secure-card-number-field"; 3 | export * from "./secure-card-expiration-field"; 4 | export * from "./secure-card-cvv-field"; 5 | export * from "./secure-submit-button"; 6 | export * from "./secure-payment-form"; 7 | -------------------------------------------------------------------------------- /packages/globalpayments-js-web-components/src/components/secure-card-cvv-field.ts: -------------------------------------------------------------------------------- 1 | import { SecurePaymentElement } from "./secure-payment-element.js"; 2 | 3 | export class SecureCardCvvField extends SecurePaymentElement { 4 | static TAG_NAME = "secure-card-cvv-field"; 5 | 6 | /** 7 | * @inheritdoc 8 | */ 9 | get tagName() { 10 | return SecureCardCvvField.TAG_NAME; 11 | } 12 | 13 | /** 14 | * @inheritdoc 15 | */ 16 | get type() { 17 | return "card-cvv"; 18 | } 19 | } 20 | 21 | customElements.define(SecureCardCvvField.TAG_NAME, SecureCardCvvField); 22 | 23 | declare global { 24 | interface HTMLElementTagNameMap { 25 | "secure-card-cvv-field": SecureCardCvvField, 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/globalpayments-js-web-components/src/components/secure-card-expiration-field.ts: -------------------------------------------------------------------------------- 1 | import { SecurePaymentElement } from "./secure-payment-element.js"; 2 | 3 | export class SecureCardExpirationField extends SecurePaymentElement { 4 | static TAG_NAME = "secure-card-expiration-field"; 5 | 6 | /** 7 | * @inheritdoc 8 | */ 9 | get tagName() { 10 | return SecureCardExpirationField.TAG_NAME; 11 | } 12 | 13 | /** 14 | * @inheritdoc 15 | */ 16 | get type() { 17 | return "card-expiration"; 18 | } 19 | } 20 | 21 | customElements.define(SecureCardExpirationField.TAG_NAME, SecureCardExpirationField); 22 | 23 | declare global { 24 | interface HTMLElementTagNameMap { 25 | "secure-card-expiration-field": SecureCardExpirationField, 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/globalpayments-js-web-components/src/components/secure-card-number-field.ts: -------------------------------------------------------------------------------- 1 | import { SecurePaymentElement } from "./secure-payment-element.js"; 2 | 3 | export class SecureCardNumberField extends SecurePaymentElement { 4 | static TAG_NAME = "secure-card-number-field"; 5 | 6 | /** 7 | * @inheritdoc 8 | */ 9 | get tagName() { 10 | return SecureCardNumberField.TAG_NAME; 11 | } 12 | 13 | /** 14 | * @inheritdoc 15 | */ 16 | get type() { 17 | return "card-number"; 18 | } 19 | } 20 | 21 | customElements.define(SecureCardNumberField.TAG_NAME, SecureCardNumberField); 22 | 23 | declare global { 24 | interface HTMLElementTagNameMap { 25 | "secure-card-number-field": SecureCardNumberField, 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/globalpayments-js-web-components/src/components/secure-submit-button.ts: -------------------------------------------------------------------------------- 1 | import { SecurePaymentElement } from "./secure-payment-element.js"; 2 | 3 | export class SecureSubmitButton extends SecurePaymentElement { 4 | static TAG_NAME = "secure-submit-button"; 5 | 6 | /** 7 | * @inheritdoc 8 | */ 9 | get tagName() { 10 | return SecureSubmitButton.TAG_NAME; 11 | } 12 | 13 | /** 14 | * @inheritdoc 15 | */ 16 | get type() { 17 | return "submit"; 18 | } 19 | 20 | /** 21 | * @inheritdoc 22 | */ 23 | getTargetEvents() { 24 | return Array.of(...super.getTargetEvents(), ...["click"]); 25 | } 26 | } 27 | 28 | customElements.define(SecureSubmitButton.TAG_NAME, SecureSubmitButton); 29 | 30 | declare global { 31 | interface HTMLElementTagNameMap { 32 | "secure-submit-button": SecureSubmitButton, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/globalpayments-js-web-components/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./components"; 2 | -------------------------------------------------------------------------------- /packages/globalpayments-js-web-components/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | 4 | "compilerOptions": { 5 | "declaration": true, 6 | "declarationDir": "./lib", 7 | "lib": ["DOM", "ES2015", "ESNext"], 8 | "moduleResolution": "node", 9 | "outDir": "lib", 10 | "strict": true, 11 | "target": "ES2015" 12 | }, 13 | "include": ["**/*"] 14 | } 15 | -------------------------------------------------------------------------------- /packages/globalpayments-js-web-components/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rules": { 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /packages/globalpayments-js/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .vscode/ 3 | .rpt2_cache/ 4 | dist/ 5 | 6 | # Logs 7 | logs 8 | *.log 9 | npm-debug.log* 10 | 11 | # Runtime data 12 | pids 13 | *.pid 14 | *.seed 15 | 16 | # Directory for instrumented libs generated by jscoverage/JSCover 17 | lib-cov 18 | 19 | # Coverage directory used by tools like istanbul 20 | coverage 21 | 22 | # nyc test coverage 23 | .nyc_output 24 | 25 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 26 | .grunt 27 | 28 | # node-waf configuration 29 | .lock-wscript 30 | 31 | # Compiled binary addons (http://nodejs.org/api/addons.html) 32 | build/Release 33 | 34 | # Dependency directories 35 | node_modules 36 | jspm_packages 37 | 38 | # Optional npm cache directory 39 | .npm 40 | 41 | # Optional REPL history 42 | .node_repl_history 43 | 44 | # ignore generated declaration files 45 | types/* 46 | !types/global-type.d.ts 47 | 48 | # ide local files 49 | .idea 50 | -------------------------------------------------------------------------------- /packages/globalpayments-js/.npmignore: -------------------------------------------------------------------------------- 1 | .rpt2_cache/ 2 | .vscode/ 3 | dist/ 4 | examples/ 5 | src/ 6 | test/ 7 | !types/ 8 | tsconfig.json 9 | tslint.json 10 | yarn.lock 11 | -------------------------------------------------------------------------------- /packages/globalpayments-js/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "always", 3 | "trailingComma": "all" 4 | } 5 | -------------------------------------------------------------------------------- /packages/globalpayments-js/TODO: -------------------------------------------------------------------------------- 1 | submit button treatment during tokenization, especially for globalpayments 2 | i18n 3 | i18n date format? https://github.com/hps/heartland-tokenization/issues/40 4 | expiration date dropdowns? https://github.com/hps/heartland-tokenization/issues/15 5 | add heartland gift bin range to card-types 6 | -------------------------------------------------------------------------------- /packages/globalpayments-js/bin/replace-gp-ref.js: -------------------------------------------------------------------------------- 1 | const replace = require('replace-in-file'); 2 | const options = { 3 | files: [ 4 | 'dist/*.html', 5 | ], 6 | 7 | // Replacement to make (string or regex) 8 | from: /\/dist\/globalpayments/g, 9 | to: 'globalpayments', 10 | }; 11 | replace(options) 12 | .then(changedFiles => { 13 | console.log('Modified files:', changedFiles.map(f => f.file).join(', ')); 14 | }) 15 | .catch(error => { 16 | console.error('Error occurred:', error); 17 | }); 18 | -------------------------------------------------------------------------------- /packages/globalpayments-js/bin/update-version.js: -------------------------------------------------------------------------------- 1 | const replace = require('replace-in-file'); 2 | const options = { 3 | files: [ 4 | 'src/assets/artifactVersion.txt', 5 | 'src/lib/version.ts', 6 | 'README.md', 7 | ], 8 | 9 | // Replacement to make (string or regex) 10 | from: /\d+\.\d+\.\d+/g, 11 | to: require('../package.json').version, 12 | }; 13 | replace(options) 14 | .then(changedFiles => { 15 | console.log('Modified files:', changedFiles.map(f => f.file).join(', ')); 16 | }) 17 | .catch(error => { 18 | console.error('Error occurred:', error); 19 | }); 20 | -------------------------------------------------------------------------------- /packages/globalpayments-js/cypress.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultCommandTimeout": 15000, 3 | "fixturesFolder": "test/fixtures", 4 | "integrationFolder": "test/integration", 5 | "pluginsFile": "test/plugins", 6 | "screenshotsFolder": "test/screenshots", 7 | "supportFile": "test/support", 8 | "video": false, 9 | "videosFolder": "test/videos", 10 | "chromeWebSecurity": false 11 | } 12 | -------------------------------------------------------------------------------- /packages/globalpayments-js/docs/images/example-drop-in-blank-credit-card.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/docs/images/example-drop-in-blank-credit-card.png -------------------------------------------------------------------------------- /packages/globalpayments-js/docs/images/example-drop-in-blank-echeck.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/docs/images/example-drop-in-blank-echeck.png -------------------------------------------------------------------------------- /packages/globalpayments-js/docs/images/example-drop-in-blank-gift.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/docs/images/example-drop-in-blank-gift.png -------------------------------------------------------------------------------- /packages/globalpayments-js/docs/images/example-drop-in-blank-track.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/docs/images/example-drop-in-blank-track.png -------------------------------------------------------------------------------- /packages/globalpayments-js/docs/images/example-drop-in-credit-card.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/docs/images/example-drop-in-credit-card.png -------------------------------------------------------------------------------- /packages/globalpayments-js/docs/images/example-drop-in-echeck.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/docs/images/example-drop-in-echeck.png -------------------------------------------------------------------------------- /packages/globalpayments-js/docs/images/example-drop-in-gift.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/docs/images/example-drop-in-gift.png -------------------------------------------------------------------------------- /packages/globalpayments-js/docs/images/example-drop-in-track.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/docs/images/example-drop-in-track.png -------------------------------------------------------------------------------- /packages/globalpayments-js/docs/images/example-raw-credit-card.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/docs/images/example-raw-credit-card.png -------------------------------------------------------------------------------- /packages/globalpayments-js/docs/images/example-raw-echeck.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/docs/images/example-raw-echeck.png -------------------------------------------------------------------------------- /packages/globalpayments-js/docs/images/example-raw-gift.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/docs/images/example-raw-gift.png -------------------------------------------------------------------------------- /packages/globalpayments-js/docs/images/example-raw-payment-request-review.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/docs/images/example-raw-payment-request-review.png -------------------------------------------------------------------------------- /packages/globalpayments-js/docs/images/example-raw-payment-request.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/docs/images/example-raw-payment-request.png -------------------------------------------------------------------------------- /packages/globalpayments-js/docs/images/example-raw-track.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/docs/images/example-raw-track.png -------------------------------------------------------------------------------- /packages/globalpayments-js/examples/globalpayments/hash.php: -------------------------------------------------------------------------------- 1 | TIMESTAMP) ? $request->TIMESTAMP : '', 9 | isset($request->MERCHANT_ID) ? $request->MERCHANT_ID : '', 10 | isset($request->ORDER_ID) ? $request->ORDER_ID : '', 11 | '', 12 | isset($request->CURRENCY) ? $request->CURRENCY : '', 13 | isset($request->PAYER_REF) ? $request->PAYER_REF : '', 14 | isset($request->PMT_REF) ? $request->PMT_REF : '', 15 | ]; 16 | 17 | $request->SHA1HASH = sha1(sha1(implode('.', $toHash)) . '.' . $globalpaymentsSharedSecret); 18 | 19 | echo json_encode($request); 20 | -------------------------------------------------------------------------------- /packages/globalpayments-js/examples/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Examples 7 | 8 | 9 |

Examples

10 | 11 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /packages/globalpayments-js/examples/transit/curl.php: -------------------------------------------------------------------------------- 1 | sprintf('%s', $contentType), 16 | 'Content-Length' => $data === null ? 0 : strlen($data), 17 | ]); 18 | $headers = []; 19 | foreach ($requestHeaders as $key => $value) { 20 | $headers[] = $key . ': '. $value; 21 | } 22 | curl_setopt($request, CURLOPT_CONNECTTIMEOUT, $timeout); 23 | curl_setopt($request, CURLOPT_TIMEOUT, $timeout); 24 | curl_setopt($request, CURLOPT_RETURNTRANSFER, true); 25 | curl_setopt($request, CURLOPT_SSL_VERIFYPEER, false); //true,); 26 | curl_setopt($request, CURLOPT_SSL_VERIFYHOST, false); //2,); 27 | curl_setopt($request, CURLOPT_CUSTOMREQUEST, strtoupper($verb)); 28 | curl_setopt($request, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); 29 | curl_setopt($request, CURLOPT_POSTFIELDS, $data); 30 | curl_setopt($request, CURLOPT_HTTPHEADER, $headers); 31 | curl_setopt($request, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS); 32 | curl_setopt($request, CURLOPT_VERBOSE, false); 33 | curl_setopt($request, CURLOPT_ENCODING, ''); 34 | 35 | $curlResponse = curl_exec($request); 36 | $curlInfo = curl_getinfo($request); 37 | $curlError = curl_errno($request); 38 | 39 | return [$curlResponse, $curlInfo, $curlError]; 40 | }; 41 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/apm/enums.ts: -------------------------------------------------------------------------------- 1 | export const enum ApmInternalEvents { 2 | PaymentMethodsRequestStart = "payment-methods-request-start", 3 | PaymentMethodsRequestCompleted = "payment-methods-request-completed", 4 | NavigatesBackBySelectAnotherPaymentMethod = "payment-navigates-back-select-another-payment-method", 5 | } 6 | 7 | export const enum QRCodePaymentsActions { 8 | RedirectAction = "REDIRECT", 9 | RedirectInFrameAction = "REDIRECT_IN_FRAME", 10 | PresentQRCodeAction = "PRESENT_QR_CODE", 11 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/apm/non-card-payments/components/constants.ts: -------------------------------------------------------------------------------- 1 | export const REDIRECT_ACTION_DELAY_IN_SECONDS = 2000; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/apm/non-card-payments/contracts.ts: -------------------------------------------------------------------------------- 1 | export interface IApmConfiguration { 2 | allowedPaymentMethods?: PaymentMethod[]; 3 | } 4 | 5 | export interface PaymentMethod { 6 | provider: string; 7 | category?: string; 8 | image?: string; 9 | enabled?:boolean; 10 | } 11 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/apm/qr-code-payments/components/generate-qr-code.ts: -------------------------------------------------------------------------------- 1 | import getAssetBaseUrl from "../../../internal/gateways/gp-api/get-asset-base-url"; 2 | 3 | export function removeScriptById(scriptId: string): void { 4 | const scriptElement = document.getElementById(scriptId); 5 | 6 | if (scriptElement && scriptElement.tagName === 'SCRIPT') { 7 | scriptElement.remove(); 8 | } 9 | } 10 | 11 | export async function loadQRCodeLibraryAndGenerate(text: string): Promise { 12 | return new Promise((resolve, reject) => { 13 | const script = document.createElement('script'); 14 | script.type = 'text/javascript'; 15 | script.src = `${getAssetBaseUrl('')}vendor/qrcode.js`; 16 | script.id = 'qr-code-script'; 17 | script.onload = () => { 18 | // Script has loaded, now generate the QR code 19 | generateQRCode(text).then(resolve).catch(reject); 20 | }; 21 | script.onerror = () => { 22 | reject(new Error('Failed to load QRCode library')); 23 | }; 24 | document.body.appendChild(script); 25 | }); 26 | } 27 | 28 | export async function generateQRCode(text: string): Promise { 29 | return new Promise((resolve, reject) => { 30 | // @ts-ignore 31 | const qr = new QRCode.toDataURL(text, (error: any, url: string) => { 32 | if (error) { 33 | reject(error); 34 | } else { 35 | resolve(url); 36 | } 37 | }); 38 | }); 39 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/apm/qr-code-payments/contracts.ts: -------------------------------------------------------------------------------- 1 | import {IApmConfiguration} from "../non-card-payments/contracts"; 2 | 3 | export interface IQRCodePaymentsConfiguration extends IApmConfiguration { 4 | enabled?: boolean; 5 | } 6 | 7 | export interface IPaymentMethodConfiguration extends IApmConfiguration { 8 | provider: { 9 | brand: string; 10 | }; 11 | image: string; 12 | } 13 | 14 | export interface IPaymentMethodConfigurationNormalized extends Omit { 15 | provider: string; 16 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/apm/qr-code-payments/helpers.ts: -------------------------------------------------------------------------------- 1 | import { QRCodePaymentsProviderBrands, QRCodePaymentsWeChatProviderBrands } from "../../internal/lib/enums"; 2 | import { IPaymentMethodConfiguration, IPaymentMethodConfigurationNormalized } from "./contracts"; 3 | 4 | export const normalizePaymentMethodConfigurations = (paymentMethodConfigurations: IPaymentMethodConfiguration): IPaymentMethodConfigurationNormalized => { 5 | const { provider } = paymentMethodConfigurations; 6 | return { 7 | ...paymentMethodConfigurations, 8 | provider: provider.brand, 9 | }; 10 | } 11 | 12 | export const validateProviderBrand = (providerBrand: string): string => { 13 | return ( 14 | [ 15 | QRCodePaymentsWeChatProviderBrands.WeChatBrand, 16 | QRCodePaymentsWeChatProviderBrands.WeChatMethodResponse, 17 | QRCodePaymentsWeChatProviderBrands.WeChatAccountResponse 18 | ].some(pb => pb.toLocaleLowerCase() === providerBrand.toLocaleLowerCase()) 19 | ) ? QRCodePaymentsProviderBrands.WeChat 20 | : providerBrand; 21 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/apm/qr-code-payments/requests/get-qr-code-payment-methods.ts: -------------------------------------------------------------------------------- 1 | import { Environments } from "../../../common/enums"; 2 | import { options } from "../../../internal"; 3 | import { IError } from "../../../internal/gateways"; 4 | import getGateway from "../../../internal/lib/get-gateway"; 5 | import { IDictionary } from "../../../internal/lib/util"; 6 | 7 | export default (data: IDictionary) => { 8 | const gateway = getGateway(); 9 | 10 | if (!gateway) return Promise.reject(createInvalidConfigurationError("no gateway available")); 11 | 12 | return new Promise((resolve, reject) => { 13 | 14 | if (!gateway.actions.getQRCodePaymentMethods || !gateway.urls.getQRCodePaymentMethodsUrl) return Promise.reject(createInvalidConfigurationError("no installment gateway action/url available")); 15 | 16 | const url = gateway.urls.getQRCodePaymentMethodsUrl(); 17 | 18 | gateway.actions.getQRCodePaymentMethods(url, options.env || "", data) 19 | .then((response: IDictionary) => { 20 | return response; 21 | }) 22 | .then((response: any) => { 23 | if ((response as IError).error) { 24 | reject(response); 25 | return; 26 | } 27 | 28 | if (gateway.requiredSettings.indexOf("X-GP-Api-Key") !== -1) { 29 | resolve(response); 30 | return; 31 | } 32 | 33 | resolve(response); 34 | }) 35 | .catch(reject); 36 | }); 37 | }; 38 | 39 | function createInvalidConfigurationError(message: string) { 40 | return { 41 | error: true, 42 | reasons: [ 43 | { code: "INVALID_CONFIGURATION", message }, 44 | ], 45 | }; 46 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/artifactVersion.txt: -------------------------------------------------------------------------------- 1 | 4.1.10 -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/field.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Secure Payment Form 7 | 41 | 42 | 43 |
44 |
45 |
46 |
47 | 48 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/fonts/DMSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/src/assets/fonts/DMSans-Regular.ttf -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/fonts/GPCommerce-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/src/assets/fonts/GPCommerce-Regular.woff2 -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/fonts/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/src/assets/fonts/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/BrandSecurityIcon_BOIPA.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/BrandSecurityIcon_Commerzbank.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/BrandSecurityIcon_EService.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/BrandSecurityIcon_NBGPay.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/alert-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/clock-timer.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/cross-grey.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/ctp-check.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/ctp-coloured-cards.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/ctp-lock.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/ctp-shopping-cart.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/cvv-amex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/src/assets/images/cvv-amex.png -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/cvv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/src/assets/images/cvv.png -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/gp-cc-amex.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/gp-cc-diners.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/gp-cc-maestro.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/gp-cc-mastercard.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/gp-cc-visa.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/gp-fa-question-circle.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/gp-lock-alt.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/info.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/logo-amex@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/src/assets/images/logo-amex@2x.png -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/logo-discover@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/src/assets/images/logo-discover@2x.png -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/logo-jcb@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/src/assets/images/logo-jcb@2x.png -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/logo-mastercard@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/src/assets/images/logo-mastercard@2x.png -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/logo-unknown@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/src/assets/images/logo-unknown@2x.png -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/logo-visa@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/src/assets/images/logo-visa@2x.png -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/mastercard.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/qr-code-expired.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/src/assets/images/qr-code-expired.png -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/qr-code-redirect-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/src/assets/images/qr-code-redirect-logo.png -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/realex-grey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/src/assets/images/realex-grey.png -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/shield-and-logos@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/src/assets/images/shield-and-logos@2x.png -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/virgin-money-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/globalpayments/globalpayments-js/a77db1ddcf00d5f307e14b707c5397e944f11536/packages/globalpayments-js/src/assets/images/virgin-money-logo.png -------------------------------------------------------------------------------- /packages/globalpayments-js/src/assets/images/visa.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/common/browser-helpers.ts: -------------------------------------------------------------------------------- 1 | 2 | export const isSafari: boolean = navigator.userAgent.indexOf('Safari') !== -1 && navigator.userAgent.indexOf('Chrome') === -1; 3 | 4 | // The "document.documentMode" property is IE-specific. 5 | // Only Internet Explorer (IE) returns a defined value and for all browsers other than IE it will return an 'undefined' value. 6 | export const isIE = Boolean((window.document as any)[`documentMode`]); -------------------------------------------------------------------------------- /packages/globalpayments-js/src/common/constants.ts: -------------------------------------------------------------------------------- 1 | import { getBrandThemeNames } from "../internal/lib/styles/themes/brand-themes/brand-themes"; 2 | import { CardFormFieldNames, HostedFieldStyles } from "./enums"; 3 | 4 | export const HOSTED_FIELD_NAME_KEYS: string[] = [ 5 | CardFormFieldNames.CardNumber, 6 | CardFormFieldNames.CardExpiration, 7 | CardFormFieldNames.CardCvv, 8 | CardFormFieldNames.CardHolderName, 9 | ]; 10 | 11 | export const HOSTED_FIELD_STYLE_NAMES: string[] = [ 12 | HostedFieldStyles.Default, 13 | HostedFieldStyles.Simple, 14 | HostedFieldStyles.Blank, 15 | HostedFieldStyles.GpDefault, 16 | ]; 17 | 18 | export const HOSTED_FIELD_BRAND_THEMES_NAMES: string[] = getBrandThemeNames(); -------------------------------------------------------------------------------- /packages/globalpayments-js/src/common/helpers.ts: -------------------------------------------------------------------------------- 1 | const encode = (data: string): string => { 2 | return window.btoa(data); 3 | } 4 | 5 | const decode = (encodedData: string): string => { 6 | return window.atob(encodedData); 7 | } 8 | 9 | export const DataEncoderHelper = { 10 | encode, 11 | decode, 12 | }; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/built-in-validations/constants.ts: -------------------------------------------------------------------------------- 1 | export const BUILT_IN_VALIDATIONS_VALIDATION_ROUND_COUNTER_KEY: string = "validationRoundCounter"; 2 | 3 | export const POLAND: string = "PL"; 4 | 5 | export const GERMANY: string = "DE"; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/built-in-validations/english-characters-validation.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Validate a string to accept only english characters 3 | * 4 | * @param value 5 | * @returns escaped text 6 | */ 7 | export default function containsOnlyEnglishCharacters(value: string) { 8 | // Define a regular expression pattern that matches only English letters 9 | const pattern = /^[a-zA-Z.~'` -]+$/; 10 | 11 | // Test the input string against the pattern 12 | return pattern.test(value); 13 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/formatters/card-number.ts: -------------------------------------------------------------------------------- 1 | import { typeByNumber } from "../lib/card-types"; 2 | import IFormatter from "./formatter"; 3 | 4 | export default class CardNumber implements IFormatter { 5 | public format(cardNumber: string): string { 6 | cardNumber = cardNumber.replace(/\D/g, ""); 7 | const type = typeByNumber(cardNumber); 8 | 9 | if (!type) { 10 | return cardNumber; 11 | } 12 | 13 | const matches = cardNumber.match(type.format); 14 | 15 | if (!matches) { 16 | return cardNumber; 17 | } 18 | 19 | if (!type.format.global) { 20 | matches.shift(); 21 | } 22 | return matches.join(" ").replace(/^\s+|\s+$/gm, ""); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/formatters/expiration.ts: -------------------------------------------------------------------------------- 1 | import IFormatter from "./formatter"; 2 | 3 | export default class Expiration implements IFormatter { 4 | public format(exp: string, final = false): string { 5 | const pat = /^\D*(\d{1,2})(\D+)?(\d{1,4})?/; 6 | const groups = exp.match(pat); 7 | let month: string; 8 | let del: string; 9 | let year: string; 10 | 11 | if (!groups) { 12 | return ""; 13 | } 14 | 15 | month = groups[1] || ""; 16 | del = groups[2] || ""; 17 | year = groups[3] || ""; 18 | 19 | if (year.length > 0) { 20 | del = " / "; 21 | } else if (month.length === 2 || del.length > 0) { 22 | del = " / "; 23 | } else if (month.length === 1 && month !== "0" && month !== "1") { 24 | del = " / "; 25 | } 26 | 27 | if (month.length === 1 && del !== "") { 28 | month = "0" + month; 29 | } 30 | 31 | if (final && year.length === 2) { 32 | year = new Date().getFullYear().toString().slice(0, 2) + year; 33 | } 34 | 35 | return month + del + year; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/formatters/formatter.ts: -------------------------------------------------------------------------------- 1 | interface IFormatter { 2 | format: (value: any) => any; 3 | } 4 | 5 | export default IFormatter; 6 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/billpay/action-normalize-response.ts: -------------------------------------------------------------------------------- 1 | import { ISuccess } from ".."; 2 | import { IDictionary } from "../../lib/util"; 3 | 4 | export default (data: IDictionary) => { 5 | if (data.error && data.reasons) { 6 | return { 7 | error: data.error, 8 | reasons: data.reasons, 9 | }; 10 | } 11 | 12 | if (!data.GetTokenResult || !data.GetTokenResult.IsSuccessful) { 13 | const message = 14 | (data.GetTokenResult || {}).ErrorMessage || "Unexpected error"; 15 | const reasons = [{ code: "INVALID_REQUEST", message }]; 16 | 17 | return { 18 | error: true, 19 | reasons, 20 | }; 21 | } 22 | 23 | const response: ISuccess = { 24 | details: {}, 25 | paymentReference: data.GetTokenResult.Token, 26 | }; 27 | 28 | return response; 29 | }; 30 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/billpay/action-tokenize.ts: -------------------------------------------------------------------------------- 1 | import { options } from "../../lib/options"; 2 | import { IDictionary } from "../../lib/util"; 3 | 4 | const tokenTypes = { 5 | check: "2", 6 | credit: "1", 7 | }; 8 | 9 | export default async (url: string, env: string, data: IDictionary) => { 10 | const request: any = { 11 | merchantName: options.merchantName, 12 | }; 13 | 14 | if (data["card-number"]) { 15 | request.tokenData = data["card-number"].replace(/\s/g, ""); 16 | request.type = tokenTypes.credit; 17 | } else if (data["account-number"]) { 18 | request.tokenData = `${data["account-number"]}|${data["routing-number"]}`; 19 | request.type = tokenTypes.check; 20 | } 21 | 22 | try { 23 | const headers = { 24 | "Content-Type": "application/json", 25 | }; 26 | const resp = await fetch(url, { 27 | body: JSON.stringify(request), 28 | credentials: "omit", 29 | headers: typeof Headers !== "undefined" ? new Headers(headers) : headers, 30 | method: "POST", 31 | }); 32 | return resp.json(); 33 | } catch (e) { 34 | return { 35 | error: true, 36 | reasons: [{ code: e.name, message: e.message }], 37 | }; 38 | } 39 | }; 40 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/billpay/action-validate-data.ts: -------------------------------------------------------------------------------- 1 | import { IErrorReason } from ".."; 2 | import { IDictionary } from "../../lib/util"; 3 | 4 | export default (data: IDictionary) => { 5 | const errors: IErrorReason[] = []; 6 | 7 | if (!data["card-number"] && !data["card-track"] && !data["account-number"]) { 8 | if (!data["card-number"]) { 9 | errors.push({ 10 | code: "INVALID_CARD_NUMBER", 11 | message: "The card number is invalid.", 12 | }); 13 | } else if (!data["account-number"]) { 14 | errors.push({ 15 | code: "INVALID_ACCOUNT_NUMBER", 16 | message: "The account number is invalid", 17 | }); 18 | } 19 | } 20 | 21 | if (data["account-number"] && !data["routing-number"]) { 22 | errors.push({ 23 | code: "INVALID_ROUTING_NUMBER", 24 | message: "The routing number is invalid", 25 | }); 26 | } 27 | 28 | return errors; 29 | }; 30 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/billpay/index.ts: -------------------------------------------------------------------------------- 1 | import { IActions } from ".."; 2 | import { options } from "../../lib/options"; 3 | 4 | import actionNormalizeResponse from "./action-normalize-response"; 5 | import actionTokenize from "./action-tokenize"; 6 | import actionValidateData from "./action-validate-data"; 7 | 8 | export const supports = { 9 | tokenization: { 10 | cardNotPresent: true, 11 | eCheck: true, 12 | }, 13 | }; 14 | 15 | const domains = { 16 | production: "https://heartlandpaymentservices.net", 17 | sandbox: "https://staging.heartlandpaymentservices.net", 18 | }; 19 | 20 | export const urls = { 21 | tokenization: (prod: boolean) => 22 | `${ 23 | prod ? domains.production : domains.sandbox 24 | }/QuickPayService/QuickPayService.svc/GetToken`, 25 | }; 26 | 27 | export const actions: IActions = { 28 | normalizeResponse: actionNormalizeResponse, 29 | tokenize: actionTokenize, 30 | validateData: actionValidateData, 31 | }; 32 | 33 | export const requiredSettings = ["merchantName"]; 34 | 35 | export const getEnv = () => { 36 | return options.env || "production"; 37 | }; 38 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/genius/action-normalize-response.ts: -------------------------------------------------------------------------------- 1 | import { IDictionary } from "../../lib/util"; 2 | 3 | export default (data: IDictionary) => { 4 | if (data.error && data.reasons) { 5 | return { 6 | error: data.error, 7 | reasons: data.reasons, 8 | }; 9 | } 10 | 11 | // TODO: parse these properly 12 | if (data.errors) { 13 | const reasons = []; 14 | 15 | for (const i in data.errors) { 16 | if (!data.errors.hasOwnProperty(i)) { 17 | continue; 18 | } 19 | 20 | const reason = data.errors[i]; 21 | const serverErrorType = 22 | reason.code === "SERVER_REQUIRED" ? "missing" : "invalid"; 23 | let code = "ERROR"; 24 | let message = `An unknown error has occurred. Details: ${reason.error_Code} - ${reason.reason}`; 25 | 26 | if (reason.reason === "cardnumber") { 27 | code = "INVALID_CARD_NUMBER"; 28 | message = `The card number is ${serverErrorType}`; 29 | } else if (reason.reason === "expirationdate") { 30 | code = "INVALID_CARD_EXPIRATION"; 31 | message = `The card expiration date is ${serverErrorType}`; 32 | } else if (reason.reason === "cvv") { 33 | code = "INVALID_CARD_SECURITY_CODE"; 34 | message = `The card security code is ${serverErrorType}`; 35 | } 36 | 37 | reasons.push({ 38 | code, 39 | message, 40 | }); 41 | } 42 | 43 | return { 44 | error: true, 45 | reasons, 46 | }; 47 | } 48 | 49 | const response: any = { 50 | paymentReference: data.token, 51 | }; 52 | 53 | return response; 54 | }; 55 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/genius/action-tokenize.ts: -------------------------------------------------------------------------------- 1 | import { IDictionary } from "../../lib/util"; 2 | 3 | export default async (url: string, env: string, data: IDictionary) => { 4 | const request: any = { 5 | merchantApiKey: data.webApiKey, 6 | }; 7 | 8 | if (data["card-number"]) { 9 | request.cardnumber = data["card-number"].replace(/\s/g, ""); 10 | } 11 | 12 | if (data["card-cvv"]) { 13 | request.cvv = data["card-cvv"]; 14 | } 15 | 16 | if ( 17 | data["card-expiration"] && 18 | data["card-expiration"].indexOf(" / ") !== -1 19 | ) { 20 | const exp = data["card-expiration"].split(" / "); 21 | request.expirationmonth = exp[0] || ""; 22 | request.expirationyear = (exp[1] || "").substr(2, 2); 23 | } 24 | 25 | if (data["card-holder-name"]) { 26 | request.cardholder = data["card-holder-name"]; 27 | } 28 | 29 | try { 30 | const headers = { 31 | "Content-Type": "application/json", 32 | }; 33 | const resp = await fetch(url, { 34 | body: JSON.stringify(request), 35 | credentials: "omit", 36 | headers: typeof Headers !== "undefined" ? new Headers(headers) : headers, 37 | method: "POST", 38 | }); 39 | return resp.json(); 40 | } catch (e) { 41 | return { 42 | error: true, 43 | reasons: [{ code: e.name, message: e.message }], 44 | }; 45 | } 46 | }; 47 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/genius/action-validate-data.ts: -------------------------------------------------------------------------------- 1 | import { IErrorReason } from ".."; 2 | import { IDictionary } from "../../lib/util"; 3 | 4 | export default (data: IDictionary) => { 5 | const errors: IErrorReason[] = []; 6 | 7 | if (!data["card-number"]) { 8 | errors.push({ 9 | code: "INVALID_CARD_NUMBER", 10 | message: "The card number is invalid.", 11 | }); 12 | } 13 | 14 | if (!data["card-cvv"]) { 15 | errors.push({ 16 | code: "INVALID_CARD_SECURITY_CODE", 17 | message: "The card security code is invalid.", 18 | }); 19 | } 20 | 21 | if (!data["card-expiration"]) { 22 | errors.push({ 23 | code: "INVALID_CARD_EXPIRATION", 24 | message: "The card expiration is invalid.", 25 | }); 26 | } 27 | 28 | return errors; 29 | }; 30 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/genius/index.ts: -------------------------------------------------------------------------------- 1 | import { IActions } from ".."; 2 | import { options } from "../../lib/options"; 3 | 4 | import actionNormalizeResponse from "./action-normalize-response"; 5 | import actionTokenize from "./action-tokenize"; 6 | import actionValidateData from "./action-validate-data"; 7 | 8 | export const supports = { 9 | apm: { 10 | applePay: false, 11 | googlePay: false, 12 | }, 13 | consumerAuthentication: false, 14 | tokenization: { 15 | cardNotPresent: true, 16 | cardPresent: false, 17 | eCheck: false, 18 | gift: false, 19 | }, 20 | }; 21 | 22 | const domains = { 23 | // Genius Checkout has an automatic sandbox feature for developer / partner accounts 24 | production: "https://ecommerce.merchantware.net", 25 | sandbox: "https://ecommerce.merchantware.net", 26 | }; 27 | 28 | export const urls = { 29 | tokenization: (prod: boolean) => 30 | `${prod ? domains.production : domains.sandbox}/v1/api/tokens`, 31 | }; 32 | 33 | export const actions: IActions = { 34 | normalizeResponse: actionNormalizeResponse, 35 | tokenize: actionTokenize, 36 | validateData: actionValidateData, 37 | }; 38 | 39 | export const requiredSettings = ["webApiKey"]; 40 | 41 | export const getEnv = () => { 42 | return options.env || "production"; 43 | }; 44 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/globalpayments/action-setup.ts: -------------------------------------------------------------------------------- 1 | import { options } from "../../lib/options"; 2 | import { postMessage as pm } from "../../lib/post-message"; 3 | 4 | let setup = false; 5 | 6 | export default async () => { 7 | if (setup) { 8 | return; 9 | } 10 | 11 | setup = true; 12 | 13 | // keep `pm.receive` call in callback version to ensure we receive the 14 | // hash request 15 | pm.receive(async (data: any) => { 16 | if (data.type === "gateway:globalpayments:hash" && options.hash) { 17 | const hashed = await options.hash(data.data); 18 | pm.post( 19 | { 20 | data: hashed, 21 | id: data.id, 22 | type: "gateway:globalpayments:hash-result", 23 | }, 24 | data.id, 25 | ); 26 | } 27 | }); 28 | }; 29 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/globalpayments/action-validate-data.ts: -------------------------------------------------------------------------------- 1 | import { IErrorReason } from "../"; 2 | import { IDictionary } from "../../lib/util"; 3 | 4 | export default (data: IDictionary) => { 5 | const errors: IErrorReason[] = []; 6 | 7 | if (!data["card-number"]) { 8 | errors.push({ 9 | code: "INVALID_CARD_NUMBER", 10 | message: "The card number is invalid.", 11 | }); 12 | } 13 | 14 | if (!data["card-cvv"]) { 15 | errors.push({ 16 | code: "INVALID_CARD_SECURITY_CODE", 17 | message: "The card security code is invalid.", 18 | }); 19 | } 20 | 21 | if (!data["card-expiration"]) { 22 | errors.push({ 23 | code: "INVALID_CARD_EXPIRATION", 24 | message: "The card expiration is invalid.", 25 | }); 26 | } 27 | 28 | if (!data["card-holder-name"]) { 29 | errors.push({ 30 | code: "INVALID_CARD_HOLDER_NAME", 31 | message: "The card holder name is invalid.", 32 | }); 33 | } 34 | 35 | return errors; 36 | }; 37 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/globalpayments/index.ts: -------------------------------------------------------------------------------- 1 | import { IActions } from ".."; 2 | import { options } from "../../lib/options"; 3 | 4 | import actionNormalizeResponse from "./action-normalize-response"; 5 | import actionSetup from "./action-setup"; 6 | import actionTokenize from "./action-tokenize"; 7 | import actionValidateData from "./action-validate-data"; 8 | 9 | export const supports = { 10 | apm: { 11 | applePay: true, 12 | googlePay: false, 13 | }, 14 | consumerAuthentication: true, 15 | tokenization: { 16 | cardNotPresent: true, 17 | cardPresent: false, 18 | eCheck: false, 19 | gift: false, 20 | }, 21 | }; 22 | 23 | const domains = { 24 | production: "https://pay.realexpayments.com", 25 | sandbox: "https://pay.sandbox.realexpayments.com", 26 | }; 27 | 28 | export const urls = { 29 | tokenization: (prod: boolean) => 30 | `${prod ? domains.production : domains.sandbox}/pay`, 31 | }; 32 | 33 | export const getEnv = () => { 34 | const def = "production"; 35 | 36 | return options.env || def; 37 | }; 38 | 39 | export const actions: IActions = { 40 | normalizeResponse: actionNormalizeResponse, 41 | setup: actionSetup, 42 | tokenize: actionTokenize, 43 | validateData: actionValidateData, 44 | }; 45 | 46 | export const requiredSettings = [ 47 | "merchantId", 48 | "account", 49 | // "hash", 50 | "env", 51 | ]; 52 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/gp-api/action-normalize-response.ts: -------------------------------------------------------------------------------- 1 | import { ISuccess } from ".."; 2 | import cardTypes from "../../lib/card-types"; 3 | import { IDictionary } from "../../lib/util"; 4 | 5 | export default (data: IDictionary) => { 6 | if (data.error && data.reasons) { 7 | return { 8 | error: data.error, 9 | reasons: data.reasons, 10 | }; 11 | } 12 | 13 | if (data.error_code) { 14 | const reasons = [ 15 | { 16 | code: data.error_code, 17 | message: data.detailed_error_description, 18 | }, 19 | ]; 20 | 21 | return { 22 | error: true, 23 | reasons, 24 | }; 25 | } 26 | 27 | const response: ISuccess = { 28 | details: { 29 | accountId: data.account_id, 30 | accountName: data.account_name, 31 | fingerprint: data.fingerprint, 32 | fingerprintPresenceIndicator: data.fingerprint_presence_indicator, 33 | merchantId: data.merchant_id, 34 | merchantName: data.merchant_name, 35 | reference: data.reference 36 | }, 37 | paymentReference: data.id 38 | }; 39 | 40 | if (data.card && data.card.masked_number_last4) { 41 | response.details.cardNumber = data.card.masked_number_last4; 42 | } 43 | 44 | if (data.card && data.card.brand) { 45 | response.details.cardType = cardTypeOfGpApiBrand(data.card.brand); 46 | } 47 | 48 | return response; 49 | }; 50 | 51 | const cardTypeOfGpApiBrand = (brand: string): string => { 52 | if (cardTypes.map((ct) => ct.code).indexOf(brand.toLocaleLowerCase())) { 53 | return brand.toLocaleLowerCase(); 54 | } 55 | 56 | return brand; 57 | }; 58 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/gp-api/action-validate-data.ts: -------------------------------------------------------------------------------- 1 | import { IErrorReason } from "../"; 2 | import { IDictionary } from "../../lib/util"; 3 | import { options } from "../../lib/options"; 4 | 5 | export default (data: IDictionary) => { 6 | const errors: IErrorReason[] = []; 7 | 8 | if (!data["card-number"]) { 9 | errors.push({ 10 | code: "INVALID_CARD_NUMBER", 11 | message: "The card number is invalid.", 12 | }); 13 | } 14 | 15 | if (data["card-holder-name"] && data["card-holder-name"].length > 100) { 16 | errors.push({ 17 | code: "TOO_LONG_DATA", 18 | message: "The card holder name is too long", 19 | }); 20 | } 21 | 22 | if (options.requireCardHolderName ) { 23 | if (!data["card-holder-name"]) { 24 | errors.push({ 25 | code: "INVALID_CARD_HOLDER_NAME", 26 | message: "The card holder is mandatory", 27 | }); 28 | } 29 | } 30 | 31 | return errors; 32 | }; 33 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/gp-api/get-apm-payment-methods.ts: -------------------------------------------------------------------------------- 1 | import { IDictionary } from "../../lib/util"; 2 | import { setGpApiHeaders } from "../../lib/set-headers"; 3 | 4 | export default async (url: string, _env: string, data: IDictionary) => { 5 | const headers = setGpApiHeaders(); 6 | 7 | try { 8 | const resp = await fetch(url, { 9 | credentials: "omit", 10 | headers, 11 | method: "GET", 12 | }); 13 | 14 | return resp.json(); 15 | } catch (e: any) { 16 | return { 17 | error: true, 18 | reasons: [{ code: e.name, message: e.message }], 19 | }; 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/gp-api/get-asset-base-url.ts: -------------------------------------------------------------------------------- 1 | import version from "../../../lib/version"; 2 | import getEnv from "./get-env"; 3 | 4 | export default (result: string) => { 5 | const majorVersion = version.split(".")[0] || version[0]; 6 | 7 | switch (getEnv()) { 8 | case "local": 9 | return `http://localhost:7777/dist/`; 10 | case "qa": 11 | return `https://js-qa.np-hpp.globalpay.com/${version}/`; 12 | case "sandbox": 13 | return `https://js-cert.globalpay.com/${version}/`; 14 | case "production": 15 | return `https://js.globalpay.com/${version}/`; 16 | default: 17 | return result; 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/gp-api/get-env.ts: -------------------------------------------------------------------------------- 1 | import { options } from "../../lib/options"; 2 | 3 | export default () => { 4 | return options.env || "production"; 5 | }; 6 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/heartland/action-normalize-response.ts: -------------------------------------------------------------------------------- 1 | import { ISuccess } from ".."; 2 | import { IDictionary } from "../../lib/util"; 3 | 4 | export default (data: IDictionary) => { 5 | if (data.error && data.reasons) { 6 | return { 7 | error: data.error, 8 | reasons: data.reasons, 9 | }; 10 | } 11 | 12 | if (data.error) { 13 | const reasons = []; 14 | 15 | switch (data.error.param) { 16 | case "card.number": 17 | reasons.push({ 18 | code: "INVALID_CARD_NUMBER", 19 | message: data.error.message, 20 | }); 21 | break; 22 | case "card.exp_month": 23 | case "card.exp_year": 24 | reasons.push({ 25 | code: "INVALID_CARD_EXPIRATION_DATE", 26 | message: data.error.message, 27 | }); 28 | break; 29 | default: 30 | break; 31 | } 32 | 33 | return { 34 | error: true, 35 | reasons, 36 | }; 37 | } 38 | 39 | const response: ISuccess = { 40 | details: {}, 41 | paymentReference: data.token_value, 42 | }; 43 | 44 | if (data.card && data.card.number) { 45 | response.details.cardNumber = data.card.number; 46 | } 47 | 48 | if (data.is_fsahsa) { 49 | response.details.isHsaFsa = data.is_fsahsa === "Y"; 50 | } 51 | 52 | if (data.surcharge_allowed) { 53 | response.details.canSurcharge = data.surcharge_allowed === "Y"; 54 | } 55 | 56 | return response; 57 | }; 58 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/heartland/action-validate-data.ts: -------------------------------------------------------------------------------- 1 | import { IErrorReason } from "../"; 2 | import { IDictionary } from "../../lib/util"; 3 | 4 | export default (data: IDictionary) => { 5 | const errors: IErrorReason[] = []; 6 | 7 | if (!data["card-number"] && !data["card-track"] && !data["account-number"]) { 8 | if (!data["card-number"]) { 9 | errors.push({ 10 | code: "INVALID_CARD_NUMBER", 11 | message: "The card number is invalid.", 12 | }); 13 | } else if (!data["account-number"]) { 14 | errors.push({ 15 | code: "INVALID_ACCOUNT_NUMBER", 16 | message: "The account number is invalid", 17 | }); 18 | } 19 | } 20 | 21 | if (data["account-number"] && !data["routing-number"]) { 22 | errors.push({ 23 | code: "INVALID_ROUTING_NUMBER", 24 | message: "The routing number is invalid", 25 | }); 26 | } 27 | 28 | return errors; 29 | }; 30 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/openedge/action-normalize-response.ts: -------------------------------------------------------------------------------- 1 | export default (data: any) => { 2 | return data; 3 | }; 4 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/openedge/action-validate-data.ts: -------------------------------------------------------------------------------- 1 | import { IErrorReason } from "../"; 2 | import { IDictionary } from "../../lib/util"; 3 | 4 | export default (data: IDictionary) => { 5 | const errors: IErrorReason[] = []; 6 | const cardNumber = data["card-number"].replace(/\s+/g, ""); 7 | 8 | // The error message here is irrelevant - actual 'invalid_input' error is generated in tokenize.ts. 9 | // For type compatibility reason, this code is preserved here. 10 | // if (!data["card-number"] && !data["card-track"] && !data["account-number"]) { 11 | if (cardNumber.length < 13 || cardNumber.length > 19) { 12 | errors.push({ 13 | code: "invalid_input", 14 | // @ts-ignore 15 | detail: [ 16 | { 17 | data_path: "/card/card_number", 18 | description: "Invalid data", 19 | }, 20 | ], 21 | message: "Invalid input data.", 22 | }); 23 | } 24 | 25 | return errors; 26 | }; 27 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/openedge/get-asset-base-url.ts: -------------------------------------------------------------------------------- 1 | import version from "../../../lib/version"; 2 | import getEnv from "./get-env"; 3 | 4 | export default (result: string) => { 5 | const majorVersion = version.split(".")[0] || version[0]; 6 | 7 | switch (getEnv()) { 8 | case "local": 9 | return `http://localhost:8080/v${majorVersion}/`; 10 | case "dev": 11 | return `https://js.dev.paygateway.com/secure_payment/v${majorVersion}/`; 12 | case "pqa": 13 | return `https://js.pqa.paygateway.com/secure_payment/v${majorVersion}/`; 14 | case "qa": 15 | return `https://js.qa.paygateway.com/secure_payment/v${majorVersion}/`; 16 | case "test": 17 | return `https://js.test.paygateway.com/secure_payment/v${majorVersion}/`; 18 | case "prod": 19 | return `https://js.paygateway.com/secure_payment/v${majorVersion}/`; 20 | case "GP": 21 | return result; 22 | default: 23 | return result; 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/openedge/get-env.ts: -------------------------------------------------------------------------------- 1 | import { options } from "../../lib/options"; 2 | 3 | export default () => { 4 | return options["X-GP-Environment"] || "local"; 5 | }; 6 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/openedge/index.ts: -------------------------------------------------------------------------------- 1 | import { IActions } from ".."; 2 | import { IDictionary } from "../../lib/util"; 3 | 4 | import actionNormalizeResponse from "./action-normalize-response"; 5 | import actionTokenize from "./action-tokenize"; 6 | import actionValidateData from "./action-validate-data"; 7 | import getAssetBaseUrl from "./get-asset-base-url"; 8 | import getEnv from "./get-env"; 9 | 10 | export const supports = { 11 | apm: { 12 | applePay: true, 13 | googlePay: false, 14 | }, 15 | consumerAuthentication: true, 16 | tokenization: { 17 | cardNotPresent: true, 18 | cardPresent: true, 19 | eCheck: true, 20 | gift: true, 21 | }, 22 | }; 23 | /* tslint:disable:object-literal-sort-keys */ 24 | const domains: IDictionary = { 25 | local: "https://api-sandbox.dev.paygateway.com", 26 | dev: "https://api.dev.paygateway.com", 27 | pqa: "https://api.dev.paygateway.com", 28 | qa: "https://api.qa.paygateway.com", 29 | test: "https://api.pit.paygateway.com", 30 | prod: "https://api.paygateway.com", 31 | }; 32 | /* tslint:enable:object-literal-sort-keys */ 33 | 34 | export const urls = { 35 | assetBaseUrl: getAssetBaseUrl, 36 | tokenization: (prod: boolean) => 37 | `${domains[getEnv()]}/tokenization/temporary_tokens`, 38 | }; 39 | 40 | export const actions: IActions = { 41 | normalizeResponse: actionNormalizeResponse, 42 | tokenize: actionTokenize, 43 | validateData: actionValidateData, 44 | }; 45 | 46 | export const requiredSettings = ["X-GP-Api-Key", "X-GP-Environment"]; 47 | 48 | export { getEnv }; 49 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/transit/action-normalize-response.ts: -------------------------------------------------------------------------------- 1 | import { IDictionary } from "../../lib/util"; 2 | 3 | export default (data: IDictionary) => { 4 | if (data.error && data.reasons) { 5 | return { 6 | error: data.error, 7 | reasons: data.reasons, 8 | }; 9 | } 10 | 11 | // TODO: parse these properly 12 | if (["FAIL", "FAILURE"].indexOf(data.status) !== -1) { 13 | return { 14 | error: true, 15 | reasons: [ 16 | { 17 | code: "ERROR", 18 | message: `${data.responseCode}: ${data.message}`, 19 | }, 20 | ], 21 | }; 22 | } 23 | 24 | const response: any = { 25 | paymentReference: data.tsepToken, 26 | requestId: data.transactionId, 27 | }; 28 | 29 | return response; 30 | }; 31 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/transit/action-validate-data.ts: -------------------------------------------------------------------------------- 1 | import { IErrorReason } from ".."; 2 | import { IDictionary } from "../../lib/util"; 3 | 4 | export default (data: IDictionary) => { 5 | const errors: IErrorReason[] = []; 6 | 7 | if (!data["card-number"]) { 8 | errors.push({ 9 | code: "INVALID_CARD_NUMBER", 10 | message: "The card number is invalid.", 11 | }); 12 | } 13 | 14 | if (!data["card-cvv"]) { 15 | errors.push({ 16 | code: "INVALID_CARD_SECURITY_CODE", 17 | message: "The card security code is invalid.", 18 | }); 19 | } 20 | 21 | if (!data["card-expiration"]) { 22 | errors.push({ 23 | code: "INVALID_CARD_EXPIRATION", 24 | message: "The card expiration is invalid.", 25 | }); 26 | } 27 | 28 | return errors; 29 | }; 30 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/gateways/transit/index.ts: -------------------------------------------------------------------------------- 1 | import { IActions } from ".."; 2 | import { options } from "../../lib/options"; 3 | 4 | import actionNormalizeResponse from "./action-normalize-response"; 5 | import actionTokenize from "./action-tokenize"; 6 | import actionValidateData from "./action-validate-data"; 7 | 8 | export const supports = { 9 | apm: { 10 | applePay: false, 11 | googlePay: false, 12 | }, 13 | consumerAuthentication: false, 14 | tokenization: { 15 | cardNotPresent: true, 16 | cardPresent: false, 17 | eCheck: false, 18 | gift: false, 19 | }, 20 | }; 21 | 22 | const domains = { 23 | // Genius Checkout has an automatic sandbox feature for developer / partner accounts 24 | production: "https://gateway.transit-pass.com", 25 | sandbox: "https://stagegw.transnox.com", 26 | }; 27 | 28 | export const urls = { 29 | tokenization: (prod: boolean) => { 30 | options.tsepHost = prod ? domains.production : domains.sandbox; 31 | return `${options.tsepHost}/transit-tsep-web/jsView/${options.deviceId}?${options.manifest}`; 32 | }, 33 | }; 34 | 35 | export const actions: IActions = { 36 | normalizeResponse: actionNormalizeResponse, 37 | tokenize: actionTokenize, 38 | validateData: actionValidateData, 39 | }; 40 | 41 | export const requiredSettings = ["deviceId", "manifest"]; 42 | 43 | export const getEnv = () => { 44 | return options.env || "production"; 45 | }; 46 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/index.ts: -------------------------------------------------------------------------------- 1 | // Holds global state and functions for managing iframe 2 | // communication and event management. 3 | // 4 | // Not intended for external use. 5 | 6 | import { EventEmitter } from "globalpayments-lib"; 7 | export * from "./lib/loaded-frames"; 8 | export * from "./lib/options"; 9 | export * from "./lib/post-message"; 10 | 11 | export { default as tokenize } from "./requests/tokenize"; 12 | 13 | export const bus = new EventEmitter(); 14 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/add-sandbox-alert.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Adds an alert letting the user know they're in sandbox mode 3 | * 4 | * @param target 5 | * 6 | */ 7 | export function addSandboxAlert( 8 | target: string | HTMLElement, 9 | insertBefore?: Node, 10 | ) { 11 | const el = document.createElement("div"); 12 | const text = document.createTextNode( 13 | "This page is currently in sandbox/test mode. Do not use real/active card numbers.", 14 | ); 15 | el.appendChild(text); 16 | el.className = "sandbox-warning"; 17 | el.style.display = "block"; 18 | el.style.width = "100%"; 19 | el.style.marginBottom = "5px"; 20 | el.style.color = "#fff"; 21 | el.style.backgroundColor = "#770000"; 22 | el.style.padding = "8px 5px"; 23 | el.style.fontFamily = "Verdana"; 24 | el.style.fontWeight = "100"; 25 | el.style.fontSize = "12px"; 26 | el.style.textAlign = "center"; 27 | el.style.boxSizing = "border-box"; 28 | 29 | if (typeof target === "string") { 30 | const element = document.querySelector(target) as HTMLElement; 31 | 32 | if (!element) { 33 | throw new Error("Credit card form target does not exist"); 34 | } 35 | 36 | target = element; 37 | } 38 | 39 | if (!target) { 40 | return; 41 | } 42 | 43 | if (insertBefore) { 44 | target.insertBefore(el, insertBefore); 45 | } else { 46 | target.insertBefore(el, target.firstChild); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/asset-base-url.ts: -------------------------------------------------------------------------------- 1 | import getGateway from "../../internal/lib/get-gateway"; 2 | import { options } from "../../internal/lib/options"; 3 | import version from "../../lib/version"; 4 | 5 | export default () => { 6 | const majorVersion = version.split(".")[0] || version[0]; 7 | const result = `https://js.globalpay.com/${version}/`; 8 | 9 | const gateway = getGateway(); 10 | 11 | if (gateway && gateway.urls.assetBaseUrl) { 12 | return gateway.urls.assetBaseUrl(result); 13 | } 14 | 15 | switch (options.env) { 16 | case "local": 17 | return `http://localhost:7777/dist/`; 18 | case "qa": 19 | return `https://js-qa.np-hpp.globalpay.com/${version}/`; 20 | case "sandbox": 21 | return `https://js-cert.globalpay.com/${version}/`; 22 | case "production": 23 | return `https://js.globalpay.com/${version}/`; 24 | default: 25 | return result; 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/build-tokenization-url.ts: -------------------------------------------------------------------------------- 1 | import getGateway from "./get-gateway"; 2 | import { options } from "./options"; 3 | import { IDictionary } from "./util"; 4 | 5 | export default (queryString?: IDictionary): string => { 6 | const gateway = getGateway(); 7 | 8 | if (!gateway) { 9 | return ""; 10 | } 11 | 12 | const base = gateway.urls.tokenization( 13 | gateway.getEnv(options) === "production", 14 | ); 15 | 16 | if (!queryString) { 17 | return base; 18 | } 19 | 20 | let query = "?"; 21 | 22 | for (const param in queryString) { 23 | if (queryString.hasOwnProperty(param) && queryString[param]) { 24 | query += param + "=" + encodeURIComponent(queryString[param]) + "&"; 25 | } 26 | } 27 | 28 | return base + query; 29 | }; 30 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/currency-conversion/components/enums.ts: -------------------------------------------------------------------------------- 1 | export enum CurrencyConversionStyles { 2 | CONTAINER = 'currency-conversion-container', 3 | MERCHANT_CURRENCY_ID = 'merchant-currency', 4 | CARD_CURRENCY_ID = 'card-currency' 5 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/currency-conversion/contracts/constants.ts: -------------------------------------------------------------------------------- 1 | export const DCC_KEY = 'currency-conversion'; 2 | 3 | export const DCC_CONFIG_DEFAULT_CHANNEL = 'CNP'; 4 | export const DCC_CONFIG_DEFAULT_ENTRY_MODE = 'ECOM'; 5 | export const DCC_CONFIG_DEFAULT_TRANSACTION_TYPE = 'SALE'; 6 | 7 | export const DCC_AVAILABILITY_STATUS_KEY: string = "dccAvailabilityStatus"; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/currency-conversion/contracts/enums.ts: -------------------------------------------------------------------------------- 1 | export enum CurrencyConversionEvents { 2 | CurrencyConversionRequestStart = 'currency-conversion-request-start', 3 | CurrencyConversionRequestCompleted = 'currency-conversion-request-completed', 4 | CurrencyConversionRequestFailed = 'currency-conversion-request-failed', 5 | CurrencyConversionHide = 'currency-conversion-validate-fields', 6 | CurrencyConversionFieldsValidated = 'currency-conversion-fields-validated', 7 | 8 | CurrencyConversionRequestData = 'currency-conversion-request-data', 9 | CurrencyConversionAccumulateData = 'currency-conversion-accumulate-data', 10 | CurrencyConversionPassData = 'currency-conversion-pass-data', 11 | 12 | CurrencyConversionSendValue = 'currency-conversion-send-value', 13 | } 14 | 15 | export enum CurrencyConversionStatus { 16 | CurrencyConversionNotAvailable = 'NOT_AVAILABLE', 17 | CurrencyConversionAvailable = 'AVAILABLE' 18 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/currency-conversion/contracts/interfaces.ts: -------------------------------------------------------------------------------- 1 | export interface CurrencyConversionPaymentData { 2 | id: string; 3 | exchangeRate: string; 4 | exchangeRateSource: string; 5 | cardHolderAmount: string; 6 | cardHolderCurrency: string; 7 | merchantAmount: string; 8 | merchantCurrency: string; 9 | marginPercentageRate: string; 10 | exchangeRateTimeCreated: string; 11 | commissionPercentage: string; 12 | currencyConversionAccepted: string 13 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/currency-conversion/requests/query-currency-conversion.ts: -------------------------------------------------------------------------------- 1 | import { IError } from "../../../gateways"; 2 | import getGateway from "../../get-gateway"; 3 | import { options } from "../../options"; 4 | import { IDictionary } from "../../util"; 5 | 6 | export default (data: IDictionary) => { 7 | const gateway = getGateway(); 8 | 9 | if (!gateway) return Promise.reject(createInvalidConfigurationError("no gateway available")); 10 | 11 | return new Promise((resolve, reject) => { 12 | if (!gateway.actions.queryCurrencyConversion || !gateway.urls.queryCurrencyConversionUrl) return Promise.reject(createInvalidConfigurationError("no currency conversion gateway action/url available")); 13 | 14 | const url = gateway.urls.queryCurrencyConversionUrl(); 15 | gateway.actions.queryCurrencyConversion(url, options.env || "", data) 16 | .then((response: IDictionary) => { 17 | return response; 18 | }) 19 | .then((response: any) => { 20 | if ((response as IError).error) { 21 | reject(response); 22 | return; 23 | } 24 | 25 | if (gateway.requiredSettings.indexOf("X-GP-Api-Key") !== -1) { 26 | resolve(response); 27 | return; 28 | } 29 | 30 | resolve(response); 31 | }) 32 | .catch(reject); 33 | }); 34 | }; 35 | 36 | function createInvalidConfigurationError(message: string) { 37 | return { 38 | error: true, 39 | reasons: [ 40 | { code: "INVALID_CONFIGURATION", message }, 41 | ], 42 | }; 43 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/currency-conversion/utils/reset-currency-conversion.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Resets the currency conversion by removing all children from the container, 3 | * clearing the value of the payment field inside the iframe, and hiding validation messages. 4 | * @param dccField The iframe field associated with the currency conversion. 5 | */ 6 | import { IframeField } from "../../../../ui"; 7 | import { CurrencyConversionStyles } from "../components/enums"; 8 | 9 | export const resetCurrencyConversion = (dccField: IframeField | undefined): void => { 10 | // Remove all children from the container except the iframe 11 | dccField?.container?.querySelector(`.${CurrencyConversionStyles.CONTAINER}`)?.remove(); 12 | 13 | // Clear the value of the payment field inside the iframe 14 | dccField?.setValue(''); 15 | 16 | // Hide validation messages associated with the dccField 17 | dccField?.hideValidation(); 18 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/detectLanguage.ts: -------------------------------------------------------------------------------- 1 | import translations from "./translations/translations"; 2 | import {options} from "./options"; 3 | import {Language} from "./enums"; 4 | 5 | let currentLanguage: Language | string = Language.en; // Default language 6 | const DEFAULT_LANGUAGE = 'en'; 7 | 8 | export function setCurrentLanguage(lang?: Language): string { 9 | if (lang && translations.hasOwnProperty(lang)){ 10 | currentLanguage = lang; 11 | } 12 | return currentLanguage; 13 | } 14 | 15 | export function getCurrentLanguage(): string { 16 | const lang = options.language; 17 | if (lang && translations.hasOwnProperty(lang)){ 18 | currentLanguage = lang; 19 | } 20 | return currentLanguage; 21 | } 22 | 23 | export function getTranslationSet(language: string, featureSet: string): any { 24 | const translationSet = translations[language][featureSet] || translations[DEFAULT_LANGUAGE][featureSet]; 25 | return translationSet || {}; 26 | } 27 | 28 | export function getTranslationLanguageSet(language: string): any { 29 | const translationLanguageSet = translations[language] || translations[DEFAULT_LANGUAGE]; 30 | return translationLanguageSet || {}; 31 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/dot-placeholders.ts: -------------------------------------------------------------------------------- 1 | export default [ 2 | "•••• •••• •••• ••••", 3 | "···· ···· ···· ····", 4 | "•••••••••", 5 | "·········", 6 | "••••", 7 | "····", 8 | "•••", 9 | "···", 10 | ]; 11 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/encode-entities.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Escapes all potentially dangerous characters, so that the 3 | * resulting string can be safely inserted into attribute or 4 | * element text. 5 | * 6 | * @param value 7 | * @returns escaped text 8 | */ 9 | export default function encodeEntities(value: string) { 10 | return value 11 | .replace(/&/g, "&") 12 | .replace(//g, ">") 14 | .replace(/"/g, """); 15 | } 16 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/ev.ts: -------------------------------------------------------------------------------- 1 | export default class Ev { 2 | public static listen( 3 | node: EventTarget, 4 | eventName: string, 5 | callback: EventListener, 6 | ) { 7 | if (document.addEventListener !== undefined) { 8 | node.addEventListener(eventName, callback, false); 9 | } else { 10 | if (node === document) { 11 | (document.documentElement as any).attachEvent( 12 | "onpropertychange", 13 | (e: Event) => { 14 | if ((e as any).propertyName === eventName) { 15 | callback(e); 16 | } 17 | }, 18 | ); 19 | } else { 20 | (node as any).attachEvent("on" + eventName, callback); 21 | } 22 | } 23 | } 24 | public static trigger(node: EventTarget, eventName: string) { 25 | if (document.createEvent !== undefined) { 26 | const event = document.createEvent("Event"); 27 | event.initEvent(eventName, true, true); 28 | node.dispatchEvent(event); 29 | } else { 30 | (document.documentElement as any)[eventName]++; 31 | } 32 | } 33 | public static ignore(eventName: string, callback: EventListener) { 34 | if (document.removeEventListener !== undefined) { 35 | document.removeEventListener(eventName, callback, false); 36 | } else { 37 | (document.documentElement as any).detachEvent( 38 | "onpropertychange", 39 | (e: Event) => { 40 | if ((e as any).propertyName === eventName) { 41 | callback(e); 42 | } 43 | }, 44 | ); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/get-gateway.ts: -------------------------------------------------------------------------------- 1 | import { availableGateways, IGatewayModule } from "../gateways"; 2 | import { options } from "./options"; 3 | 4 | const configHasAllRequiredSettings = (settings: string[]) => { 5 | const totalSettings = settings.length; 6 | let count = 0; 7 | 8 | for (let i = 0; i < totalSettings; i++) { 9 | const setting = settings[i]; 10 | if (options.hasOwnProperty(setting) && options[setting] !== undefined) { 11 | count++; 12 | } 13 | } 14 | 15 | return count === totalSettings; 16 | }; 17 | 18 | export default (): IGatewayModule | undefined => { 19 | for (const key in availableGateways) { 20 | if (!availableGateways.hasOwnProperty(key)) { 21 | continue; 22 | } 23 | 24 | const gateway = availableGateways[key]; 25 | 26 | if (configHasAllRequiredSettings(gateway.requiredSettings)) { 27 | return gateway; 28 | } 29 | } 30 | 31 | return undefined; 32 | }; 33 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/installments/components/add-issuer-banner.ts: -------------------------------------------------------------------------------- 1 | import { IframeField } from "../../../../ui"; 2 | import { getHaveVirginMoneyCreditCardBannerTemplate } from "../templates/common"; 3 | 4 | export default function addIssuerBanner(iframeField: IframeField | undefined) { 5 | const contest = getHaveVirginMoneyCreditCardBannerTemplate(); 6 | iframeField?.container?.appendChild(contest); 7 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/installments/components/modal/styles.ts: -------------------------------------------------------------------------------- 1 | const styles = (_assetBaseUrl: string) => { 2 | return { 3 | ".secure-payment-form .modal-overlay": { 4 | background: "#0000006e", 5 | position: "fixed", 6 | top: "0", 7 | left: "0", 8 | margin: "0 auto", 9 | width: "100%", 10 | height: "100%", 11 | display: "flex", 12 | "justify-content": "center", 13 | "align-items": "center", 14 | "z-index": "9999", 15 | }, 16 | ".secure-payment-form .modal-wrapper": { 17 | "font-family": "DMSans", 18 | background: "#FFFFFF", 19 | "border-width": "0px", 20 | "border-radius": "8px", 21 | 22 | overflow: "hidden", 23 | }, 24 | } 25 | } 26 | 27 | export default styles; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/installments/contracts/constants.ts: -------------------------------------------------------------------------------- 1 | export const INSTALLMENTS_KEY = 'installments'; 2 | 3 | export const INSTALLMENTS_CONFIG_DEFAULT_CHANNEL = 'CNP'; 4 | export const INSTALLMENTS_CONFIG_DEFAULT_ENTRY_MODE = 'ECOM'; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/installments/contracts/enums.ts: -------------------------------------------------------------------------------- 1 | export enum InstallmentEvents { 2 | CardInstallmentsFieldValidated = "card-installments-field-validated", 3 | 4 | CardInstallmentsRequestStart = "card-installments-request-start", 5 | CardInstallmentsRequestCompleted = "card-installments-request-completed", 6 | CardInstallmentsRequestFailed = "card-installments-request-failed", 7 | CardInstallmentsHide = "card-installments-hide", 8 | 9 | CardInstallmentsRequestData = 'card-installments-request-data', 10 | CardInstallmentsPassData = 'card-installments-pass-data', 11 | CardInstallmentsAccumulateData = 'card-installments-accumulate-data', 12 | } 13 | 14 | export enum InstallmentAvailableStatus { 15 | Available = "AVAILABLE", 16 | NotAvailable = "NOT_AVAILABLE", 17 | } 18 | 19 | export enum InstallmentTermModes { 20 | APR = "APR", 21 | FEE = "FEE", 22 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/installments/contracts/installment-action.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * InstallmentAction class model. 3 | */ 4 | export default class InstallmentAction { 5 | id: string; 6 | type: string; 7 | timeCreated: string; 8 | resultCode: string; 9 | appId: string; 10 | appName: string; 11 | 12 | constructor( 13 | _id: string, 14 | _type: string, 15 | _timeCreated: string, 16 | _resultCode: string, 17 | _appId: string, 18 | _appName: string, 19 | ) { 20 | this.id = _id; 21 | this.type = _type; 22 | this.timeCreated = _timeCreated; 23 | this.resultCode = _resultCode; 24 | this.appId = _appId; 25 | this.appName = _appName; 26 | } 27 | } 28 | 29 | export function installmentActionMapper(origin: { 30 | id: string, 31 | type: string, 32 | time_created: string, 33 | result_code: string, 34 | app_id: string, 35 | app_name: string, 36 | }): InstallmentAction { 37 | return { 38 | id: origin.id, 39 | type: origin.type, 40 | timeCreated: origin.time_created, 41 | resultCode: origin.result_code, 42 | appId: origin.app_id, 43 | appName: origin.app_name, 44 | }; 45 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/installments/contracts/installment-payment-method.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * InstallmentPaymentMethod class model. 3 | */ 4 | export default class InstallmentPaymentMethod { 5 | public entryMode: string; 6 | public card: { 7 | brand: string, 8 | maskedNumberLast4: string 9 | }; 10 | 11 | constructor( 12 | _entryMode: string, 13 | _card: { 14 | brand: string, 15 | maskedNumberLast4: string 16 | }, 17 | ) { 18 | this.entryMode = _entryMode; 19 | this.card = _card; 20 | } 21 | } 22 | 23 | export function installmentPaymentMethodMapper(origin: { 24 | entry_mode: string, 25 | card: { 26 | brand: string, 27 | masked_number_last4: string 28 | }, 29 | }): InstallmentPaymentMethod { 30 | return { 31 | entryMode: origin.entry_mode, 32 | card: { 33 | brand: origin.card.brand, 34 | maskedNumberLast4: origin.card.masked_number_last4, 35 | }, 36 | }; 37 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/installments/contracts/installment-term-fees.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * InstallmentTermFees class model. 3 | */ 4 | export default class InstallmentTermFees { 5 | public currency: string; 6 | public totalAmount: string; 7 | public fixedAmount: string; 8 | public monthlyAmount: string; 9 | 10 | constructor( 11 | _currency: string, 12 | _totalAmount: string, 13 | _fixedAmount: string, 14 | _monthlyAmount: string 15 | ) { 16 | this.currency = _currency; 17 | this.totalAmount = _totalAmount; 18 | this.fixedAmount = _fixedAmount; 19 | this.monthlyAmount = _monthlyAmount; 20 | } 21 | } 22 | 23 | export function installmentTermFeesMapper(origin: { 24 | currency: string, 25 | total_amount: string, 26 | fixed_amount: string, 27 | monthly_amount: string 28 | }): InstallmentTermFees { 29 | return { 30 | currency: origin.currency, 31 | totalAmount: origin.total_amount, 32 | fixedAmount: origin.fixed_amount, 33 | monthlyAmount: origin.monthly_amount, 34 | }; 35 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/installments/helpers/currency.ts: -------------------------------------------------------------------------------- 1 | import { 2 | getCurrencySymbol as _getCurrencySymbol, 3 | addCurrencyToAmount as _addCurrencyToAmount, 4 | } from "../../../../common/currency"; 5 | 6 | export const getCurrencySymbol = (currency: string): string => _getCurrencySymbol(currency); 7 | 8 | export const addCurrencyToAmount = (currency: string, amount: string | number | undefined): string => _addCurrencyToAmount(currency, amount); -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/installments/requests/query-installment-plans.ts: -------------------------------------------------------------------------------- 1 | import { IError } from "../../../gateways"; 2 | import getGateway from "../../get-gateway"; 3 | import { options } from "../../options"; 4 | import { IDictionary } from "../../util"; 5 | 6 | export default (data: IDictionary) => { 7 | const gateway = getGateway(); 8 | 9 | if (!gateway) return Promise.reject(createInvalidConfigurationError("no gateway available")); 10 | 11 | return new Promise((resolve, reject) => { 12 | if (!gateway.actions.queryInstallmentPlans || !gateway.urls.queryInstallmentPlans) return Promise.reject(createInvalidConfigurationError("no installment gateway action/url available")); 13 | 14 | const url = gateway.urls.queryInstallmentPlans(false); 15 | gateway.actions.queryInstallmentPlans(url, options.env || "", data) 16 | .then((response: IDictionary) => { 17 | return response; 18 | }) 19 | .then((response: any) => { 20 | if ((response as IError).error) { 21 | reject(response); 22 | return; 23 | } 24 | 25 | if (gateway.requiredSettings.indexOf("X-GP-Api-Key") !== -1) { 26 | resolve(response); 27 | return; 28 | } 29 | 30 | resolve(response); 31 | }) 32 | .catch(reject); 33 | }); 34 | }; 35 | 36 | function createInvalidConfigurationError(message: string) { 37 | return { 38 | error: true, 39 | reasons: [ 40 | { code: "INVALID_CONFIGURATION", message }, 41 | ], 42 | }; 43 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/loaded-frames.ts: -------------------------------------------------------------------------------- 1 | import { IFrameCollection } from "../../ui"; 2 | export const loadedFrames: IFrameCollection = {}; 3 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/object-assign.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates a single object by merging a `source` (default) and `properties` 3 | * obtained elsewhere. Any properties in `properties` will overwrite 4 | * matching properties in `source`. 5 | * 6 | * @param source 7 | * @param properties 8 | */ 9 | export default function objectAssign(source: object, properties: object) { 10 | const destination: object = {}; 11 | 12 | if (!source) { 13 | source = {}; 14 | } 15 | 16 | for (const property in source) { 17 | if (source.hasOwnProperty(property)) { 18 | (destination as any)[property] = (source as any)[property]; 19 | } 20 | } 21 | 22 | for (const property in properties) { 23 | if (properties.hasOwnProperty(property)) { 24 | (destination as any)[property] = (properties as any)[property]; 25 | } 26 | } 27 | 28 | return destination; 29 | } 30 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/options.ts: -------------------------------------------------------------------------------- 1 | import { IConfiguration } from "../../tools/configure"; 2 | export const options: IConfiguration = {}; 3 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/order-information/constants.ts: -------------------------------------------------------------------------------- 1 | export const ORDER_INFORMATION_KEY = 'order-information'; 2 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/order-information/contracts.ts: -------------------------------------------------------------------------------- 1 | export interface IOrderInformationData { 2 | merchantName: string; 3 | orderTotalAmount: string; 4 | orderReference: string; 5 | currencyCode: string; 6 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/payment-field-id.ts: -------------------------------------------------------------------------------- 1 | export default "secure-payment-field"; 2 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/set-headers.ts: -------------------------------------------------------------------------------- 1 | import { options } from "./options"; 2 | import { ApiVersion } from "./enums"; 3 | import version from "../../lib/version"; 4 | 5 | export function setGpApiHeaders() { 6 | const headers = { 7 | "Accept": "application/json", 8 | "Authorization": `Bearer ${options.accessToken || ""}`, 9 | "Content-Type": "application/json", 10 | "X-GP-Version": options.apiVersion || ApiVersion.default, 11 | "X-GP-Library": `javascript;version=${version}`, 12 | }; 13 | 14 | return typeof Headers !== "undefined" ? new Headers(headers) : headers; 15 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/styles/apple-pay/common.ts: -------------------------------------------------------------------------------- 1 | const styles = (assetBaseUrl: string) => { 2 | const imageBase = assetBaseUrl + "images/"; 3 | 4 | return { 5 | "apple-pay-button": { 6 | "--apple-pay-button-width": "100%", 7 | "--apple-pay-button-height": "50px", 8 | "--apple-pay-button-border-radius": "3px", 9 | "--apple-pay-button-padding": "0px 0px", 10 | "--apple-pay-button-box-sizing": "border-box", 11 | display: "block", 12 | margin: "8px 0", 13 | } 14 | }; 15 | }; 16 | 17 | export default styles; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/styles/built-in-validations/common.ts: -------------------------------------------------------------------------------- 1 | export const fieldStyles = (assetBaseUrl: string) => { 2 | const imageBase = assetBaseUrl + "images/"; 3 | const fontBase = assetBaseUrl + "fonts/"; 4 | 5 | const customColors = { 6 | validationRed: '#E12619', 7 | }; 8 | 9 | return { 10 | "#secure-payment-field[type=text].field-validation-wrapper": { 11 | "font-family": "var(--inputfield-container-font-error, DMSans)", 12 | }, 13 | "#secure-payment-field[type=tel].hf-invalid": { 14 | border: `1px solid var(--inputfield-container-color-border-error, ${customColors.validationRed}) !important`, 15 | }, 16 | "#secure-payment-field[type=text].hf-invalid": { 17 | border: `1px solid var(--inputfield-container-color-border-error, ${customColors.validationRed}) !important`, 18 | }, 19 | }; 20 | }; 21 | 22 | const styles = (assetBaseUrl: string) => { 23 | const imageBase = assetBaseUrl + "images/"; 24 | 25 | return { }; 26 | }; 27 | 28 | export default styles; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/styles/built-in-validations/default.ts: -------------------------------------------------------------------------------- 1 | import { 2 | fieldStyles as getCommonBuiltInValidationFieldStyles, 3 | } from './common'; 4 | 5 | export const fieldStyles = (assetBaseUrl: string) => { 6 | const imageBase = assetBaseUrl + "images/"; 7 | const fontBase = assetBaseUrl + "fonts/"; 8 | 9 | return { 10 | ...getCommonBuiltInValidationFieldStyles(assetBaseUrl), 11 | 12 | "img.card-number-icon": { 13 | background: `transparent url(${imageBase}logo-unknown@2x.png) no-repeat`, 14 | "background-size": "100%", 15 | width: "65px", 16 | height: "40px", 17 | right: "12px", 18 | top: "6px", 19 | "background-position": "50% 50%" 20 | }, 21 | }; 22 | }; 23 | 24 | export const styles = (assetBaseUrl: string) => { 25 | const imageBase = assetBaseUrl + "images/"; 26 | 27 | return { }; 28 | }; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/styles/built-in-validations/gp-default.ts: -------------------------------------------------------------------------------- 1 | import { 2 | fieldStyles as getCommonBuiltInValidationFieldStyles, 3 | } from './common'; 4 | 5 | export const fieldStyles = (assetBaseUrl: string) => { 6 | const imageBase = assetBaseUrl + "images/"; 7 | const fontBase = assetBaseUrl + "fonts/"; 8 | 9 | return { 10 | ...getCommonBuiltInValidationFieldStyles(assetBaseUrl), 11 | 12 | "img.card-number-icon": { 13 | background: `transparent url(${imageBase}gp-cc-generic.svg) no-repeat right center`, 14 | right: "10px", 15 | top: "13px", 16 | width: "24px", 17 | height: "16px", 18 | "background-size": "20px", 19 | }, 20 | }; 21 | }; 22 | 23 | export const styles = (assetBaseUrl: string) => { 24 | const imageBase = assetBaseUrl + "images/"; 25 | 26 | const cvvTooltipInvalidStyle = { 27 | border: "1px solid var(--inputfield-container-color-border-error, #E12619)", 28 | "border-left": "none", 29 | }; 30 | 31 | return { 32 | ".secure-payment-form .hf-cvv-tooltip-invalid": cvvTooltipInvalidStyle, 33 | ".secure-payment-form .hf-cvv-tooltip-invalid:hover": cvvTooltipInvalidStyle, 34 | ".secure-payment-form .hf-cvv-tooltip-invalid:focus": cvvTooltipInvalidStyle, 35 | }; 36 | }; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/styles/built-in-validations/simple.ts: -------------------------------------------------------------------------------- 1 | import { 2 | fieldStyles as getCommonBuiltInValidationFieldStyles, 3 | } from './common'; 4 | 5 | export const fieldStyles = (assetBaseUrl: string) => { 6 | const imageBase = assetBaseUrl + "images/"; 7 | const fontBase = assetBaseUrl + "fonts/"; 8 | 9 | return { 10 | ...getCommonBuiltInValidationFieldStyles(assetBaseUrl), 11 | 12 | "img.card-number-icon": { 13 | background: `transparent url(${imageBase}logo-unknown@2x.png) no-repeat`, 14 | "background-size": "100%", 15 | width: "60px", 16 | height: "30px", 17 | right: "0", 18 | top: "7px", 19 | }, 20 | "#field-validation-wrapper": { 21 | "margin-top": "0px!important" 22 | } 23 | }; 24 | }; 25 | 26 | export const styles = (assetBaseUrl: string) => { 27 | const imageBase = assetBaseUrl + "images/"; 28 | 29 | return { }; 30 | }; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/styles/currency-conversion/gp-default.ts: -------------------------------------------------------------------------------- 1 | import getCurrencyConversionStyles from './common'; 2 | 3 | export const fieldStyles = () => { 4 | return { 5 | "#secure-payment-field[hidden]" : { 6 | display: "none!important", 7 | opacity: "0!important", 8 | visibility: "false!important" 9 | } 10 | }; 11 | }; 12 | 13 | export const styles = () => { 14 | return { 15 | ...getCurrencyConversionStyles() 16 | }; 17 | }; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/styles/google-pay/common.ts: -------------------------------------------------------------------------------- 1 | const styles = (assetBaseUrl: string) => { 2 | const imageBase = assetBaseUrl + "images/"; 3 | const customColors = { 4 | azure76LightBlue: '#148EE6', 5 | }; 6 | 7 | return { 8 | "#googlePay": { 9 | height: "50px", 10 | margin: "8px 0", 11 | }, 12 | "#googlePay button:focus": { 13 | outline: `2px solid ${customColors.azure76LightBlue}`, 14 | "outline-offset": "2px" 15 | } 16 | }; 17 | }; 18 | 19 | export default styles; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/styles/installments/default.ts: -------------------------------------------------------------------------------- 1 | import getCommonInstallmentStyles from './common'; 2 | 3 | const styles = (assetBaseUrl: string) => { 4 | const imageBase = assetBaseUrl + "images/"; 5 | 6 | return { 7 | ...getCommonInstallmentStyles(assetBaseUrl), 8 | }; 9 | }; 10 | 11 | export default styles; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/styles/installments/gp-default.ts: -------------------------------------------------------------------------------- 1 | import getCommonInstallmentStyles from './common'; 2 | 3 | const styles = (assetBaseUrl: string) => { 4 | const imageBase = assetBaseUrl + "images/"; 5 | 6 | return { 7 | ...getCommonInstallmentStyles(assetBaseUrl), 8 | }; 9 | }; 10 | 11 | export default styles; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/styles/installments/simple.ts: -------------------------------------------------------------------------------- 1 | import getCommonInstallmentStyles from './common'; 2 | 3 | const styles = (assetBaseUrl: string) => { 4 | const imageBase = assetBaseUrl + "images/"; 5 | 6 | return { 7 | ...getCommonInstallmentStyles(assetBaseUrl), 8 | }; 9 | }; 10 | 11 | export default styles; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/styles/order-information/common.ts: -------------------------------------------------------------------------------- 1 | const styles = (_assetBaseUrl: string) => { 2 | return { 3 | ".order-information": { 4 | display: "flex !important", 5 | "flex-direction": "column", 6 | "align-items": "center", 7 | "font-family": "var(--dropInUI-orderSummary-itemMerchant-fontFamily, DMSans)" 8 | }, 9 | ".title-field": { 10 | "font-weight": "var(--dropInUI-orderSummary-itemMerchant-font-weight-text, bold)", 11 | "line-height": "var(--dropInUI-orderSummary-itemMerchant-line-height, 2.25rem)", 12 | "font-size": "var(--dropInUI-orderSummary-itemMerchant-font-size-text, 1.25rem)" 13 | }, 14 | ".order-information-field": { 15 | "line-height": "var(--dropInUI-orderSummary-itemMerchant-line-height, 2.25rem)", 16 | "font-size": "var(--dropInUI-orderSummary-itemOrderID-font-size-text, 0.875rem)", 17 | "font-weight": "var(--dropInUI-orderSummary-itemOrderID-font-weight-text, 400)" 18 | }, 19 | }; 20 | }; 21 | 22 | export default styles; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/styles/payment-methods/paypal.ts: -------------------------------------------------------------------------------- 1 | const styles = (assetBaseUrl: string) => { 2 | const imageBase = assetBaseUrl + "images/"; 3 | 4 | const customColors = { 5 | outlineBlue: '#355EC5', 6 | defaultYellow: '#FFC439', 7 | hoverYellow: '#E4BC52', 8 | }; 9 | 10 | const commonColumnFlexCenterStyles = { 11 | display: "flex", 12 | "flex-direction": "column", 13 | "align-items": "center", 14 | }; 15 | 16 | return { 17 | ".secure-payment-form .paypal-button-wrapper": { 18 | ...commonColumnFlexCenterStyles, 19 | }, 20 | ".secure-payment-form .paypal-button": { 21 | position: "relative", 22 | background: `${customColors.defaultYellow} url(${imageBase}paypal.svg) no-repeat 50% 50%`, 23 | height: "46px", 24 | border: "0px", 25 | width: "100%", 26 | "border-radius": "2px", 27 | margin: "8px 0", 28 | cursor: "pointer" 29 | }, 30 | ".secure-payment-form .paypal-button:hover": { 31 | "background-color": `${customColors.hoverYellow}`, 32 | }, 33 | ".secure-payment-form .paypal-button:focus": { 34 | "background-color": `${customColors.defaultYellow}`, 35 | outline: `2px solid ${customColors.outlineBlue}`, 36 | "outline-offset": "2px" 37 | }, 38 | }; 39 | }; 40 | 41 | export default styles; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/styles/themes/brand-themes/brand-theme-boipa-uk.ts: -------------------------------------------------------------------------------- 1 | import { 2 | getBaseThemeStyles as getBaseThemeStyles, 3 | } from "./base/base-theme"; 4 | import { IThemePreset } from "./base/contracts"; 5 | import { getThemePreset as getThemePresetBOIPA } from "./brand-theme-boipa"; 6 | 7 | // Brand theme: BOIPA UK 8 | const themePreset: IThemePreset = { 9 | // Inherits the BOIPA preset and overrides the footer logos 10 | ...getThemePresetBOIPA(), 11 | 12 | name: 'BOIPA UK preset', 13 | 14 | images: { 15 | brand: { 16 | buttonPrimaryIcon: "BrandSecurityIcon_BOIPA.svg", 17 | 18 | footer: { 19 | desktopLogo: "BrandFooterLogo_BOIPA_Desktop_UK.svg", 20 | tabletLogo: "BrandFooterLogo_BOIPA_Tablet_Mobile_UK.svg", 21 | mobileLogo: "BrandFooterLogo_BOIPA_Tablet_Mobile_UK.svg", 22 | }, 23 | }, 24 | }, 25 | }; 26 | 27 | const fieldStyles = (assetBaseUrl: string) => { 28 | return { 29 | ...getBaseThemeStyles(assetBaseUrl, themePreset).fieldStyles, 30 | }; 31 | }; 32 | 33 | const parentStyles = (assetBaseUrl: string) => { 34 | return { 35 | ...getBaseThemeStyles(assetBaseUrl, themePreset).parentStyles, 36 | }; 37 | }; 38 | 39 | export const getThemeStyles = (assetBaseUrl: string): { fieldStyles: object, parentStyles: object} => { 40 | return { 41 | fieldStyles: fieldStyles(assetBaseUrl), 42 | parentStyles: parentStyles(assetBaseUrl), 43 | }; 44 | } 45 | 46 | export const getThemePreset = (): IThemePreset => themePreset; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/styles/themes/helpers.ts: -------------------------------------------------------------------------------- 1 | import { HOSTED_FIELD_BRAND_THEMES_NAMES } from "../../../../common/constants"; 2 | import { BrandThemes } from "../../enums"; 3 | 4 | export const isBrandTheme = (style: string | undefined) => { 5 | if (!style) return false; 6 | 7 | return HOSTED_FIELD_BRAND_THEMES_NAMES.indexOf(style) !== -1; 8 | } 9 | 10 | export const isEserviceThemeApplied = (style: string | undefined) =>{ 11 | if(style === BrandThemes.BrandThemeESERVICE){ 12 | return true 13 | } 14 | return false 15 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/translations/translations.ts: -------------------------------------------------------------------------------- 1 | import en from "./en"; 2 | import fr from "./fr"; 3 | import zh from "./zh"; 4 | import cs from "./cs"; 5 | import de from "./de"; 6 | import el from "./el"; 7 | import es from "./es"; 8 | import pl from "./pl"; 9 | import it from "./it"; 10 | import pt from "./pt"; 11 | import ro from "./ro"; 12 | import sk from "./sk"; 13 | import sl from "./sl"; 14 | import tr from "./tr"; 15 | import sv from "./sv"; 16 | import ru from "./ru"; 17 | import ja from "./ja"; 18 | import hu from "./hu"; 19 | import hr from "./hr"; 20 | import nl from "./nl"; 21 | import uk from "./uk"; 22 | import vi from "./vi"; 23 | import mt from "./mt"; 24 | 25 | import {IDictionary} from "../util"; 26 | import ga from "./ga"; 27 | import lv from "./lv"; 28 | import et from "./et"; 29 | 30 | type Translations = { 31 | [key: string]: IDictionary; 32 | }; 33 | 34 | const translations: Translations = { 35 | en, // en - English 36 | fr, // fr - French 37 | zh, // zh - Chinese 38 | cs, // cs - Czech 39 | de, // de - German 40 | el, // el - Greek 41 | es, // es - Spanish 42 | pl, // pl - Polish 43 | it, // it - Italian 44 | pt, // pt - Portuguese 45 | ro, // ro - Romanian 46 | sk, // sk - Slovak 47 | sl, // sl - Slovenian 48 | tr, // tr - Turkish 49 | sv, // sv - Swedish 50 | ru, // ru - Russian 51 | ja, // ja - Japanese 52 | hu, // hu - Hungarian 53 | hr, // hr - Croatian 54 | nl, // nl - Dutch 55 | uk, // uk - Ukrainian 56 | vi, // vi - Vietnamese 57 | mt, // MT - Maltese 58 | ga, // IE - Gaelic Irish 59 | lv, // LV - Latvia 60 | et // EE - Estonia 61 | }; 62 | 63 | export default translations; 64 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/lib/util.ts: -------------------------------------------------------------------------------- 1 | export interface IDictionary { 2 | [key: string]: any; 3 | } 4 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/validators/card-number.ts: -------------------------------------------------------------------------------- 1 | import { luhnCheck, typeByNumber } from "../lib/card-types"; 2 | import IValidator from "./validator"; 3 | 4 | export default class CardNumber implements IValidator { 5 | public validate(cardNumber: string): boolean { 6 | if (!cardNumber) { 7 | return false; 8 | } 9 | 10 | cardNumber = cardNumber.replace(/[-\s]/g, ""); 11 | const type = typeByNumber(cardNumber); 12 | 13 | if (!type) { 14 | return false; 15 | } 16 | return ( 17 | luhnCheck(cardNumber) && type.lengths.indexOf(cardNumber.length) !== -1 18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/validators/cvv.ts: -------------------------------------------------------------------------------- 1 | import IValidator from "./validator"; 2 | 3 | export default class Cvv implements IValidator { 4 | public validate(cvv: string, isAmex?: boolean): boolean { 5 | if (!cvv) { 6 | return false; 7 | } 8 | 9 | cvv = cvv.replace(/^\s+|\s+$/g, ""); 10 | 11 | if (!/^\d+$/.test(cvv)) { 12 | return false; 13 | } 14 | 15 | if (typeof isAmex !== "undefined" && isAmex === true) { 16 | return cvv.length === 4; 17 | } 18 | 19 | if (typeof isAmex !== "undefined" && isAmex === false) { 20 | return cvv.length === 3; 21 | } 22 | 23 | return 3 <= cvv.length && cvv.length <= 4; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/internal/validators/validator.ts: -------------------------------------------------------------------------------- 1 | interface IValidator { 2 | validate: (value: any) => boolean; 3 | } 4 | 5 | export default IValidator; 6 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/lib/version.ts: -------------------------------------------------------------------------------- 1 | export default "4.1.10"; 2 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/payment-request/complete.ts: -------------------------------------------------------------------------------- 1 | import { loadedFrames, postMessage } from "../internal"; 2 | 3 | /** 4 | * Completes a payment via the PaymentRequest API after 5 | * the server-side authorization request is performed 6 | * 7 | * @param data Payment status: "fail", "success", "unknown" 8 | */ 9 | export default (status: PaymentComplete) => { 10 | const frames = loadedFrames; 11 | for (const frameId in frames) { 12 | if (!frames.hasOwnProperty(frameId)) { 13 | continue; 14 | } 15 | 16 | postMessage.post( 17 | { 18 | data: { status }, 19 | id: frameId, 20 | type: "ui:iframe-field:payment-request-complete", 21 | }, 22 | frameId, 23 | ); 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/payment-request/defaults.ts: -------------------------------------------------------------------------------- 1 | export function defaultInstruments() { 2 | return [{ supportedMethods: ["basic-card"] }]; 3 | } 4 | 5 | export function defaultDetails() { 6 | return {} as PaymentDetailsInit; 7 | } 8 | 9 | export function defaultOptions() { 10 | return {}; 11 | } 12 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/payment-request/index.ts: -------------------------------------------------------------------------------- 1 | export { default as complete } from "./complete"; 2 | export { default as setup } from "./setup"; 3 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/ui/iframe-field/action-add-stylesheet.ts: -------------------------------------------------------------------------------- 1 | export { addStylesheet as default } from "../../internal/lib/styles"; 2 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/ui/iframe-field/action-get-cvv.ts: -------------------------------------------------------------------------------- 1 | import { options, postMessage } from "../../internal"; 2 | import paymentFieldId from "../../internal/lib/payment-field-id"; 3 | 4 | /** 5 | * Gets the value of the `card-cvv` hosted field 6 | * 7 | * @param id ID of the hosted field 8 | * @param type Field type of the hosted field 9 | * @returns 10 | */ 11 | export default (id: string, type: string) => { 12 | const el = document.getElementById(paymentFieldId); 13 | if (!el) { 14 | return; 15 | } 16 | 17 | // While we only expose a function for the `card-cvv` 18 | // hosted field, we validate the type once again for 19 | // safe measure. 20 | if (type !== "card-cvv") { 21 | return; 22 | } 23 | 24 | if (!(el as HTMLInputElement).value) { 25 | return; 26 | } 27 | 28 | // We also validate that the configured gateway is only 29 | // TransIT or Heartland Bill Pay. 30 | const isTransit = options.deviceId && options.manifest; 31 | const isBillPay = options.merchantName; 32 | 33 | postMessage.post( 34 | { 35 | data: isTransit || isBillPay ? (el as HTMLInputElement).value : null, 36 | id, 37 | type: "ui:iframe-field:get-cvv", 38 | }, 39 | "parent", 40 | ); 41 | }; 42 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/ui/iframe-field/action-hide-validation.ts: -------------------------------------------------------------------------------- 1 | import { postMessage } from "../../internal"; 2 | import { CardFormFieldNames, HostedFieldValidationEvents } from "../../common/enums"; 3 | import paymentFieldId from "../../internal/lib/payment-field-id"; 4 | 5 | /** 6 | * Hide the validation message for a hosted field 7 | * 8 | * @param id The hosted field id 9 | * @param fieldType The hosted field type 10 | */ 11 | export default (id: string, fieldType: string) => { 12 | const el = document.getElementById(paymentFieldId); 13 | if (!el) return; 14 | 15 | el.setAttribute('style', 'width: 100%;'); 16 | 17 | const fieldWrapperDiv = el.parentElement; 18 | if (!fieldWrapperDiv) return; 19 | 20 | fieldWrapperDiv.setAttribute('style', 'flex-direction: unset;'); 21 | 22 | const fieldSelector = `#secure-payment-field[type=${fieldType === CardFormFieldNames.CardHolderName ? 'text' : 'tel'}]`; 23 | const fieldInput = document.querySelector(fieldSelector); 24 | fieldInput?.classList.remove('hf-invalid'); 25 | 26 | if (fieldType === CardFormFieldNames.CardNumber) { 27 | const cardNumberTypeLogo = document.querySelector(`#secure-payment-field-wrapper > img.card-number-icon`); 28 | cardNumberTypeLogo?.classList.remove('hf-invalid'); 29 | } else if (fieldType === CardFormFieldNames.CardCvv) { 30 | postMessage.post( 31 | { 32 | data: { }, 33 | id, 34 | type: `ui:iframe-field:${HostedFieldValidationEvents.ValidationCvvTooltipHide}`, 35 | }, 36 | "parent", 37 | ); 38 | } 39 | 40 | const validationMessageDiv = document.querySelector(`#field-validation-wrapper`); 41 | validationMessageDiv?.remove(); 42 | }; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/ui/iframe-field/action-payment-request-complete.ts: -------------------------------------------------------------------------------- 1 | import { postMessage } from "../../internal"; 2 | import { IDictionary } from "../../internal/lib/util"; 3 | 4 | /** 5 | * Completes a payment via the PaymentRequest API 6 | * after the integrator performs the server-side 7 | * authorization request. This is triggered in the parent 8 | * window, but the PaymentRequest functionality and 9 | * data only exists within the hoted field. 10 | * 11 | * @param id ID of the hosted field 12 | * @param data Payment status from the integrator 13 | */ 14 | export default async (id: string, data: IDictionary) => { 15 | if (!(window as any).globalPaymentResponse) { 16 | postMessage.post( 17 | { 18 | data: { 19 | code: "ERROR", 20 | message: "Missing PaymentResponse object", 21 | }, 22 | id, 23 | type: "ui:iframe-field:error", 24 | }, 25 | "parent", 26 | ); 27 | return; 28 | } 29 | ((window as any).globalPaymentResponse as PaymentResponse) 30 | .complete(data.data.status) 31 | .then(() => { 32 | postMessage.post( 33 | { 34 | id, 35 | type: "ui:iframe-field:payment-request-completed", 36 | }, 37 | "parent", 38 | ); 39 | }) 40 | .catch((e: Error) => { 41 | postMessage.post( 42 | { 43 | data: { 44 | code: "ERROR", 45 | message: e.message, 46 | }, 47 | id, 48 | type: "ui:iframe-field:error", 49 | }, 50 | "parent", 51 | ); 52 | }); 53 | }; 54 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/ui/iframe-field/action-set-card-type.ts: -------------------------------------------------------------------------------- 1 | import paymentFieldId from "../../internal/lib/payment-field-id"; 2 | 3 | /** 4 | * Sets the class list of a hosted field to include 5 | * the card type inferred from the `card-number` field 6 | * emitting the `ui:iframe-field:card-type` through 7 | * the parent window. 8 | * 9 | * @param cardType The inferred card type 10 | * @returns 11 | */ 12 | export default (cardType?: string) => { 13 | const el = document.getElementById(paymentFieldId); 14 | if (!el) { 15 | return; 16 | } 17 | 18 | // Work with the element's className for backwards 19 | // compatibility 20 | const classList = el.className.split(" "); 21 | const length = classList.length; 22 | let i = 0; 23 | let c = ""; 24 | 25 | for (i; i < length; i++) { 26 | c = classList[i]; 27 | if (c && c.indexOf("card-type-") !== -1) { 28 | delete classList[i]; 29 | } 30 | } 31 | 32 | if (cardType) { 33 | classList.push("card-type-" + cardType); 34 | } 35 | 36 | el.className = classList.join(" "); 37 | }; 38 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/ui/iframe-field/action-set-focus.ts: -------------------------------------------------------------------------------- 1 | import paymentFieldId from "../../internal/lib/payment-field-id"; 2 | 3 | /** 4 | * Sets input focus on the hosted field 5 | */ 6 | export default () => { 7 | const el = document.getElementById(paymentFieldId); 8 | if (!el) { 9 | return; 10 | } 11 | 12 | el.focus(); 13 | }; 14 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/ui/iframe-field/action-set-label.ts: -------------------------------------------------------------------------------- 1 | import encodeEntities from "../../internal/lib/encode-entities"; 2 | import paymentFieldId from "../../internal/lib/payment-field-id"; 3 | 4 | /** 5 | * Sets the label of a hosted field 6 | * 7 | * @param text The desired input label 8 | */ 9 | export default (text: string) => { 10 | const el = document.getElementById(paymentFieldId); 11 | if (!el) { 12 | return; 13 | } 14 | 15 | // Set the label on the input via aria-label 16 | el.setAttribute("aria-label", encodeEntities(text)); 17 | // ... and on the main landmark via aria-label 18 | document 19 | .querySelectorAll("main") 20 | .forEach((e) => e.setAttribute("aria-label", encodeEntities(text))); 21 | // ... and also on the hidden label element via its text content 22 | document 23 | .querySelectorAll(`#${paymentFieldId}-label`) 24 | .forEach((e) => (e.textContent = encodeEntities(text))); 25 | }; 26 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/ui/iframe-field/action-set-placeholder.ts: -------------------------------------------------------------------------------- 1 | import encodeEntities from "../../internal/lib/encode-entities"; 2 | import paymentFieldId from "../../internal/lib/payment-field-id"; 3 | import dotPlaceholders from "../../internal/lib/dot-placeholders"; 4 | 5 | /** 6 | * Sets the placeholder text of a hosted field 7 | * 8 | * @param placeholder The desired palceholder text 9 | */ 10 | export default (placeholder: string) => { 11 | const el = document.getElementById(paymentFieldId); 12 | if (!el) { 13 | return; 14 | } 15 | 16 | // Determine if the placeholder text should be encoded 17 | if (dotPlaceholders.indexOf(placeholder) !== -1) { 18 | // Allow various dot placeholders 19 | el.setAttribute("placeholder", placeholder); 20 | } else { 21 | // Encode the placeholder text 22 | el.setAttribute("placeholder", encodeEntities(placeholder)); 23 | } 24 | }; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/ui/iframe-field/action-set-text.ts: -------------------------------------------------------------------------------- 1 | import encodeEntities from "../../internal/lib/encode-entities"; 2 | import paymentFieldId from "../../internal/lib/payment-field-id"; 3 | 4 | /** 5 | * Sets the text content of a hosted field 6 | * 7 | * @param text The desired text value 8 | */ 9 | export default (text: string) => { 10 | const el = document.getElementById(paymentFieldId); 11 | if (!el) { 12 | return; 13 | } 14 | 15 | el.textContent = encodeEntities(text); 16 | }; 17 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/ui/iframe-field/action-set-type-cvv.ts: -------------------------------------------------------------------------------- 1 | import dotPlaceholders from "../../internal/lib/dot-placeholders"; 2 | import paymentFieldId from "../../internal/lib/payment-field-id"; 3 | 4 | /** 5 | * Change values of maxlength and placeholder attributes of the cvv input 6 | * depending on card type 7 | * 8 | * @param maxlength The maximum number of characters desired 9 | * @param placeholder Placeholder for show 10 | * @param id cvv input id 11 | */ 12 | export default (maxlength: string) => { 13 | const el = document.getElementById(paymentFieldId); 14 | if (!el) { 15 | return; 16 | } 17 | 18 | const currentPlaceholder = el.getAttribute("placeholder"); 19 | 20 | // Just change the placeholder when it belongs to our own code 21 | if (currentPlaceholder && dotPlaceholders.indexOf(currentPlaceholder) > -1) { 22 | const charPlaceholder = currentPlaceholder[0]; 23 | let placeholder = ""; 24 | for (let index = 0; index < Number(maxlength); index++) { 25 | placeholder = placeholder + charPlaceholder; 26 | } 27 | el.setAttribute("placeholder", placeholder); 28 | } 29 | 30 | el.setAttribute("maxlength", maxlength); 31 | }; -------------------------------------------------------------------------------- /packages/globalpayments-js/src/ui/iframe-field/action-set-value.ts: -------------------------------------------------------------------------------- 1 | import encodeEntities from "../../internal/lib/encode-entities"; 2 | import Events from "../../internal/lib/events"; 3 | import paymentFieldId from "../../internal/lib/payment-field-id"; 4 | 5 | /** 6 | * Sets the value of a hosted field 7 | * 8 | * @param text The desired input value 9 | */ 10 | export default (text: string) => { 11 | const el = document.getElementById(paymentFieldId); 12 | if (!el) { 13 | return; 14 | } 15 | 16 | el.setAttribute("value", encodeEntities(text)); 17 | 18 | // trigger events on the target element 19 | Events.trigger("keyup", el); 20 | Events.trigger("input", el); 21 | }; 22 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/ui/iframe-field/currency-conversion/action-get-value.ts: -------------------------------------------------------------------------------- 1 | import { postMessage } from "../../../internal"; 2 | import { IDictionary } from "../../../internal/lib/util"; 3 | import {CurrencyConversionEvents} from "../../../internal/lib/currency-conversion/contracts/enums"; 4 | 5 | /** 6 | * Initiates a currency conversion request and posts the response data to the parent window. 7 | * @param id The ID of the message. 8 | * @param data An object containing the data required for the currency conversion request. 9 | */ 10 | export default (id: string, data: IDictionary): void => { 11 | // If ID is not provided, return early 12 | if (!id) return; 13 | 14 | // Destructure required data from the input 15 | const { value, selectedCurrency } = data.data; 16 | 17 | postMessage.post( 18 | { 19 | data: { value, selectedCurrency }, 20 | id, 21 | type: `ui:iframe-field:${CurrencyConversionEvents.CurrencyConversionSendValue}`, 22 | }, 23 | "parent", 24 | ); 25 | }; 26 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/ui/iframe-field/installments/action-request-accumulate-data.ts: -------------------------------------------------------------------------------- 1 | import { postMessage } from "../../../internal"; 2 | import { InstallmentEvents } from "../../../internal/lib/installments/contracts/enums"; 3 | import { IDictionary } from "../../../internal/lib/util"; 4 | import CardNumberValidator from "../../../internal/validators/card-number"; 5 | import CardExpirationValidator from "../../../internal/validators/expiration"; 6 | 7 | export default (id: string, _type: string, data: IDictionary) => { 8 | const w = window as any; 9 | 10 | w.installmentData = w.installmentData || {}; 11 | w.installmentData[data.data.type] = data.data.value; 12 | 13 | const installmentData = { 14 | cardNumber: w.installmentData['card-number'], 15 | cardExpiration: w.installmentData['card-expiration'], 16 | cardCvv: w.installmentData['card-cvv'], 17 | }; 18 | const { cardNumber, cardExpiration, cardCvv } = installmentData; 19 | 20 | if (!cardNumber 21 | || !new CardNumberValidator().validate(cardNumber) 22 | || !cardExpiration 23 | || !new CardExpirationValidator().validate(cardExpiration) 24 | || !cardCvv 25 | || cardCvv && cardCvv.length < 3 26 | ) { 27 | return; 28 | }; 29 | 30 | const eventType = `ui:iframe-field:${InstallmentEvents.CardInstallmentsRequestStart}`; 31 | postMessage.post( 32 | { 33 | data: installmentData, 34 | id, 35 | type: eventType, 36 | }, 37 | "parent", 38 | ); 39 | }; 40 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/ui/iframe-field/installments/action-request-data.ts: -------------------------------------------------------------------------------- 1 | import { postMessage as pm } from "../../../internal"; 2 | import { InstallmentEvents } from "../../../internal/lib/installments/contracts/enums"; 3 | import paymentFieldId from "../../../internal/lib/payment-field-id"; 4 | import { IDictionary } from "../../../internal/lib/util"; 5 | 6 | export default (id: string, type: string, data: IDictionary) => { 7 | const field = document.getElementById(paymentFieldId) as HTMLInputElement; 8 | const value = field && field.value ? field.value : ""; 9 | 10 | pm.post( 11 | { 12 | data: { 13 | target: data.data.target, 14 | type, 15 | value, 16 | }, 17 | id, 18 | type: `ui:iframe-field:${InstallmentEvents.CardInstallmentsPassData}`, 19 | }, 20 | "parent", 21 | ); 22 | }; 23 | -------------------------------------------------------------------------------- /packages/globalpayments-js/src/ui/iframe-field/qr-code-payment-methods/action-request-start.ts: -------------------------------------------------------------------------------- 1 | import { IDictionary } from "@globalpayments/js/types/internal/lib/util"; 2 | import { ApmInternalEvents } from "../../../apm/enums"; 3 | import { postMessage } from "../../../internal"; 4 | import getQrCodePaymentMethods from "../../../apm/qr-code-payments/requests/get-qr-code-payment-methods"; 5 | 6 | /** 7 | * Requests the QR Code Payment methods 8 | */ 9 | export default (id: string, data: IDictionary): void => { 10 | if (!id) return; 11 | 12 | getQrCodePaymentMethods({ 13 | }).then((response: any) => { 14 | const paymentMethodConfigurations: any[] = response[`payment_method_configurations`]; 15 | 16 | // Complete the request event 17 | postMessage.post( 18 | { 19 | data: { 20 | paymentMethodConfigurations, 21 | ...data, 22 | }, 23 | id, 24 | type: `ui:iframe-field:${ApmInternalEvents.PaymentMethodsRequestCompleted}`, 25 | }, 26 | "parent", 27 | ); 28 | }).catch(error => { 29 | // tslint:disable-next-line:no-console 30 | console.log('Request Error: Payment Methods Request Failed.', error); 31 | }); 32 | } -------------------------------------------------------------------------------- /packages/globalpayments-js/src/ui/index.ts: -------------------------------------------------------------------------------- 1 | import UIForm from "./form"; 2 | 3 | export * from "./iframe-field"; 4 | 5 | /** 6 | * Allows integrators to custom payment data entry forms for credit 7 | * card, eCheck / ACH, or gift and loyalty cards. 8 | * 9 | * @param options Form options. 10 | * @returns 11 | */ 12 | export function form(options: any) { 13 | return new UIForm(options.fields, options.styles || {}); 14 | } 15 | -------------------------------------------------------------------------------- /packages/globalpayments-js/test/fixtures/heartland/ach-dropin/runner.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Heartland Examples 6 | 7 | 8 | 9 | 10 |
11 | 12 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /packages/globalpayments-js/test/fixtures/heartland/card-dropin/runner.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Heartland Examples 6 | 7 | 8 | 9 | 10 |
11 | 12 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /packages/globalpayments-js/test/fixtures/heartland/card-track/runner.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Heartland Examples 6 | 7 | 8 | 9 | 10 |
11 |
12 |
13 | 14 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /packages/globalpayments-js/test/fixtures/heartland/gift-dropin/runner.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Heartland Examples 6 | 7 | 8 | 9 | 10 |
11 | 12 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /packages/globalpayments-js/test/fixtures/heartland/gift/runner.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Heartland Examples 6 | 7 | 8 | 9 | 10 |
11 |
12 |
13 | 14 |
15 |
16 |
17 | 18 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /packages/globalpayments-js/test/fixtures/heartland/sandbox-alert-non-prod/runner.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Heartland Examples 6 | 7 | 8 | 9 | 10 |
11 | 12 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /packages/globalpayments-js/test/fixtures/heartland/sandbox-alert-prod/runner.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Heartland Examples 6 | 7 | 8 | 9 | 10 |
11 | 12 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /packages/globalpayments-js/test/integration/billpay/tokenization_spec.js: -------------------------------------------------------------------------------- 1 | import { 2 | assertTokenError, 3 | assertCardTokenSuccess, 4 | assertAchTokenSuccess, 5 | click, 6 | enter, 7 | visit, 8 | } from "../../support/helpers"; 9 | 10 | describe("billpay - tokenization", () => { 11 | describe("card", () => { 12 | beforeEach(() => { 13 | visit("billpay/card"); 14 | }); 15 | 16 | it("tokenizes card without error", () => { 17 | cy.get("#cardNumber > iframe").then(enter("4111111111111111")); 18 | cy.get("#cardExpiration > iframe").then(enter("12 / 2025")); 19 | cy.get("#cardCvv > iframe").then(enter("123")); 20 | cy.get("#cardSubmit > iframe").then(click()); 21 | 22 | cy.get("#testResult").then(assertCardTokenSuccess); 23 | }); 24 | 25 | it("fails to tokenize with bad data - card number", () => { 26 | cy.get("#cardNumber > iframe").then(enter("a")); 27 | cy.get("#cardSubmit > iframe").then(click()); 28 | 29 | cy.get("#testResult").then(assertTokenError); 30 | }); 31 | }); 32 | 33 | describe("ach", () => { 34 | beforeEach(() => { 35 | visit("billpay/ach"); 36 | }); 37 | 38 | it("tokenizes account without error", () => { 39 | cy.get("#accountNumber > iframe").then(enter("1357902468")); 40 | cy.get("#routingNumber > iframe").then(enter("122000030")); 41 | cy.get("#achSubmit > iframe").then(click()); 42 | 43 | cy.get("#testResult").then(assertAchTokenSuccess); 44 | }); 45 | }); 46 | }); 47 | -------------------------------------------------------------------------------- /packages/globalpayments-js/test/integration/experience/accessibility_spec.js: -------------------------------------------------------------------------------- 1 | import { visit } from "../../support/helpers"; 2 | 3 | function terminalLog(violations) { 4 | cy.task( 5 | 'log', 6 | `${violations.length} accessibility violation${ 7 | violations.length === 1 ? '' : 's' 8 | } ${violations.length === 1 ? 'was' : 'were'} detected` 9 | ) 10 | // pluck specific keys to keep the table readable 11 | const violationData = violations.map( 12 | ({ id, impact, description, nodes }) => ({ 13 | id, 14 | impact, 15 | description, 16 | nodes: nodes.length 17 | }) 18 | ) 19 | 20 | cy.task('table', violationData) 21 | } 22 | 23 | describe("experience - attributes", () => { 24 | beforeEach(() => { 25 | visit("accessibility"); 26 | cy.injectAxe(); 27 | }); 28 | 29 | it('Has no detectable a11y violations on load', () => { 30 | cy.checkA11y(null, null, terminalLog); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /packages/globalpayments-js/test/integration/experience/attributes_spec.js: -------------------------------------------------------------------------------- 1 | import { 2 | shouldHaveAttribute, 3 | shouldHaveText, 4 | visit, 5 | } from "../../support/helpers"; 6 | 7 | describe("experience - attributes", () => { 8 | beforeEach(() => { 9 | visit("heartland/card-attributes"); 10 | }); 11 | 12 | it("sets placeholders", () => { 13 | cy 14 | .get("#cardNumber > iframe") 15 | .then(shouldHaveAttribute("placeholder", "•••• •••• •••• ••••")); 16 | cy 17 | .get("#cardExpiration > iframe") 18 | .then(shouldHaveAttribute("placeholder", "MM / YYYY")); 19 | cy.get("#cardCvv > iframe").then(shouldHaveAttribute("placeholder", "•••")); 20 | }); 21 | 22 | it("sets initial values", () => { 23 | cy 24 | .get("#cardNumber > iframe") 25 | .then(shouldHaveAttribute("value", "4111 1111 1111 1111")); 26 | cy 27 | .get("#cardExpiration > iframe") 28 | .then(shouldHaveAttribute("value", "12 / 2025")); 29 | cy.get("#cardCvv > iframe").then(shouldHaveAttribute("value", "123")); 30 | }); 31 | 32 | it("sets initial text", () => { 33 | cy.get("#cardSubmit > iframe").then(shouldHaveText("Place Order")); 34 | }); 35 | 36 | it("sets initial input types", () => { 37 | cy.get("#cardHolder > iframe").then(shouldHaveAttribute("type", "text")); 38 | cy.get("#cardNumber > iframe").then(shouldHaveAttribute("type", "tel")); 39 | cy.get("#cardExpiration > iframe").then(shouldHaveAttribute("type", "tel")); 40 | cy.get("#cardCvv > iframe").then(shouldHaveAttribute("type", "tel")); 41 | cy.get("#cardSubmit > iframe").then(shouldHaveAttribute("type", "button")); 42 | }); 43 | }); 44 | -------------------------------------------------------------------------------- /packages/globalpayments-js/test/integration/experience/disposal_spec.js: -------------------------------------------------------------------------------- 1 | import { 2 | visit, 3 | } from "../../support/helpers"; 4 | 5 | describe("experience - disposal", () => { 6 | beforeEach(() => { 7 | visit("heartland/card-disposal"); 8 | }); 9 | 10 | it("should have no form elements after calling dispose", () => { 11 | cy.wait(500); 12 | cy 13 | .get("#cardNumber") 14 | .children() 15 | .should("have.length", 0); 16 | cy 17 | .get("#cardExpiration") 18 | .children() 19 | .should("have.length", 0); 20 | cy 21 | .get("#cardCvv") 22 | .children() 23 | .should("have.length", 0); 24 | cy 25 | .get("#cardSubmit") 26 | .children() 27 | .should("have.length", 0); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /packages/globalpayments-js/test/integration/experience/sandbox-alert_spec.js: -------------------------------------------------------------------------------- 1 | import { visit } from "../../support/helpers"; 2 | 3 | describe("experience - sandbox alert", () => { 4 | describe("production", () => { 5 | beforeEach(() => { 6 | visit("heartland/sandbox-alert-prod"); 7 | }); 8 | 9 | it("doesn't show alert", () => { 10 | cy.get("#form > .sandbox-warning").should("not.exist"); 11 | }); 12 | }); 13 | 14 | describe("non-production", () => { 15 | beforeEach(() => { 16 | visit("heartland/sandbox-alert-non-prod"); 17 | }); 18 | 19 | it("shows alert", () => { 20 | cy.get("#form > .sandbox-warning").should("exist"); 21 | }); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /packages/globalpayments-js/test/integration/experience/styles_spec.js: -------------------------------------------------------------------------------- 1 | import { 2 | shouldHaveStyle, 3 | shouldNotHaveStyle, 4 | visit, 5 | } from "../../support/helpers"; 6 | 7 | describe("experience - styles", () => { 8 | beforeEach(() => { 9 | visit("heartland/card-styled"); 10 | }); 11 | 12 | it("applies styles to a single form", () => { 13 | cy 14 | .get("#cardNumber > iframe") 15 | .then(shouldHaveStyle("background-color", "rgb(255, 0, 0)")); 16 | cy 17 | .get("#cardExpiration > iframe") 18 | .then(shouldHaveStyle("background-color", "rgb(255, 0, 0)")); 19 | cy 20 | .get("#cardCvv > iframe") 21 | .then(shouldHaveStyle("background-color", "rgb(255, 0, 0)")); 22 | cy 23 | .get("#cardSubmit > iframe") 24 | .then(shouldHaveStyle("background-color", "rgb(255, 0, 0)")); 25 | 26 | cy 27 | .get("#cardNumber > iframe") 28 | .then(shouldHaveStyle("border-top-color", "rgb(255, 0, 0)")); 29 | cy 30 | .get("#cardExpiration > iframe") 31 | .then(shouldNotHaveStyle("border-top-color", "rgb(255, 0, 0)")); // default 32 | cy 33 | .get("#cardCvv > iframe") 34 | .then(shouldNotHaveStyle("border-top-color", "rgb(255, 0, 0)")); // default 35 | cy 36 | .get("#cardSubmit > iframe") 37 | .then(shouldNotHaveStyle("border-top-color", "rgb(255, 0, 0)")); // default 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /packages/globalpayments-js/test/integration/genius/tokenization_spec.js: -------------------------------------------------------------------------------- 1 | import { 2 | assertTokenError, 3 | assertCardTokenSuccess, 4 | click, 5 | enter, 6 | visit, 7 | } from "../../support/helpers"; 8 | 9 | describe("genius - tokenization", () => { 10 | describe("card", () => { 11 | beforeEach(() => { 12 | visit("genius/card"); 13 | }); 14 | 15 | it("tokenizes card without error", () => { 16 | cy.get("#cardNumber > iframe").then(enter("4111111111111111")); 17 | cy.get("#cardExpiration > iframe").then(enter("12 / 2025")); 18 | cy.get("#cardCvv > iframe").then(enter("123")); 19 | cy.get("#cardSubmit > iframe").then(click()); 20 | 21 | cy.get("#testResult").then(assertCardTokenSuccess); 22 | }); 23 | 24 | it("fails to tokenize with bad data", () => { 25 | cy.get("#cardNumber > iframe").then(enter("a")); 26 | cy.get("#cardSubmit > iframe").then(click()); 27 | 28 | cy.get("#testResult").then(assertTokenError); 29 | }); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /packages/globalpayments-js/test/integration/transit/tokenization_spec.js: -------------------------------------------------------------------------------- 1 | import { 2 | assertTokenError, 3 | assertCardTokenSuccess, 4 | click, 5 | enter, 6 | visit, 7 | } from "../../support/helpers"; 8 | 9 | describe("transit - tokenization", () => { 10 | describe("card", () => { 11 | beforeEach(() => { 12 | visit("transit/card"); 13 | }); 14 | 15 | it("tokenizes card without error", () => { 16 | cy.get("#cardNumber > iframe").then(enter("4111111111111111")); 17 | cy.get("#cardExpiration > iframe").then(enter("12 / 2025")); 18 | cy.get("#cardCvv > iframe").then(enter("123")); 19 | cy.get("#cardSubmit > iframe").then(click()); 20 | 21 | cy.get("#testResult").then(assertCardTokenSuccess); 22 | }); 23 | 24 | it("fails to tokenize with bad data", () => { 25 | cy.get("#cardNumber > iframe").then(enter("a")); 26 | cy.get("#cardSubmit > iframe").then(click()); 27 | 28 | cy.get("#testResult").then(assertTokenError); 29 | }); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /packages/globalpayments-js/test/plugins/index.js: -------------------------------------------------------------------------------- 1 | // *********************************************************** 2 | // This example plugins/index.js can be used to load plugins 3 | // 4 | // You can change the location of this file or turn off loading 5 | // the plugins file with the 'pluginsFile' configuration option. 6 | // 7 | // You can read more here: 8 | // https://on.cypress.io/plugins-guide 9 | // *********************************************************** 10 | 11 | // This function is called when a project is opened or re-opened (e.g. due to 12 | // the project's config changing) 13 | 14 | module.exports = (on, _config) => { 15 | // `on` is used to hook into various events Cypress emits 16 | // `config` is the resolved Cypress config 17 | on("before:browser:launch", (browser = {}, args) => { 18 | if (browser.name === "chrome") { 19 | // allow parent window to interact with iframes 20 | args.push("--disable-site-isolation-trials"); 21 | return args; 22 | } 23 | }); 24 | 25 | on("task", { 26 | log(message) { 27 | console.log(message); 28 | 29 | return null; 30 | }, 31 | table(message) { 32 | if (console.table) { 33 | console.table(message); 34 | } 35 | 36 | return null; 37 | } 38 | }); 39 | }; 40 | -------------------------------------------------------------------------------- /packages/globalpayments-js/test/run.ps1: -------------------------------------------------------------------------------- 1 | function Npm { 2 | if (Get-Command "yarn" -ErrorAction SilentlyContinue) { 3 | return "yarn" 4 | } else { 5 | return "npm" 6 | } 7 | } 8 | 9 | $Process = Start-Process -FilePath Npm -ArgumentList "run start" -PassThru 10 | $ServerPid = $Process.Id 11 | 12 | Start-Process -FilePath Npm -ArgumentList "run test" -PassThru -Wait 13 | 14 | Stop-Process -Id $ServerPid -ErrorAction stop 15 | -------------------------------------------------------------------------------- /packages/globalpayments-js/test/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | npm_run() { 4 | if command -v yarn >/dev/null 2>&1; then 5 | yarn "$@" 6 | else 7 | npm "$@" 8 | fi 9 | } 10 | 11 | npm_run start & 12 | SERVER_PID=$! 13 | 14 | npm_run test 15 | 16 | killall node 17 | -------------------------------------------------------------------------------- /packages/globalpayments-js/test/support/index.js: -------------------------------------------------------------------------------- 1 | // *********************************************************** 2 | // This example support/index.js is processed and 3 | // loaded automatically before your test files. 4 | // 5 | // This is a great place to put global configuration and 6 | // behavior that modifies Cypress. 7 | // 8 | // You can change the location of this file or turn off 9 | // automatically serving support files with the 10 | // 'supportFile' configuration option. 11 | // 12 | // You can read more here: 13 | // https://on.cypress.io/configuration 14 | // *********************************************************** 15 | 16 | // Import commands.js using ES2015 syntax: 17 | // import './commands'; 18 | 19 | // Alternatively you can use CommonJS syntax: 20 | // require('./commands') 21 | 22 | // import 'cypress-axe'; 23 | 24 | Cypress.Screenshot.defaults({ 25 | screenshotOnRunFailure: false, 26 | }); 27 | -------------------------------------------------------------------------------- /packages/globalpayments-js/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "declaration": true, 4 | "declarationDir": "types", 5 | "importHelpers": true, 6 | "lib": ["dom", "esnext"], 7 | "removeComments": false, 8 | "sourceMap": true, 9 | "strict": true, 10 | "target": "es3" 11 | }, 12 | "include": [ 13 | "src/**/*", 14 | "test/**/*" 15 | ], 16 | "exclude": [ 17 | "node_modules", 18 | "lib" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /packages/globalpayments-js/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rules": { 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /packages/globalpayments-js/types/global-type.d.ts: -------------------------------------------------------------------------------- 1 | import def from "./index"; 2 | 3 | declare global { 4 | interface Window { 5 | GlobalPayments: typeof def; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/globalpayments-lib/.gitignore: -------------------------------------------------------------------------------- 1 | lib/ 2 | node_modules/ 3 | -------------------------------------------------------------------------------- /packages/globalpayments-lib/.npmignore: -------------------------------------------------------------------------------- 1 | !lib/ 2 | node_modules/ 3 | src/ 4 | !polyfills.js 5 | .prettierrc 6 | tsconfig.json 7 | tslint.json 8 | -------------------------------------------------------------------------------- /packages/globalpayments-lib/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "always", 3 | "trailingComma": "all" 4 | } 5 | -------------------------------------------------------------------------------- /packages/globalpayments-lib/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "globalpayments-lib", 3 | "version": "1.8.5", 4 | "description": "Helper library for Global Payments JavaScript libraries", 5 | "main": "lib/index.js", 6 | "module": "lib/index.js", 7 | "types": "lib/index.d.ts", 8 | "typings": "lib/index.d.ts", 9 | "author": "Heartland Developer Portal ", 10 | "license": "GPL-2.0", 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/globalpayments/globalpayments-js.git" 14 | }, 15 | "scripts": { 16 | "build": "tsc", 17 | "clean": "rimraf lib", 18 | "format": "prettier --write src/**/* !src/assets/**/* !test/run.sh !test/run.ps1 !test/fixtures/**/*.html", 19 | "prebuild": "rimraf lib && yarn test:lint", 20 | "prepare": "yarn build", 21 | "test:lint": "tslint --project tsconfig.json" 22 | }, 23 | "dependencies": { 24 | "base64-js": "^1.3.0", 25 | "promise-polyfill": "^8.1.0", 26 | "unfetch": "^4.1.0" 27 | }, 28 | "devDependencies": { 29 | "rimraf": "*", 30 | "typescript": "*" 31 | }, 32 | "gitHead": "09776fcfe6140ce5b1ea8fc55fb4867b15565f1d" 33 | } 34 | -------------------------------------------------------------------------------- /packages/globalpayments-lib/polyfills.js: -------------------------------------------------------------------------------- 1 | require('./lib/polyfills'); 2 | -------------------------------------------------------------------------------- /packages/globalpayments-lib/src/generate-guid.ts: -------------------------------------------------------------------------------- 1 | export function generateGuid() { 2 | const S4 = () => { 3 | // tslint:disable-next-line:no-bitwise 4 | return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1); 5 | }; 6 | return `${S4()}${S4()}-${S4()}-${S4()}-${S4()}-${S4()}${S4()}${S4()}`; 7 | } 8 | -------------------------------------------------------------------------------- /packages/globalpayments-lib/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./event-emitter"; 2 | export * from "./generate-guid"; 3 | -------------------------------------------------------------------------------- /packages/globalpayments-lib/src/polyfills/array-foreach.ts: -------------------------------------------------------------------------------- 1 | if (!Array.prototype.forEach) { 2 | Array.prototype.forEach = function ( 3 | fn: (value: any, index: number, arr: any[]) => void, 4 | ) { 5 | for (let i = 0; i < this.length; i++) { 6 | fn(this[i], i, this); 7 | } 8 | }; 9 | } 10 | -------------------------------------------------------------------------------- /packages/globalpayments-lib/src/polyfills/base64.ts: -------------------------------------------------------------------------------- 1 | import { fromByteArray, toByteArray } from "base64-js"; 2 | 3 | export function base64encode(text: string): string { 4 | let i: number; 5 | const len = text.length; 6 | const Arr: any = typeof Uint8Array !== "undefined" ? Uint8Array : Array; 7 | const u8array = new Arr(len); 8 | 9 | for (i = 0; i < len; i++) { 10 | u8array[i] = text.charCodeAt(i); 11 | } 12 | 13 | return fromByteArray(u8array); 14 | } 15 | 16 | export function base64decode(text: string): string { 17 | const u8Array = toByteArray(text); 18 | let i: number; 19 | const len = u8Array.length; 20 | let bStr = ""; 21 | 22 | for (i = 0; i < len; i++) { 23 | bStr += String.fromCharCode(u8Array[i]); 24 | } 25 | 26 | return bStr; 27 | } 28 | 29 | window.btoa = window.btoa || base64encode; 30 | window.atob = window.atob || base64decode; 31 | -------------------------------------------------------------------------------- /packages/globalpayments-lib/src/polyfills/index.ts: -------------------------------------------------------------------------------- 1 | import "unfetch/polyfill"; 2 | 3 | import "./array-foreach"; 4 | import "./base64"; 5 | import "./json"; 6 | import "./object-freeze"; 7 | import "./object-getownpropertynames"; 8 | import "./parentnode-prepend"; 9 | import "./promise"; 10 | import "./string-repeat"; 11 | -------------------------------------------------------------------------------- /packages/globalpayments-lib/src/polyfills/json.ts: -------------------------------------------------------------------------------- 1 | import { JSON } from "./json2"; 2 | 3 | (window as any).JSON = (window as any).JSON || JSON; 4 | -------------------------------------------------------------------------------- /packages/globalpayments-lib/src/polyfills/object-freeze.ts: -------------------------------------------------------------------------------- 1 | // ES5 15.2.3.9 2 | // http://es5.github.com/#x15.2.3.9 3 | if (!Object.freeze) { 4 | Object.freeze = (object: any) => { 5 | if (Object(object) !== object) { 6 | throw new TypeError("Object.freeze can only be called on Objects."); 7 | } 8 | // this is misleading and breaks feature-detection, but 9 | // allows "securable" code to "gracefully" degrade to working 10 | // but insecure code. 11 | return object; 12 | }; 13 | } 14 | 15 | // detect a Rhino bug and patch it 16 | try { 17 | Object.freeze(() => undefined); 18 | } catch (exception) { 19 | Object.freeze = ((freezeObject) => { 20 | return (object: any) => { 21 | if (typeof object === "function") { 22 | return object; 23 | } else { 24 | return freezeObject(object); 25 | } 26 | }; 27 | })(Object.freeze); 28 | } 29 | -------------------------------------------------------------------------------- /packages/globalpayments-lib/src/polyfills/object-getownpropertynames.ts: -------------------------------------------------------------------------------- 1 | if (!Object.prototype.hasOwnProperty) { 2 | Object.prototype.hasOwnProperty = function (prop: string) { 3 | return typeof (this as any)[prop] !== "undefined"; 4 | }; 5 | } 6 | 7 | if (!Object.getOwnPropertyNames) { 8 | Object.getOwnPropertyNames = (obj) => { 9 | const keys = []; 10 | for (const key in obj) { 11 | if ( 12 | typeof obj.hasOwnProperty !== "undefined" && 13 | obj.hasOwnProperty(key) 14 | ) { 15 | keys.push(key); 16 | } 17 | } 18 | return keys; 19 | }; 20 | } 21 | -------------------------------------------------------------------------------- /packages/globalpayments-lib/src/polyfills/parentnode-prepend.ts: -------------------------------------------------------------------------------- 1 | // Source: https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/prepend 2 | ((arr) => { 3 | arr.forEach((item) => { 4 | if (item.hasOwnProperty("prepend")) { 5 | return; 6 | } 7 | 8 | Object.defineProperty(item, "prepend", { 9 | configurable: true, 10 | enumerable: true, 11 | writable: true, 12 | value: function prepend() { 13 | const argArr = Array.prototype.slice.call(arguments); 14 | const docFrag = document.createDocumentFragment(); 15 | 16 | argArr.forEach((argItem) => { 17 | const isNode = argItem instanceof Node; 18 | docFrag.appendChild( 19 | isNode ? argItem : document.createTextNode(String(argItem)), 20 | ); 21 | }); 22 | 23 | this.insertBefore(docFrag, this.firstChild); 24 | }, 25 | }); 26 | }); 27 | })([Element.prototype, Document.prototype, DocumentFragment.prototype]); 28 | -------------------------------------------------------------------------------- /packages/globalpayments-lib/src/polyfills/promise.ts: -------------------------------------------------------------------------------- 1 | import * as Promise from "promise-polyfill"; 2 | 3 | (window as any).Promise = 4 | (window as any).Promise || (Promise as any).default || Promise; 5 | -------------------------------------------------------------------------------- /packages/globalpayments-lib/src/polyfills/string-repeat.ts: -------------------------------------------------------------------------------- 1 | if (!String.prototype.repeat) { 2 | String.prototype.repeat = function (length: number) { 3 | let result = ""; 4 | 5 | for (let i = 0; i < length; i++) { 6 | result += this; 7 | } 8 | 9 | return result; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /packages/globalpayments-lib/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "declaration": true, 4 | "lib": ["dom", "esnext"], 5 | "outDir": "lib", 6 | "removeComments": false, 7 | "sourceMap": true, 8 | "strict": true, 9 | "target": "es5" 10 | }, 11 | "include": [ 12 | "src/**/*" 13 | ], 14 | "exclude": [ 15 | "node_modules", 16 | "lib" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /packages/globalpayments-lib/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rules": { 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "./packages", 4 | "paths": { 5 | "@globalpayments/js": ["globalpayments-js"], 6 | "@globalpayments/js-loader": ["globalpayments-js-loader"], 7 | "@globalpayments/js-web-components": ["globalpayments-js-web-components"], 8 | "globalpayments-3ds": ["globalpayments-3ds"], 9 | "globalpayments-lib": ["globalpayments-lib"], 10 | } 11 | } 12 | } --------------------------------------------------------------------------------