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
getPaymentConfig
query 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
addProductsToNewCart
to create a new cart and add the item.Commerce returns a
cart
object, which includes the cartid
field.Run
createPaymentOrder
to 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
setCartAsInactive
to set the correspondingcartId
as inactive and to avoid having multiple active carts for logged-in customers.PayPal returns an
id
value.Adobe Commerce generates a
order_id
and forwards the value in themp_order_id
field and the PayPal response in theid
field.Run the
placeOrder
mutation.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
getPaymentConfig
query 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
addProductsToNewCart
to create a new cart and add the item.Commerce returns a
cart
object, which includes the cartid
field.Run
setCartAsInactive
to set a specificcartId
as inactive.Commerce returns a confirmation that a specific
cartId
is inactive.If the shopper clicks the smart button again,
addProductsToNewCart
mutation runs once more to return a newcart
object.