npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mangopay-cardregistration-js-kit

v1.2.2

Published

MANGOPAY Card Registration JavaScript Kit is a client library designed to take care of the card registration process.

Downloads

20,175

Readme

MANGOPAY Card Registration JavaScript Kit Build Status

MANGOPAY CardRegistration JavaScript Kit is a client library designed to take care of the card registration process. Refer to MANGOPAY REST API documentation and MANGOPAY card registration process for more information.

Browser compatibility

The library makes cross-origin Ajax calls (CORS) to get the card token and handle card registration with MANGOPAY API. Therefore it requires a browser that supports CORS. The kit does not support Internet Explorer 6 & 7 and Opera Mini.

The payment page that collects card details should use HTTPS. The kit will not work in Internet Explorer 8 and 9 if this page is not encrypted with SSL.

Installation

The kit has been written in pure JavaScript and has no external dependencies. It is enough to include the kit file on your card payment page:

<script type="text/javascript" src="mangopay-kit.js"></script>

Typically you would also have MANGOPAY SDK up and running to work with the MANGOPAY API. Java, PHP, .NET, Python and Ruby distributions are available.

The kit is also available for installation from npm if you prefer.

Configuration

Set mangoPay.cardRegistration.clientId to your MANGOPAY Client ID. mangoPay.cardRegistration.baseURL is set to sandbox environment by default. To enable production environment, set it to https://api.mangopay.com.

Usage

Make sure you have the right configuration in place:

// Set MANGOPAY API base URL and Client ID
mangoPay.cardRegistration.baseURL = "https://api.sandbox.mangopay.com";
mangoPay.cardRegistration.clientId = {your-client-id};

Create a new CardRegistration object on the server and pass it over to the JavaScript kit:

// Initialize with card register data prepared on the server
mangoPay.cardRegistration.init({
    cardRegistrationURL: {CardRegistrationURL property}, 
    preregistrationData: {PreregistrationData property}, 
    accessKey: {AccessKey property},
    Id: {Id property}
});

Collect card details from the user on a payment form:

// Card data collected from the user
var cardData = {
     cardNumber: $("#card_number").val(), 
     cardExpirationDate: $("#card_exp_date").val(), 
     cardCvx: $("#card_cvx").val(),
     cardType: $("#card_type").val()
};

Then call mangoPay.cardRegistration.registerCard:

// Register card
mangoPay.cardRegistration.registerCard(
    cardData, 
    function(res) {
        // Success, you can use res.CardId now that points to registered card
    },
    function(res) {
        // Handle error, see res.ResultCode and res.ResultMessage
    }
);

Running the demo

There is a simple PHP demo code included that shows how to use the kit. The demo page requires MANGOPAY SDK class to do the server-side work. Make sure that MANGOPAY PHP SDK is accessible to the demo page.

Unit Tests

Jasmine unit tests are placed under tests dir and can be launched in a browser using tests/index.html. Unit test covers only validation classes and requests with invalid data.

License

MANGOPAY JavaScript Kit is distributed under MIT license.

Contacts

Report bugs or suggest features using issue tracker at GitHub.