Copied to clipboard

Flag this post as spam?

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


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Kevin Blake 23 posts 45 karma points
    May 08, 2014 @ 12:54
    Kevin Blake
    0

    Integrating BrainTree payment into template not working

    I'm following the instructions here for 'Integrate the Payment Form into Your Own Page'

    http://www.publicvoid.dk/SetupUCommerceToIncludeBraintreePaymentsAsAPaymentMethod.aspx

    The form works fine with the config set to (auto), and using the default template.  But now I've updated it, I get the following errors:

    umbracoMacroError Loading Razor Script (file: BrainTree Payment Form) Sequence contains no elements    at NHibernate.Linq.DefaultQueryProvider.ExecuteQuery(NhLinqExpression nhLinqExpression, IQuery query, NhLinqExpression nhQuery)
      at NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression)
      at NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression expression)
      at System.Linq.Queryable.Single[TSource](IQueryable`1 source, Expression`1 predicate)
      at ASP._Page_macroScripts_uCommerce_BrainTreePaymentForm_cshtml.Execute() in \macroScripts\uCommerce\BrainTreePaymentForm.cshtml:line 8
      at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
      at System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors)
      at System.Web.WebPages.WebPage.ExecutePageHierarchy()
      at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
      at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)
      at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
    0.1405490.009866
    macroError loading MacroEngine script (file: /uCommerce/BrainTreePaymentForm.cshtml, Type: ''
    Sequence contains no elements
      at NHibernate.Linq.DefaultQueryProvider.ExecuteQuery(NhLinqExpression nhLinqExpression, IQuery query, NhLinqExpression nhQuery)
      at NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression)
      at NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression expression)
      at System.Linq.Queryable.Single[TSource](IQueryable`1 source, Expression`1 predicate)
      at ASP._Page_macroScripts_uCommerce_BrainTreePaymentForm_cshtml.Execute() in \macroScripts\uCommerce\BrainTreePaymentForm.cshtml:line 8
      at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
      at System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors)
      at System.Web.WebPages.WebPage.ExecutePageHierarchy()
      at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
      at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)
      at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
      at umbraco.macro.loadMacroScript(MacroModel macro)
      at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)

     

    It's basically failing because no new entries are placed into the uCommercePaymentProperty table (and related) for the payment

    Braintree config

     merchantId=""
        publicKey=""
        privateKey=""
     callbackUrl="(auto)"
        paymentFormUrl="/store/cart/payment.aspx"
        paymentFormTemplate="/templates/BraintreePaymentForm.htm"
     acceptUrl="http://localhost:61493/store/cart/confirmation/"
        declineUrl="http://localhost:61493/store/cart/preview/"
     debug="false"
        testMode="true"
    />

    BrainTreePaymentForm.cshtml

    @using UCommerce.EntitiesV2;
    @using UCommerce.Transactions.Payments;
    @{
        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)))

    The step before seems to have the purchase order completed successfully, and requests the payment.. 

            TransactionLibrary.ExecuteBasketPipeline();
    TransactionLibrary.RequestPayments();
    The URL that's returned as a result seems to have the Guid populated...
    /store/cart/payment.aspx?paymentGuid=c160e02c-4a9b-412a-85ea-cdcba1a70b58

    What am I missing?

    Many thanks,
    Kevin.

  • Søren Spelling Lund 1797 posts 2786 karma points
    May 21, 2014 @ 11:17
    Søren Spelling Lund
    0

    Hi Kevin,

    If it's working with the default HTML template I assume that it might be because something was removed or renamed in the new template. Do you have all the keys represented in the new template ##EXPMONTH## and so forth?

    Also I would expect merchant id to have a value.

  • Kevin Blake 23 posts 45 karma points
    May 21, 2014 @ 11:34
    Kevin Blake
    0

    Hi Soren - thanks for the reply :)

    My local config does have those values, but I removed them to protect the innocent...

    I actually ended up changing this to a custom Braintree S2S provider because we had requirements to customise the checkout flow more than the default TR method allows (combining payment page with other information, server-side validation, etc) - so this is no longer an issue.

    Looking back through source control (for the benefit of others that might stumble upon this question), and I can't see there being any changes to the template from the default, other than removing the html/body tags to fit into the rest of the page.

Please Sign in or register to post replies

Write your reply to:

Draft