Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dan 15 posts 86 karma points
    Jun 22, 2018 @ 10:26
    Dan
    0

    Merchello and BrainTree Subscription Transaction Payment for recurring payments

    I am using Merchello in Umbraco to set up a simple e-commerce site but the products that are available require monthly recurring payments (subscriptions). I have activated the BrainTree payment provider in Merchello and entered all API keys credentials for my sandbox account. I have created a new Record of Subscription Transaction payment method and have set up the subscriptions in my BrainTree sandbox account.

    On checkout, when coming to the payment method page and I select the 'Record of Subscription Transaction' from the drop down and select next, I am displayed with an empty payment page.

    I am just wondering if I have missed something and is there any further steps that I need to take to get this set up and working correctly?

    Thanks,

    Dan

  • Briant Diehl 3 posts 73 karma points
    Jun 23, 2018 @ 21:37
    Briant Diehl
    0

    I'm currently trying to accomplish the same thing. It doesn't look like recurring payments with braintree is set up to work right out of the box. Being new to Merchello, I've had a hard time finding any working examples to get me started. That being said, I'd recommend taking a look at the source code for Merchello and FastTrack: https://github.com/Merchello/Merchello

    I'm still in the early stages of my own project, but I believe you're going to need to make a custom controller with various subscribe/unsubscribe actions. I haven't gotten along far enough to test this yet, but following the instructions spelled out in the braintree/merchello plugin (now a part of merchello core) you should be able to get started.

    https://github.com/rustyswayne/Merchello.Plugin.Payment.Braintree

    If I'm just setting up a merchello surface controller it may look something like this:

    internal class BraintreeHelper
    {
        public static BraintreeProviderSettings GetBraintreeProviderSettings()
        {
            return new BraintreeProviderSettings() {
                EnvironmentType = EnvironmentType.Sandbox,
                PublicKey = ConfigurationManager.AppSettings["publicKey"],
                PrivateKey = ConfigurationManager.AppSettings["privateKey"],
                MerchantId = ConfigurationManager.AppSettings["merchantId"],
                MerchantDescriptor = new MerchantDescriptor()
                    {
                        Name = ConfigurationManager.AppSettings["merchantName"],
                        Url = ConfigurationManager.AppSettings["merchantUrl"],
                        Phone = ConfigurationManager.AppSettings["merchantPhone"]
                    },
                DefaultTransactionOption = (TransactionOption)Enum.Parse(typeof(TransactionOption), ConfigurationManager.AppSettings["defaultTransactionOption"])
            };
        }
    }
    
    public class BraintreeSubscriptionController : MerchelloSurfaceController
    {
    
        public ActionResult CreateSubscription()
        {
            var braintreeApiService = new BraintreeApiService(BraintreeHelper.GetBraintreeProviderSettings());
            var subscriptionApiService = braintreeApiService.Subscription;
    
            SubscriptionRequest request = new SubscriptionRequest({ YourSubscriptionRequestOptions  });
            //subscriptionApiService looks like it has all the methods you'll need to create your recurring payments
            subscriptionApiService.Create(request);
    
            return CurrentUmbracoPage();
        }
    }
    

    You'll also have to set up a subscription product in Braintree. I believe you'll have to save your user to braintree and then add the subscription to that user using merchello's BraintreeSubscriptionApiService.

    Hopefully this helps get you started. I've been banging my own head against a wall trying to figure this out. Perhaps someone with a little more know how will chime in on this.

  • Dan 15 posts 86 karma points
    Jun 29, 2018 @ 08:50
    Dan
    0

    Hi Briant,

    Thanks for your reply, this really helps! As I use both PayPal and Braintree for the recurring payments (the user is authorised using PayPal checkout which then returns a nonce). On Authorisation, I use Ajax to post the payment nonce to the surface controller which then either creates / fetches the Braintree customer and then creates the subscription.

    Is there a way to assign this to the Brain tree subscription payment method because I have noticed in ResolvePayment.cshtml in Fasttrack, there is no case within the switch statement for this payment method. What I was thinking of doing is creating the case which then fetches the view with the PayPal checkout button?

    Thanks, Dan

Please Sign in or register to post replies

Write your reply to:

Draft