globalpayments / rxp-js

Global Payments Ecommerce JavaScript Library
MIT License
34 stars 70 forks source link

Realex JS Library

You can sign up for a Realex account at https://developer.realexpayments.com

Hosted Payment Page (HPP) JS Library

Usage

The Javascript required to initialise the library is below. This code must only be executed when the DOM is fully loaded. (default method: lightbox)

RealexHpp.init(payButtonId, merchantUrl, jsonFromServerSdk[, options]);

Enable the logger

The following code enables a logger that will emit an event on each step performed by the library. Should be used for debugging only.

RealexHpp.setConfigItem('enableLogging', true);
window.addEventListener(RealexHpp.constants.logEventName, function(e) {
    console.log(e.detail);
});

Consuming the resulting POST

Once the payment has completed the Realex JSON response will be posted within to the supplied merchantUrl. The name of the field containing the JSON response is hppResponse.

If you prefer to handle response manually, provide your own callback function in "merchantUrl". The answer will be pre-parsed to an object ready to be used.

Examples

Remote JS Library

Validation functions

Usage

RealexRemote.validateCardNumber(cardNumber);
RealexRemote.validateCardHolderName(cardHolderName);
RealexRemote.validateCvn(cvn);
RealexRemote.validateAmexCvn(amexCvn);
RealexRemote.validateExpiryDateFormat(expiryDate);
RealexRemote.validateExpiryDateNotInPast(expiryDate);

License

See the LICENSE file.