AvailablePaymentMethodsQuery
Description
Retrieves available payment methods for a cart.
This page documents the checkoutPaymentMethods operation registered in CheckoutPaymentMethodsQuery.
Endpoint
query checkoutPaymentMethods($cartId: String!, $country_code: String, $shipping_method: String, $site_id: Int) {
checkoutPaymentMethods(cartId: $cartId, country_code: $country_code, shipping_method: $shipping_method, site_id: $site_id) {
# Return fields
}
}
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
| cartId | String | Yes | The unique identifier of the cart for which to retrieve payment methods. This ID is obtained from createGuestCart or createCustomerCart mutations. |
| country_code | String | No | The country code to use for determining available payment methods. If not provided, the store's default country will be used. |
| shipping_method | String | No | The shipping method code to use for determining available payment methods. Some payment methods may only be available with certain shipping methods. |
| site_id | Int | No | The site ID to use for determining available payment methods. If not provided, the current site ID will be used. |
Return Values
The query returns an array of PaymentMethod objects with the following fields:
| Field | Type | Description |
|---|---|---|
| code | String | The code of the payment method (e.g., "checkmo", "paypal"). |
| title | String | The display name of the payment method. |
| instructions | String | Any special instructions or information about the payment method. |
| amount | Money | The cost of using this payment method, if applicable. |
Money Structure
The amount field uses the Money structure:
| Field | Type | Description |
|---|---|---|
| value | Float! | The numerical value of the amount. |
| currency | String! | The currency code (e.g., "USD"). |
Usage Example
query {
checkoutPaymentMethods(
cartId: "abc123",
country_code: "US",
shipping_method: "flatrate"
) {
code
title
instructions
amount {
value
currency
}
}
}
Example Response
{
"data": {
"checkoutPaymentMethods": [
{
"code": "checkmo",
"title": "Check / Money Order",
"instructions": "Please send a check to Store Name, Store Street, Store Town, Store State / County, Store Postcode.",
"amount": {
"value": 0.00,
"currency": "USD"
}
},
{
"code": "paypal",
"title": "PayPal",
"instructions": "You will be redirected to the PayPal website after submitting your order.",
"amount": {
"value": 0.00,
"currency": "USD"
}
}
]
}
}
Notes
- The available payment methods may vary based on the cart contents, shipping address, shipping method, and store configuration.
- Some payment methods may have additional fees, which are reflected in the
amountfield. - The
instructionsfield provides information that should be displayed to the customer when they select the payment method. - To set a payment method on the cart, use the
setPaymentMethodOnCheckoutmutation. - The country code should be a valid two-letter ISO country code (e.g., "US", "GB", "DE").
- The shipping method code should match one of the codes returned by the
checkoutShippingMethodsquery. - Different payment methods may have different behaviors during the checkout process. Some payment methods may redirect the user to an external payment gateway after the order is placed.
- If
country_code,shipping_method, orsite_idis omitted, plugin defaults and cart-selected method are used where available.