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
The sample app uses the minimal fields for creating a customer record:
@app.route('/create-customer', methods=['POST'])defcreate_customer():
# Reads application/json and returns a responsedata=json.loads(request.data)
try:
# Create a new customer objectcustomer=stripe.Customer.create(email=data['email'])
# At this point, associate the ID of the Customer object with your# own internal representation of a customer, if you have one.resp=jsonify(customer=customer)
# We're simulating authentication here by storing the ID of the customer# in a cookie.resp.set_cookie('customer', customer.id)
returnrespexceptExceptionase:
returnjsonify(error=str(e)), 403
The guide uses richer, more detailed examples for the customer records:
# Set your secret key. Remember to switch to your live secret key in production.# See your keys here: https://dashboard.stripe.com/apikeysimportstripestripe.api_key="sk_test_51MTwG0Fe8VbCz0t5SXlmkvi6ymOeib8OC0M4VHIxRS5rXjqVaDtDOHJnmK6TPPqbc9tTZBZfHT21UHlLAOV4W4RT004JYwc5pC"stripe.Customer.create(
email="{{CUSTOMER_EMAIL}}",
name="{{CUSTOMER_NAME}}",
shipping={
"address": {
"city": "Brothers",
"country": "US",
"line1": "27 Fredrick Ave",
"postal_code": "97712",
"state": "CA",
},
"name": "{{CUSTOMER_NAME}}",
},
address={
"city": "Brothers",
"country": "US",
"line1": "27 Fredrick Ave",
"postal_code": "97712",
"state": "CA",
},
)
Ideally, the two would match to make it easier for a developer to switch between them. Using more complicated, realistic data is also closer to the real-world experience of the user.
Thank you for your feedback. @rgy-stripe
As a method to aim for more specific examples while reducing the complexity of implementation, what do you think about adding an AddressElement, for instance? https://docs.stripe.com/elements/address-element
In this case, instead of using the customer.create API, information is updated during the Payment Intent's confirm process, which is slightly different from the proposed workflow.
Bug reportFeature requestThe sample app uses the minimal fields for creating a customer record:
The guide uses richer, more detailed examples for the customer records:
Ideally, the two would match to make it easier for a developer to switch between them. Using more complicated, realistic data is also closer to the real-world experience of the user.
Additional context
The text was updated successfully, but these errors were encountered: