createPaymentOrder mutation
data-variant=info
data-slots=text
The createPaymentOrder mutation creates a payment order for later processing with Payment Services enabled.
The mutation can return details about the following payment methods supported in Payment Services:
- Apple Pay
- Google Pay
- PayPal Hosted Fields
- PayPal Smart Buttons
Each of these payment methods can have a different payment source, for example, PayPal Hosted Fields only works with credit cards. You need to run getPaymentConfig and setPaymentMethodOnCart endpoints before running the createPaymentOrder mutation.
See PayPal currency codes documentation for more information about the value of the currency_code in the response.
Syntax
mutation {
createPaymentOrder(
input: CreatePaymentOrderInput!
) CreatePaymentOrderOutput
}
Reference
The createPaymentOrder reference provides detailed information about the types and fields defined in this mutation.
Example usage
The following example creates a payment order. The payment method was previously set to payment_services_paypal_hosted_fields.
Request:
mutation {
createPaymentOrder(input: {
cartId: "AJCY8dhIfuch9LcDHAxEkw7oG3DjGdKt"
methodCode: "payment_services_paypal_hosted_fields"
paymentSource: "cc"
location: CHECKOUT
vaultIntent: false
}) {
id
mp_order_id
status
amount
currency_code
}
}
Response:
{
"data": {
"createPaymentOrder": {
"id": "9SA28234K9340625D",
"mp_order_id": "mp-order-8b0488f9-46c5-4640-b577-c5f7d90cf224",
"status": "CREATED",
"amount": 50,
"currency_code": "USD"
}
}
}