From 0ec46b03b50af03d5b7538c00b7bb0421786bf2a Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Fri, 20 Jan 2017 16:02:17 -0500 Subject: [PATCH] feat(stripe): add stripe plugin (#913) * feat(stripe): add stripe plugin * add stripe to index * add param doc --- src/index.ts | 3 ++ src/plugins/stripe.ts | 105 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 src/plugins/stripe.ts diff --git a/src/index.ts b/src/index.ts index ed004c6cbc..634a23da83 100644 --- a/src/index.ts +++ b/src/index.ts @@ -100,6 +100,7 @@ import { SQLite } from './plugins/sqlite'; import { StatusBar } from './plugins/statusbar'; import { Stepcounter } from './plugins/stepcounter'; import { StreamingMedia } from './plugins/streaming-media'; +import { Stripe } from './plugins/stripe'; import { ThreeDeeTouch } from './plugins/3dtouch'; import { Toast } from './plugins/toast'; import { TouchID } from './plugins/touchid'; @@ -211,6 +212,7 @@ export * from './plugins/sqlite'; export * from './plugins/statusbar'; export * from './plugins/stepcounter'; export * from './plugins/streaming-media'; +export * from './plugins/stripe'; export * from './plugins/text-to-speech'; export * from './plugins/themeable-browser'; export * from './plugins/toast'; @@ -321,6 +323,7 @@ window['IonicNative'] = { StatusBar, Stepcounter, StreamingMedia, + Stripe, ThreeDeeTouch, Toast, TouchID, diff --git a/src/plugins/stripe.ts b/src/plugins/stripe.ts new file mode 100644 index 0000000000..7728174198 --- /dev/null +++ b/src/plugins/stripe.ts @@ -0,0 +1,105 @@ +import {Plugin, Cordova} from './plugin'; + +export interface StripeCardTokenParams { + /** + * Card number + */ + number: string; + /** + * Expiry month + */ + expMonth: number; + /** + * Expiry year + */ + expYear: number; + /** + * CVC / CVV + */ + cvc?: string; + /** + * Cardholder name + */ + name?: string; + /** + * Address line 1 + */ + address_line1?: string; + /** + * Address line 2 + */ + address_line2?: string; + /** + * City + */ + address_city?: string; + /** + * State / Province + */ + address_state?: string; + /** + * Country + */ + address_country?: string; + /** + * Postal code / ZIP Code + */ + postal_code?: string; + /** + * 3-letter ISO code for currency + */ + currency?: string; +} + +/** + * @name Stripe + * @description + * A plugin that allows you to use Stripe's Native SDKs for Android and iOS. + * + * @usage + * ``` + * import { Stripe } from 'ionic-native'; + * + * Stripe.setPublishableKey('my_publishable_key'); + * + * let card = { + * number: '4242424242424242', + * expMonth: 12, + * expYear: 2020, + * cvc: 220 + * }; + * + * Stripe.createToken(card) + * .then(token => console.log(token)) + * .catch(error => console.error(error)); + * + * ``` + * + * @interfaces + * StripeCardTokenParams + */ +@Plugin({ + pluginName: 'Stripe', + plugin: 'cordova-plugin-stripe', + pluginRef: 'cordova.plugins.stripe', + repo: 'https://github.com/zyramedia/cordova-plugin-stripe' +}) +export class Stripe { + + /** + * Set publishable key + * @param publishableKey {string} Publishable key + * @return {Promise} + */ + @Cordova() + static setPublishableKey(publishableKey: string): Promise { return; } + + /** + * Create Credit Card Token + * @param params {StripeCardTokenParams} Credit card information + * @return {Promise} returns a promise that resolves with the token, or reject with an error + */ + @Cordova() + static createCardToken(params: StripeCardTokenParams): Promise { return; } + +}