#wagamumma_best-practices
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/1370354667875340339
📝 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.
- wagamumma_best-practices, 2 days ago, 22 messages
- wagamumma_best-practices, 2 days ago, 34 messages
expressCheckoutElement.on('shippingaddresschange', async (event) => {
const response = await fetch('/stripe-components/public/update-shipping-address.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
shippingAddress: event.address,
}),
});
I am getting it and i can get the country, post code etc but does event.address also have name/phone?
I've no idea what that code does as it's not calling a Stripe API
Oh, you mean the event payload?
possibly yes, currently i just pass the event.address to PHP, is there another item I can send which would include the name/phone?
Well name is a property in ther event, just not in the address hash: https://docs.stripe.com/js/elements_object/express_checkout_element_shippingaddresschange_event#express_checkout_element_on_shipping_address_change-handler-name
Phone number would be in the confirm event assuming you're requesting it from the wallet: https://docs.stripe.com/js/elements_object/express_checkout_element_confirm_event#express_checkout_element_on_confirm-handler-billingDetails
ok thanks, is it weird even the example the name is blank?
{
name: "",
address: {
city: "San Francisco",
state: "CA",
postal_code: "94107",
country: "US",
},
resolve: function(payload) {
shippingAddress: event.address,
shippingName: event.name
would that work for the name do you think?
Yes should do
Did you verify that event.name is present in the payload? Is there a name set in the wallet?
it's using the test/sandbox wallet details so there should be a name, it returns a name "Card Holder" in the billing details on complete
const optionsExpress = {
shippingAddressRequired: true,
allowedShippingCountries: ['GB'],
shippingRates:shippingRatesArr,
emailRequired: true,
phoneNumberRequired: true,
};
// Set up Stripe.js and Elements to use in checkout form.
const elements = stripe.elements(options);
// Create and mount the Express Checkout Element
const expressCheckoutElement = elements.create('expressCheckout',optionsExpress);
expressCheckoutElement.mount('#express-checkout-element');
// need to change this to an actual amount! (this is when a customer cancels an express checkout without paying etc)
expressCheckoutElement.on('cancel', () => {
elements.update({amount: carttotal})
});
expressCheckoutElement.on('shippingaddresschange', async (event) => {
const response = await fetch('/stripe-components/public/update-shipping-address.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
shippingAddress: event.address,
shippingName: event.name
}),
});
I dont know if "event.name" exists or not I guess
Thewn you should log event and see what it contains
Then I guess the name is unset in whatever wallet is providing the details
The name does just appear to be empty for some reason... also another issue how would I get address line 1 as this only seems to return the city, country, postcode, state? but that's no use without the house number / first line of the address?
You can't in that event for privacy reasons:
To maintain privacy, browsers might anonymize the shipping address by removing sensitive information that isn't necessary to calculate shipping costs. Depending on the country, some fields can be missing or partially redacted. For example, the shipping address in the US can only contain a city, state, and ZIP code. The full shipping address appears in the confirm event object after the purchase is confirmed in the browser’s payment interface.
(might be why name is omitted, too)
in reality that event is intended to caluclate shipping costs. you don't need name and line1 for that – you can them in the confirm payload
ok I see, I can get the billing name/address at the end of checkout but what if the shipping name/address are different to the billing is my worry? Like if you bought a gift to send to someone else?
$email = $paymentMethod->billing_details->email;
$address = $paymentMethod->billing_details->address;
these I get in a webhook, is there a $paymentMethod->shipping_details that would contain the full shippiung address at that point?
I don't understand? You'd have different fields for each so if they're unique you can handle them as such: billingDetails, shippingAddress
https://docs.stripe.com/js/elements_object/express_checkout_element_confirm_event
ok thanks so at that point the shipping address WOULD include the first line of address/name?
that would contain the full shippiung address at that point?
No we don't persist the shipping details on a Payment Method, they'd be on the Payment Intent object/events: https://docs.stripe.com/api/payment_intents/object#payment_intent_object-shipping
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I would assume so yes, should be easy enough to test