-
Notifications
You must be signed in to change notification settings - Fork 132
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
Talk about features that would help Single Page Apps #29
Comments
I have actually had a lot of success using Angular and braintree-web. I didn't know that braintree-angular exists so I will need to take a look at that. A couple things I would recommend are:
There are more that I ran into so I will update as I run into them. |
@trainerbill regarding |
Awesome! Thanks for the heads up on that. |
👍 for a quick resolution of this. These issues make it really difficult to integrate braintree in a SPA. |
We appreciate a quick fix to ease integration. |
👍 |
1 similar comment
👍 |
We were experiencing an issue where loading the braintree widget (with This is a serious issue, since it could allow a user A access to the vault of a user B after user A logged out, if the page was not refreshed meanwhile. After investigating the problem more thoroughly, we were able to work around the issue, but we had to resort to some nasty hacks and fragile solutions that might break with future releases of We found that all the following steps are required for a proper cleanup and new setup of the widget:
After all these steps are done, we can then require the To remove the event listeners left hanging in the A If you could provide a Reloading of |
wow @tnunes i was trying the same kind of workaround a couple of days ago, but missed the callbacks and event listeners on the window. thanks for the info. do you think the hosted fields would have the same issues? |
Hi @imgntn, I haven't used hosted fields, so I can't help you that. I know, however, that |
Since github doesn't support voting for issues, I'm adding a comment: Please add |
+1 |
We NEED braintree.destroy()! |
Really need this. Stripe has it, but we don't want to give up on Braintree just because of this issue. |
+1 @tnunes, Do you know if it's possible to target the braintree 'on message' events listener without deleting all others ? Any Ideas of their name ? |
@baillyje, what I do is monkey-patch the In my implementation I accumulate all event listeners in an array before proxying to the real Then, in my This is hackish and fragile, but as long as nothing aside from braintree adds listeners to the page from the moment you call |
We have the same problem @tnunes described, thank you for the hack. Still, I think we are going to do an full page reload until |
Glad I stumbled upon this issue, was tearing my hair out trying to figure out why I was getting errors in my Ember app when I tried to add and remove paypal accounts. A teardown method would really help out for single page apps. |
+1 need Braintree.destroy or at least Braintree.update, in order for Braintree.setup to be only called once and prevent unnecessary iframes and event listeners from spawning. |
+1 come on braintree, we're all waiting! |
+1 Would be really helpful. Reloading the whole page seriously detracts from our whole checkout experience. |
+1 Come on braintree, get your act together. Come live in the future with us. Everyone is designing single-page applications and it is extremely frustrating when we have to integrate with libraries designed by companies who think they use the latest tech, but actually have no clue. This is CS 101 fundamentals; make your code self-contained; make it leave no trace on the system its running on. We thought we should use braintree because it would be easier to integrate, but it's taking the same amount to time, and same amount of nasty hacks as it takes to integrate with your parent company. You sitting on this issue for 3 months shows that you either don't care about your users experience, or you have no clue what single-page applications are about, hence don't see how badly you're crippling the experience of our users and developers. Either way, it reflects poorly on your company. Forgive my strong language; but this is exactly how I feel. But now we're all trapped to writing shitty code, because either you guys don't care, or you guys just don't get it. Wake up!! |
Pretty much what he said. I've wasted hours and hours trying to make
|
Hey folks - I'm a Product Manager with the Braintree SDK and Developer Experience team. We understand your frustration and the importance of providing an experience that works in a myriad of integration scenarios, including Single Page Applications. We also recognize that this is an area in which we can improve our SDK. We're currently actively exploring the features we need to add and making considerations to preserve compatibility for all braintree.js users. This is our best path forward for us to provide a more ideal and complete experience for all of our merchants. I'll keep you posted on the progress of this as I know that it is currently resulting in a less than ideal integration experience. In the meantime, take a look at the docs for our advanced integration or feel free to contact me (rohit@getbraintree.com) if you have further questions or concerns. |
@rturumella There's no information in your documentation on how we can do custom integration with PayPal, other than this one line here: https://developers.braintreepayments.com/javascript+dotnet/guides/paypal/overview "Braintree offers a few options when accepting PayPal payments. First, you'll need to choose whether you would like to use our Drop-in UI or a custom integration. Learn more about differences between these integrations". |
@rturumella Any chance you guys can publish the un-minified source of the JS client? Might just make it easier for us to workaround this issue. |
@rturumella thanks very much for the explanation. FWIW the worst part of this for us - the scariest part - was when we On 1 September 2015 at 01:56, rturumella notifications@github.com wrote:
|
As @rturumella mentioned last week, we are delivering a beta build of Right now this new version is deployed as a
We will be adding full documentation in an accompanying production release in the coming weeks. In the meantime, we would love to take in some feedback on this new functionality. We know how important this is and we want to make sure when it goes out in production that the experience is rock solid. Since version 2.7.0, the configuration object passed during var myIntegration;
braintree.setup(TOKEN, 'dropin', {
onReady: function (integration) {
myIntegration = integration;
}
});
// When you're ready to destroy your integration
myIntegration.teardown(function () {
// braintree.setup can safely be run again!
}); This |
@kyledetella @rturumella just tested this and it seems to be working fine. I added a |
@rturumella Does this update also apply to hosted fields js? |
@cityreader this update will apply to |
@kyledetella How are we doing on the hosted fields integration? |
@theotherzach the Have you had a chance to try out |
@kyledetella sounds good - looking forward to the new beta.
Also my onFieldEvent fires for all inputs on submit - but just after the error msg. They all appear to be empty according to the onFieldEvent, and the container is ".braintree-hosted-fields-invalid" - which obvously tells me something is wrong with my braintree init. I'm guessing the above is caused by the way react is rendering js and markup. Will i be able to control this better, when the teardown-function is added to braintree? Thanks for keeping us all updated through development! |
@rbsmidt the As for the other issues you mentioned (placeholders and options not being applied), these sound unrelated to Regarding your last question, let me make sure I understand, are you asking if it is possible to setup hosted fields dynamically after page load? If so, yes you are able to do that. If I am misunderstanding the question, let me know. |
Thanks for your reply @kyledetella Yes i've been debugging a bit more, and it seems that you are right, my issue lies elsewhere. I'm happy to provide an example:
As stated in my last comment, i the onReady-event fires successfully after componentDidMount and the initPayment, but my placeholders doesn't show up, and the onFieldEvent doesn't fire either. When i press the submit-button, my three hosted fields gets the class Any idea what could cause this setup issue? Best regards, |
@rbsmidt It looks like if you replace the Here is an example of the updated code for you to try out: ...
render: function(){
console.log('render checkout', this);
return(
<div className="grid-checkout">
<h3>Check ud</h3>
<form id="payment-form">
<input type="text" name="firstname" id="fistname" placeholder="Fornavn" />
<input type="text" name="lastname" id="lastname" placeholder="Efternavn" />
<input type="text" name="email" id="email" placeholder="Email" />
<input type="text" name="tlf" id="tlf" placeholder="Telefon" />
<p><img src="/images/icon_security.svg" height="15" width="auto" /> Sikker betaling <img src="/images/cc@2x.png" width="auto" height="25"/></p>
<div id="card-number"></div>
<div id="cvv"></div>
<div id="expiration-date"></div>
<button>Betal</button>
</form>
</div>
);
}
});
... I hope this helps you out. Let us know if you have any more questions. |
@lilaconlee Ahh you are totally right. I tested with divs instead of inputs, and it worked like a charm! Thanks a bunch. |
@kyledetella we needed to change our drop-in solution out for hosted fields because of styling concerns. |
Hi, I've just been playing with the beta version and found that the onReady callback is not called in some cases, meaning that you aren't provided with the teardown function to clean it up. Specifically if the form is hidden at the time that setup() is called, onReady is not called until you that form becomes visible. If it never becomes visible then you never get the callback so cannot unregister the event handlers. I've run into this because I have a multi-step check out process with the dropin UI on the second page, so I was loading it in the background since it can take a while to load. Is this intentional? If so why? Cheers, |
@davidbryant thanks for bringing this up. You are correct that This is by design since the integration is technically not "ready" until it has fully rendered and is capable of tokenizing payment methods. The concept of wanting to "preload" the Drop-in is interesting and I am glad you brought it up. The semantics of To be honest though, it is unlikely we will change this pattern anytime soon, so in the case of your UI, I would recommend initializing Drop-in only after you have rendered the containing view and tearing it down prior to un-rendering that view. |
So this would also imply that I need to prevent all navigation within a SPA from the time that I call braintree setup() until it fires its onReady event? Otherwise there's a chance that a navigation event in that timeframe will prevent onReady from being fired and so not provide me with the teardown callback? |
@davidbryant that is correct. It's not a convenient restriction, but in integrations such as dropin or hosted-fields there is a lot of cross-domain machinery being asynchronously set in motion; cutting it off halfway through with a navigation event could lead to dangling DOM nodes, event handlers, or an unusable integration. |
This afternoon version This thread was originally opened to engage a dialogue on this matter and it certainly served that purpose. Should you experience any specific issues with |
@kyledetella how should we handle BraintreeData.setup() when using teardown()? Right now I'm calling braintree.setup(this.props.paymentToken, "custom", {
onReady: function(integration) {
Checkout.braintreeIntegration = integration;
},
id: "payment-method-form",
hostedFields: {...});
BraintreeData.setup(this.props.merchantId, 'payment-method-form', 'production'); And then later using Checkout.braintreeIntegration.teardown() as needed. It's working well, but will there be complications if I'm repeatedly calling BraintreeData.setup()? |
@cheyner it doesn't sound as though you are experiencing issues when repeatedly calling |
@kyledetella Thank you, the Just one bug I encountered: the |
@bezhermoso glad to hear Would you mind opening a separate issue regarding |
The primary concern for most participants in this thread has been addressed in last week's Please open new issues for any further Single Page App concerns or questions. Thanks! |
Thanks for the functionality. When will it be documented? Can you now call .setup() then braintree.teardown() and .setup again? |
@trainerbill we will provide full documentation once this release is hotlinked. That should happen sometime this week. For now, the explanation and code provided above remains accurate.
Yes, that is a core allowance with this new feature! |
Some months ago we badly needed this teardown() feature. We were changing billing just now and it's great that it's now available! Thank you! For those looking for the documentation: |
@parreirat glad to hear it helped out! Also, good call on posting the documentation in this thread, that slipped my mind! |
braintree-web
's design comes from a time when checkout flows generally used a<form>
POST. This is no longer the case in 2015, where SPAs and JS-heavy checkout flows are common.There are a couple things that keep
braintree-web
from working well in SPAs, the biggest of which is thatbraintree.setup
can only be called once per page load.I'm starting this thread to discuss what kinds of features would be useful for making
braintree-web
work better in JS-heavy checkout flows.Related Issues:
The text was updated successfully, but these errors were encountered: