Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize PayPal and ApplePay with local braintree library #873

Open
niklv opened this issue Feb 26, 2024 · 4 comments
Open

Initialize PayPal and ApplePay with local braintree library #873

niklv opened this issue Feb 26, 2024 · 4 comments

Comments

@niklv
Copy link

niklv commented Feb 26, 2024

In my project we already have self-hosted braintree-web cleint from npm. It will be great to add option to initialize PayPal and ApplePay with my braintree library instanse, to skip 3rd party scripts loading in initialization.

@cbarton
Copy link
Member

cbarton commented Nov 13, 2024

Recurly.JS will check if the module that is being requested (client, applePay, etc.) is available in the compatible version before loading the library via the 3rd party script.

Is the ask to provide the instance of the braintree.client that has already been initialized with the client authorization token?

@niklv
Copy link
Author

niklv commented Nov 18, 2024

No, I want to speed-up recurly initialization by providing already bundled braintree package. So there no need to load this lib from 3rd party. (I use official braintree-web npm package)

@cbarton
Copy link
Member

cbarton commented Nov 18, 2024

Per my comment above, we will not load the 3rd party library should the module be loaded already .

Could you provide me with the BT library version you are using? I want to confirm that it does not match what RJS expects because that might be the reason why it is triggering the external load. If it doesn't match we might be able to loosen that version constraint since there isn't much in the way of breaking changes in the library in v3.

@niklv
Copy link
Author

niklv commented Nov 21, 2024

I ensure that the same version of Braintree used by Recurly is bundled in my project:
https://github.com/recurly/recurly-js/blob/master/lib/util/braintree-loader.js#L6
However, if the versions differ (e.g., Recurly upgrades its Braintree version), it causes a mismatch in the Braintree modules. This happens because some modules are preloaded by me, while others are loaded by Recurly with the new version, leading to errors.

To handle this, I clear all Braintree references from the global window and allow Recurly to load all the dependencies itself.

It would be more elegant to pass my Braintree version directly in the Recurly configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants