All Projects → zyra → Cordova Plugin Stripe

zyra / Cordova Plugin Stripe

Licence: mit
A Cordova plugin that lets you use Stripe's Native SDKs for Android and iOS.

Projects that are alternatives of or similar to Cordova Plugin Stripe

Cordova Plugin Qrscanner
A fast, energy efficient, highly-configurable QR code scanner for Cordova apps and the browser.
Stars: ✭ 485 (+438.89%)
Mutual labels:  cordova, cordova-plugin
Cordova Plugin Linkedin
Cordova plugin for LinkedIn
Stars: ✭ 17 (-81.11%)
Mutual labels:  cordova, cordova-plugin
Cordova Plugin Admob Free
Cordova AdMob Plugin
Stars: ✭ 508 (+464.44%)
Mutual labels:  cordova, cordova-plugin
scanbot-sdk-example-ionic
Scanbot scanner SDK example app for Ionic with Cordova.
Stars: ✭ 24 (-73.33%)
Mutual labels:  cordova, cordova-plugin
Cordova Plugin Wechat
A cordova plugin, a JS version of Wechat SDK
Stars: ✭ 1,198 (+1231.11%)
Mutual labels:  cordova, cordova-plugin
Cordova Plugin Geofence
Geofencing plugin for cordova
Stars: ✭ 261 (+190%)
Mutual labels:  cordova, cordova-plugin
Cordova Admob Pro
🔥 Cordova Plugin for Google AdMob, DFP, ADX. Easy monetization using mobile Ad, with single line of JavaScript. Compatible with Cordova CLI, Inoic, PhoneGap Build, etc.
Stars: ✭ 690 (+666.67%)
Mutual labels:  cordova, cordova-plugin
cordova-plugin-flurryanalytics
Adds support for all that Flurry Analytics flavored goodness to your Cordova based apps
Stars: ✭ 23 (-74.44%)
Mutual labels:  cordova, cordova-plugin
Awesome Cordova Plugins
A curated list of awesome Cordova Apache Plugins https://cordova.apache.org/plugins/
Stars: ✭ 33 (-63.33%)
Mutual labels:  cordova, cordova-plugin
Cordova Plugin Permissionscope
🔓 Cordova plugin to handle iOS permissions
Stars: ✭ 27 (-70%)
Mutual labels:  cordova, cordova-plugin
ionic-native-sms-retriever-plugin-master
Cross-platform plugin for Cordova / PhoneGap to Retrieve SMS. Available for Android.
Stars: ✭ 16 (-82.22%)
Mutual labels:  cordova, cordova-plugin
Ionic4
This repo contains example code for ionic4. Get Step by Step tutorial of this repo examples using https://ampersandacademy.com/tutorials/ionic-framework-4
Stars: ✭ 37 (-58.89%)
Mutual labels:  cordova, cordova-plugin
cordova-plugin-today-widget
Add a today widget app extension target to your cordova project.
Stars: ✭ 51 (-43.33%)
Mutual labels:  cordova, cordova-plugin
Vue Cordova
Vue.js plugin for Cordova
Stars: ✭ 328 (+264.44%)
Mutual labels:  cordova, cordova-plugin
cordova-plugin-apkupdater
This plugin allows your Android app to download and install compressed updates without the Google Play Store.
Stars: ✭ 46 (-48.89%)
Mutual labels:  cordova, cordova-plugin
Cordova Plugin Camera Preview
Cordova plugin that allows camera interaction from HTML code
Stars: ✭ 528 (+486.67%)
Mutual labels:  cordova, cordova-plugin
example-cordova-code-push-plugin
Ionic + Cordova Code Push Plugin Example
Stars: ✭ 45 (-50%)
Mutual labels:  cordova, cordova-plugin
cordova-plugin-dbcopy
Copy SQLite Database from www folder to default app database location
Stars: ✭ 90 (+0%)
Mutual labels:  cordova, cordova-plugin
Cordova Plugin Disable Bitcode
Cordova plugin to disable bitcode in iOS build settings
Stars: ✭ 19 (-78.89%)
Mutual labels:  cordova, cordova-plugin
Cl.kunder.webview
This cordova plugin enables you to open a second webview
Stars: ✭ 36 (-60%)
Mutual labels:  cordova, cordova-plugin

This repository is not actively maintained and full functionality is not guaranteed.

Developing Cordova plugins is no longer a priority.

Check this Capacitor Stripe plugin repo for a maintained alternative.

This repo will be updated eventually by porting over the Capacitor plugin code. PRs are welcome.


Cordova Stripe Plugin

A Cordova plugin that lets you use Stripe Native SDKs for Android, iOS and Browser.

npm npm npm

Installation

cordova plugin add cordova-plugin-stripe


Usage

First we need to set our publishable key. This can be your test or live key.

cordova.plugins.stripe.setPublishableKey('pk_test_MyPublishableKey');

Now we can create a credit card token to send to our backend.

var card = {
  number: '4242424242424242', // 16-digit credit card number
  expMonth: 12, // expiry month
  expYear: 2020, // expiry year
  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)
  address_city: 'Toronto', // city (optional)
  address_state: 'Ontario', // state/province (optional)
  address_country: 'Canada', // country (optional)
  postalCode: 'L5L5L5', // Postal Code / Zip Code (optional)
  currency: 'CAD' // Three-letter ISO currency code (optional)
};

function onSuccess(tokenId) {
    console.log('Got card token!', tokenId);
}

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

cordova.plugins.stripe.createCardToken(card, onSuccess, onError);


// bank account example
var bankAccount = {
  routing_number: '11000000',
  account_number: '000123456789',
  account_holder_name: 'John Smith', // optional
  account_holder_type: 'individual', // optional
  currency: 'CAD',
  country: 'CA'
};

cordova.plugins.stripe.createBankAccountToken(bankAccount, onSuccess, onError);

Once you have the token, you can now send it to your backend so you can charge the customer later on.



API Reference



stripe

stripe.setPublishableKey(key, [success], [error])

Set publishable key

Kind: static method of 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

Kind: static method of stripe

Param Type Description
creditCard CreditCardTokenParams Credit card information
success function Success callback
error function Error callback

stripe.createBankAccountToken(bankAccount, success, error)

Create a bank account token

Kind: static method of stripe

Param Type Description
bankAccount BankAccountTokenParams Bank account information
success function Success callback
error function Error callback

stripe.validateCardNumber(cardNumber, success, error)

Validates card number

Kind: static method of 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

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

Param Type Description
cvc string CVC/CVV
success function
error function

Example

function onSuccess() {
  console.log('isValid');
}

function onError() {
  console.log('invalid');
}

cordova.plugin.stripe.validateCVC('424', onSuccess, onError);

stripe.getCardType(cardNumber, success, error)

Gets a card type from a card number

Kind: static method of stripe

Param Type Description
cardNumber string Credit card number
success function
error function

Example

cordova.plugins.stripe.getCardType('4242424242424242', function(cardType) {
  console.log(cardType); // visa
});

stripe.CreditCardTokenParams : Object

Parameters to create a credit card token

Kind: static typedef of 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
postalCode 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
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.




Tests

To test this plugin with cordova-plugin-test-framework, run the following command to install the tests:

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. The plugin will automatically inject Stripe.js script into the web page when initialized.

Thanks to klirix for submitting a PR for the browser platform.



Contribution

  • Having an issue? or looking for support? Open an issue and we will get you the help you need.
  • Got a new feature or a bug fix? Fork the repo, make your changes, and submit a pull request.

Support this project

If you find this project useful, please star the repo to let people know that it's reliable. Also, share it with friends and colleagues that might find this useful as well. Thank you 😄

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].