BrainTree SDK Bindings for Android & iOS

tuyenvtuyenv Vu Duc TuyenVNUniversity ✭✭

Hi everyone,

Yet another binding for BrainTreePayment SDK, a PayPal service.

Please check out and report issues if any.

Cheers.

Posts

  • AndrAndr André USMember ✭✭

    Greetings,

    I am trying to integrate the iOS DropIn in my project, but I am having trouble doing so.

    When calling any of the methods, I get errors such as:

    Could not create an native instance of the type "BraintreeDropIn.BTDropInRequest": the native class hasn't been loaded.

    Here is the simple code I am using, based on the documentation:
    private void ShowBraintreeDropIn(string clientTokenOrTokenizationKey)
    {
    var request = new BTDropInRequest();
    var dropIn = new BTDropInController(clientTokenOrTokenizationKey, request, HandleBTDropInControllerHandler);
    PresentViewController(dropIn, false, null);
    }

            void HandleBTDropInControllerHandler(BTDropInController controller, BTDropInResult result, Foundation.NSError error)
            {
                if (error != null)
                {
                    System.Diagnostics.Debug.WriteLine("ERROR");
                }
                else if (result != null && result.Cancelled == true)
                {
                    System.Diagnostics.Debug.WriteLine("CANCELLED");
                }
                else
                {
                    Button.SetTitle(result.PaymentDescription, UIControlState.Normal);
    
                    var selectedPaymentOptionType = result.PaymentOptionType;
                    var selectedPaymentMethod = result.PaymentMethod;
                    var selectedPaymentMethodIcon = result.PaymentIcon;
                    var selectedPaymentMethodDescription = result.PaymentDescription;
                }
                controller.DismissViewController(true, null);
            }
    

    Can anyone help?

  • tuyenvtuyenv Vu Duc Tuyen VNUniversity ✭✭

    Let me try then.

  • AndrAndr André USMember ✭✭
    edited June 27

    After cleaning and rebuilding the project, the app crashes on startup without any errors.

    Simulator log:

    (UIKitApplication:com.XXXX.XXXXXXXX[0x476b][3347][3499]): Service exited due to Abort trap: 6

  • AndrAndr André USMember ✭✭
    edited June 27

    This is really weird, but the project runs without issues, with the added packages and Using statement.

    But, as soon as I add any of the IOS Dropin classes, it crashes at launch.

    Adding something as simples as the following replicates my issue:

    var request = new BTDropInRequest();

  • tuyenvtuyenv Vu Duc Tuyen VNUniversity ✭✭

    Could you share the code you run?

  • AndrAndr André USMember ✭✭

    Yes, sure. Here it is.

    `
    using System;

    using UIKit;
    using BraintreeDropIn;

    namespace HealthBooking.iOS
    {
    public partial class ViewController : UIViewController
    {
    public ViewController(IntPtr handle) : base(handle)
    {
    }

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
    
            // Perform any additional setup after loading the view, typically from a nib.
            Button.AccessibilityIdentifier = "myButton";
            Button.TouchUpInside += delegate
            {
                ShowBraintreeDropIn("MY_KEY_HIDDEN_FOR_PUBLIC_EXPOSURE");
            };
        }
    
        public override void DidReceiveMemoryWarning()
        {
            base.DidReceiveMemoryWarning();
            // Release any cached data, images, etc that aren't in use.     
        }
    
        private void ShowBraintreeDropIn(string clientTokenOrTokenizationKey)
        {
            var request = new BTDropInRequest();
            var dropIn = new BTDropInController(clientTokenOrTokenizationKey, request, HandleBTDropInControllerHandler);
            PresentViewController(dropIn, false, null);
        }
    
        void HandleBTDropInControllerHandler(BTDropInController controller, BTDropInResult result, Foundation.NSError error)
        {
            if (error != null)
            {
                System.Diagnostics.Debug.WriteLine("ERROR");
            }
            else if (result != null && result.Cancelled == true)
            {
                System.Diagnostics.Debug.WriteLine("CANCELLED");
            }
            else
            {
                Button.SetTitle(result.PaymentDescription, UIControlState.Normal);
    
                var selectedPaymentOptionType = result.PaymentOptionType;
                var selectedPaymentMethod = result.PaymentMethod;
                var selectedPaymentMethodIcon = result.PaymentIcon;
                var selectedPaymentMethodDescription = result.PaymentDescription;
            }
            controller.DismissViewController(true, null);
        }
    
    }
    

    }`

  • tuyenvtuyenv Vu Duc Tuyen VNUniversity ✭✭

    Thank you for reporting issue. It's fixed now :). Plz enjoy and report issues if any. It's better to log an issue on GitHub :).

  • AndrAndr André USMember ✭✭

    I will ;) Thank you for the support.

    Cheers.

  • Yannis.0214Yannis.0214 Yannis Konstas USMember

    @tuyenv Hi - I need to use the Braintree DropInRequest in a Xamarin Android project in order to use Paypal - I'm following this - https://developers.braintreepayments.com/start/hello-client/android/v2#present-drop-in-ui

    I've downloaded your binding here - https://github.com/NAXAM/xand-braintree-sdk it doesn't appear to build on a Mac (2 errors):

    Error CS0113: A member `Com.Braintreepayments.Api.Exceptions.ErrorWithResponse.Message' marked as override cannot be marked as new or virtual (CS0113) (Naxam.BrainTree.Droid)

    Error CS0113: A member `Com.Braintreepayments.Api.Exceptions.GoogleApiClientException.Message' marked as override cannot be marked as new or virtual (CS0113) (Naxam.BrainTree.Droid)

    I'm going to try on Windows on Visual Studio, but in the meantime can you confirm if the full DropIn library is available within this binding?

    Cheers!
    Y

  • Yannis.0214Yannis.0214 Yannis Konstas USMember

    Hey Vu

    I've got around the build errors by using the Nuget Packages instead.

    Only thing I can't figure out is how to access them in a Xamarin Android project - using Naxam etc, does resolve?

    Could you advise please?

    Thanks again!

  • tuyenvtuyenv Vu Duc Tuyen VNUniversity ✭✭

    @Yannis.0214,

    You should get it by VS QuickFix feature.

    Otherwise, plz try Com.BrainTree.

    We don't change the namespace of binding package.

    Cheers.

  • Yannis.0214Yannis.0214 Yannis Konstas USMember

    @tuyenv Cheers! I can access

    using Com.Braintreepayments.Api;
    using Com.Braintreepayments.Browserswitch;

    Could you advise how to access the DropIn components - I'm trying to follow this tutorial:

    https://developers.braintreepayments.com/guides/drop-in/android/v2

    Thanks again!

  • tuyenvtuyenv Vu Duc Tuyen VNUniversity ✭✭

    We haven't create binding for DropIn yet :).

  • Yannis.0214Yannis.0214 Yannis Konstas USMember

    @tuyenv Ah ok! Do you have any plans on doing this? ... you would be the first to do it! ;)

    Cheers

  • tuyenvtuyenv Vu Duc Tuyen VNUniversity ✭✭

    I have been the first for BrainTree already, but if it is created in few minutes I would love to create right away. :)

  • Yannis.0214Yannis.0214 Yannis Konstas USMember

    @tuyenv Could you point me in the direction of any articles / samples which I can use to take a payment using a Paypal account which doesn't require the DropIn binding, and just uses your (excellent) Braintree binding?

    Thanks again!

  • tuyenvtuyenv Vu Duc Tuyen VNUniversity ✭✭
    edited August 18

    @Yannis.0214 Plz ask BrainTree on that case. :) I could help right away to create the binding with a paid price.

    Cheers.

Sign In or Register to comment.