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.
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"
}
}
}
Input attributes
The CreatePaymentOrderInput object contains the following input attributes:
cartIdlocationPRODUCT_DETAIL, MINICART, CART, CHECKOUT, ADMINmethodCodepaymentSourcecc), PayPal (paypal), and Apple Pay (applepay)vaultIntenthosted_fields payment method. The default value is falseOutput attributes
The CreatePaymentOrderOutput object contains the payment order details that are needed to fulfill a payment.
idmp_order_ididamountcurrency_codeSee PayPal currency codes documentation for more information.