Skip to content

Commit

Permalink
Merge pull request #1080 from JDIZM/master
Browse files Browse the repository at this point in the history
fixed promises example
  • Loading branch information
remi-stripe authored Nov 30, 2020
2 parents dfbe6f3 + 34551d6 commit deffb6d
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,26 +128,29 @@ callback:
// Create a new customer and then create an invoice item then invoice it:
stripe.customers
.create({
email: 'foo-customer@example.com',
email: 'customer@example.com',
})
.then((customer) => {
return stripe.invoiceItems.create({
customer: 'cus_GcAjt5gZVAtChu',
amount: 2500,
currency: 'usd',
description: 'One-time setup fee',
})
.then((invoiceItem) => {
return stripe.invoices.create({
collection_method: 'send_invoice',
customer: invoiceItem.customer,
});
})
.then((invoice) => {
// New invoice created on a new customer
})
.catch((err) => {
// Deal with an error
// have access to the customer object
return stripe.invoiceItems
.create({
customer: customer.id, // set the customer id
amount: 2500, // 25
currency: 'usd',
description: 'One-time setup fee',
})
.then((invoiceItem) => {
return stripe.invoices.create({
collection_method: 'send_invoice',
customer: invoiceItem.customer,
});
})
.then((invoice) => {
// New invoice created on a new customer
})
.catch((err) => {
// Deal with an error
});
});
```

Expand Down

0 comments on commit deffb6d

Please sign in to comment.