Payment services minicart workflow
These steps describe the additional flow of requests and responses required to place an order after adding a product to your cart with the Payment Services solution enabled.
Minicart workflow
-
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
createPaymentOrderto begin the authorization process. -
Commerce forwards the request to PayPal.
-
PayPal returns an
idvalue. -
Commerce generates an
order_idand forwards the value in themp_order_idfield and in the PayPal response in theidfield. -
Run the
syncPaymentOrdermutation to get payment details and update the quote with shipping, billing, email, and phone number details. -
Commerce returns details about the payment order.
-
Run the
setShippingMethodsOnCartmutation to define the delivery methods for your order. -
Commerce returns details about the delivery methods for your order.
-
Run the
placeOrdermutation. -
Commerce sends an authorization request to PayPal.
-
PayPal returns the result to Commerce.
-
Commerce creates an order.
setPaymentMethodOnCartInput object
For the PayPal Smart Buttons and Apple Pay payment methods, you do not need to run the setPaymentMethodOnCart mutation. The hosted fields payment method requires that you run the mutation only if one of the following conditions are true:
-
You intend to vault a card by setting
is_active_payment_token_enablertotrue. -
You have a stored payment method checkout where you intend to use a stored card by setting a
public_hashvalue.
In these cases, the payment_method object must contain a payment_services_paypal_hosted_fields object.
payment_services_paypal_hosted_fields object
The payment_services_paypal_hosted_fields can contain the following attributes:
cardBincardExpiryMonthcardExpiryYearcardLast4holderNameis_active_payment_token_enablerpayments_order_idpaypal_order_idpaypal_order_idpayment_sourcesetPaymentMethodOnCart mutation example
The following example sets the payment method to payment_services_paypal_hosted_fields:
Request:
mutation {
setPaymentMethodOnCart ( input: {
cart_id: "uocGxUi5H97XFAMhY3s66q4aFYG3Bmdr",
payment_method: {
code: "payment_services_paypal_hosted_fields",
payment_services_paypal_hosted_fields: {
payment_source: "cc",
payments_order_id: "mp-order-a4babd34-13d3-4ac0-b1b0-109bb7be1574",
paypal_order_id: "9R90936863877801D",
is_active_payment_token_enabler: true
}
}
}
) {
cart {
id
selected_payment_method {
code
}
}
}
}
Response:
{
"data": {
"setPaymentMethodOnCart": {
"cart": {
"id": "r8TKHa58b7Y8VaZHLyABNxrEdS8hJJTZ",
"selected_payment_method": {
"code": "payment_services_paypal_hosted_fields"
}
}
}
}
}