How to use external modules : Node js

Step 1: Installed stripe node js module to my wix website - https://github.com/stripe/stripe-node

Step 2: Import stripe module in wix/corvid backend/webmodules with "import Stripe from 'stripe'"

Issue: Can not find module stripe

jwt code :
import Stripe from 'stripe';
export function getStripeInstance() {
return new Stripe('pk_test_ww.........');
}

Please observer the Community Guidelines and refrain from multiple posts/comments on the same question. Also, only put your code in a code block, not your entire post.

The error message on the import can be ignored. In spite of the error, Stripe is available. This is a known issue and will be fixed.

Sure, You mean stripe is available to install but we can’t use it as of now ?

@dhiraj No, I mean ignore the error. It’s available to install, and it works.

@Yisrael (Wix) Then may be I'm doing something wrong as I'm not getting any response from stripe functions.

Client side code

import { getStripeInstanceJWT } from 'backend/stripe-test'//server side
import Stripe from 'stripe'; //client side

    //CLIENT SIDE
    const st = new Stripe("pk_test_ww....");
    console.log(st.charges.create({
                                //params
                                 })
                                 .then((resp) =>    {
                                 console.log(resp);
                                 })
                                 .catch((ex) =>
                                 {
                                 console.log(ex);//can not find web module stripe
                                 }));

// BACKEND
getStripeInstanceJWT().then((r) => { console.log(r) })
.catch((ex) => { console.log(ex.message) }); //can not find web module stripe
});

@dhiraj You need to use the Stripe NPM library in the backend. I’m not sure it will work client-side, not to mention that it would not be secure as you would be exposing sensitive information (keys, data, etc) to visitor.

@yisrael-wix I’ve tried both ways(please refer the code I’ve posted above).

Approach one : Call stripe functions in backend (say stripe.jsw) and then call those function from front-end.
step 1: install stripe node package
step 2: import stripe in the backend(import Stripe from ‘stripe’ )
step 3: write functions in backend to interact with stripe
step 4: import backend/jwt in fount end code and consume the functions .

Approach 2: Import stripe directly on from-end and consume the functions

@dhiraj Are your backend functions in a web-module (.jsw) file?

@dhiraj Also, please do not put your entire post in a code block. Just put the code .

@yisrael-wix Yes, I tried with “.jsw” and “.js” both.

@dhiraj Understand that we are unable to debug or rewrite complex code and page configurations. However, I’ll look at it and try to at least figure out what’s going on. Please post the editor URL of your site. Only authorized Wix personnel can get access to your site in the editor. Please include the name of the page involved.

@yisrael-wix https://wix.com/editor/b21aa3f5-7d56-43db-82f9-7965b637f7af?editorSessionId=a8ee57cd-92e1-49c5-8a3f-195e381d5b43&referralInfo=dashboard Page name : tests (blank-2). Event : On button3 click I want to get stripe instance. Issue: Promise is taking me to “Module not found error” always.

@Dhiraj Saini I click on #button3 and I get this error message in the console:
Converting circular structure to JSON
So, what that tells me is that the Stripe library responds. but you are getting ill-formed results.

The Stripe NPM library is not a part of the Corvid product (which is what this forum is about). You will need to refer to the Stripe documentation and follow their examples. For more information, you can also go to the Stripe repository .

You might also consider using the Stripe example as it is well-tested.

Another option would be to configure Wix Pay to use Stripe .