#timothyWU-commercejs

1 messages · Page 1 of 1 (latest)

vagrant sail
#

Sure! Although I don't think we have some official doc specifically for commercejs

tranquil galleon
#

hello ! thanks for the quick response !

#

but like i said, i m a newbie so i don t really know how to use this implementation with stripe element so i was wondering if i could get some help 😅

#

but know i m a bit lost about what to do to

vagrant sail
#

Looks like you are better stick with the Commercejs Doc

#

It uses a bit old integration on Card Element (We have a newer Payment Element component) tho

tranquil galleon
#

so i have to remove all of the thing i ve made with your doc or ? i m sorry i m very bad in devellopement

vagrant sail
#
const order = await commerce.checkout.capture(checkoutTokenId, {
      ...orderDetails,
      // Include Stripe payment method ID:
      payment: {
        gateway: 'stripe',
        stripe: {
          payment_method_id: paymentMethodResponse.paymentMethod.id,
        },
      },
    })

This part let me believe commerce.checkout is a dedicated commercejs component

#

Unfortunately yes, if you are willing to continue with commercejs

#

If you don't use them then it's totally fine to continue with our official Doc

#

And you have a newer component

tranquil galleon
#

thx, but i ve already put my database on commercejs it s gonna be hard only using stripe it ll take a lot of time

vagrant sail
#

Sure, so let's just continue with the their guide

tranquil galleon
#

and if i understand correctly, i have to replace the page /api/create-payment-flow by their exemple ?

vagrant sail
#

Rather removing instead of replacing

#

I think commercejs does all the headless backend for you, so you won't need a backend yourself

tranquil galleon
#

ok, and i where should i put this exemple? in the folder api like create-payment-intent ? or on the client side on a page ?

#

my project is like this

vagrant sail
#

Should be client side

tranquil galleon
#

ok si i have to put in the payement.js files where i was calling only stripe like your doc were doing ?

meager harbor
#

Hi! I'm taking over this thread.

#

Unfortunately we don't know how commercejs works here. So I would recommend to ask your questions to commercejs support directly.

tranquil galleon
#

ok ! thx a lot for your time

meager harbor
tranquil galleon
#

thx

meager harbor
tranquil galleon
#

ok thx, and if i want to use the elements on stripe.js ? how can i import or get it ?

#

i have something like that

meager harbor
#

Once you loaded Stripe js with const stripe = Stripe('pk_test_xxx'), you can create an element like this const elements = stripe.elements() and const card = elements.create("card").

tranquil galleon
#

when i try to get Stripe it s give me this error

meager harbor
tranquil galleon
#

yes i loaded it on the first line

#

line 77

outer parrot
#

looks like more of a typescript error than anything actually problematic

#

why aren't you using loadStripe? If you're using React that's what you need to do.

#

overall I suggest you ask the community of that plugin you're using, there's a link to a Slack server in their documentation and they likely have developer support there and can help with integrating with their own docs. We can only really help you here if you're building a vanilla integration with our products and not via that third party

tranquil galleon
outer parrot
#

yeah but that doesn't make sense to me since the code in your screenshot is clearly React

#

the code in that third party page you linked doesn't look like React though, so I don't know what you're doing overall or if that project uses React or not

tranquil galleon
tranquil galleon
#

and i m very new in devellopement, and for now i don t have other choice than following what they give me as example

outer parrot
#

well you could not use React, that seems to be adding complication

#

like just use their exact basic vanilla-JS sample from scratch

#

if you're new it's going to be hard to take some existing project and integrate with another existing project using two different frameworks so you need to start simple

tranquil galleon
#

yes but my entire project has been built in react so i don t have other choice

tranquil galleon
outer parrot
#

maybe ask your more experienced colleagues for help then

tranquil galleon
#

they only know a bit

outer parrot
#

I see

tranquil galleon
#

so i should try to transform this implementation in react ?

outer parrot
#

I mean you might not be able to since it's a third party library intended for vanilla JS. I don't know, I never heard of this library before today

#

if you want to use React maybe try integrating with Stripe directly(https://stripe.com/docs/stripe-js/react) instead of that commerceJS, I don't know your requirements and I can't do your job for you