Passing customer address to Checkout API

In the Checkout API, I am currently setting ask_for_shipping_address to true to have the API collect that information for me. I am now planning a change in workflow such that I need the shipping address before I call the API (I’m planning on using the USPS API to get shipping cost information). I’ll still need the address in the e-mail that is sent by the Checkout API, so would I set ask_for_shipping_address to false and then set the pre_populate_shipping_address fields with the address that I have already collected? if not, how would I obtain the customer’s shipping address on my end, once the order has been placed and paid for?

Thanks!

If you are now collecting the shipping address before the API call you can include the address in the order fulfillment shipment_details of the CreateCheckout API call. Then with the Orders API you can get the shipping details associated to the order.

Two questions:

  1. How much of the OrderFulfillment object needs to be fleshed out in order for me to use the OrderFulfillmentRecipient object?
  2. Do I need to use the Orders API to retrieve the shipping address, or will it automatically be sent in the e-mail that Square sends indicating that I have a new order?

Thanks!

  1. Just the display_name is required as far as I see while testing, although presumably you would want to use the address field since that’s what you’re after.
  2. You’ll need to use the Orders API to retrieve the information.

Okay…

Right now, using the Checkout API and ask_for_shipping_address = true, I receive an e-mail automatically with the customer’s order information, including the shipping address. If I set that property to false and collect it myself, and if it is not sent to me automatically via e-mail (even if I set the shipping address properties):

  1. What is the point of setting those properties in the first place? I already have them in my web application…
  2. How do I (the seller) find out that an order has occurred and that it needs to be sent to a particular address?

Thanks!

  1. To clarify: if you set pre_populate_shipping_address, then ask_for_shipping_address needs to be true, else this won’t work. If you’re planning on setting it to false, then you need to collect it somehow else which was the suggestion above (although I don’t think it would show in the email). So your best bet is to pre populate the shipping address, and leave ask_for_shipping_address set to true.
  2. You can either listen for payment webhooks (recommended) or set up your own orders polling where you retrieve the orders to see if there’s any new orders.