Vault a card during a checkout authorization
These steps describe the flow of requests and responses required to vault a credit card during a typical checkout authorization with Payment Services enabled.
The following conditions must be true to vault a card during checkout:
- You must have installed Payment Services for Adobe Commerce 2.10.0 or higher.
- The customer must be logged in.
Workflow
Run the
getPaymentConfig
query to fetch the payment configuration needed to render details of hosted fields.Commerce returns the payment configuration information.
Run the
setPaymentMethodOnCart
mutation to set the payment method.Adobe Commerce returns a
Cart
object.Run the
createPaymentOrder
mutation withvaultIntent
set totrue
to begin the authorization process.Commerce forwards the request to PayPal.
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
setPaymentMethodOnCart
again withis_active_payment_token_enabler
set totrue
. This indicates whether a customer-entered credit/debit card should be tokenized for later usage.Adobe Commerce returns a token.
(Optional) If hosted fields and the Signifyd integration are enabled, run the
getPaymentOrder
query.(Optional) Adobe Commerce returns details about the payment order.
Run the
placeOrder
mutation.Commerce sends an authorization request to PayPal.
PayPal returns the result to Commerce.
Commerce creates an order.
Paypal returns a vault token.
Commerce stores the vault token for the vaulted card.
Additional information
It is only possible to vault configuration details for hosted fields. See getPaymentConfig
query for more information.
setPaymentMethodOnCart
mutation example
The following example shows the setPaymentMethodOnCart
mutation with the attribute is_active_payment_token_enabler
set to true
.
Request:
Copied to your clipboardmutation {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 {idselected_payment_method {code}}}}
Response:
Copied to your clipboard{"data": {"setPaymentMethodOnCart": {"cart": {"id": "uocGxUi5H97XFAMhY3s66q4aFYG3Bmdr","selected_payment_method": {"code": "payment_services_paypal_hosted_fields"}}}}}