Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkout stuck in processing mode #261

Open
newhub-spec opened this issue Dec 4, 2024 · 3 comments
Open

Checkout stuck in processing mode #261

newhub-spec opened this issue Dec 4, 2024 · 3 comments

Comments

@newhub-spec
Copy link

newhub-spec commented Dec 4, 2024

Description:

The project was installed successfully in Vercel with Host & Stripe Test Key variables. I can add products to the cart but pressing checkout button go in Processing...
woonuxt-problem-1

I have included the Stripe domains in CORS allowed list of GraphQL plugin setting. However, it is still showing the errors.

In Chrome, it is only showing Proxy errors which is the last line of above Mozilla console screenshot:
{
"client": "default",
"operationType": "query",
"operationName": "getStripePaymentIntent",
"statusCode": 200,
"gqlErrors": [
{
"message": "Internal server error",
"extensions": {
"category": "internal"
},
"locations": [
{
"line": 3,
"column": 3
}
],
"path": [
"stripePaymentIntent"
]
}
]
}

I will appreciate the solution to make this great project working.

Thanks & regards.

@orbikular
Copy link

orbikular commented Jan 27, 2025

Go to your checkout.vue and then have a look at the payNow Method.

I moved the following 2 lines:

const { stripePaymentIntent } = await GqlGetStripePaymentIntent();
const clientSecret = stripePaymentIntent?.clientSecret || '';

into the following if.

Which looks like this now:

const payNow = async () => {
  buttonText.value = t('messages.general.processing');
  try {
    if (orderInput.value.paymentMethod.id === 'stripe' && stripe && elements.value) {
      const { stripePaymentIntent } = await GqlGetStripePaymentIntent();
      const clientSecret = stripePaymentIntent?.clientSecret || '';
      const cardElement = elements.value.getElement('card') as StripeCardElement;
      const { setupIntent } = await stripe.confirmCardSetup(clientSecret, { payment_method: { card: cardElement } });
      const { source } = await stripe.createSource(cardElement as CreateSourceData);

      if (source) orderInput.value.metaData.push({ key: '_stripe_source_id', value: source.id });
      if (setupIntent) orderInput.value.metaData.push({ key: '_stripe_intent_id', value: setupIntent.id });

      isPaid.value = setupIntent?.status === 'succeeded' || false;
      orderInput.value.transactionId = source?.created?.toString() || new Date().getTime().toString();
      deleteThumbnails();
    }
  } catch (error) {
    console.error(error);
    buttonText.value = t('messages.shop.placeOrder');
  }

  proccessCheckout(isPaid.value);
  try {
    gtag_report_conversion();
    console.warn('gtag_report_conversion');
  } catch (e) {
    console.error(e);
  }
};

Otherwise the code is trying to get a payment intent even if you have selected another payment option.

If you are about to pay with stripe, this probably won't resolve the issue.

@alexookah
Copy link
Contributor

@orbikular
Could you make a PR to check your suggested solution?

@alexookah
Copy link
Contributor

@orbikular
i think your proposed changes fix this issue. can you make a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants