question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'init' of undefined for stripe.init()

See original GitHub issue

I am successfully using this library on Android with no problems. On iOS, I cannot get past this error. I have tried to follow all of the other fixes in the other bug report threads with similar issues to no avail. (#102, #53, #81) This includes reinstalling the project and starting from scratch several times. Using the instructions with Pods and manually. I have installed the example project and got it working. This has never been an Expo project. The library links and appears to be working until I try to initialize it with stripe.init().

`import stripe from ‘tipsi-stripe’; console.log(‘STRIPE’, stripe);

stripe.init({ publishableKey: ‘pk_test_xxxx’ });`

This console log shows that it is there but when I actually try to use it, it says it is undefined. STRIPE Stripe {stripeInitialized: false, init: function, deviceSupportsApplePay: function, canMakeApplePayPayments: function, paymentRequestWithApplePay: function…}canMakeApplePayPayments: function ()cancelApplePayRequest: function ()completeApplePayRequest: function ()createSourceWithParams: function ()createTokenWithBankAccount: function ()createTokenWithCard: function ()deviceSupportsApplePay: function ()init: function ()openApplePaySetup: function ()paymentRequestWithApplePay: function ()paymentRequestWithCardForm: function ()stripeInitialized: true__proto__: Object ExceptionsManager.js:65 Cannot read property 'init' of undefined

image image

If I run stripe.init() without any arguments which makes it fail as it should, I get this error: ExceptionsManager.js:65 Failed options type: The options publishableKey is marked as required in Stripe.init, but its value is undefined. What is going on?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
GenericJamcommented, Jan 13, 2018

I agree you should follow the installation guide as that seems to work for most people but I tried both methods (pod and manual) and it didn’t copy over the header search paths it needed to build properly. It will build but it doesn’t get put into ‘NativeModules’ so it isn’t there when tipsi-stripe tries to pull it out and you get the undefined or null type error when you try to use it.

Using this screen as a guide, you need to make sure the bottom one is on your list in the Header Search Paths. If you are new to Xcode, click on the folder at the top left of the left pane. This will bring you back to your project folder. Click on the folder at the top that has your project name (be careful you aren’t on a sub-project folder as they also have all these settings), go to Build Settings in the center panel. Look here for reference of what it should look like. There will probably be lots of things in this so just do a search in the top right corner of the center panel for ‘header search paths’ or something similar and go to the results. Click on the paths section and it will pop up this little dialog (like in the first link) to allow you to edit them. You can either type it in manually or with Finder open you can drag the node_modules>tipsi-stripe>ios>TPSStripe folder into this dialog and it will link them itself.

That was what solved it for me. Apologies if any of these instructions are inaccurate as I’m doing it from memory as I’m not at work. Hopefully this fixes it for you.

Also, when in doubt clean your build and or build folders.

1reaction
spyshowercommented, Apr 26, 2019

@Genericjam Can you give me some help here please? It’s been so many hours working on this and I still can’t get it working…

Screenshot 2019-04-24 at 23 11 58
Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native - Tipsi-stripe Error - 'Cannot read property 'init' of ...
I am trying to integrate Stripe into my React-Native project by following the Tipsi-stripe ... Cannot read property 'init' of undefined.
Read more >
Cannot read property 'init' of undefined - KNIME Forum
Hi All, I am getting following error when I open a view (component with widget, or a simple Box plot etc.): The error...
Read more >
Stripe API reference – Errors – curl
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries....
Read more >
Error codes | Stripe Documentation
Learn more about error codes and how to resolve them.
Read more >
Initializing - Stripe JS Reference
Your Stripe publishable API key is required when calling this function, as it identifies your website to Stripe. When you're ready to accept...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found