stripe-js: [BUG]: Issue: Stripe Integration Errors in Magento 1.9
What happened?
I am currently working with Magento 1.9 and encountered issues related to Stripe integration after recent changes. Here are the specific errors I am facing:
-
Error in
prototype.js: prototype.js:828 Uncaught TypeError: Cannot read properties of undefined (reading ‘length’) at v3/:1:154936 at prototype.js:865:29 at prototype.js:825:18 at Array.forEach (<anonymous>) at Array.each (prototype.js:824:12) at Array.collect (prototype.js:864:10) at 3534 (v3/:1:154903) at e (v3/:1:119) at 4200 (v3/:1:157974) at e (v3/:1:119) -
Error in
stripe_payments.js: stripe_payments.js:136 Uncaught ReferenceError: Stripe is not defined at Object.onLoadStripeJsV3 (stripe_payments.js:136:13) at stripeJsV3.onload (stripe_payments.js:109:20)
Steps to Reproduce
- Integrate Stripe with Magento 1.9.
- Load the checkout page to trigger Stripe’s JavaScript.
Expected Behavior
Stripe integration should work without any JavaScript errors, allowing smooth payment processing.
Actual Behavior
The errors mentioned above are triggered, causing the Stripe payment processing to fail.
Additional Information
I believe these issues are due to the recent changes made by Stripe. Please provide guidance or a solution to resolve these errors.
Thank you.
Environment
- Magento Version: 1.9
- Stripe Integration: Latest version
Environment
No response
Reproduction
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (1 by maintainers)
I have temporarily fixed the issue by defining the Stripe file before
prototype.jsin the head section:Example:
If anyone needs further assistance or has any questions, feel free to reach out to me directly on WhatsApp: Click here to message me …
Hello @all
I have temporarily fixed the issue by defining the Stripe file before prototype.js in the head section:
Example:
<head> <script src="https://js.stripe.com/v3/"></script> <script src="path/to/prototype.js"></script> </head>Above solution will not work if you have custom module for js merge so I have fixed it as well.
If anyone want solution mail me on : mageexpert92@gmail.com
The provided solution only fixes the first of the two errors and loads the script even on non-checkout pages. To fix the source of the problem and keep Stripe script loading asynchronous, you need to save the native
Array.mapbefore it gets overwritten byunderscorelibrary that is used by Magento 1 and then reassign it before loading the Stripe v3 script. The script can then initialize with the nativemap. When the script is loaded, you can revert the reassignment.Change your
header.phtml:Change your
stripe_payments.js: