Forum Xamarin.Forms

How to implement Stripe or Braintree for Xamarin Forms?

SteveRussellSteveRussell Member ✭✭✭
I tried to implement Judopay, and everything went well, but in the end, they refused to offer their service because my app is apparently a “high risk”, so I’m looking for another solution.

I tried Paypal.Forms but direct card payments won’t work because the solution has basically been deprecated.

I see no tutorials for Braintree or Stripe for Xamarin Forms and I’m new so I cannot simply create my own implementation for Braintree based on Braintree.iOS and Braintree.Android

My best option right now is to try and follow but I’m having difficulty following the tutorial.

Best Answer


  • SteveRussellSteveRussell Member ✭✭✭
    > @Amar_Bait said:
    > Simple Google search for "braintree xamarin forms":

    I’ve contacted Alejandro about Braintree.Forms and he said that he hasn’t finished working on it so it’s unusable now.

    And like I said, I’m new, and without a guide, I’m unable to create my own implementation using Android and iOS bindings (I don’t know how to do that)
  • Amar_BaitAmar_Bait DZMember ✭✭✭✭✭
    edited July 2019

    The 2 other links I provided are the bindings you need, all the hard work has already been done. Now you just need to create a DependencyService that calls the SDK in each platform. Start coding and I will guide you through no problem.

    Your code architecture should be something like this:

    In your shared project (.NET Standard)

    namespace YourApp
        // Interface for the dependency service
        // Usage: await DependencyService.Get<IBraintreeService>().BuyAsync("Xamarin.Forms guide book", 9.99m);
        public interface IBraintreeService
            Task BuyAsync(string product, decimal price);

    In your Android and iOS projects:

    // we register the service so DependecyService.Get returns this class
    [assembly: Dependency(typeof(BraintreeService))]
    namespace YourApp.Droid // or YourApp.iOS
        public class BraintreeService : IBraintreeService // we implement the interface
            public async Task BuyAsync(string product, decimal price)
                if (product == null)
                    throw new ArgumentNullException(nameof(product));
                if (price <= 0)
                    throw new ArgumentOutOfRangeException(nameof(price));
                // use
                // or to make the payment
  • SteveRussellSteveRussell Member ✭✭✭

    Thanks for sending me in the right direction!

    I have added the interface and the dependency service, and I'm going to NAXAM braintree iOS binding github, but I don't see their usage code. They just send me to which is all in Swift and Objective-C

  • SteveRussellSteveRussell Member ✭✭✭

    Do you know if this will work?

    I wanted to test it but I don't know what a payment nonce is.

    A payment method nonce is a secure, one-time-use reference to payment information. It's the key element that allows your server to communicate sensitive payment information to Braintree without ever touching the raw data.

    I'm not sure what that I could use as nonce

Sign In or Register to comment.