1
+ # Cordova Stripe Plugin
2
+ A Cordova plugin that lets you use Stripe Native SDKs for Android, iOS and Browser.
3
+
1
4
[ ![ npm] ( https://img.shields.io/npm/l/express.svg )] ( https://www.npmjs.com/package/cordova-plugin-stripe )
2
5
3
6
[ ![ NPM] ( https://nodei.co/npm/cordova-plugin-stripe.png?stars&downloads )] ( https://nodei.co/npm/cordova-plugin-stripe/ )
4
7
[ ![ NPM] ( https://nodei.co/npm-dl/cordova-plugin-stripe.png?months=6&height=2 )] ( https://nodei.co/npm/cordova-plugin-stripe/ )
5
8
6
- # Cordova Stripe Plugin
7
- A Cordova plugin that lets you use Stripe Native SDKs for Android, iOS and Browser.
8
-
9
- - [ Installation] ( #installation )
10
- - [ Usage] ( #usage )
11
- - [ API] ( #api )
12
- - [ setPublishableKey] ( #setpublishablekey )
13
- - [ createCardToken] ( #createcardtoken )
14
- - [ createBankAccountToken] ( #createbankaccounttoken )
15
- - [ validateCardNumber] ( #validatecardnumber )
16
- - [ validateCVC] ( #validatecvc )
17
- - [ validateExpiryDate] ( #validateexpirydate )
18
- - [ getCardType] ( #getcardtype )
19
- - [ Tests] ( #tests )
20
- - [ Browser Support] ( #browser-support )
21
-
22
- <br >
23
- <br >
24
9
25
10
## Installation
26
11
``` shell
@@ -44,7 +29,7 @@ var card = {
44
29
number: ' 4242424242424242' , // 16-digit credit card number
45
30
expMonth: 12 , // expiry month
46
31
expYear: 2020 , // expiry year
47
- cvc: ' 220' , // CVC / CCV
32
+ cvc: ' 220' , // CVC / CCV
48
33
name: ' John Smith' , // card holder name (optional)
49
34
address_line1: ' 123 Some Street' , // address line 1 (optional)
50
35
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
85
70
<br >
86
71
87
72
88
- ## API
73
+ ## API Reference
89
74
90
- ### setPublishableKey
91
- ```
92
- setPublishableKey(key, success, error)
93
- ```
94
- * ** key** : Publishable key (string)
95
- Set the publishable key.
96
75
97
- ### createCardToken
98
- ```
99
- createCardToken(creditCard, success, error)
100
- ```
101
- * ** creditCard** : Credit card information. See example above for available properties. (Object)
76
+ * [ stripe] ( #module_stripe )
77
+ * [ .setPublishableKey(key, [ success] , [ error] )] ( #module_stripe.setPublishableKey )
78
+ * [ .createCardToken(creditCard, success, error)] ( #module_stripe.createCardToken )
79
+ * [ .createBankAccountToken(bankAccount, success, error)] ( #module_stripe.createBankAccountToken )
80
+ * [ .validateCardNumber(cardNumber, success, error)] ( #module_stripe.validateCardNumber )
81
+ * [ .validateExpiryDate(expMonth, expYear, success, error)] ( #module_stripe.validateExpiryDate )
82
+ * [ .validateCVC(cvc, success, error)] ( #module_stripe.validateCVC )
83
+ * [ .getCardType(cardNumber, success, error)] ( #module_stripe.getCardType )
84
+ * [ .CreditCardTokenParams] ( #module_stripe.CreditCardTokenParams ) : <code >Object</code >
85
+ * [ .BankAccountTokenParams] ( #module_stripe.BankAccountTokenParams ) : <code >object</code >
86
+
87
+
88
+ <br >
89
+ <br >
90
+
91
+ <a name =" module_stripe " ></a >
92
+
93
+ ## stripe
94
+ <a name =" module_stripe.setPublishableKey " ></a >
95
+
96
+ ### stripe.setPublishableKey(key, [ success] , [ error] )
97
+ Set publishable key
98
+
99
+ ** Kind** : static method of <code >[ stripe] ( #module_stripe ) </code >
100
+
101
+ | Param | Type | Description |
102
+ | --- | --- | --- |
103
+ | key | <code >string</code > | Publishable key |
104
+ | [ success] | <code >function</code > | Success callback |
105
+ | [ error] | <code >function</code > | Error callback |
106
+
107
+ <a name =" module_stripe.createCardToken " ></a >
108
+
109
+ ### stripe.createCardToken(creditCard, success, error)
102
110
Create a credit card token
103
111
104
- ### createBankAccountToken
105
- ```
106
- createBankAccountToken(bankAccount, success, error)
107
- ```
108
- * ** bankAccount** : Bank account information. See example above for available properties. (Object)
112
+ ** Kind** : static method of <code >[ stripe] ( #module_stripe ) </code >
113
+
114
+ | Param | Type | Description |
115
+ | --- | --- | --- |
116
+ | creditCard | <code >[ CreditCardTokenParams] ( #module_stripe.CreditCardTokenParams ) </code > | Credit card information |
117
+ | success | <code >function</code > | Success callback |
118
+ | error | <code >function</code > | Error callback |
119
+
120
+ <a name =" module_stripe.createBankAccountToken " ></a >
121
+
122
+ ### stripe.createBankAccountToken(bankAccount, success, error)
109
123
Create a bank account token
110
124
111
- ### validateCardNumber
112
- ```
113
- validateCardNumber(cardNumber, success, error)
114
- ```
115
- * ** cardNumber** : Credit card number
116
- Validate card number. Success callback will be called if valid, and error callback will be called if invalid.
125
+ ** Kind** : static method of <code >[ stripe] ( #module_stripe ) </code >
117
126
118
- ### validateCVC
119
- ```
120
- validateCVC(cvc, success, error)
121
- ```
122
- * ** cvc** : CVC
123
- Validate CVC number. Success callback will be called if valid, and error callback will be called if invalid.
127
+ | Param | Type | Description |
128
+ | --- | --- | --- |
129
+ | bankAccount | <code >[ BankAccountTokenParams] ( #module_stripe.BankAccountTokenParams ) </code > | Bank account information |
130
+ | success | <code >function</code > | Success callback |
131
+ | error | <code >function</code > | Error callback |
124
132
125
- ### validateExpiryDate
126
- ```
127
- validateExpiryDate(expMonth, expYear, success, error)
128
- ```
129
- * ** expMonth** : Expiry month (string)
130
- * ** expYear** : 4 digits expiry year (string)
131
- Validate epxiry date. Success callback will be called if valid, and error callback will be called if invalid.
133
+ <a name =" module_stripe.validateCardNumber " ></a >
134
+
135
+ ### stripe.validateCardNumber(cardNumber, success, error)
136
+ Validates card number
137
+
138
+ ** Kind** : static method of <code >[ stripe] ( #module_stripe ) </code >
139
+
140
+ | Param | Type | Description |
141
+ | --- | --- | --- |
142
+ | cardNumber | <code >String</code > | Credit card number |
143
+ | success | <code >function</code > | Success callback that will be called if card number is valid |
144
+ | error | <code >function</code > | Error callback that will be called if card number is invalid |
145
+
146
+ <a name =" module_stripe.validateExpiryDate " ></a >
147
+
148
+ ### stripe.validateExpiryDate(expMonth, expYear, success, error)
149
+ Validates the expiry date of a card
150
+
151
+ ** Kind** : static method of <code >[ stripe] ( #module_stripe ) </code >
152
+
153
+ | Param | Type | Description |
154
+ | --- | --- | --- |
155
+ | expMonth | <code >number</code > | Expiry month |
156
+ | expYear | <code >number</code > | Expiry year |
157
+ | success | <code >function</code > | |
158
+ | error | <code >function</code > | |
159
+
160
+ <a name =" module_stripe.validateCVC " ></a >
161
+
162
+ ### stripe.validateCVC(cvc, success, error)
163
+ Validates a CVC of a card
164
+
165
+ ** Kind** : static method of <code >[ stripe] ( #module_stripe ) </code >
166
+
167
+ | Param | Type | Description |
168
+ | --- | --- | --- |
169
+ | cvc | <code >string</code > | CVC/CVV |
170
+ | success | <code >function</code > | |
171
+ | error | <code >function</code > | |
172
+
173
+ ** Example**
174
+ ``` js
175
+ function onSuccess () {
176
+ console .log (' isValid' );
177
+ }
178
+
179
+ function onError () {
180
+ console .log (' invalid' );
181
+ }
132
182
133
- ### getCardType
183
+ cordova . plugin . stripe . validateCVC ( ' 424 ' , onSuccess, onError);
134
184
```
135
- getCardType(cardNumber, success)
185
+ <a name =" module_stripe.getCardType " ></a >
186
+
187
+ ### stripe.getCardType(cardNumber, success, error)
188
+ Gets a card type from a card number
189
+
190
+ ** Kind** : static method of <code >[ stripe] ( #module_stripe ) </code >
191
+
192
+ | Param | Type | Description |
193
+ | --- | --- | --- |
194
+ | cardNumber | <code >string</code > | Credit card number |
195
+ | success | <code >function</code > | |
196
+ | error | <code >function</code > | |
197
+
198
+ ** Example**
199
+ ``` js
200
+ cordova .plugins .stripe .getCardType (' 4242424242424242' , function (cardType ) {
201
+ console .log (cardType); // visa
202
+ });
136
203
```
137
- * ** cardNumber** : Credit card number
138
- Get card type. Will return one of the following: ` Visa ` , ` MasterCard ` , ` American Express ` , ` Discover ` , ` Diners Club ` , ` JBC ` or ` Unknown ` .
204
+ <a name =" module_stripe.CreditCardTokenParams " ></a >
205
+
206
+ ### stripe.CreditCardTokenParams : <code >Object</code >
207
+ Parameters to create a credit card token
208
+
209
+ ** Kind** : static typedef of <code >[ stripe] ( #module_stripe ) </code >
210
+ ** Properties**
211
+
212
+ | Name | Type | Description |
213
+ | --- | --- | --- |
214
+ | number | <code >string</code > | Card number |
215
+ | expMonth | <code >number</code > | Expiry month |
216
+ | expYear | <code >number</code > | Expiry year |
217
+ | cvc | <code >string</code > | CVC/CVV |
218
+ | name | <code >string</code > | Cardholder name |
219
+ | address_line1 | <code >string</code > | Address line 1 |
220
+ | address_line2 | <code >string</code > | Address line 2 |
221
+ | address_city | <code >string</code > | Address line 2 |
222
+ | address_state | <code >string</code > | State/Province |
223
+ | address_country | <code >string</code > | Country |
224
+ | postal_code | <code >string</code > | Postal/Zip code |
225
+ | currency | <code >string</code > | 3-letter code for currency |
226
+
227
+ <a name =" module_stripe.BankAccountTokenParams " ></a >
228
+
229
+ ### stripe.BankAccountTokenParams : <code >object</code >
230
+ Parameters to create a bank account token
231
+
232
+ ** Kind** : static typedef of <code >[ stripe] ( #module_stripe ) </code >
233
+ ** Properties**
234
+
235
+ | Name | Type | Description |
236
+ | --- | --- | --- |
237
+ | routing_number | <code >string</code > | Routing number |
238
+ | account_number | <code >string</code > | Account number |
239
+ | currency | <code >string</code > | Currency code. Example: ` CAD ` . |
240
+ | country | <code >string</code > | Country code. Example: ` CA ` . |
241
+ | account_holder_name | <code >string</code > | Account holder name |
242
+ | account_holder_type | <code >string</code > | Account holder type. This can be ` individual ` or ` company ` . |
243
+
244
+ <br >
245
+ <br >
246
+
139
247
140
248
<br >
141
249
<br >
@@ -151,5 +259,5 @@ cordova plugin add https://github.com/zyramedia/cordova-plugin-stripe#:/tests
151
259
152
260
## Browser support
153
261
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.
154
-
262
+
155
263
* Thanks to [ klirix] ( https://github.com/klirix ) for submitting a [ PR] ( https://github.com/zyramedia/cordova-plugin-stripe/pull/5 ) for the browser platform.*
0 commit comments