-
Notifications
You must be signed in to change notification settings - Fork 756
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5642eb2
commit 578a768
Showing
1 changed file
with
13 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,20 +31,30 @@ The package needs to be configured with your account's secret key which is | |
available in your [Stripe Dashboard][api-keys]. Require it with the key's | ||
value: | ||
|
||
<!-- prettier-ignore --> | ||
```js | ||
const stripe = require('stripe')('sk_test_...'); | ||
|
||
stripe.customers.create({ | ||
email: '[email protected]', | ||
}); | ||
}) | ||
.then(customer => console.log(customer.id)) | ||
.catch(error => console.error(error)); | ||
``` | ||
|
||
Or using ES modules, this looks more like: | ||
Or using ES modules and `async`/`await`: | ||
|
||
```js | ||
import Stripe from 'stripe'; | ||
const stripe = new Stripe('sk_test_...'); | ||
//… | ||
|
||
(async () => { | ||
const customer = await stripe.customers.create({ | ||
email: '[email protected]', | ||
}); | ||
|
||
console.log(customer.id); | ||
})(); | ||
``` | ||
|
||
### Usage with TypeScript | ||
|