An open API service indexing awesome lists of open source software.

https://github.com/checkout/frames-cordova

A Cordova plugin for Checkout.com Frames product
https://github.com/checkout/frames-cordova

cordova cordova-plugin payment-processing phonegap phonegap-plugin

Last synced: about 1 month ago
JSON representation

A Cordova plugin for Checkout.com Frames product

Awesome Lists containing this project

README

        

# 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
```shell
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:
```javascript
cordova.plugins.Checkout.initSandboxClient("pk_test_MyTESTPublicKey",
function() {
// Success, no need to do anything
}, function (error) {
// Error, message returned
});
```

Production:
```javascript
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.

```javascript
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:
```javascript
{
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](https://api-reference.checkout.com/#operation/requestAPaymentOrPayout), without you having to process or store any sensitive information.

## Documentation

* [Checkout](#module_cko)
* [.initSandboxClient(publicKey, [success], [error])](#module_cko.initSandboxClient)
* [.initLiveClient(publicKey, [success], [error])](#module_cko.initLiveClient)
* [.generateToken(ckoCardTokenRequest, [success], [error])](#module_cko.generateToken)
* [Models](#module_models)
* [CkoCardTokenRequest](#module_models.CkoCardTokenRequest) : Object
* [CkoCardTokenResponse](#module_models.CkoCardTokenResponse) : Object
* [Address](#module_models.Address) : Object
* [Phone](#module_models.Phone) : Object


## 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](#module_models.CkoCardTokenRequest) | payment token request object|
| success | function | Success callback returns [CkoCardTokenResponse](#module_models.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](#module_models.Address) | The cardholder's billing address | Optional |
| phone | [Phone](#module_models.Address) | 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](#module_models.Address) | The cardholder's billing address |
| phone | [Phone](#module_models.Address) | 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](https://github.com/apache/cordova-plugin-test-framework)

Install the tests plugin:
```shell
cordova plugin add @checkout.com/cordova-plugin-checkout/tests
```