-
Notifications
You must be signed in to change notification settings - Fork 23
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
Comments
Please review #18. |
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; |
@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. I recall when it was Realexpayments there were three parameters to the library:
1 and 3 were handled by php-sdk. |
@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. |
@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. |
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. |
Hi. I was trying to import your library and implement the demo example.
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?
The text was updated successfully, but these errors were encountered: