2
2
3
3
Use [ Stripe.js] ( https://stripe.com/docs/stripe-js ) as an ES module.
4
4
5
- ** Note** : For compliance reasons, Stripe.js must be loaded directly from
6
- ` https://js.stripe.com ` , and cannot be included in a bundle or hosted yourself.
7
- This package wraps the global ` Stripe ` function provided by the Stripe.js
8
- script as an ES module.
5
+ ** Note** : To be
6
+ [ PCI compliant] ( https://stripe.com/docs/security#validating-pci-compliance ) , you
7
+ must load Stripe.js directly from ` https://js.stripe.com ` . You cannot included
8
+ it in a bundle or host it yourself. This package wraps the global ` Stripe `
9
+ function provided by the Stripe.js script as an ES module.
9
10
10
11
[ ![ npm version] ( https://img.shields.io/npm/v/@stripe/stripe-js.svg?style=flat-square )] ( https://www.npmjs.com/package/@stripe/stripe-js )
11
12
@@ -20,21 +21,22 @@ each page of your site.
20
21
<script src =" https://js.stripe.com/v3/" ></script >
21
22
```
22
23
23
- Then import and use Stripe.js as you would any other module.
24
+ Then import and use Stripe.js as you would any other module.
24
25
25
26
``` js
26
27
import {Stripe } from ' @stripe/stripe-js' ;
27
28
28
29
const stripe = Stripe (' pk_test_TYooMQauvdEDq54NiTphI7jx' );
29
30
```
30
31
31
- We’ve placed a random API key in this example. Replace it with your [ actual
32
- publishable API keys] ( https://dashboard.stripe.com/account/apikeys ) to test
33
- this code through your Stripe account.
32
+ We’ve placed a random API key in this example. Replace it with your
33
+ [ actual publishable API keys] ( https://dashboard.stripe.com/account/apikeys ) to
34
+ test this code through your Stripe account.
34
35
35
- For more information on how to use Stripe.js, please refer to the [ Stripe.js
36
- API reference] ( https://stripe.com/docs/js ) or learn to [ accept
37
- a payment] ( https://stripe.com/docs/payments/accept-a-payment ) with Stripe.
36
+ For more information on how to use Stripe.js, please refer to the
37
+ [ Stripe.js API reference] ( https://stripe.com/docs/js ) or learn to
38
+ [ accept a payment] ( https://stripe.com/docs/payments/accept-a-payment ) with
39
+ Stripe.
38
40
39
41
### ` loadStripe `
40
42
@@ -48,20 +50,21 @@ import {loadStripe} from '@stripe/stripe-js';
48
50
const stripe = await loadStripe (' pk_test_TYooMQauvdEDq54NiTphI7jx' );
49
51
```
50
52
51
- We’ve placed a random API key in this example. Replace it with your [ actual
52
- publishable API keys] ( https://dashboard.stripe.com/account/apikeys ) to test
53
- this code through your Stripe account.
53
+ We’ve placed a random API key in this example. Replace it with your
54
+ [ actual publishable API keys] ( https://dashboard.stripe.com/account/apikeys ) to
55
+ test this code through your Stripe account.
54
56
55
57
For more information on how to use Stripe.js once it loads, please refer to the
56
- [ Stripe.js API reference] ( https://stripe.com/docs/js ) or learn to [ accept
57
- a payment] ( https://stripe.com/docs/payments/accept-a-payment ) with Stripe.
58
+ [ Stripe.js API reference] ( https://stripe.com/docs/js ) or learn to
59
+ [ accept a payment] ( https://stripe.com/docs/payments/accept-a-payment ) with
60
+ Stripe.
58
61
59
62
## Ensuring Stripe.js is available everywhere
60
63
61
- To best leverage Stripe’s advanced fraud functionality, ensure that Stripe.js
62
- is loaded on every page, not just your checkout page. This allows Stripe to
63
- detect anomalous behavior that may be indicative of fraud as customers browse
64
- your website.
64
+ To best leverage Stripe’s advanced fraud functionality, ensure that Stripe.js is
65
+ loaded on every page, not just your checkout page. This allows Stripe to detect
66
+ anomalous behavior that may be indicative of fraud as customers browse your
67
+ website.
65
68
66
69
If you are adding the ` <script> ` tag manually, make sure you do so on every
67
70
page. If you are relying on the script insertion that this module provides, and
@@ -81,9 +84,9 @@ import '@stripe/stripe-js';
81
84
82
85
### Manually include the script tag
83
86
84
- Manually add the Stripe.js script tag to the ` <head> ` of each page on your
85
- site. If you use ` loadStripe ` , it will use this script tag rather than
86
- inserting a new one.
87
+ Manually add the Stripe.js script tag to the ` <head> ` of each page on your site.
88
+ If you use ` loadStripe ` , it will use this script tag rather than inserting a new
89
+ one.
87
90
88
91
``` html
89
92
<!-- Somewhere in your site's <head> -->
@@ -98,5 +101,5 @@ inserting a new one.
98
101
99
102
### Contributing
100
103
101
- If you would like to contribute to React Stripe.js, please make sure to read
102
- our [ contributor guidelines] ( CONTRIBUTING.md ) .
104
+ If you would like to contribute to React Stripe.js, please make sure to read our
105
+ [ contributor guidelines] ( CONTRIBUTING.md ) .
0 commit comments