I'm building an SPA with Svelte that's supported by Craft and Craft Commerce. Currently, I'm fetching products, building the cart locally, syncing it with the server, and taking payments using Stripe and the card element. I've got Craft module interfacing between Commerce and the client. It works really well, and the order completes absolutely fine. I have a few questions:

  1. The way Craft Commerce likes to work is you create a payment method and pass the ID to Commerce so payment can be taken server-side. The advantage of this method is you can make use of the Commerce backend for handling refunds, etc. But don't I need to be redirecting some users to their bank for authentication? Which suggests it all needs to happen client-side? Right now, if I use a Stripe test card that requires SCA2, it fails, of course.

  2. The official Stripe plugin supports SCA. How is this implemented, when payment isn't taken at the frontend? I've never seen a redirect to a bank once in my testing.

  3. In this talk (https://dotall.com/sessions/headless-commerce-with-craft-cms-and-gatsby), Brian creates a token for the transaction and passes that to Commerce, I think. How might he be doing this? Conceptually.

  4. So I can better support Google Pay and Apple Pay, I'm wanting to take payment on the client-side, which is quite a change. At the moment, I'm thinking that after taking payment client-side, I need to create a transaction using my Craft module (using the Commerce transactions service), then complete payment (using the payments controller) and mark the order as complete (using the order element's markAsComplete method) in Commerce. But I feel if I go this way, I've got to pretty much replicate all of Commerce's payment functionality, such as refunds, partial transactions, etc. Is this broadly the right path I should be taking?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.