GithubHelp home page GithubHelp logo

mntry / webtoken Goto Github PK

View Code? Open in Web Editor NEW
3.0 11.0 0.0 385 KB

Monetary's WebToken JS Client

Home Page: https://mntry.github.io/WebToken/

HTML 84.45% CSS 15.55%
credit-card security tokens ecommerce webtoken payment-form cvv expiration

webtoken's Introduction

Getting started with Monetary WebToken

Include the client on your page

Add the secure, hosted JavaScript client in the <head> of your page:
<script src="https://token.monetary.co/v1/client"></script>

Define the required form and controls

Give your payment form an ID:
<form id="payment_form">
Add the following 4 payment information input controls to your form:
<input type="text" data-token="card_number" />
<input type="text" data-token="exp_month" />
<input type="text" data-token="exp_year" />
<input type="text" data-token="cvv" />

Note: The payment info input controls must not have ID or Name attributes.

Define an input control to insert the token into:
<input type="hidden" id="token" />

Define required JavaScript

Define a JavaScript callback method for token events:
var tokenCallback = function(response) {
  if (response.Error)
  {
    alert("Token error: " + response.Error);
  }
  else
  {
    var token = response.Token;
    document.getElementById("token").value = token;
  }
}

Request a token!

Call requestToken with your public authenticator, payment form name, and token callback method:
MonetaryWebToken.requestToken("[Public Key Goes Here]", "payment_form", tokenCallback);
The response object received by your callback method looks like this:
On Success
{
  Token: "otuABCDEFGHIJ",
  Brand: "Visa",
  ExpirationMonth: "12",
  ExpirationYear: "2020",
  Last4: "1111"
}
On Failure
{
  Error: "Failed to create token"
}

Validation Helper Methods!

The Monetary WebToken client provides a few methods to help integrators validate their input fields, for card number, expiration date, and CVV that return bool values indicating input validity.

Validate Credit Card Number
var validCard = MonetaryWebToken.validateCardNumber("4242424242424242");
Validate Expiration Date
var validExpirationDate = MonetaryWebToken.validateExpirationDate("06", "2020");
Validate CVV
var validCVV = MonetaryWebToken.validateCVV("123");

Use your tokens!

Now that you've got fresh tokens in your payment form, you can submit the form and process token payments on Monetary's payment platform!

Report bugs

If you encounter any bugs or issues with the latest version of WebToken, please report them to us by opening a GitHub Issue!

webtoken's People

Contributors

rbonestell avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webtoken's Issues

Getting "Failed to create token" error

I am getting the error mentioned in subject even after using the correct public key that i received in email.

I tried running the standalone HTML, HTML hosted in IIS with and without SSL. what could be wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.