Skip to Content

paymentMethods

Retrieve all available payment methods supported by the store.

Query Structure

query { paymentMethods { id name description enabled } }

Arguments

ArgumentTypeDescriptionRequiredDefault
NoneN/AThis query does not accept any arguments.NoN/A

Return Type

[PaymentMethod]

Each PaymentMethod object contains the following fields:

FieldTypeDescription
idIntUnique identifier for the payment method.
nameStringThe display name of the payment method.
descriptionStringA brief description of the payment method.
enabledBooleanIndicates if the payment method is currently enabled.

Examples

Basic Query

query { paymentMethods { id name } }

Advanced Query

query { paymentMethods { id name description enabled } }

Field Selection

query { paymentMethods { name enabled } }

cURL Example

curl -X POST https://www.mystoreurl.com/graphql/0.8.0/ \ -H "Content-Type: application/json" \ -d '{"query":"query { paymentMethods { id name description enabled } }"}'

JavaScript Example

async function fetchPaymentMethods() { const query = ` query { paymentMethods { id name description enabled } } `; try { const response = await fetch('https://www.mystoreurl.com/graphql/0.8.0/', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ query }), }); const result = await response.json(); if (result.errors) { console.error('GraphQL errors:', result.errors); return; } console.log('Available payment methods:', result.data.paymentMethods); } catch (error) { console.error('Network or fetch error:', error); } } fetchPaymentMethods();

Response Format

The response contains a data object with a paymentMethods array. Each element in the array is a PaymentMethod object with the fields requested.

Example response:

{ "data": { "paymentMethods": [ { "id": 1, "name": "Credit Card", "description": "Pay using credit or debit card.", "enabled": true }, { "id": 2, "name": "PayPal", "description": "Secure payment via PayPal.", "enabled": true }, { "id": 3, "name": "Bank Transfer", "description": "Direct bank transfer payment.", "enabled": false } ] } }

Error Handling

Possible error scenarios include:

Error CodeDescriptionHandling Recommendation
400Bad Request - malformed query or syntax error.Verify query syntax and structure.
500Internal Server Error - unexpected server issue.Retry after some time or contact support.
GRAPHQL_VALIDATION_FAILEDQuery validation failed.Check query fields and arguments.

Errors are returned in the errors array in the GraphQL response. Always check for the presence of errors before processing data.

Performance Considerations

  • This query returns all available payment methods without pagination or filtering.
  • Since the dataset is typically small, performance impact is minimal.
  • Avoid requesting unnecessary fields to reduce response size.
  • Cache responses where possible, as payment methods change infrequently.
  • Rate limiting applies globally to the API; avoid excessive query frequency.

Authentication

This API currently does not require authentication. However, authentication requirements may be introduced in future versions. Monitor API updates for any changes to authentication requirements.

PaymentMethod

FieldTypeDescription
idIntUnique identifier for the payment method.
nameStringThe display name of the payment method.
descriptionStringA brief description of the payment method.
enabledBooleanIndicates if the payment method is currently enabled.

Notes

  • The paymentMethods query does not accept any arguments.
  • Use field selection to optimize the response payload.
  • The enabled field helps determine which payment methods are currently active and available for checkout.
  • Keep your client-side cache updated if payment methods are subject to change in your store.
Last updated on