Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when importing from globalpayments-js module #17

Open
andrii-kryvoviaz opened this issue Oct 27, 2019 · 6 comments
Open

Error when importing from globalpayments-js module #17

andrii-kryvoviaz opened this issue Oct 27, 2019 · 6 comments

Comments

@andrii-kryvoviaz
Copy link
Contributor

Hi. I was trying to import your library and implement the demo example.

image

Here is what I got: ERROR in node_modules/globalpayments-js/types/global-type.d.ts(1,17): error TS2307: Cannot find module './'.. Is there any solution?

Btw, are you going to publish the package to NPM?

@andrii-kryvoviaz
Copy link
Contributor Author

Please review #18.

@slogsdon
Copy link
Contributor

Hi @AndyKrivovjas! Thanks for sending this over. We have been investigating our options for delivering the JS library via NPM, and the current thought is to deploy a loader to NPM that asynchronously loads the library and includes the library's TypeScript type declarations. This is to retain the PCI-DSS benefits from hosting the library on our servers.

If interested, you can achieve the loading side of this effort with the below code:

// @ts-check

/**
 * Latest version deployed on the gateway
 */
const DEFAULT_VERSION = "1.3.0";

/**
 * Global load flag to help prevent double loading
 */
let flag = false;

/**
 * Creates a new `script` element on the page to load the Global Payments JS library.
 * 
 * Default version is `1.0.1`. Default callback performs no action. 
 * 
 * Examples:
 * 
 *   - `load();`
 *   - `load("1.0.0");`
 *   - `load("1.0.0", () => console.log("loaded"));`
 *   - `load(() => console.log("loaded"));`
 *
 * @param {string | Function} [versionOrCallback] Supply a version number to override the default
 * @param {Function} [callback] Supply a callback in order to react to the library loading onto the page
 */
function load(versionOrCallback, callback) {
  // allow a callback to be passed in without a version
  if (versionOrCallback instanceof Function && callback === undefined) {
    callback = versionOrCallback;
    versionOrCallback = DEFAULT_VERSION;
  }

  // wrap the callback to ensure it's callable
  const cb = () => callback && callback();

  // return earlier if we've already loaded the script
  if (flag) {
    cb();
    return;
  }

  const script = document.createElement("script");
  script.src = "https://api2.heartlandportico.com/securesubmit.v1/token/gp-" + versionOrCallback + "/globalpayments.min.js";
  // try not to block rendering
  script.defer = true;
  script.onload = () => {
    flag = true;
    cb();
  };
  document.getElementsByTagName("head")[0].appendChild(script);
}

/**
 * Allow default version to be read by the integrator
 */
load.defaultVersion = DEFAULT_VERSION;

module.exports = load;

@andrii-kryvoviaz
Copy link
Contributor Author

@slogsdon It would be great if you publish such package to NPM.

One more thing. I was playing around with your library lately and I couldn't find how to connect the JS library with php-sdk.
https://developer.globalpay.com/#!/hpp/card-payments#hpp-authorization

I recall when it was Realexpayments there were three parameters to the library:

  1. HPP Request url;
  2. Gateway url;
  3. HPP Response url.

1 and 3 were handled by php-sdk.
Now it doesn't seem to work this way. Where can I find the relevant documentation in order to implement global payments solution both backend and frontend?

@slogsdon
Copy link
Contributor

@AndyKrivovjas This JS library doesn't yet support the full GP eCommerce / Realex HPP. It uses the HPP's Direct Post option under the hood to vault the card, so 1 and 3 are handled automatically for you.

If you're looking to leverage the full GP eCommerce HPP, you'll want to use the legacy rxp-js library on the frontend. You could then reference the documentation on how to configure the SDK to create the HPP request and parse the response.

@andrii-kryvoviaz
Copy link
Contributor Author

@slogsdon Are you planning adding support for it?

The legacy library isn't much extendable either. It requires an html element to work; I cannot run it directly from the code.

@slogsdon
Copy link
Contributor

slogsdon commented Nov 6, 2019

Yes, we'd like to add support for the GP eCommerce HPP within this library, although we don't currently have an ETA for this work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants