Respond to a Shipping Option Change
Deprecated
This component is deprecated. See below for guidance about what to use instead.
Note
The Square payment form is deprecated and replaced by the Web Payments SDK.
You should use the Web Payments SDK to take payments on a web client. The Web Payments SDK uses modern web styling as shown in the following image:
Recalculate shipping fees and taxes when a buyer changes the shipping option in the Apple Pay or Google Pay payment sheet.
Before you start
You have integrated the payment form into your web application.
You have enabled Apple Pay or Google Pay in your payment page.
Shipping option changes
Use the shippingOptionChanged callback to respond to a change in the shipping option selected in the Apple Pay or Google Pay payment sheet.
Add a shippingOptionChanged
callback function to the callbacks
property of the SqPaymentForm
initializing argument. The callback is invoked when a shipping option is changed on the payment sheet. Use the callback to calculate a new shipping cost and other fees. If the calculation results in a line item amount change, update the payment request with the new amounts by calling the
done function in the callback.
For an Apple Pay payment request, avoid a timeout by calling done
within 30 seconds to respond to the shipping option change. Pass in an optional PaymentDetailsUpdate
object to update the payment total or line items.
Google Pay does not timeout the shipping option changed callback.
If you need more assistance, contact Developer Support or ask for help in the Developer Forums.