Closed nd0nd0 closed 2 years ago
const checkOutData = { clientMutationId: v4(), customerNote: orderNote, paymentMethod: 'COD', isPaid: true, shipping: {...}, billing: {...} };
const [checkout, { data: checkoutResponse, loading: checkoutLoading }] = useMutation(CHECKOUT_MUTATION, { variables: { input: checkOutData }, onError: (error) => { if (error) { setRequestError(error?.graphQLErrors?.[0]?.message ?? ''); } }, });
const CHECKOUT_MUTATION = gql ' mutation CHECKOUT_MUTATION($input: CheckoutInput!) { checkout(input: $input) { clientMutationId order { id orderKey orderNumber status } result redirect } } ';
Error: Invalid payment method. Could I be doing something wrong here?
@nd0nd0 you should be using cod not COD. cod is the Cash On Delivery payment gateway id. And that is what the paymentMethod field expects.
cod
COD
id
paymentMethod
Thank you, that fixed the issue.
const checkOutData = { clientMutationId: v4(), customerNote: orderNote, paymentMethod: 'COD', isPaid: true, shipping: {...}, billing: {...} };
const [checkout, { data: checkoutResponse, loading: checkoutLoading }] = useMutation(CHECKOUT_MUTATION, { variables: { input: checkOutData }, onError: (error) => { if (error) { setRequestError(error?.graphQLErrors?.[0]?.message ?? ''); } }, });
const CHECKOUT_MUTATION = gql ' mutation CHECKOUT_MUTATION($input: CheckoutInput!) { checkout(input: $input) { clientMutationId order { id orderKey orderNumber status } result redirect } } ';
Error: Invalid payment method. Could I be doing something wrong here?