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

Stripe webhook handler is failing #10092

Closed
2 tasks done
DiegoRam opened this issue Nov 13, 2024 · 5 comments
Closed
2 tasks done

Stripe webhook handler is failing #10092

DiegoRam opened this issue Nov 13, 2024 · 5 comments

Comments

@DiegoRam
Copy link

What Medusa version and documentation are you using?

v2

Preliminary Checks

Issue Summary

I've integrated stripe successfully following through all docs, but I think I missing the happy path.

resolve: "@medusajs/medusa/payment", options: { providers: [ { resolve: "@medusajs/medusa/payment-stripe", id: "stripe", options: { apiKey: process.env.STRIPE_API_KEY, webhookSecret: process.env.STRIPE_WEBHOOK_SECRET }, },
this is my medusa-config.ts entry
But on DB it's created the payment provider with this ID
pp_stripe_stripe

problem im getting into is on handler webhooks actually
When stripe sends me a new event like payment_intent.succesful, logs are reporting me this

{"level":"error","message":"An error occurred while processing payment.webhook_received: Error: Could not find a payment provider with id: pp_stripe","timestamp":"2024-11-13 19:59:05"} do_app_name:starfish-app do_component_name:aec-chile-backend _id:cKobJ5MBaBimwrJera5c _type: - _index:logs _score: -

please notice payment provider id reported: pp_stripe
Where I should keep looking for the issue?

How can this issue be resolved?

...

Are you interested in working on this issue?

  • I would like to fix this issue
@Xarenn
Copy link

Xarenn commented Nov 14, 2024

It's not working for me also...

error: An error occurred while processing payment.webhook_received: Error: Could not find a payment provider with id: pp_stripe http: POST /hooks/payment/stripe ← - (200) - 9.047 ms info: Processing payment.webhook_received which has 1 subscribers error: An error occurred while processing payment.webhook_received: Error: Could not find a payment provider with id: pp_stripe http: POST /hooks/payment/stripe ← - (200) - 2.829 ms http: POST /store/payment-collections/pay_col_01JCKZWWM99YHRAWPHH78JM4NM/payment-sessions ← - (200) - 1158.875 ms http: GET /store/carts/cart_01JCKZW1HPT6FMF4ER5W5WAMRJ ← - (200) - 26.212 ms http: GET /store/products?id%5B0%5D=prod_01JCKXP8ZBWPWN9XK42FQQ81ZN&region_id=reg_01JCKXD5H9X9MGR3TBMJMZPHT0&fields=%2Avariants.calculated_price%2C%2Bvariants.inventory_quantity ← - (200) - 29.818 ms http: GET /store/customers/me ← - (401) - 6.080 ms info: Processing payment.webhook_received which has 1 subscribers error: An error occurred while processing payment.webhook_received: Error: Could not find a payment provider with id: pp_stripe info: Processing payment.webhook_received which has 1 subscribers error: An error occurred while processing payment.webhook_received: Error: Could not find a payment provider with id: pp_stripe

@sradevski
Copy link
Member

Thanks for opening a ticket, we'll have a look into it.

@DiegoRam
Copy link
Author

@sradevski I forgot to mention that when I've integrated stripe, pp_stripe_stripe provider id was created, that's why webhook is not finding that provider id

@olivermrbl
Copy link
Contributor

Hey @DiegoRam, could you please update your issue to follow our bug report template? Would make it a whole lot easier for us to help out 🙏

@adrien2p
Copy link
Member

@DiegoRam thank you very much for opening this issue.
I ve open a pr in order to improve the error message in order to make it clearer what is happening. On the other hand, the issue is link to the webhook path that is being used. We will improve the documentation around it soon but let me share what should be the webhook path here. cc @shahednasser

When configuring your stripe provider you provided an id, under the hood we are creating a unique key to register the provider in the container. The key is composed as follow: pp_${provider.identifier}_${id}, here the idenfier is a static value on the class of the provider, for stripe it is one of the following values:

export const PaymentProviderKeys = {
  STRIPE: "stripe",
  BAN_CONTACT: "stripe-bancontact",
  BLIK: "stripe-blik",
  GIROPAY: "stripe-giropay",
  IDEAL: "stripe-ideal",
  PRZELEWY_24: "stripe-przelewy24",
  PROMPT_PAY : "stripe-promptpay",
}

when you configure the web hook end point in your stripe dashboard, we expect the last segment to be as follow: ${identifier}_${id} with the id being the one in your medusa config and the idenfier being one of the above depending on the provider you are using.

Let me know if that make sense 👍

@linear linear bot closed this as completed Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants