I'm relatively new to Umbraco, so appologies if this is a dumb question. However, I've just started looking into Merchello and so far it looks fantastic. I now want to add the PayPal payment provider, but I can't find any documentation on how to do this anywhere?
Hi there! Welcome to the Umbraco community and specifically to Merchello.
We haven't added any documentation around this yet, but I will get something together and will post in this thread ASAP (then we'll add it to the repo).
We only have scraps of documentation thus far on the gateway providers but have it scheduled to be working on the formal (merchello.com) docs this month. We will be starting with the Notification provider.
However, I'd be happy to help you out getting the PayPal provider patched up. Also Nik Walhberg's team (Scandia) are the ones that built it originally ...
In that plugin, other than updating the dependencies, I think the return notification needs some work - perhaps going to a HttpHandler.
We're working on refactoring the plugin today/tomorrow to make it work with the core changes as well as cleaning up the return notification (whcih, as Rusty pointed out, defintiely needs some TLC). Along with this we'll also start some documentation which should help folks use it.
Hey Nik - let me know if you want to chat about it as you get going - I'll set my alarm to start work EST tomorrow ... 6am here ... so feel free to ping me on Skype if you like. Have a bunch of stuff on my plate tomorrow and I should start early anyway ;-)
Hey Rusty, thanks. We're working through some of the items now and will post to our Basecamp project as things come up. We should schedule a review once it's complete. Thanks for waking early! :) Hope you have a coffee nearby.
Hi Eidos, sorry that we didn't update you sooner. We're also releaseing a new version with additional features this week. I will post a message here when that is complete, but feel free to check out this one in the meantime.
I'm also having a bash using the Paypal gateway plugin. Could you point me in the direction of a sample of where it integrates in my CheckoutController (or equivalent)? Cutting my teeth on Merchello as well so trying to get my head round it all!
Hi guys, I will get some more documetaion up there but for now I wanted to let you know that we've released a new version of the plugin that also provides automaitc redirect for authorization and capture of the payment (assuming the user successfully logs in to PayPal).
If you haven't already, grab the latest plugin and documentation from the our page:http://our.umbraco.org/projects/collaboration/merchello-paypal-express-payment-provider
when I call IPaymentResult attempt = base.Basket.SalePreparation().AuthorizePayment(<PayPalMethodKey>);
the result is the following: attempt.Payment.Success = false attempt.Payment.Error.Message = "Order total is invlaid" attempt.Payment.Exception.Message = "Order total is invlaid" attempt.Payment.Result.Amount = 86.8974 attempt.Payment.Result.Authorized = false attempt.Payment.Result.Collected = false attempt.Payment.Result.......
I'm using sendbox test account and its api key. User should be redirected to the paypal website, is it correct? Have you got any idea what is the problem?
Hi Nik,
Can you help me? I am some question for you.
Demo website
I look that in your PayPal Express plugin you link this demo website: http://merchello.scandi.co/
Where I can find the source? I need to know how to activate the PayPal payment, check the success or fail result, then how to show confirm or do rollback.
Issues after fail PayPal communication
If I try to test to communicate to PayPal and it fail (because wrong account information), I look that the Basket does not works properly. There are some strange behavior that it can be solved by changing the products list (change quantity, add or remove item) for 2 or mre times (one time is not enough).
What is the best way to do a rollback?
I would that the buyer view the check-up basket page, where he can look the fail result of transaction. He will change the payment method or retry with the same.
But I can't do it because, after gateway fails, the Basket (or salesPreparation object) is not consistency.
Developing plugin
I look that January 12, 2015 you publish the 1.0.1 version.
Is this the final release? I am working to apply some change to source today.
The demo source is really not anyting more than just a standard Umbraco 7 install with Merchello 1.6. The thing that changed as part of our installation is the invoice confirmation. The following example shows how a link might be included if the user reaches the confirmation page but the payment has not yet been authorized.
I will find a place to post our sample site so you can see the entier solution, but this is the only place where we've made changes (merchReceiptPage.cshtml).
@inherits MerchKit.Mvc.MerchKitTemplatePage
@using System.Diagnostics
@using Merchello.Core
@using Merchello.Core.Models
@{
Layout = "merchBase.cshtml";
var invoiceKey = string.IsNullOrEmpty( Request.QueryString["inv"]) ? Guid.Empty : new Guid(Request.QueryString["inv"].DecryptWithMachineKey());
// Get the invoice
var invoice = MerchelloContext.Current.Services.InvoiceService.GetByKey(invoiceKey);
if (invoice == null)
{
Response.Redirect(HomePage.Url);
}
Debug.Assert(invoice != null, "invoice != null");
// We are planning on adding a few extension methods to assist in the retrieving the shipment information ...
// get the shipment line item
var shipmentLineItem = invoice.Items.FirstOrDefault(x => x.LineItemType == LineItemType.Shipping);
IShipment shipment = null;
var shipmentName = "";
if (shipmentLineItem != null)
{
// there will be only one shipment in this version
shipment = shipmentLineItem.ExtendedData.GetShipment<InvoiceLineItem>();
shipmentName = shipmentLineItem.Name;
}
var payments = invoice.Payments();
}
<section id="primary">
<h1>@Umbraco.GetDictionaryValue("merchReceiptHeadline")</h1>
<section class="receipt">
<p>@Umbraco.GetDictionaryValue("merchInvoiceNoLabel"): @invoice.PrefixedInvoiceNumber()</p>
<p>
@MvcHtmlString.Create(Umbraco.GetDictionaryValue("merchThanksParagraph"))
@if (payments.Count() > 0) { var payment = payments.First(); if (!payment.Authorized && payment.ExtendedData != null && payment.ExtendedData.ContainsKey("OrderConfirmUrl")) { <a href='@(payment.ExtendedData["OrderConfirmUrl"])'>Please confirm your order!</a> } }
</p>
<h3>Billed To</h3>
<span class="fn">@invoice.BillToName</span>
<span class="adr">
<span class="street-address">@invoice.BillToAddress1</span>
<span class="extended-address">@invoice.BillToAddress2</span>
<span class="locality">@invoice.BillToLocality</span>, <span class="region">@invoice.BillToRegion</span> <span class="postal-code">@invoice.BillToPostalCode</span>
<span class="country-name">@GetCountryName(invoice.BillToCountryCode)</span>
</span>
@if (shipment != null)
{
<h3>Shipped To</h3>
<span class="fn">@shipment.ToName</span>
<span class="adr">
<span class="street-address">@shipment.ToAddress1</span>
<span class="extended-address">@shipment.ToAddress2</span>
<span class="locality">@shipment.ToLocality</span>, <span class="region">@shipment.ToRegion</span> <span class="postal-code">@shipment.ToPostalCode</span>
<span class="country-name">@GetCountryName(shipment.ToCountryCode)</span>
</span>
}
<table class="order-summary">
@foreach (var item in invoice.Items.Where(x => x.LineItemType == LineItemType.Product))
{
<tr class="product">
<td>@item.Name<span class="variant">x @item.Quantity @@ @item.Price.ToString("C")</span></td>
<td>@item.TotalPrice.ToString("C")</td>
</tr>
}
<tr class="subtotal">
<td>@Umbraco.GetDictionaryValue("merchSubtotalLabel")</td>
<td>@invoice.TotalItemPrice().ToString("C")</td>
</tr>
<tr class="shipping">
<td>@Umbraco.GetDictionaryValue("merchShippingLabel")<span class="variant">@shipmentName</span></td>
<td>@invoice.TotalShipping().ToString("C")</td>
</tr>
<tr class="taxes">
<td>@Umbraco.GetDictionaryValue("merchTaxesLabel")</td>
<td>@invoice.TotalTax().ToString("C")</td>
</tr>
<tr class="total">
<td>@Umbraco.GetDictionaryValue("merchTotalLabel")</td>
<td>@invoice.Total.ToString("C")</td>
</tr>
</table>
</section>
</section>
@functions
{
private string GetCountryName(string countryCode)
{
return MerchelloContext.Current.Services.StoreSettingService.GetCountryByCode(countryCode).Name;
}
}
I compared my controller code with MerchKitApiController: they are the same.
I test plugin using a bad paypal account. Then when buyer try to confirm the basket, website returns an expected error.
If the buyer try again with another click to confirm button, the application returns an unexpected issue: System.NullReferenceException.
I think that I need to invoke a rollback method...
Is it right?
I look that I can solve this with 2 or more updates of basket.items list.
stack
in Merchello.Core.Persistence.Repositories.ItemCacheRepository.PersistDeletedItem(IItemCache entity) in c:\Working Repositories\GitHub\Merchello\src\Merchello.Core\Persistence\Repositories\ItemCacheRepository.cs:riga 133
in Merchello.Core.Persistence.Repositories.MerchelloRepositoryBase`1.PersistDeletedItem(IEntity entity) in c:\Working Repositories\GitHub\Merchello\src\Merchello.Core\Persistence\Repositories\MerchelloRepositoryBase.cs:riga 126
in Merchello.Core.Persistence.UnitOfWork.PetaPocoUnitOfWork.Commit(Action`1 transactionCompleting) in c:\Working Repositories\GitHub\Merchello\src\Merchello.Core\Persistence\UnitOfWork\PetaPocoUnitOfWork.cs:riga 115
in Merchello.Core.Services.ItemCacheService.Delete(IItemCache itemCache, Boolean raiseEvents) in c:\Working Repositories\GitHub\Merchello\src\Merchello.Core\Services\ItemCacheService.cs:riga 177
in Merchello.Core.Sales.SalesPreparationEvents.SalePreparationBaseOnFinalizing(SalePreparationBase sender, SalesPreparationEventArgs`1 args) in c:\Working Repositories\GitHub\Merchello\src\Merchello.Core\Sales\SalesPreparationEvents.cs:riga 52
in Umbraco.Core.Events.TypedEventHandler`2.Invoke(TSender sender, TEventArgs e)
in Merchello.Core.Sales.SalePreparationBase.AuthorizePayment(IPaymentGatewayMethod paymentGatewayMethod, ProcessorArgumentCollection args) in c:\Working Repositories\GitHub\Merchello\src\Merchello.Core\Sales\SalePreparationBase.cs:riga 338
in Merchello.Web.Workflow.BasketSalePreparation.AuthorizePayment(IPaymentGatewayMethod paymentGatewayMethod, ProcessorArgumentCollection args) in c:\Working Repositories\GitHub\Merchello\src\Merchello.Web\Workflow\BasketSalePreparation.cs:riga 39
in WebLib.Controller.BasketApiController.ConfirmBasket(JObject namedArgs) in c:\InetWeb\Domini\Benesse-Store.it\wwwv2\AppCode\WebLib\Controller\BasketApiController.cs:riga 596
in lambda_method(Closure , Object , Object[] )
in System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>cDisplayClass13.c(Object instance, Object[] methodParameters)
in System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
in System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)
NIK,
I build many changes to your PayPal plugin. Are you interested to it? I can push the version to GitHub.
I am not expert to collaboration in opensource project, then maybe my work is to trash.
I do this changes:
send Ship address to PayPal
Currency is set with invoice.Currency value
prices is round to 0 or 2 decimals (it depends by currency)
Custom lineTime are discard
add ReturnUrl, CancelUrl and AllArticlesPath to backoffice setting
add feature to customize ReturnUrl, CancelUrl and AllArticlesPath per request (with ProcessorArgumentCollection)
Hi Flavio, that'd be great. We're definitely open to suggestions and improvements. Feel free to do a pull request in GitHub and we'll check it out and merge in as appropriate. There may be some items that we'll have feedback on, but that's the nature of contributing :)
You just need to make sure the model.PaymentMethodKey is the key for the PayPal payment method. If you have multiple payment providers configured (and activated)
the PayPal plugin will return an OrderConfirmUrl if the payment was successful or throw an exception if it was not (with a message and success flag set to false).
try
{
var response = GetPayPalService().SetExpressCheckout(new SetExpressCheckoutReq { SetExpressCheckoutRequest = new SetExpressCheckoutRequestType(setExpressCheckoutRequestDetails) });
if (response.Ack == AckCodeType.SUCCESS)
{
payment.ExtendedData.SetValue(Constants.ExtendedDataKeys.OrderConfirmUrl, "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + response.Token);
return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, true);
}
var errorMessage = response.Errors.Count > 0 ? response.Errors[0].LongMessage : "An unknown error";
return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception(errorMessage)), invoice, false);
}
catch (Exception ex)
{
return new PaymentResult(Attempt<IPayment>.Fail(payment, ex), invoice, false);
}
I have the same issue with the sample site. I just used the documentation of the paypal plug-in together with the sample site, but I never got redirected to the paypal site. Any ideas why? How can I debug this?
What event/command from merchello should trigger the plugin to redirect to paypal?
In your checkout controller you confirm the order with the following code (or like this): attempt = preparation.AuthorizePayment(paymentMethod.Key);
If paypal plugin works fine (attempt.Payment.Success==true), you mast to redirect the user to the following url: string url = attempt.Payment.Result.ExtendedData.GetValue("OrderConfirmUrl")
Hope one more chipping in on this thread is OK! But also trying to set up the PayPal processor. Have set up the Gateway provider but getting the following error.
[NullReferenceException: Object reference not set to an instance of an object.]
Merchello.Plugin.Payments.PayPal.PayPalPaymentProcessor.ExpressCheckout(IInvoice invoice, IPayment payment) in d:\Merchello\SVN\GitHub\Plugin\Payments\PayPal\src\Merchello.Plugin.Payments.PayPal\PayPalPaymentProcessor.cs:48
Merchello.Plugin.Payments.PayPal.Provider.PayPalPaymentGatewayMethod.ProcessPayment(IInvoice invoice) in d:\Merchello\SVN\GitHub\Plugin\Payments\PayPal\src\Merchello.Plugin.Payments.PayPal\Provider\PayPalPaymentGatewayMethod.cs:74
Merchello.Plugin.Payments.PayPal.Provider.PayPalPaymentGatewayMethod.PerformAuthorizePayment(IInvoice invoice, ProcessorArgumentCollection args) in d:\Merchello\SVN\GitHub\Plugin\Payments\PayPal\src\Merchello.Plugin.Payments.PayPal\Provider\PayPalPaymentGatewayMethod.cs:50
Merchello.Core.Gateways.Payment.PaymentGatewayMethodBase.AuthorizePayment(IInvoice invoice, ProcessorArgumentCollection args) in c:\Working Repositories\GitHub\Merchello\src\Merchello.Core\Gateways\Payment\PaymentGatewayMethodBase.cs:108
Merchello.Core.Sales.SalePreparationBase.AuthorizePayment(IPaymentGatewayMethod paymentGatewayMethod, ProcessorArgumentCollection args) in c:\Working Repositories\GitHub\Merchello\src\Merchello.Core\Sales\SalePreparationBase.cs:336
Merchello.Web.Workflow.BasketSalePreparation.AuthorizePayment(IPaymentGatewayMethod paymentGatewayMethod, ProcessorArgumentCollection args) in c:\Working Repositories\GitHub\Merchello\src\Merchello.Web\Workflow\BasketSalePreparation.cs:39
Merchello.Core.Sales.SalePreparationBase.AuthorizePayment(Guid paymentMethodKey, ProcessorArgumentCollection args) in c:\Working Repositories\GitHub\Merchello\src\Merchello.Core\Sales\SalePreparationBase.cs:363
Merchello.Core.Sales.SalePreparationBase.AuthorizePayment(Guid paymentMethodKey) in c:\Working Repositories\GitHub\Merchello\src\Merchello.Core\Sales\SalePreparationBase.cs:373
MerchelloDemo.Web.Controllers.PaymentPageController.SelectPayment(PaymentPageViewModel vm) in c:\Projects\Source\Spikes\MerchelloDemo\MerchelloDemo.Web\Controllers\PaymentPageController.cs:74 ...
This occurs when I call AuthorizePayment here:
var paymentMethod = MerchelloContext.Current.Gateways.Payment.GetPaymentGatewayMethodByKey(vm.SelectedPaymentMethod).PaymentMethod;
var preparation = basket.SalePreparation();
preparation.SavePaymentMethod(paymentMethod);
var attempt = preparation.AuthorizePayment(paymentMethod.Key);
I am also suffering from the same problem @Damiaan reported when integrating the PayPal express plugin: authorize.Payment.Success is false, and the reported error in authorize.Payment is {"CancelURL is invalid."}
CancelURL is a parameter PayPal expects when setting up the checkout, but it is not available as a setting in the provider configuration. Can you shed some light on how I can set this parameter so the redirect to the PayPal checkout works?
Andy, are you sure you have setup everything correctly?
Barry, I have still the problem and haven't had any time to dive in. I remember something that paypal rejects local (http://localhost:4444) urls. Let us know if you solved the problem!
righht now we use Confirmation Return URL for the cancel URL. If the user confirms (pays) for the order, then the standard confirmation page is displayed, if they choose to cancel the PayPal process, then they are redirected to the Invoice Details (which is the same as the order confirmation), but this time a link is displayed to "try again" (see code in earler post in this thread).
Also, when configuring the confirm URL, make sure to keep it relative and not absolute (exclude the domain). We're prefixing the return URL based on the current site domain.
Thanks Nik excluding the domain from the confirm URL was it! You should include this little gotcha in the instructions PDF :-)
Could you also give me a pointer on how to look up the invoice on my confirm page please? I would like to display a page similar to the receipt on the Kitten example, however this depends on a reference to the invoice key in the URL and I cannot figure out how this can be passed to Paypal in the plugin settings. Is there a token I can use, or do I need to implement a different method to return the buyer's invoice?
I have Merchello 1.8.0 and Paypal Provider version 1.0.4 (downloaded from project page). I have installed successfully both plugins without any errors, createad a sandbox account, configured the account on paypal provider backoffice, and now I would like to have some paypal action...
The Merchello store is very good, I have created a new theme, and it is working fine. Congratulations for all your work!
Now I have a problem, on the confirm sale page, I have configure two payments: cash and paypal.
When I select Cash, everything is ok, and I can create the order, but when I select paypal, the "confirm sale" button disappear.
Anyone with the same problem? The 1.0.4 version work with the 1.8.0 version of Merchello? What are the Paypal configurations that I should have?
Nik advised a few weeks ago that his team was working on a Bazaar version of PayPal for release on/about 4/20. I guess keep checking back? We've had to abandon this PayPal payment extension and roll our own, due to time constraints, but it has great promise.
Sorry all, we've been swamped here and have not had time to come up for air to work on this. I will reach out to Rusty and try to coordinate ASAP! Thanks for your continued support.
The post from the button is pointing to ConfirmPayPalSale from the SalePreparationOperationsController (I've just copied the controller name to show you the example).
You have to write your own method to make this work.
This is the method I'm currently using for handling the PayPal payments:
[HttpPost]
public ActionResult ConfirmPayPalSale(CheckoutConfirmationForm model)
{
if (!ModelState.IsValid) return this.CurrentUmbracoPage();
var preparation = Basket.SalePreparation();
preparation.RaiseCustomerEvents = false;
preparation.ClearShipmentRateQuotes();
var shippingAddress = Basket.SalePreparation().GetShipToAddress();
// Get the shipment again
var shipment = Basket.PackageBasket(shippingAddress).FirstOrDefault();
// get the quote using the "approved shipping method"
var quote = shipment.ShipmentRateQuoteByShipMethod(model.ShipMethodKey);
// save the quote
Basket.SalePreparation().SaveShipmentRateQuote(quote);
var paymentMethod = GatewayContext.Payment.GetPaymentGatewayMethodByKey(model.PaymentMethodKey).PaymentMethod;
preparation.SavePaymentMethod(paymentMethod);
// AuthorizePayment will save the invoice with an Invoice Number.
var attempt = preparation.AuthorizePayment(paymentMethod.Key);
if (!attempt.Payment.Success)
{
return this.CurrentUmbracoPage();
}
// Trigger the order confirmation notification
var billingAddress = attempt.Invoice.GetBillingAddress();
string contactEmail;
if (string.IsNullOrEmpty(billingAddress.Email) && !CurrentCustomer.IsAnonymous)
{
contactEmail = ((ICustomer)CurrentCustomer).Email;
}
else
{
contactEmail = billingAddress.Email;
}
if (!string.IsNullOrEmpty(contactEmail))
{
Notification.Trigger("OrderConfirmation", attempt, new[] { contactEmail });
}
// store the invoice key in the CustomerContext for use on the receipt page.
CustomerContext.SetValue("invoiceKey", attempt.Invoice.Key.ToString());
string url = attempt.Payment.Result.ExtendedData.GetValue("RedirectUrl");
return Redirect(url);
}
Thanks for the info here. I'm still struggling to get PayPal working. I'm running with the Bazaar Starter Kit which was installed via the packages so I don't have access to the source code for it - is it available? I don't see it on github.
I've added the code for the PayPal button on the front end and that's working correctly, however, without access to the source can I add the controller action which deals with the PayPal request? I don't have access to SalePreparationOperationsController to add the new action as it's compiled within the Bazaar .dll.
Thank you for your quick reply. I understand, there is not controller to handle the request... I do not know the Merchello or PayPal structure, I have only changed some views on Baazar project and thats it.
Witch project do I need to compile? I have the VS project for the Merchello 1.8.0 with Bazaar. Can I use that to compile the code on top?
Just a update. I have managed to make it to work. I have found the controller on the Bazzar project and included your code. It is working ok now, many thanks for your help.
Now I have a question about the Return URL configuration.
I have configured my receipt page: /checkout/receipt/?inv=%INVOICE%
And Paypal plugin redirect correctly to this page with the inv variable filled in.
My question here is: Should the corresponding order change the status to Paid, or to other status? I need to make some actions after the order is payed thru paypal, so I need to have absolutely sure that everything went ok on PayPal process.
On my case I do not see any difference between the order before paypal process and after the Paypal redirection.
You need to add the confirm Sale Button for PayPal on CheckoutConfirmationForm.cshtml partial view and add the ConfirmPayPalSale POST action on SalePreparationOperationsController on Bazzar Store.
@ianblak10: yuo find merchello bazaar info merchello repo on github. You download merchello repo and find bazaar project. The merchello repo is a vs2013 solution with already Umbraco installed.
Thanks Biagio, I got the Bazaar source from the github repo. I made Tom's changes there and copied the bazaar dll back to my project and now I have PayPal functioning!
Now, as I mentioned, I have added the paypal provider from the CMS, but in the confirmation page, when I choose Paypal, the button Confirm Sale disappears.
Do I need to do some changes to controllers and even to the CashPayment MethodForm Please?
At the final stage of the PayPal payment, i'm getting this error. This occurs when you click 'Continue' on the Paypal page itself:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
Method not found: 'Void Merchello.Web.Workflow.IBasket.Empty()'.
</ExceptionMessage>
<ExceptionType>System.MissingMethodException</ExceptionType>
<StackTrace>
at Merchello.Plugin.Payments.PayPal.Controllers.PayPalApiController.SuccessPayment(Guid invoiceKey, Guid paymentKey, String token, String payerId) at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.<ExecuteAsync>b__4() at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)
Not as yet, probably won't get a chance until tomorrow. I suspect the method that's missing has been abstracted out within a later version of the package. I probably won't have time tonight.
I have been trying to follow this thread but have got completely lost. Basically I am running the following versions of Umbraco and Merchello:
Umbraco V7.2.6
Merchello V1.8.3
I have installed the PayPal Express payment provider V1.0.4 and although it appears in my list of payment options in the checkout, when I select it and click Submit I am not redirected anywhere.
I am plugging Merchello into an existing site so the use of the Bazaar package not an option so have been following the Samples outlined here:
Your payment handling function should look something like this
[HttpPost]
public ActionResult ConfirmPayPalSale(CheckoutConfirmationForm model)
{
if (!ModelState.IsValid) return this.CurrentUmbracoPage();
var preparation = Basket.SalePreparation();
preparation.RaiseCustomerEvents = false;
preparation.ClearShipmentRateQuotes();
var shippingAddress = Basket.SalePreparation().GetShipToAddress();
// Get the shipment again
var shipment = Basket.PackageBasket(shippingAddress).FirstOrDefault();
// get the quote using the "approved shipping method"
var quote = shipment.ShipmentRateQuoteByShipMethod(model.ShipMethodKey);
// save the quote
Basket.SalePreparation().SaveShipmentRateQuote(quote);
var paymentMethod = GatewayContext.Payment.GetPaymentGatewayMethodByKey(model.PaymentMethodKey).PaymentMethod;
preparation.SavePaymentMethod(paymentMethod);
// AuthorizePayment will save the invoice with an Invoice Number.
var attempt = preparation.AuthorizePayment(paymentMethod.Key);
if (!attempt.Payment.Success)
{
return this.CurrentUmbracoPage();
}
// Trigger the order confirmation notification
var billingAddress = attempt.Invoice.GetBillingAddress();
string contactEmail;
if (string.IsNullOrEmpty(billingAddress.Email) && !CurrentCustomer.IsAnonymous)
{
contactEmail = ((ICustomer)CurrentCustomer).Email;
}
else
{
contactEmail = billingAddress.Email;
}
if (!string.IsNullOrEmpty(contactEmail))
{
Notification.Trigger("OrderConfirmation", attempt, new[] { contactEmail });
}
// store the invoice key in the CustomerContext for use on the receipt page.
CustomerContext.SetValue("invoiceKey", attempt.Invoice.Key.ToString());
string url = attempt.Payment.Result.ExtendedData.GetValue("RedirectUrl");
return Redirect(url);
}
Unforetunately, I cannot make Paypal to work successfully.
So, I had included the a new HttpPost action method in the SalePreparationOpertaionsConteller and also added the below code in the CheckoutConfirmationForm.cshtml
Now, when I click on the Paypal button to continue with paypal, I am not being redirected to the Paypal Page, but just a blank page as the following link:
Installing Payment Provider Plugins
Hi all,
I'm relatively new to Umbraco, so appologies if this is a dumb question. However, I've just started looking into Merchello and so far it looks fantastic. I now want to add the PayPal payment provider, but I can't find any documentation on how to do this anywhere?
I've noticed that's it located here: https://github.com/Merchello/Merchello/tree/1.5.0/Plugin/Payments so I assume it's just a case of dropping some files somewhere?
Any help with this would be greatly appreciated.
Thanks
Hi there! Welcome to the Umbraco community and specifically to Merchello.
We haven't added any documentation around this yet, but I will get something together and will post in this thread ASAP (then we'll add it to the repo).
Thanks,
Nik
Thanks! Look forward to your reply
To install the plugin, I opened the plugin project and I updated the references (merchello and umbraco).
After that, I referenced the plugin project in the Umbraco project.
Finally, I copied all contents form the plugin project app_plugin folder in the umbraco project app_plugin folder.
someone has worked differently?
@Eidos the plugins (like payment providers and shipping providers) are generally installed a standard Umbraco packages.
The paypal plugin seems not have the package generator.
In addition, seems it is not updated to the latest version of umbraco and merchello.
I can try to update it. There is any guide/tutorial to build a payment provider?
Hi Eidos,
We only have scraps of documentation thus far on the gateway providers but have it scheduled to be working on the formal (merchello.com) docs this month. We will be starting with the Notification provider.
However, I'd be happy to help you out getting the PayPal provider patched up. Also Nik Walhberg's team (Scandia) are the ones that built it originally ...
In that plugin, other than updating the dependencies, I think the return notification needs some work - perhaps going to a HttpHandler.
Hi Eidos/Rusty,
We're working on refactoring the plugin today/tomorrow to make it work with the core changes as well as cleaning up the return notification (whcih, as Rusty pointed out, defintiely needs some TLC). Along with this we'll also start some documentation which should help folks use it.
Thanks for your patience all.
Best,
Nik
Hi Nik, hi Rusty,
They are good news.
Thanks
Hey Nik - let me know if you want to chat about it as you get going - I'll set my alarm to start work EST tomorrow ... 6am here ... so feel free to ping me on Skype if you like. Have a bunch of stuff on my plate tomorrow and I should start early anyway ;-)
Hey Rusty, thanks. We're working through some of the items now and will post to our Basecamp project as things come up. We should schedule a review once it's complete. Thanks for waking early! :) Hope you have a coffee nearby.
@Nik - any news about the paypal plugin?
Hi Eidos,
Could it be this that you are looking for http://our.umbraco.org//projects/collaboration/merchello-paypal-express-payment-provider
/Dennis
I didn't found it.
Thanks!
Hi Eidos, sorry that we didn't update you sooner. We're also releaseing a new version with additional features this week. I will post a message here when that is complete, but feel free to check out this one in the meantime.
Thanks!
Thanks Nik, as soon as possible I will test your plugin and the next week version!=)
Hi Nik,
I'm also having a bash using the Paypal gateway plugin. Could you point me in the direction of a sample of where it integrates in my CheckoutController (or equivalent)? Cutting my teeth on Merchello as well so trying to get my head round it all!
Thanks, Craig
Hi guys, I will get some more documetaion up there but for now I wanted to let you know that we've released a new version of the plugin that also provides automaitc redirect for authorization and capture of the payment (assuming the user successfully logs in to PayPal).
If you haven't already, grab the latest plugin and documentation from the our page:http://our.umbraco.org/projects/collaboration/merchello-paypal-express-payment-provider
Cheers!
Hi Nik,
one problem:
when I call
IPaymentResult attempt = base.Basket.SalePreparation().AuthorizePayment(<PayPalMethodKey>);
the result is the following:
attempt.Payment.Success = false
attempt.Payment.Error.Message = "Order total is invlaid"
attempt.Payment.Exception.Message = "Order total is invlaid"
attempt.Payment.Result.Amount = 86.8974
attempt.Payment.Result.Authorized = false
attempt.Payment.Result.Collected = false
attempt.Payment.Result.......
I'm using sendbox test account and its api key.
User should be redirected to the paypal website, is it correct?
Have you got any idea what is the problem?
Thanks
Hi Eidos.
I suggest you to round any price to 2 decimals. PayPal requires that the price is round to 2 decimals, and the decimal separator must be ".".
Use this:
var myStringPrice = decimalPrice.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture);
Hi Nik,
Can you help me? I am some question for you.
Demo website
I look that in your PayPal Express plugin you link this demo website: http://merchello.scandi.co/
Where I can find the source? I need to know how to activate the PayPal payment, check the success or fail result, then how to show confirm or do rollback.
Issues after fail PayPal communication
If I try to test to communicate to PayPal and it fail (because wrong account information), I look that the Basket does not works properly. There are some strange behavior that it can be solved by changing the products list (change quantity, add or remove item) for 2 or mre times (one time is not enough).
What is the best way to do a rollback?
I would that the buyer view the check-up basket page, where he can look the fail result of transaction. He will change the payment method or retry with the same.
But I can't do it because, after gateway fails, the Basket (or salesPreparation object) is not consistency.
Developing plugin
I look that January 12, 2015 you publish the 1.0.1 version.
Is this the final release? I am working to apply some change to source today.
Thanks!
Hi Flavio Spezi
I think that you can found the source code for the PayPal provider here: https://github.com/Merchello/Merchello/tree/1.6.1/Plugin/Payments/PayPal
Hope this helps,
/Dennis
Thanks Dennis, I'm searching the demo source.
Hi Flavio, thanks for posting your questions.
The demo source is really not anyting more than just a standard Umbraco 7 install with Merchello 1.6. The thing that changed as part of our installation is the invoice confirmation. The following example shows how a link might be included if the user reaches the confirmation page but the payment has not yet been authorized.
I will find a place to post our sample site so you can see the entier solution, but this is the only place where we've made changes (merchReceiptPage.cshtml).
Let me know if this helps. Thanks!
Hi Flavio,
The demo shop source can you find here: https://github.com/Merchello/Samples/tree/master/Samples/Kitten/Merchello.StarterSite and I can see that there have been made a pull-request for PayPal, 2 days ago, and the file that have been made changes to is located here: https://github.com/Merchello/Samples/blob/master/Samples/Kitten/Merchello.StarterSite/App_Code/MerchKit/Controllers/MerchKitApiController.cs
You can find the pull-request here https://github.com/Merchello/Samples/pull/20 perhaps, it can help you closer.
/Dennis
@Flavio: thanks for your suggests.
I tried to change the price so that the total has 2 decimals but ApproveOrderCreation is false again and return the same error.
@Nik in your PerformAuthorizePayment method, how do you check if the order total is invalid or not? (so I know where I get wrong)
Eidos, which version of the plugin are you using? Also, what version of Merchello do you have installed?
Umbraco 7.2.1, Merchello 1.6.1 and PayPal 1.0.1
I compared my controller code with
MerchKitApiController
: they are the same.I test plugin using a bad paypal account. Then when buyer try to confirm the basket, website returns an expected error.
If the buyer try again with another click to
confirm
button, the application returns an unexpected issue:System.NullReferenceException
.I think that I need to invoke a rollback method...
Is it right?
I look that I can solve this with 2 or more updates of
basket.items
list.stack
Hi Flavio, I think this is unlreated to the payment provider plugins. This last issue should probably have it's own thread.
Thanks,
Nik
Ok, I created new issue: http://issues.merchello.com/youtrack/issue/M-573
NIK,
I build many changes to your PayPal plugin. Are you interested to it? I can push the version to GitHub.
I am not expert to collaboration in opensource project, then maybe my work is to trash.
I do this changes:
I am at your command, Nik
Hi Flavio, that'd be great. We're definitely open to suggestions and improvements. Feel free to do a pull request in GitHub and we'll check it out and merge in as appropriate. There may be some items that we'll have feedback on, but that's the nature of contributing :)
Thanks for your feedback and work on this Flavio!
Best,
Nik
thanks @Nik and @Flavio:
now the PayPal plugin seems to work fine but I will test it!
The problem was about the separator of decimal price (I had to fix it in all occurrences).
Short question: how can I obtain the paymentMethodKey from an invoice? (I woult like to use the same result order page for all payment used).
It is simply when you have only one Payment:
invoice.Payments().First().PaymentMethodKey
Hi Nik, Flavio,
this code below seems only to handle cashpayments
Currently it doesn't redirect to paypal. Do we need to add extra code when the paymentmethod is PayPal?
We couldn't find any code nor example on that.
Can any of you enlight me? :)
Hi Raoul,
You just need to make sure the model.PaymentMethodKey is the key for the PayPal payment method. If you have multiple payment providers configured (and activated)
may not return the PayPal payment method key.
Hi Rusty,
I checked this one... the key which we get is the paypal key.
Hey Raoul,
the PayPal plugin will return an OrderConfirmUrl if the payment was successful or throw an exception if it was not (with a message and success flag set to false).
Are you using 1.0.0 or 1.0.1?
Thanks,
Nik
Hi Nik,
Thx for your reply.
We are 1.01
Looking at Rusty's reply I would imagine that there is an automatic redirect to paypal which we don't get to work.
Your code above is this the one which is invoking the redirect to paypal?
Raoul
Hi,
I have the same issue with the sample site. I just used the documentation of the paypal plug-in together with the sample site, but I never got redirected to the paypal site. Any ideas why? How can I debug this?
What event/command from merchello should trigger the plugin to redirect to paypal?
Kind regards
Damiaan
In your checkout controller you confirm the order with the following code (or like this):
attempt = preparation.AuthorizePayment(paymentMethod.Key);
If paypal plugin works fine (attempt.Payment.Success==true), you mast to redirect the user to the following url:
string url = attempt.Payment.Result.ExtendedData.GetValue("OrderConfirmUrl")
Hi guys thanks for helping out!
Currently the property of Authorize.Payment.Success is false. The error message on the Payment object is: "Order total is invalid."
Any hints?
Hi Nik,
We looked it up and apparently this is a PayPal error
10401 Transaction refused because of an invalid argument. See additional error messages for details. Order total is invalid. SetExpressCheckout
We found a work-around. We needed to set the culture needs to en-US before running the payment handling.
We have now a new Exception from PayPal.
Invalid CancelUrl how can we sort this?
Hope one more chipping in on this thread is OK! But also trying to set up the PayPal processor. Have set up the Gateway provider but getting the following error.
This occurs when I call AuthorizePayment here:
Many thanks in advance for any pointers.
Andy
I am also suffering from the same problem @Damiaan reported when integrating the PayPal express plugin: authorize.Payment.Success is false, and the reported error in authorize.Payment is {"CancelURL is invalid."}
CancelURL is a parameter PayPal expects when setting up the checkout, but it is not available as a setting in the provider configuration. Can you shed some light on how I can set this parameter so the redirect to the PayPal checkout works?
Andy, are you sure you have setup everything correctly? Barry, I have still the problem and haven't had any time to dive in. I remember something that paypal rejects local (http://localhost:4444) urls. Let us know if you solved the problem!
Thanks Damiaan, I tried your suggestion but using a non-localhost address does not help unfortunately.
Hi all,
righht now we use Confirmation Return URL for the cancel URL. If the user confirms (pays) for the order, then the standard confirmation page is displayed, if they choose to cancel the PayPal process, then they are redirected to the Invoice Details (which is the same as the order confirmation), but this time a link is displayed to "try again" (see code in earler post in this thread).
Also, when configuring the confirm URL, make sure to keep it relative and not absolute (exclude the domain). We're prefixing the return URL based on the current site domain.
Hope this helps.
Cheers,
Nik
Thanks Nik excluding the domain from the confirm URL was it! You should include this little gotcha in the instructions PDF :-)
Could you also give me a pointer on how to look up the invoice on my confirm page please? I would like to display a page similar to the receipt on the Kitten example, however this depends on a reference to the invoice key in the URL and I cannot figure out how this can be passed to Paypal in the plugin settings. Is there a token I can use, or do I need to implement a different method to return the buyer's invoice?
Have you tried to install the latest version of the PlugIn?
You can find it here:
https://github.com/Merchello/Merchello/tree/1.8.1/Plugin/Payments/PayPal
Hi all,
I have Merchello 1.8.0 and Paypal Provider version 1.0.4 (downloaded from project page). I have installed successfully both plugins without any errors, createad a sandbox account, configured the account on paypal provider backoffice, and now I would like to have some paypal action...
The Merchello store is very good, I have created a new theme, and it is working fine. Congratulations for all your work!
Now I have a problem, on the confirm sale page, I have configure two payments: cash and paypal.
When I select Cash, everything is ok, and I can create the order, but when I select paypal, the "confirm sale" button disappear.
Anyone with the same problem? The 1.0.4 version work with the 1.8.0 version of Merchello? What are the Paypal configurations that I should have?
Which are the rights url to configure into Paypal gateway plugin?
Nik advised a few weeks ago that his team was working on a Bazaar version of PayPal for release on/about 4/20. I guess keep checking back? We've had to abandon this PayPal payment extension and roll our own, due to time constraints, but it has great promise.
Sorry all, we've been swamped here and have not had time to come up for air to work on this. I will reach out to Rusty and try to coordinate ASAP! Thanks for your continued support.
Best,
Nik
Hi guys,
Is there any solution to Cristovao's issue yet? I am having the same problem.
Thanks
Me too
You need to add a separate button for the PayPal payment when using the Bazaar Starter kit:
Hi Tom,
Thank you for your clarification. I have placed the div with the button and now it appears.
But are you sure that it is the correct controller name? When I make the "Confirm Sale" request, I have a 404 not found error...
Note: I am working with a PayPal Sandbox Account, I havent enable the https yet, I do not now if this is relevant..
Any sugestions?
Hi Cristovao,
The post from the button is pointing to ConfirmPayPalSale from the SalePreparationOperationsController (I've just copied the controller name to show you the example).
You have to write your own method to make this work.
This is the method I'm currently using for handling the PayPal payments:
Hey Tom,
Thanks for the info here. I'm still struggling to get PayPal working. I'm running with the Bazaar Starter Kit which was installed via the packages so I don't have access to the source code for it - is it available? I don't see it on github.
I've added the code for the PayPal button on the front end and that's working correctly, however, without access to the source can I add the controller action which deals with the PayPal request? I don't have access to SalePreparationOperationsController to add the new action as it's compiled within the Bazaar .dll.
Thanks, Ian.
Hi Tom,
Thank you for your quick reply. I understand, there is not controller to handle the request... I do not know the Merchello or PayPal structure, I have only changed some views on Baazar project and thats it.
Witch project do I need to compile? I have the VS project for the Merchello 1.8.0 with Bazaar. Can I use that to compile the code on top?
I take a look on the PayPal page on GitHub https://github.com/Merchello/Merchello/tree/1.6.1/Plugin/Payments/PayPal
But this do not seem to be the current 1.0.4 version of the plugin available on Umbraco page (I have installed version 1.0.4).
If you have a Visual Studio Sample project for me to integrate the code you have posted it will help me and others.
Again, thank you for your help.
Hi Tom,
Just a update. I have managed to make it to work. I have found the controller on the Bazzar project and included your code. It is working ok now, many thanks for your help.
Hi again,
Now I have a question about the Return URL configuration. I have configured my receipt page: /checkout/receipt/?inv=%INVOICE% And Paypal plugin redirect correctly to this page with the inv variable filled in.
My question here is: Should the corresponding order change the status to Paid, or to other status? I need to make some actions after the order is payed thru paypal, so I need to have absolutely sure that everything went ok on PayPal process.
On my case I do not see any difference between the order before paypal process and after the Paypal redirection.
Thanks in advance.
Is it support recurring payments?
Why don't appear the confirmation button?
Hi Biagio,
You need to check the Tom Van Rompaey responses.
You need to add the confirm Sale Button for PayPal on CheckoutConfirmationForm.cshtml partial view and add the ConfirmPayPalSale POST action on SalePreparationOperationsController on Bazzar Store.
It is working OK with me.
Note: Merchello 1.8.0 and PayPal plugin 1.0.4
Hi,
don't work anymore in Merchello 1.9.x. They have changed the code. See here: https://our.umbraco.org/projects/collaboration/merchello/merchello/67161-where-is-confirm-button-when-i-choose-paypal-as-payment-method
Now works...but I think is better to create the code like Cash Payment or Braintree directly into their controllers.
Which are the rights url to configure into Paypal gateway plugin?
@ianblak10: yuo find merchello bazaar info merchello repo on github. You download merchello repo and find bazaar project. The merchello repo is a vs2013 solution with already Umbraco installed.
Thanks Biagio, I got the Bazaar source from the github repo. I made Tom's changes there and copied the bazaar dll back to my project and now I have PayPal functioning!
Thanks guys!
Good. High Five, please, if all ok.
Hi guys, do we have a working sample project?
I have Merchello installed, products, a basket and checkout process. At the moment the checkout process just saves the payment details.
I have installed the PayPal plugin, but struggling to find solid documentation for the controller that 'talks' with paypal.
thanks
Hi Cristovao,
How have you managed it to work?
Currently, I have installed the Payapl Express Plugin and in CashPaymentMethodForm has the following:
Now, as I mentioned, I have added the paypal provider from the CMS, but in the confirmation page, when I choose Paypal, the button Confirm Sale disappears.
Do I need to do some changes to controllers and even to the CashPayment MethodForm Please?
Thank you. Appreciate any help.
Kind Regards.
Hi Simon, you need to add this snippet underneath you cash method of that view:
At the final stage of the PayPal payment, i'm getting this error. This occurs when you click 'Continue' on the Paypal page itself:
Hi Jason,
I have done that,, but do you need to alter the controller?
Thank you.
Hi yes you need to get the Bazaar source and add a httppost method. There's a post above describing it. Then build and add the dll to your project
Have you solved the error that you have mentioned above?
Thank you
Not as yet, probably won't get a chance until tomorrow. I suspect the method that's missing has been abstracted out within a later version of the package. I probably won't have time tonight.
Are you now getting the same error?
Hi Simon, see this thread to fix the error as per my post above:
https://our.umbraco.org/projects/collaboration/merchello/merchello/70231-paypal-express-payment-provider-method-not-found-exception
I have been trying to follow this thread but have got completely lost. Basically I am running the following versions of Umbraco and Merchello:
Umbraco V7.2.6 Merchello V1.8.3
I have installed the PayPal Express payment provider V1.0.4 and although it appears in my list of payment options in the checkout, when I select it and click Submit I am not redirected anywhere.
I am plugging Merchello into an existing site so the use of the Bazaar package not an option so have been following the Samples outlined here:
https://github.com/Merchello/Samples
Does the PayPal plugin not work with the code samples that are given, if not what is the best way around my current dilemma?
Hi Graham, integrating Paypal into your site with or without the Bazaar build as a base, will require a small amount of work.
Setting up your payment provider and gateway is done by the sounds of it.
You next need to :
Create a Paypal button - this button should call your payment handling controller, in particular the paypal handler
Your payment handling function should look something like this
You will also need to change the Paypal Plugin dll. See this post here to either make the change yourself or download the modified dll. https://our.umbraco.org/projects/collaboration/merchello/merchello/70231-paypal-express-payment-provider-method-not-found-exception
I can supply a working sample site using the bazaar store if this helps.
Hope this helps
Jason
p.s. don't forget to add your paypal information into the provider
Hi,
Could you post Umbraco log?
HI Guys,
Unforetunately, I cannot make Paypal to work successfully.
So, I had included the a new HttpPost action method in the SalePreparationOpertaionsConteller and also added the below code in the CheckoutConfirmationForm.cshtml
Now, when I click on the Paypal button to continue with paypal, I am not being redirected to the Paypal Page, but just a blank page as the following link:
Also, I have configured the paypal plugin with a sandbox account.
I am really lost about this.
Does anybody have a solution please?
Thank you in advance.
I've not installed the 1.11 version. Have you recompiled the Paypal sources with Merchello 1.11?
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.