uCommerce comes with built-in support for Braintree payments. This guide will walk you through getting uCommerce to work with Braintree for payment processing.
With Braintree you are responsible for hosting the payment form. A simple form is provided by uCommerce, but it will need a better look and feel. Acquire, cancel, and refund are available. This is implemented with the Transparent Redirect method.
A wide range of currencies available, but you decide which currency to use when you create a merchant account. Each merchant account can only process a single currency.
Add a new payment method, under “uCommerce –> Settings –> Orders –> Payment Methods”. You can call it whatever you like, here I have used “Braintree”.
Click the newly created node and select “Braintree” in the Service drop down list. Fill out the rest of the required information, like where it’s available from under the “Access” tab, pricing and the language tabs. When you are done click “Save”.
That’s everything in the uCommerce interface.
All those settings in the Braintree gateway are optional.
You log into your account at https://www.braintreegateway.com/login and sandbox at
On the Menu at the top, click “Processing” and the click “Add/Edit” in the CVV line.
Make sure that all is checked, and “For Any Transaction” is selected, to get CVV validation enabled. End by clicking “Save”.
Now we need to edit the Braintree.config file.
You will find the Braintree.config file in the following location, where “rootdir” is the directory on the computer where you installed Umbraco: “rootdir\umbraco\UCommerce\Configuration\Braintree.config”. Usually “rootdir” is c:\inetpub.
Some of the below information are found in the Braintree gateway, so start by logging in you aren’t already.
On the Menu at the top, click “Account” -> “My User” –> “API Keys”.
Here you find “merchantId”:
In the Menu at the top, click “Account” -> “My User” –> “API Keys”. Here you find the “publicKey”.
On the Menu at the top, click “Account” -> “My User” –> “API Keys” -> “View”. Here you find the “privateKey”.
Unless you have implemented your own version of the callback handling, this should be set to “(auto)”.
You can optionally host the payment form inside your own pages. To do this override the value “(auto)” with the URL on which the payment form is rendered.
Remember to use the CommerceLibrary:RenderPaymentForm or the RenderPage of the IPaymentWindow. Please find code samples in a later section.
Path to the paymentFormTemplate. The default paymentFormTemplate BraintreePaymentForm.htm is located in the Configuration folder under uCommerce.
To get the customer redirected back to you page after ended payment, you have to specify a return url depending on payments result: Accept or decline.
Test mode will toggle the payment method service to use a test environment. A sandbox account is used in testMode.
Valid values “true” or “false”.
Running a pipeline once payment is authorized can be helpful if you need to complete the order once the customer returns to your site.
To run a “pipeline” once the callback if received and processed, open Umbraco click “Commerce” select the payment method (“Braintree”). In the pipeline drop down list select Checkout and then click “Save”.
Now the default pipeline that comes with uCommerce will be run after each successful callback. This sets the Basket to an Order, gives it an OrderNumber, and other things.
The payment form is populated with the contents of paymentFormTemplate file chosen in the config file, no matter which way you choose to integrate it.
The HTML inputs that have a name specified in the default file are needed to submit the form to Braintree. It is possible to changes types of the fields, add other attributes and move the fields around, but they must retain the names assigned to them.
The Braintree provider will insert values at runtime by replacing placeholder values, e.g. “##XX##” tags. You can safely remove these placeholders if you wish to handle the form values yourself.
If you want to integrate the payment form into one of your pages you’ll want to modify the template HTML to include only the form element and get rid of the html and body tags.
var paymentGuid = HttpContext.Current.Request["paymentGuid"];
var payment = Payment.All().Single(x => x.PaymentProperties.Where(y => y.Key == "paymentGuid" && y.Value == paymentGuid).Count() > 0);
var paymentMethod = payment.PaymentMethod;
var paymentWindow = paymentMethod.GetPaymentMethodService() as IPaymentWindow;
@Html.Raw(paymentWindow.RenderPage(new PaymentRequest(payment.PurchaseOrder, payment)))
<xsl:variable name="paymentGuid" select="umbraco.library:RequestQueryString('paymentGuid')"/>
<xsl:value-of select="CommerceLibrary:RenderPaymentForm($paymentGuid)" disable-output-escaping="yes"/>
To be able to acquire, cancel, and refund payments you need to enable two pipeline tasks in the ToCompletedOrder pipeline and ToCancelled pipeline.
The pipeline configuration is found in /umbraco/ucommerce/pipelines.
· Test mode – Make sure test mode if turned off when going live.
The opinions expressed herein are my own personal opinions and do not represent
my employer's view in any way.