#prasun_code
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1326934524436676639
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- prasun_api, 3 days ago, 11 messages
If collecting both billing and shipping address you can't
Is that possible only collecting shipping or billing?
If only collecting a billing address that checkbox won't be there
what needs to change in the api parameter here?
To not collect shipping?
To not collect billing or vice versa.
You can only opt out of shipping
Don't pass shipping_address_collection or shipping_options in the request
Okay, got it.
And if I want to vice versa i.e. to keep shipping in the form and opt out the billing.
You can't
Okay, got it.
Thanks.
Can I allow only US in the billing country and also prepopulate value?
You can't allow only US. However, you can prepopulate by passing in a customer who already has their billing address set: https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-customer
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Okay
$customer = $this->stripe->customers->create([
'address' => [
'city' => $customerData['city'],
'country' => 'US',
'line1' => $customerData['address1'],
'line2' => $customerData['address2'] ?? null,
'postal_code' => $customerData['zip'],
'state' => $customerData['state'],
],
'email' => $customerData['email'],
'name' => $customerData['first_name'] . " " . $customerData['last_name'],
'phone' => "+1" . $customerData['homephone'],
'shipping' => [
'address' => [
'city' => $customerData['city'],
'country' => 'US',
'line1' => $customerData['address1'],
'line2' => $customerData['address2'] ?? null,
'postal_code' => $customerData['zip'],
'state' => $customerData['state'],
],
'name' => $customerData['first_name'] . " " . $customerData['last_name'],
'phone' => "+1" . $customerData['homephone'],
],
]);
$customerId = $customer->id;
I am creating the customer record first then assigning the customer ID in the checkout session
API
'customer' => $customerId,
Is it enough to prefill in the checkout form?
email and phone number are already prefilled.