From bdcccc4d3a76cd78fbf6e884b9589be621b06d14 Mon Sep 17 00:00:00 2001 From: ZM Bot Date: Sun, 2 Apr 2017 01:56:35 +0000 Subject: [PATCH] docs(): update readme [ci skip] --- README.md | 228 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 168 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index 0493632..04bdd1f 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,11 @@ +# Cordova Stripe Plugin +A Cordova plugin that lets you use Stripe Native SDKs for Android, iOS and Browser. + [![npm](https://img.shields.io/npm/l/express.svg)](https://www.npmjs.com/package/cordova-plugin-stripe) [![NPM](https://nodei.co/npm/cordova-plugin-stripe.png?stars&downloads)](https://nodei.co/npm/cordova-plugin-stripe/) [![NPM](https://nodei.co/npm-dl/cordova-plugin-stripe.png?months=6&height=2)](https://nodei.co/npm/cordova-plugin-stripe/) -# Cordova Stripe Plugin -A Cordova plugin that lets you use Stripe Native SDKs for Android, iOS and Browser. - -- [Installation](#installation) -- [Usage](#usage) -- [API](#api) - - [setPublishableKey](#setpublishablekey) - - [createCardToken](#createcardtoken) - - [createBankAccountToken](#createbankaccounttoken) - - [validateCardNumber](#validatecardnumber) - - [validateCVC](#validatecvc) - - [validateExpiryDate](#validateexpirydate) - - [getCardType](#getcardtype) -- [Tests](#tests) -- [Browser Support](#browser-support) - -
-
## Installation ```shell @@ -44,7 +29,7 @@ var card = { number: '4242424242424242', // 16-digit credit card number expMonth: 12, // expiry month expYear: 2020, // expiry year - cvc: '220', // CVC / CCV + cvc: '220', // CVC / CCV name: 'John Smith', // card holder name (optional) address_line1: '123 Some Street', // address line 1 (optional) address_line2: 'Suite #220', // address line 2 (optional) @@ -85,57 +70,180 @@ Once you have the token, you can now send it to your backend so you can charge t
-## API +## API Reference -### setPublishableKey -``` -setPublishableKey(key, success, error) -``` -* **key**: Publishable key (string) -Set the publishable key. -### createCardToken -``` -createCardToken(creditCard, success, error) -``` -* **creditCard**: Credit card information. See example above for available properties. (Object) +* [stripe](#module_stripe) + * [.setPublishableKey(key, [success], [error])](#module_stripe.setPublishableKey) + * [.createCardToken(creditCard, success, error)](#module_stripe.createCardToken) + * [.createBankAccountToken(bankAccount, success, error)](#module_stripe.createBankAccountToken) + * [.validateCardNumber(cardNumber, success, error)](#module_stripe.validateCardNumber) + * [.validateExpiryDate(expMonth, expYear, success, error)](#module_stripe.validateExpiryDate) + * [.validateCVC(cvc, success, error)](#module_stripe.validateCVC) + * [.getCardType(cardNumber, success, error)](#module_stripe.getCardType) + * [.CreditCardTokenParams](#module_stripe.CreditCardTokenParams) : Object + * [.BankAccountTokenParams](#module_stripe.BankAccountTokenParams) : object + + +
+
+ + + +## stripe + + +### stripe.setPublishableKey(key, [success], [error]) +Set publishable key + +**Kind**: static method of [stripe](#module_stripe) + +| Param | Type | Description | +| --- | --- | --- | +| key | string | Publishable key | +| [success] | function | Success callback | +| [error] | function | Error callback | + + + +### stripe.createCardToken(creditCard, success, error) Create a credit card token -### createBankAccountToken -``` -createBankAccountToken(bankAccount, success, error) -``` -* **bankAccount**: Bank account information. See example above for available properties. (Object) +**Kind**: static method of [stripe](#module_stripe) + +| Param | Type | Description | +| --- | --- | --- | +| creditCard | [CreditCardTokenParams](#module_stripe.CreditCardTokenParams) | Credit card information | +| success | function | Success callback | +| error | function | Error callback | + + + +### stripe.createBankAccountToken(bankAccount, success, error) Create a bank account token -### validateCardNumber -``` -validateCardNumber(cardNumber, success, error) -``` -* **cardNumber**: Credit card number -Validate card number. Success callback will be called if valid, and error callback will be called if invalid. +**Kind**: static method of [stripe](#module_stripe) -### validateCVC -``` -validateCVC(cvc, success, error) -``` -* **cvc**: CVC -Validate CVC number. Success callback will be called if valid, and error callback will be called if invalid. +| Param | Type | Description | +| --- | --- | --- | +| bankAccount | [BankAccountTokenParams](#module_stripe.BankAccountTokenParams) | Bank account information | +| success | function | Success callback | +| error | function | Error callback | -### validateExpiryDate -``` -validateExpiryDate(expMonth, expYear, success, error) -``` -* **expMonth**: Expiry month (string) -* **expYear**: 4 digits expiry year (string) -Validate epxiry date. Success callback will be called if valid, and error callback will be called if invalid. + + +### stripe.validateCardNumber(cardNumber, success, error) +Validates card number + +**Kind**: static method of [stripe](#module_stripe) + +| Param | Type | Description | +| --- | --- | --- | +| cardNumber | String | Credit card number | +| success | function | Success callback that will be called if card number is valid | +| error | function | Error callback that will be called if card number is invalid | + + + +### stripe.validateExpiryDate(expMonth, expYear, success, error) +Validates the expiry date of a card + +**Kind**: static method of [stripe](#module_stripe) + +| Param | Type | Description | +| --- | --- | --- | +| expMonth | number | Expiry month | +| expYear | number | Expiry year | +| success | function | | +| error | function | | + + + +### stripe.validateCVC(cvc, success, error) +Validates a CVC of a card + +**Kind**: static method of [stripe](#module_stripe) + +| Param | Type | Description | +| --- | --- | --- | +| cvc | string | CVC/CVV | +| success | function | | +| error | function | | + +**Example** +```js +function onSuccess() { + console.log('isValid'); +} + +function onError() { + console.log('invalid'); +} -### getCardType +cordova.plugin.stripe.validateCVC('424', onSuccess, onError); ``` -getCardType(cardNumber, success) + + +### stripe.getCardType(cardNumber, success, error) +Gets a card type from a card number + +**Kind**: static method of [stripe](#module_stripe) + +| Param | Type | Description | +| --- | --- | --- | +| cardNumber | string | Credit card number | +| success | function | | +| error | function | | + +**Example** +```js +cordova.plugins.stripe.getCardType('4242424242424242', function(cardType) { + console.log(cardType); // visa +}); ``` -* **cardNumber**: Credit card number -Get card type. Will return one of the following: `Visa`, `MasterCard`, `American Express`, `Discover`, `Diners Club`, `JBC` or `Unknown`. + + +### stripe.CreditCardTokenParams : Object +Parameters to create a credit card token + +**Kind**: static typedef of [stripe](#module_stripe) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| number | string | Card number | +| expMonth | number | Expiry month | +| expYear | number | Expiry year | +| cvc | string | CVC/CVV | +| name | string | Cardholder name | +| address_line1 | string | Address line 1 | +| address_line2 | string | Address line 2 | +| address_city | string | Address line 2 | +| address_state | string | State/Province | +| address_country | string | Country | +| postal_code | string | Postal/Zip code | +| currency | string | 3-letter code for currency | + + + +### stripe.BankAccountTokenParams : object +Parameters to create a bank account token + +**Kind**: static typedef of [stripe](#module_stripe) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| routing_number | string | Routing number | +| account_number | string | Account number | +| currency | string | Currency code. Example: `CAD`. | +| country | string | Country code. Example: `CA`. | +| account_holder_name | string | Account holder name | +| account_holder_type | string | Account holder type. This can be `individual` or `company`. | + +
+
+

@@ -151,5 +259,5 @@ cordova plugin add https://github.com/zyramedia/cordova-plugin-stripe#:/tests ## Browser support This plugin provides browser platform support. Method names and signatures match the [API above](#api). The plugin will automatically inject Stripe.js script into the web page when initialized. - + *Thanks to [klirix](https://github.com/klirix) for submitting a [PR](https://github.com/zyramedia/cordova-plugin-stripe/pull/5) for the browser platform.*