Using Paypal with Magelia

Feb 20, 2014 at 1:18 PM
I have been setting up my store to use PayPal. I am using Orchard CMS. I have the been able to get the payments to PayPal and been through the SandBox testing. All that looks good.

I would like to more fully integrate the process between the store and PayPal. I will assume that PayPal can or does send a response back to the site. In the case of using Orchard would that response go the store or the Orchard page?

How do I capture that response, and pass the information to the Store?

Once it is received, and payment has been made, how do I use that to change the Order Status to Approved?

I have looked for guidance in the documentation, the forum, general Google searches without success.

Any guidance is appreciated.

John W.
Feb 24, 2014 at 4:28 PM
Edited Feb 24, 2014 at 4:34 PM
Hi jkwrpc,

In order to catch the Paypal notification and update the order status appropriately or register the payment you have to develop your own Orchard module referencing the Magelia.WebStore module and use the IWebStoreServices implementation to access to the StoreClient.

Do not hesitate if you need a code sample or have any further questions.

Best regards,
Aloys GAUTHEY
Feb 24, 2014 at 5:12 PM
Thank you, I would really like a code sample if you have one to share. This is my first store app,my first Orchard app and I am still trying to wrap my arms around how all this (Orchard, Megelia, and PayPal) get wired together.

--
Regards

John W.
Feb 25, 2014 at 1:36 PM
Hi John,

I will prepare you a sample module project as soon as possible.

Best regards,
Aloys GAUTHEY
Mar 7, 2014 at 5:54 AM
Hi,

I'm also interested in getting some samples. In particular, is it possible to allow the user to cancel the payment on Paypal and find the items still in their cart? Right now the order is placed regardless, and the items are even taken out of the inventory.
Mar 7, 2014 at 2:05 PM
I really think having a PayPal sample will really be helpful. I have a small store, primarily software downloads. In some respects Megelia is almost too much store for my needs. However, there is a lot I like about it and because it can grow its worth learning. Having a basic payment processing sample available would be such a huge step forward and a real help to the community.

Regards

John W.
Apr 28, 2014 at 7:26 PM
adinsx wrote:
Hi John,

I will prepare you a sample module project as soon as possible.

Best regards,
Aloys GAUTHEY
Hello Aloys,

I am very much interested in your sample module, how can I put my hands on it?

Thanks in advance
Simon
Apr 30, 2014 at 2:50 PM
Hi Aloys,

Any progress with the code sample? I too am hoping to integrate Orchard Magelia with Paypal.

Regards, PK
May 5, 2014 at 2:00 PM
Edited May 5, 2014 at 2:02 PM
Hi,

We are realy sorry for the delay but the whole team has been busy lately on third release of Magelia WebStore and the extension store.

As agreed, here is a sample Paypal implementation using Magelia WebStore module for Orchard.

The following code sample that you can download from here http://www.magelia.org/download/Magelia.WebStore.Paypal.zip is composed of two parts :

=> A view that you have to copy in your Orchard current theme folder according to the following path : "[YOUR_THEME_FOLER]/Views/DisplayTemplates/Checkout/ProceedToPayment.cshtml".

You will see in this view that you have few things to specify :
var business = "[mail_address]@[provider].[ext]";                   // Your Paypal business ID

var returnPath = this.Url.Content("~/");                            // Relative path of the payment confirmation page.
var cancelPath = this.Url.Content("~/");                            // Relative path of the cancellation page.
var publicUrl = "http://www.[your_public_domain].[ext]";            // Public domain of your application, which will be used to generate public URL reachable by Paypal IPN services and to redirect the customer.
Once this view is configured and placed at the right place within the current theme folder it will be automatically used as the last step of the checkout process to automatically redirect customers on the Paypal platform, which will allow them to pay their order.

Please note that in the sample view the Paypal sandbox is used. Once you are ready to go live you will just have to remove the sandbox prefix of the url referenced in the action attribute of the form tag :
<form method="post" action="https://www.paypal.com/cgi-bin/webscr" class="mag-proceedToPayment">
=> The second part of this code sample is an Orchard module project that relies on Magelia WebStore module in order to handle Paypal IPN.

Once installed and activated this module will automatically track Paypal payments, update order status and trigger the sending of the appropriate emails to customers regarding the state of the payment reported by Paypal.

This module is simple as it contains only one controller. Its aim is to handle and verify Paypal IPN in order to register payments that you will be able to see the in the Magelia WebStore Administration console in the payments tab of the order detail screen. If the payment is declared as completed by Payal and if it corresponds to the correct order amount then the order status will be updated to "approved" otherwise if the customer has cancelled is payment the order status "cancelled" will be set.

Please note that the Paypal sandbox URL is also referenced in this controller so to go live you will have to removed the sandbox prefix :
private const String VerificationUrl = "https://www.paypal.com/cgi-bin/webscr?cmd=_notify-validate";
We hope that this code sample will be helpful and do not hesitate if you have any further questions.

Best regards,
Aloys GAUTHEY
May 6, 2014 at 7:37 PM
Thank you very much Aloys, I'll give it a try ASAP!!

Regards,
Simon