You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49-8Lines changed: 49 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -65,15 +65,15 @@ ENV.stripe = {
65
65
66
66
### Mocking the Stripe API
67
67
68
-
You can configure the Stripe API to be mocked instead of loaded from `https://js.stripe.com/v3/`. This is useful for testing.
68
+
You can configure the Stripe API to be mocked instead of loaded from `https://js.stripe.com/v3/`. This is useful for testing.
69
69
70
70
```js
71
71
ENV.stripe= {
72
72
mock:true
73
73
};
74
74
```
75
75
76
-
When enabled, a [mock Stripe object](https://github.com/code-corps/ember-stripe-elements/blob/develop/addon/utils/stripe-mock.js) will be assigned to `window.Stripe` when your app is initialized.
76
+
When enabled, a [mock Stripe object](https://github.com/code-corps/ember-stripe-elements/blob/develop/addon/utils/stripe-mock.js) will be assigned to `window.Stripe` when your app is initialized.
77
77
78
78
When using the Stripe mock in tests you will likely need to override the mock's methods according to the needs of your test like so:
79
79
@@ -154,13 +154,54 @@ You could handle these actions yourself, for example:
154
154
155
155
This addon gives you components that match the different [Element types](https://stripe.com/docs/elements/reference#element-types):
156
156
157
-
-`{{stripe-card}}` - `card` (recommended) A flexible single-line input that collects all necessary card details.
158
-
-`{{stripe-card-number}}` - `cardNumber` The card number.
159
-
-`{{stripe-card-expiry}}` - `cardExpiry` The card's expiration date.
160
-
-`{{stripe-card-cvc}}` - `cardCvc` The card's CVC number.
161
-
-`{{stripe-postal-code}}` - `postalCode` the ZIP/postal code.
157
+
Stripe recommend using the their `card` element - a flexible single-line input that collects all necessary card details.
158
+
The `{{stripe-card}}` component provides this input.
162
159
163
-
### Block usage with `options`
160
+
Additionally Stripe provide the following elements, which you can use to build your own form to collect card details:
161
+
162
+
-`cardNumber`: the card number.
163
+
-`cardExpiry`: the card's expiration date.
164
+
-`cardCvc`: the card's CVC number.
165
+
-`postalCode`: the ZIP/postal code.
166
+
167
+
These are provided via our `{{stripe-elements}}` contextual component, which yields sub-components for each element type:
168
+
169
+
```hbs
170
+
{{#stripe-elements as |elements|}}
171
+
{{elements.cardNumber}}
172
+
{{elements.cardExpiry}}
173
+
{{elements.cardCvc}}
174
+
{{elements.postalCode}}
175
+
{{/stripe-elements}}
176
+
```
177
+
178
+
> The `{{stripe-elements}}` component is a tagless component, so does not have any classes etc on it.
179
+
180
+
### Elements Options
181
+
182
+
The `{{stripe-elements}}` contextual component ensures all the individual elements are created from
183
+
the same [Stripe Elements object](https://stripe.com/docs/stripe-js/reference#the-elements-object).
184
+
185
+
If you want to pass options to the Stripe Elements object, pass them to the `{{stripe-elements}}`
186
+
contextual component. For example, when using the single-line `card` element:
187
+
188
+
```hbs
189
+
{{#stripe-elements options=elementOptions as |elements|}}
190
+
{{elements.card options=cardOptions}}
191
+
{{/stripe-elements}}
192
+
```
193
+
194
+
Or when creating your own form:
195
+
196
+
```hbs
197
+
{{#stripe-elements options=elementsOptions as |elements|}}
198
+
{{elements.cardNumber options=cardNumberOptions}}
199
+
{{elements.cardExpiry}}
200
+
{{elements.cardCvc}}
201
+
{{/stripe-elements}}
202
+
```
203
+
204
+
### Block usage with element `options`
164
205
165
206
In addition to the simple usage above, like `{{stripe-card}}`, you can also yield to a block, which will yield both an `stripeError` object and [the `stripeElement` itself](https://stripe.com/docs/elements/reference#the-element).
0 commit comments