Edit in GitHubLog an issue

createPaymentOrder mutation

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

Copied to your clipboard
mutation {
createPaymentOrder(
input: CreatePaymentOrderInput!
) CreatePaymentOrderOutput
}

Example usage

The following example creates a payment order. The payment method was previously set to payment_services_paypal_hosted_fields.

Request:

Copied to your clipboard
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:

Copied to your clipboard
{
"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:

AttributeData TypeDescription
cartId
String!
The unique ID of the cart
location
PaymentLocation!
The origin location for that payment request. The possible values are

PRODUCT_DETAIL, MINICART, CART, CHECKOUT, ADMIN methodCode | String! | The code for the selected payment method paymentSource | String! | The payment source for the payment method. The possible values are credit card (cc), PayPal (paypal), and Apple Pay (applepay) vaultIntent | Boolean | Indicates whether the payment information should be vaulted. This attribute is only applicable to the hosted_fields payment method. The default value is false

Output attributes

The CreatePaymentOrderOutput object contains the payment order details that are needed to fulfill a payment.

AttributeData TypeDescription
id
String
The unique order ID generated by PayPal
mp_order_id
String
The unique order ID generated in Commerce if Payment Services is enabled after PayPal returns the id
status
String
The status of the payment order. See order status for more information
amount
Float
The amount of the payment order
currency_code
String
The currency code of the payment order

See PayPal currency codes documentation for more information.

  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.