GithubHelp home page GithubHelp logo

isabella232 / frames-cordova Goto Github PK

View Code? Open in Web Editor NEW

This project forked from checkout/frames-cordova

0.0 0.0 0.0 27 KB

A Cordova plugin for Checkout.com Frames product

JavaScript 28.66% Java 36.55% Swift 34.79%

frames-cordova's Introduction

Cordova Checkout Plugin

A Cordova plugin for Checkout.com Frames SDK - Start accepting online card payments in just a few minutes. Supports Android & iOS.

Installation

cordova plugin add @checkout.com/cordova-plugin-checkout

Example Usage

First you need to initialize the plugin using your public key. This could be either a testing key (sandbox) or a production key

Sandbox:

cordova.plugins.Checkout.initSandboxClient("pk_test_MyTESTPublicKey", 
    function() {
        // Success, no need to do anything
    }, function (error) {
        // Error, message returned
    });

Production:

cordova.plugins.Checkout.initLiveClient("pk_MyLivePublicKey", 
    function() {
        // Success, no need to do anything
    }, function (error) {
        // Error, message returned
    });

Now you can start tokenizing credit/debit cards.

var ckoCardTokenRequest = {
    number: "4543474002249996",
    expiry_month: "6",
    expiry_year: "2025",
    name: "Bruce Wayne",
    cvv: "956",
    billing_address: {
        address_line1: "Checkout.com",
        address_line2: "90 Tottenham Court Road",
        city: "London",
        state: "London",
        zip: "W1T 4TJ",
        country: "GB"
    },
    phone: {
        country_code: "+1",
        number: "4155552671"
    }
};

function onSuccess(tokenResponse) {
    console.log('Tokenization successful', tokenResponse);
}

function onError(errorMessage) {
    console.log('Error generating token', errorMessage);
}

cordova.plugins.Checkout.generateToken(ckoCardTokenRequest, onSuccess, onError);

Example of TokenResponse:

{
    type: "card",
    token: "tok_ubfj2q76miwundwlk72vxt2i7q",
    expires_on: "2019-08-24T14:15:22Z",
    expiry_month: "6",
    expiry_year: "2025",
    scheme: "VISA",
    last4: "9996",
    bin: "454347",
    card_type: "Credit",
    card_category: "Consumer",
    issuer: "GOTHAM STATE BANK",
    issuer_country: "US",
    product_id: "F",
    product_type: "CLASSIC",
    billing_address: {
        address_line1: "Checkout.com",
        address_line2: "90 Tottenham Court Road",
        city: "London",
        state: "London",
        zip: "W1T 4TJ",
        country: "GB"
    },
    phone: {
        country_code: "+1",
        number: "4155552671"
    },
    name: "Bruce Wayne"
}

Once you get the token, you can later use it to request a payment, without you having to process or store any sensitive information.

Documentation


Checkout

Checkout.initSandboxClient(publickey, [success], [error])

Initialize Frames plugin in Sandbox mode

Param Type Description
publicKey string Sandbox account public key
[success] function Success callback
[error] function Error callback

Checkout.initLiveClient(publickey, [success], [error])

Initialize Frames plugin in Live mode

Param Type Description
publicKey string Live account public key
[success] function Success callback
[error] function Error callback

Checkout.generateToken(ckoCardTokenRequest, success, error)

Generate a payment token

Param Type Description
ckoCardTokenRequest CkoCardTokenRequest payment token request object
success function Success callback returns CkoCardTokenResponse
error function Error callback

Models

CkoCardTokenRequest : Object

Parameters to create a payment token from a card

Properties

Name Type Description Required
number string The card number Required
expiry_month string The expiry month of the card Required
expiry_year string The expiry year of the card Required
cvv string The card verification value/code. 3 digits, except for Amex (4 digits) Optional
name string The cardholder's name Optional
billing_address Address The cardholder's billing address Optional
phone Phone The cardholder's phone number Optional

CkoCardTokenResponse : Object

Object returned after successful tokenization

Properties

Name Type Description
type string The token type, in this case "card"
token string The token value
expires_on string The expiration datetime of the token
expiry_month string The expiry month of the card
expiry_year string The expiry year of the card
name string The cardholder's name
scheme string The card scheme
last4 string The last 4 digit of the card number
bin string The bin range of the card
card_type string The card type
card_category string The card category
issuer string The card issuer name
issuer_country string The card issuer country ISO
product_id string The card product id
product_type string The card product type
billing_address Address The cardholder's billing address
phone Phone The cardholder's phone number

Address : Object

Properties

Name Type Description
address_line1 string The first line of the address
address_line2 string The second line of the address
city string The address city
state string The address state
zip string The address zip/postal code
country string The two-letter ISO country code of the address

Phone : Object

Properties

Name Type Description
country_code string The international country calling code. Required for some risk checks
number string The phone number

Unit Testing

You can test this plugin with cordova-plugin-test-framework

Install the tests plugin:

cordova plugin add @checkout.com/cordova-plugin-checkout/tests

frames-cordova's People

Contributors

abdelrahman-iaaly-cko avatar

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.