Skip to content

Set Payment Method

Set the payment method for a cart.

Authentication

This query supports both authenticated customers and guest users:

  • Authenticated customers: Provide a valid customer authentication token in the Authorization header. Obtain this token via the Customer Login API.
  • Guest users: Provide the Guest Cart Token cartToken obtained from the Create Cart mutation.
Authorization: Bearer <accessToken>

Arguments

NameTypeRequiredDescription
paymentMethodString✅ YesPayment method code (e.g., moneytransfer, paypal)
successUrlString❌ NoURL to redirect on successful payment
failureUrlString❌ NoURL to redirect on failed payment
cancelUrlString❌ NoURL to redirect on cancelled payment

Response

FieldTypeDescription
successBooleanSuccess status
messageStringSuccess or error message
paymentGatewayUrlString | nullPayment gateway URL for external payment processing
paymentDataString | nullAdditional payment data if required

Common Payment Method Codes

CodeDescription
moneytransferMoney Transfer
paypalPayPal
stripeStripe
bank_transferBank Transfer
cash_on_deliveryCash on Delivery (COD)

Prerequisites

  • Billing address must be set
  • Shipping method must be selected
  • Payment method must be enabled in store

Validation Rules

  • Payment method code must be valid and enabled
  • Payment method must be available for the customer's country
  • Redirect URLs must be valid if provided
  • Cart must have items
  • All previous checkout steps must be completed

Error Responses

json
{
  "errors": {
    "paymentMethod": ["Invalid or unavailable payment method."],
    "successUrl": ["The success URL must be a valid URL."],
    "billingAddress": ["Billing address must be set first."],
    "shippingMethod": ["Shipping method must be set first."]
  }
}

Released under the MIT License.