useSquareCheckout
hook allows to checkout using Square.useSquareCheckout
hook returns an object with these properties:getStates
getUserWallet
updateOrderAddresses
updateOrderDelivery
updateOrderPayment
finalizeCheckout
modifyCart({ email: "[email protected]" })
. This is only needed for guest checkouts, if the user is logged in, this is not needed and the user's email will be used.updateOrderPayment()
function after retrieving the Square token client-side, using the Square Web Payment SDK.getStates
getStates
function is used to retrieve information about countries and states available in the system to be used when we need to update the order's address. It takes the ISO code of the country and returns the list of states along with other information related to the country itselfgetStates(iso)
iso
Promise<{ states: string | State[]; state_required: boolean }>
State
:abbr
name
id
country_id
getUserWallet
getUserWallet
function is used to retrieve information about the user's wallet.TODO
updateOrderAddresses
updateOrderAddresses
function is used to update the order's ship address. A valid ship address has the following format:updateOrderAdresses(options)
options.name
options.address1
options.address2?
options.city
options.country_id
options.state_id
options.zipcode
options.phone
options.company
Promise<void>
: A Promise that resolves when the order
object has been updated in Redux.updateOrderDelivery
updateOrderDelivery()
function allows choosing the shipping option for the current order. At the moment we do not support multiple delivery options, so this function is only needed to move the checkout from the delivery step to the payment step. During this process, shipping costs and taxes will be added to the order. updateOrderDelivery(options)
options.payment_method_type
options.source_attributes.nonce
Promise<void>
: A Promise that resolves when the order
object has been updated in Redux.updateOrderPayment
updateOrderPayment()
function allows completing the payment step of the checkout. Before using this function, the client should retrieve a token using the Web Payments SDK provided by Square. When the order is successfully completed, the payment source will be added to the user's wallet (for authenticated users only), allowing to re-use the payment token later, without having to input the credit card information againupdateOrderDelivery(options)
options.payment_method_type
options.source_attributes.nonce
Promise<void>
: A Promise that resolves when the order
object has been updated in Redux.finalizeCheckout
finalizeCheckout()
is the last method that needs to be called to complete the order with Square. Call this method when you want to move the user to the thank you page and let them start a new order. Promise<void>