8000 Merge pull request #656 from stripe/richardm-readme-handling-responses · stripe/stripe-python@d3835ab · GitHub
[go: up one dir, main page]

Skip to content

Commit d3835ab

Browse files
Merge pull request #656 from stripe/richardm-readme-handling-responses
README: response handling
2 parents 84e4c7a + 2fdd288 commit d3835ab

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,26 @@ import stripe
4343
stripe.api_key = "sk_test_..."
4444

4545
# list customers
46-
stripe.Customer.list()
46+
customers = stripe.Customer.list()
4747

48-
# retrieve single Customer
49-
stripe.Customer.retrieve("cus_123456789")
48+
# print the first customer's email
49+
print(customers.data[0].email)
50+
51+
# retrieve specific Customer
52+
customer = stripe.Customer.retrieve("cus_123456789")
53+
54+
# print that customer's email
55+
print(customer.email)
5056
```
5157

58+
### Handling exceptions
59+
60+
Unsuccessful requests raise exceptions. The class of the exception will reflect
61+
the sort of error that occurred. Please see the [Api
62+
Reference](https://stripe.com/docs/api/errors/handling) for a description of
63+
the error classes you should handle, and for information on how to inspect
64+
these errors.
65+
5266
### Per-request Configuration
5367

5468
Configure individual requests with keyword arguments. For example, you can make

0 commit comments

Comments
 (0)
0