flutter-braintree icon indicating copy to clipboard operation
flutter-braintree copied to clipboard

Braintree for Flutter Web

Open nyilkhan opened this issue 4 years ago • 19 comments

I am trying to integrate Braintree with my Flutter web application, I saw that this plugin is currently only available for iOS and Android. Are there any good solutions for implementing for flutter web, especially Braintree's client side Drop in UI.

nyilkhan avatar May 15 '20 21:05 nyilkhan

I have not come up with a good solution to this problem yet. It might be possible to use Flutter's native platform views to embed some HTML and JavaScript into a Flutter widget.

pikaju avatar May 16 '20 11:05 pikaju

@Pikaju How to show the saved cards in vault, how to get client token?

Pragya007 avatar May 16 '20 19:05 Pragya007

Are there plans to add support for Flutter Web?

dan1229 avatar Aug 29 '20 00:08 dan1229

I currently don't have plans to implement it myself, but pull requests are always welcome.

pikaju avatar Aug 29 '20 13:08 pikaju

I don't have enough experience to implement this, but this looks like it could be the solution for web implementation: https://www.youtube.com/watch?v=yYxIWEQgOe4

SeriousMonk avatar Oct 04 '21 22:10 SeriousMonk

@FRANIAZA if you'd like I can share some code - I got a hacky solution eventually going that uses the dropin Javascript API to get the nonce, return the promise and convert it to a future

it's not perfect but it works on web, never cleaned it up enough to add it to the package as i couldn't figure out how to do the multiplat code

dan1229 avatar Oct 04 '21 22:10 dan1229

@FRANIAZA if you'd like I can share some code - I got a hacky solution eventually going that uses the dropin Javascript API to get the nonce, return the promise and convert it to a future

it's not perfect but it works on web, never cleaned it up enough to add it to the package as i couldn't figure out how to do the multiplat code

Yes please, any help is greatly appreciated;

SeriousMonk avatar Oct 04 '21 22:10 SeriousMonk

@FRANIAZA you got it - please email me i cant find your contact info

dan1229 avatar Oct 05 '21 02:10 dan1229

@dan1229 I sent you an email

SeriousMonk avatar Oct 05 '21 07:10 SeriousMonk

Is there any update on this. Anyone implemented successfully and running in production?

@dan1229 Can you share the code please.

quseappdeveloper avatar May 07 '22 01:05 quseappdeveloper

@quseappdeveloper I actually wrote a blog post about this if you wanna check it out https://blog.danielnazarian.com/blog/posts/faf92b76-094d-47af-b8d5-3bccfbb4a642/

I used it in production for a few months and didn't have any major issues - it does well and with some effort could be pretty seemless but there's definitely a bit to be desired

dan1229 avatar May 10 '22 01:05 dan1229

@dan1229 the link to your block post doesn't work any more. Im currently also in the process of integrating it. I would love to see your approach, I just started taking a look at GraphQl to achieve this integration. Im guessing that u simply use the js library for flutter and through that it should be pretty straight forward to integrate Braintree with the help of their documentation.

I don't know if it still is a topic that interests you, but if you want we can connect and talk about it, also I would love to see your solution

NkITaa avatar Aug 13 '22 08:08 NkITaa

Ohp that makes sense the urls got updated a bit ago - https://blog.danielnazarian.com/blog/posts/faf92b76-094d-47af-b8d5-3bccfbb4a642/

The main thing is the repo which is on my profile - that said happy to still talk about this! I’m not sure my approach is flawless or even the right one but it definitely did the job while I needed it. Main thing that kept me from making a PR here was I didn’t really understand separating out the different platforms for the package.

Feel free to reach out though happy to help in any way I can

dan1229 avatar Aug 13 '22 14:08 dan1229

Hi @dan1229 its me again. I was wondering whether u tried your approach again? I abandoned my idea of using GraphQl & looked into ur solution today. Its pretty weird because it seems that ur example repository doesnt work. Im stuck in an endless loading screen; was that a thing that you encountered?

P.S A weird thing is that there are no errors -> maybe a problem lies in the required.js but I cant really figure it out

NkITaa avatar Dec 10 '22 11:12 NkITaa

Hey there! Sorry to say I haven't tried my approach in quite a minute at this point - since a bit before the blog post admittedly. I can take a look at the repo sometime soon and see if there's anything obvious I can fix but I no longer have that Braintree account i.e., no keys so it's a bit tricky.

required.js definitely was the source of a good bit of headache for me - I remember there being ways to work around that as well though if that's causing issues.

Admittedly could be a Flutter issue as well - Flutter has changed A LOT since I've written the post and definitely since I made this solution so could be some weirdness around the Promise conversion or something as well purely as a guess.

I'll take a look though!

dan1229 avatar Dec 10 '22 20:12 dan1229

@dan1229 I will take a Look at it as well, maybe we can fix it

I think that u don't even need a Braintree account to reproduce the problem, like u I'm guessing that it has something todo with required.js

NkITaa avatar Dec 10 '22 21:12 NkITaa

@dan1229 I already found a little mistake u made; it isnt huge but u call ur function in line 60 in ur main.dart wrongly, you just wrote showDialogBraintree(), u call it correctly with () => showDialogBraintree() or () { showDialogBraintree() }

Im sure this was by accident ;)

NkITaa avatar Dec 11 '22 12:12 NkITaa

@NkITaa wow great catch thank you! I wrote this long after I did the original solution so def a good chance of some mistakes. Updated the repo thank you again :)

dan1229 avatar Dec 11 '22 18:12 dan1229

I also developed a solution that is based on the code of @dan1229 . My code doesn't a Dialog to show the braintree flow but a standard widget. It is also more error-resistant (afaik) and enables PayPal usage. The code is published as gist: https://gist.github.com/claudius-kienle/5d38cce6e973ff359b843e1182191929 Feel free to ask if anything is unclear:)

claudius-kienle avatar Dec 26 '22 08:12 claudius-kienle