Skip to content

Magento 2: How to get payer id to be used in setPaymentMethodOnCart mutation for paypal express checkout

I am trying to get the Payer Id to be used in setPaymentMethodOnCart mutation but don’t know how to get that.

mutation {
  setPaymentMethodOnCart(input: {
    cart_id: "rMQdWEecBZr4SVWZwj2AF6y0dNCKQ8uH"
    payment_method: {
      code: "paypal_express"
      paypal_express: {
        payer_id: "<PayPal_PayerID>"
        token: "<PayPal_Token&gt"
      }
    }
  }) {
    cart {
      selected_payment_method {
        code
        title
      }
    }
  }
}

As mentioned at below link:
Paypal Expres Checkout

I checked the Magento frontend flow and getting payer_id when the users are returned back from paypal to Magento. Can someone help to get the payer_id using graphql/restapi to make payment using paypal express checkout?

Thanks in advance!