#volco
1 messages · Page 1 of 1 (latest)
Hi there!
Are you trying to load Stripe on the Frontend? Are you using plain JavaScript or React or something else?
Yes loading Stripe on the frontend, using typescript
I tried on vanilla js as well but had the same issue. Just confused if Im missing something
In the documentation we recommend doing const stripe = require('stripe')('pk_xxx');. Have you tried this?
Are the stripe definitions on definitelyTyped maintained by Stripe in any official capacity or unaffiliated?
What us definitelyTyped? Can you share a link?
Stripe type definitions for typescript
This is not maintained by Stripe, so I have no idea.
Got it, thanks. I think thats where some of my confusion comes from
Can you link the documentation which has setup using const stripe = require('stripe')('pk_xxx')?
I was referring to https://stripe.com/docs/js/including and https://www.npmjs.com/package/@stripe/stripe-js to help setup and I didn't find mention of using require
Sorry I was wrong earlier (I mixed Stripe.js and stripe-node). The way to lead Stripe.js is actually: var stripe = Stripe('pk_test_xxxx');, as mentioned here https://stripe.com/docs/js/initializing
Do you know what the difference is between loading it that way compared to loading it as described in the npm package? Theoretically, the loaded instances should be using the same library?
Hi! I'm taking over my colleague. Please, give me a moment to catch up.
Hi vanya, thanks! Sorry if anything wasn't clear, I don't think I described my issue the best
What's the 2 ways of loading in question?
Using var stripe = Stripe('pk_test_xxxx') as described in https://stripe.com/docs/js/initializing, and using stripe = await loadStripe('pk_test_key') as described in https://www.npmjs.com/package/@stripe/stripe-js
What's the issue you're facing?
What's the functionality that you are missing?
When I load the stripe instance the two different ways, different libraries are being pulled up. The first one is missing createRadarSessions functionality
I just wanted to check that theoretically, they should be getting the exact same functions
I believe the npm package (loadStripe()) contains all the functionality, while, if you include a script (Stripe()), some modules are loaded separately, to save bandwidth. Let me double check
Ah I see, that would explain it
Hm, but I don't see any extra scripts you need to load to use Radar. What's the exact error you're getting?
There's no error, I just don't have access to those functions - they're not defined
It seems like you should be able to use radar with Stripe(): https://stripe.com/docs/js/payment_intents/create_radar_session
Yeah haha that's what I was trying to do but it wasn't working. I think this issue may be related to that DefinitelyTyped library I mentioned in the beginning being loaded in. I'll do more debugging on my end, thanks for looking into it!
I have one last question
On this page https://stripe.com/docs/radar/integration, it is suggested to include the stripe.js script on every page to collect signals for fraud detection
What is the difference between the signals collected by advanced fraud signals and the information collection by radar sessions?
I just tried it out locally and it works with JS. If you use TypeScript, you could already use the npm module.
In other words, is there any data that radar sessions collects that isn't collected automatically by the stripe.js script?
I don't know much about Radar itself, it's best to ask Stripe Support: https://support.stripe.com/?contact=true
Thanks! Happy to help. Please, let me know if you have any other questions.