Adobe Commerce 2.3 reached end of support in September 2022.

Express Checkout for other PayPal solutions

Set the payment method code to payflow_express to process Express Checkout transactions when the payment method is set to any of the following:

  • Payflow Link
  • Payflow Pro
  • Payments Advanced
  • Payments Pro

PayPal Express Checkout enables customers to pay by credit card or from the security of their personal PayPal accounts. During checkout, the customer is redirected to the secure PayPal site to complete the payment information. The customer is then returned to the store to complete the remainder of the checkout process.

From a GraphQL integration standpoint, this payment method is identical to the PayPal Express Checkout payment method, with the exception that in the setPaymentMethodOnCart mutation, the payment method code is set to payflow_express.

PayPal Express Checkout workflow

The following diagram shows the workflow for placing an order when payflow_express is the specified payment method.

PayPal Express Checkout sequence diagram

The following steps describe the flow of calls required to complete a typical PayPal Express Checkout authorization. A successful purchase requires that you send three mutations to PayPal, and the buyer must approve the purchase by logging in to PayPal.

  1. When the buyer clicks a PayPal button, the frontend executes the createPaypalExpressToken mutation.

  2. Magento requests a secure token from PayPal. Magento gathers information in the specified cart and sends this information to PayPal as part of a request for a secure token.

  3. If the token request succeeds, PayPal returns a token. You must include this token in subsequent steps.

  4. Magento sends the token to the client. The createPaypalExpressToken response includes the token and the PayPal URLs to be used in the next step.

  5. Redirect the customer to PayPal for approval. Depending on your implementation, the customer is either redirected to the PayPal login screen, or the customer enters their credentials in-context.

  6. If the customer approves the payment, PayPal redirects the customer back to the payment confirmation page. The response includes the secure token and payer ID as GET parameters.

  7. Set the payment method. The frontend runs the setPaymentMethodOnCart mutation. The payload includes the PayPal token, the payer ID, and the cart ID. The cart may have been updated since the token was requested, as shipping costs, taxes, and other adjustments might have been applied to the cart. Magento submits the updated cart to PayPal.

  8. Magento returns a Cart object.

  9. Place the order with the placeOrder mutation.

  10. Magento sends the secure token, payer ID, and final cart information to PayPal.

  11. PayPal captures the payment by transferring the funds from the customer account to the appropriate merchant account.

  12. Magento creates an order, ready for fulfillment.

setPaymentMethodOnCart mutation

When you set the payment method to one of the Express Checkout payment solutions discussed in this topic, you must set the code attribute to payflow_express. In addition, the payload must contain a payflow_express object, which defines the following attributes:

Attribute Data Type Description
payer_id String! The unique ID of the PayPal customer
token String! The token returned by the createPaypalExpressToken mutation

Example usage

The following example shows the setPaymentMethodOnCart mutation with the code set to payflow_express.

Request:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
mutation {
  setPaymentMethodOnCart(input: {
    cart_id: "rMQdWEecBZr4SVWZwj2AF6y0dNCKQ8uH"
    payment_method: {
        code: "payflow_express"
        payflow_express: {
          payer_id: "<PayPal_PayerID>"
          token: "<PayPal_Token>"
        }
      }
  }) {
    cart {
      selected_payment_method {
        code
      }
    }
  }
}

Response:

1
2
3
4
5
6
7
8
9
10
11
{
  "data": {
    "setPaymentMethodOnCart": {
      "cart": {
        "selected_payment_method": {
          "code": "payflow_express",
        }
      }
    }
  }
}