wp-graphql / wp-graphql-woocommerce

Add WooCommerce support and functionality to your WPGraphQL server
https://woographql.com
GNU General Public License v3.0
644 stars 131 forks source link

Getting the valid paymentMethod on checkout mutation #641

Closed nd0nd0 closed 2 years ago

nd0nd0 commented 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?

kidunot89 commented 2 years ago

@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.

nd0nd0 commented 2 years ago

Thank you, that fixed the issue.