Create a new cart in the Product Details Page workflows
This workflow is available only with Apple Pay if you have installed Payment Services for Adobe Commerce 2.12.0 or higher.
These steps describe the flow of requests and responses with the Payment Services solution enabled for guests and logged-in customers. This workflow is required to create a new cart in the Product Details Page (PDP) with smart buttons.
Add product to a new cart in a PDP workflow
These steps describe the use case when a shopper adds a product to the cart on a PDP.
Run the
getPaymentConfigquery to fetch the payment configuration needed to render details about PayPal components, such as hosted fields, smart buttons, and Apple Pay.Adobe Commerce returns payment configuration information.
Run
addProductsToNewCartto create a new cart and add the item.Commerce returns a
cartobject, which includes the cartidfield.Run
createPaymentOrderto begin the authorization process.Commerce forwards the request to PayPal.
If there is an error during the payment process, or the shopper cancels the payment process on the PDP, run
setCartAsInactiveto set the correspondingcartIdas inactive and to avoid having multiple active carts for logged-in customers.PayPal returns an
idvalue.Adobe Commerce generates a
order_idand forwards the value in themp_order_idfield and the PayPal response in theidfield.Run the
placeOrdermutation.Commerce sends an authorization request to PayPal.
PayPal returns the result to Commerce.
Commerce creates an order.
Payment cancellation while on a PDP workflow
These steps describe the use case when a shopper cancels the payment process on the PDP.
Run the
getPaymentConfigquery to fetch the payment configuration needed to render details about PayPal components, such as hosted fields, smart buttons, and Apple Pay.Adobe Commerce returns payment configuration information.
Run
addProductsToNewCartto create a new cart and add the item.Commerce returns a
cartobject, which includes the cartidfield.Run
setCartAsInactiveto set a specificcartIdas inactive.Commerce returns a confirmation that a specific
cartIdis inactive.If the shopper clicks the smart button again,
addProductsToNewCartmutation runs once more to return a newcartobject.
