pevey / sveltekit-medusa-starter

Starter project to help you create your Medusa-powered ecommerce application
MIT License
121 stars 13 forks source link

Type error every time trying to make a payment with Stripe #6

Open wwwonka opened 1 year ago

wwwonka commented 1 year ago

After setting up all my environment variables, everything is working correctly(turnstile, address autocompletion, stripe loading)

Only the payments fail although they show up in Stripe Dashboard as "incomplete"

This is the error in the console:

Screenshot 2023-11-21 at 07 34 25@2x

Something seems to be broken in this function but I can't tell what:

 // confirm payment
    const stripeResponse = await $stripeClient.confirmPayment({ elements: $stripeElements, redirect: 'if_required' })
        if (stripeResponse.error) {
            errorMessage = stripeResponse.error.message
            processing = false
            cancel()
        } else {
            return async ({ result }) => {
                if (result.status === 200) {
                    success = true
                    order = result.data.order
                } 
            }
    }

Any ideas?

pevey commented 1 year ago

I think this probably has to do with updates to the Stripe client. You now have to include a submit() step in your Stripe checkout flow, but I haven't updated the Medusa starter to include this since I work with Vendure these days instead of Medusa.

Here is a link to an example from the Vendure starter I'm working on. The relevant part starts on line 188. https://github.com/pevey/saluna/blob/main/src/routes/checkout/%2Bpage.svelte

I hope to one day circle back and refactor this Medusa starter to include some of the improvements added when I made the Vendure starter.

amcolex commented 11 months ago

@pevey Was there any specific reason that you switched to Vendure vs Medusa?

p.s. thanks for your starter-kits :)

pevey commented 10 months ago

Medusa just has a lot of little things that are frustrating that add up to make for a much less fun developer experience than with Vendure.

For instance, Vendure uses graphql, and it is really easy to use codegen to generate a ts file of types from your backend to use in your frontend project. The autocomplete and error-checking that comes from fully embracing types in the frontend is huge. With Medusa, that is impossible. Only recently, they added a separate package, @medusajs/types, to try to address this. But after months, it is still incomplete. I just wasted an hour or so thinking, well, I will update this starter to incorporate some of the updates I've made to the Vendure storefront starter. But then I hit a wall with missing types in the types package (still no Collection or Category types). And even if the package were complete, the approach is inferior to the Vendure approach. Types generated from your own backend will include all custom entities and properties you've defined in plugins. The Medusa types package obviously will not.

Vendure is also easier to customize. It is coded mostly by one person, which is both a positive and a negative. Positives: The vision is very clear. The code is very clean, very consistent, and it implements dependency injection extremely well.

I love that Medusa exists, and I've gotten much use out of it, and the team is great. So I try to not to say negative things. But it sadly is just not the best option right now. I don't see a clear vision. If you haven't already set up your store in Medusa, my opinion is that it's an easy decision to use Vendure. It's a harder decision if it is a matter of switching. I don't regret switching, though.