Skip to main content
Version: 1.0.0

AvailablePaymentMethodsQuery

Description

Retrieves available payment methods for a cart. This query allows you to fetch all payment methods that can be used for a specific cart, including their costs and instructions.

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

ArgumentTypeRequiredDescription
cartIdStringYesThe unique identifier of the cart for which to retrieve payment methods. This ID is obtained from createGuestCart or createCustomerCart mutations.
country_codeStringNoThe country code to use for determining available payment methods. If not provided, the store's default country will be used.
shipping_methodStringNoThe shipping method code to use for determining available payment methods. Some payment methods may only be available with certain shipping methods.
site_idIntNoThe 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:

FieldTypeDescription
codeStringThe code of the payment method (e.g., "checkmo", "paypal").
titleStringThe display name of the payment method.
instructionsStringAny special instructions or information about the payment method.
amountMoneyThe cost of using this payment method, if applicable.

Money Structure

The amount field uses the Money structure:

FieldTypeDescription
valueFloat!The numerical value of the amount.
currencyString!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 amount field.
  • The instructions field 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 setPaymentMethodOnCheckout mutation.
  • 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 checkoutShippingMethods query.
  • 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.