Skip to content

Commit f260b5b

Browse files
danidelcarkeharper
andauthored
Updates GraphQL for Payment Services with new PDP workflows and details. (#484)
* updated pages as per typo * Updated TOC * fixed title * Added workflows for pdp * Fix note * Updated toc * Apply suggestions from code review Co-authored-by: Kevin Harper <keharper@users.noreply.github.com> * Update src/pages/graphql/payment-services-extension/workflows/cart-pdp.md Co-authored-by: Kevin Harper <keharper@users.noreply.github.com> * Apply suggestions from code review * Update src/pages/graphql/payment-services-extension/workflows/cart-pdp.md * Update src/pages/graphql/payment-services-extension/workflows/cart-pdp.md * Update src/pages/graphql/payment-services-extension/workflows/cart-pdp.md * Update src/pages/graphql/payment-services-extension/workflows/cart-pdp.md * Apply suggestions from code review Co-authored-by: Kevin Harper <keharper@users.noreply.github.com> --------- Co-authored-by: Kevin Harper <keharper@users.noreply.github.com>
1 parent 3e55a88 commit f260b5b

File tree

7 files changed

+93
-4
lines changed

7 files changed

+93
-4
lines changed

src/data/navigation/sections/graphql.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,6 +1371,10 @@ module.exports = [
13711371
title: "Minicart",
13721372
path: "/graphql/payment-services-extension/workflows/minicart.md",
13731373
},
1374+
{
1375+
title: "Add product to a new cart on a Product Details Page",
1376+
path: "/graphql/payment-services-extension/workflows/cart-pdp.md",
1377+
},
13741378
{
13751379
title: "Vault a card during a checkout authorization",
13761380
path: "/graphql/payment-services-extension/workflows/vault-with-purchase.md",
@@ -1411,6 +1415,10 @@ module.exports = [
14111415
title: "Mutations",
14121416
path: "/graphql/payment-services-extension/mutations/",
14131417
pages: [
1418+
{
1419+
title: "addProductsToNewCart",
1420+
path: "/graphql/payment-services-extension/mutations/add-products-new-cart/",
1421+
},
14141422
{
14151423
title: "createPaymentOrder",
14161424
path: "/graphql/payment-services-extension/mutations/create-payment-order/",
@@ -1423,6 +1431,10 @@ module.exports = [
14231431
title: "createVaultCardSetupToken",
14241432
path: "/graphql/payment-services-extension/mutations/create-vault-card-setup-token/",
14251433
},
1434+
{
1435+
title: "setCartAsInactive",
1436+
path: "/graphql/payment-services-extension/mutations/set-cart-inactive/",
1437+
},
14261438
{
14271439
title: "syncPaymentOrder",
14281440
path: "/graphql/payment-services-extension/mutations/sync-payment-order/",

src/pages/_images/graphql/payment-services-pdp-cartinactive.svg

Lines changed: 4 additions & 0 deletions
Loading

src/pages/_images/graphql/payment-services-pdp.svg

Lines changed: 4 additions & 0 deletions
Loading

src/pages/graphql/payment-services-extension/mutations/add-products-new-cart.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ This mutation is available only if you have installed [Payment Services for Adob
1111

1212
The `addProductsToNewCart` mutation always creates a new cart for the shopper then adds the specified products to that cart. This contrasts with the `addProductsToCart` mutation, which requires you to specify an existing cart ID as input.
1313

14-
>[!NOTE]
15-
>
16-
> For a logged-in customer, the customer token is passed in the [Authorization header](../../usage/authorization-tokens.md#customer-tokens).
14+
For a logged-in customer, the customer token is passed in the [Authorization header](../../usage/authorization-tokens.md#customer-tokens).
1715

1816
## Use case: smart button on the Product Details Page (PDP)
1917

src/pages/graphql/payment-services-extension/mutations/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ If you have installed [Payment Services for Adobe Commerce](https://commercemark
2222

2323
* [`createVaultCardPaymentToken`](../mutations/create-vault-card-payment-token.md)
2424

25-
If you have installed [Payment Services for Adobe Commerce](https://commercemarketplace.adobe.com/magento-payment-services.html) 2.12.0 or higher, you can use the following mutations to manage your carts in the Product page:
25+
If you have installed [Payment Services for Adobe Commerce](https://commercemarketplace.adobe.com/magento-payment-services.html) 2.12.0 or higher, you can use the following mutations to manage your carts in the Product Details Page (PDP):
2626

2727
* [`addProductsToNewCart`](../mutations/add-products-new-cart.md)
2828

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: Add product to a new cart on a Product Details Page
3+
description: Learn how Adobe Commerce uses GraphQL to create a new cart in the Product Details Page with smart buttons (Apple Pay).
4+
keywords:
5+
- GraphQL
6+
- Payments
7+
---
8+
9+
# Create a new cart in the Product Details Page workflows
10+
11+
<InlineAlert variant="info" slots="text" />
12+
13+
This workflow is available only with Apple Pay if you have installed [Payment Services for Adobe Commerce](https://commercemarketplace.adobe.com/magento-payment-services.html) 2.12.0 or higher.
14+
15+
These steps describe the flow of requests and responses with the [Payment Services](https://experienceleague.adobe.com/docs/commerce-merchant-services/payment-services/guide-overview.html) solution enabled for guests and logged-in customers. This workflow is required to [create a new cart](../mutations/add-products-new-cart.md) in the Product Details Page (PDP) with smart buttons.
16+
17+
## Add product to a new cart in a PDP workflow
18+
19+
These steps describe the use case when a shopper adds a product to the cart on a PDP.
20+
21+
![Payment Services sequence diagram](../../../_images/graphql/payment-services-pdp.svg)
22+
23+
1. Run the [`getPaymentConfig`](../../payment-services-extension/queries/get-payment-config.md) query to fetch the payment configuration needed to render details about PayPal components, such as hosted fields, smart buttons, and Apple Pay.
24+
25+
1. Adobe Commerce returns payment configuration information.
26+
27+
1. Run [`addProductsToNewCart`](../../payment-services-extension/mutations/add-products-new-cart.md) to create a new cart and add the item.
28+
29+
1. Commerce returns a `cart` object, which includes the cart `id` field.
30+
31+
1. Run [`createPaymentOrder`](../../payment-services-extension/mutations/create-payment-order.md) to begin the authorization process.
32+
33+
1. Commerce forwards the request to PayPal.
34+
35+
If there is an error during the payment process, or the shopper cancels the payment process on the PDP, run [`setCartAsInactive`](../../payment-services-extension/mutations/set-cart-inactive.md) to set the corresponding `cartId` as inactive and to avoid having multiple active carts for logged-in customers.
36+
37+
1. PayPal returns an `id` value.
38+
39+
1. Adobe Commerce generates a `order_id` and forwards the value in the `mp_order_id` field and the PayPal response in the `id` field.
40+
41+
1. Run the [`placeOrder`](../../schema/cart/mutations/place-order.md) mutation.
42+
43+
1. Commerce sends an authorization request to PayPal.
44+
45+
1. PayPal returns the result to Commerce.
46+
47+
1. Commerce creates an order.
48+
49+
## Payment cancellation while on a PDP workflow
50+
51+
These steps describe the use case when a shopper cancels the payment process on the PDP.
52+
53+
![Payment Services sequence diagram](../../../_images/graphql/payment-services-pdp-cartinactive.svg)
54+
55+
1. Run the [`getPaymentConfig`](../../payment-services-extension/queries/get-payment-config.md) query to fetch the payment configuration needed to render details about PayPal components, such as hosted fields, smart buttons, and Apple Pay.
56+
57+
1. Adobe Commerce returns payment configuration information.
58+
59+
1. Run [`addProductsToNewCart`](../../payment-services-extension/mutations/add-products-new-cart.md) to create a new cart and add the item.
60+
61+
1. Commerce returns a `cart` object, which includes the cart `id` field.
62+
63+
1. Run [`setCartAsInactive`](../../payment-services-extension/mutations/set-cart-inactive.md) to set a specific `cartId` as inactive.
64+
65+
1. Commerce returns a confirmation that a specific `cartId` is inactive.
66+
67+
1. If the shopper clicks the smart button again, `addProductsToNewCart` mutation runs once more to return a new `cart` object.

src/pages/graphql/payment-services-extension/workflows/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ If you have installed [Payment Services for Adobe Commerce](https://commercemark
1717
* [Minicart](../workflows/minicart.md)---This workflow describes the additional flow of requests and responses required to place an order after adding a product to your cart with the Payment Services extension enabled.
1818

1919
* [Checkout using a vaulted card](../workflows/vaulted-card.md)---This workflow describes a checkout authorization using a vaulted card.
20+
21+
If you have installed [Payment Services for Adobe Commerce](https://commercemarketplace.adobe.com/magento-payment-services.html) 2.12.0 or higher, check the following workflows:
22+
23+
* [Smart buttons in the Product Details Page (PDP)](../workflows/cart-pdp.md)---This workflow describes the flow of requests and responses, in Payment Services for guests and logged-in customers, required to create a new cart in the Product Details Page (PDP) with smart buttons.

0 commit comments

Comments
 (0)