Copied to clipboard

Flag this post as spam?

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


  • Barry Fogarty 493 posts 1129 karma points
    Jan 30, 2015 @ 13:17
    Barry Fogarty
    0

    SagePay payment provider

     I would like to build a payment provider for SagePay, so I would be very interested to hear from anyone with advice or pointers.  My client needs a fairly simple iFrame-based integration, so I figure the workflow will be relatively similar to the PayPal express provider.  Essentially, after card details have been submitted in the iFrame, the provider must process a status notification returned by SagePay, verify the data is legit, and return an OrderConfirmation URL that SagePay will redirect the customer to.

    Basically I would liove to hear from a) anyone who's done any integration work with SagePay, or b) Nik/Rusty or anyone at Merchello who can guide me / scaffold out setting up SagePay as a Merchello payment provider.

    FYI There is a .Net integration kit that I am taking a look at now here http://www.sagepay.co.uk/support/find-an-integration-document/server-inframe-integration-documents

    Thanks!

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Jan 31, 2015 @ 17:17
    Rusty Swayne
    1

    Hi Barry,

    I don't know if anyone has started a SagePay provider, but with the .Net integration kit it should be pretty straight forward. I can help you get things scaffolded next week and we can setup a Skype call if your interested. Send me a DM =)

  • Chris Foot 61 posts 93 karma points
    Feb 25, 2015 @ 12:42
    Chris Foot
    0

    Hi Barry,

    I understand from Rusty's tweet this morning that you now have this working. Is it possible to get a copy. The client I am working with at the moment uses sagepay so I was about to write my own provider, in fact, I was due to start today when I spotted Rusty's tweet suggesting you already have one working!

    Thanks

    Chris

  • Barry Fogarty 493 posts 1129 karma points
    Feb 25, 2015 @ 13:07
    Barry Fogarty
    0

    Hi Chris

    Sure thing Chris - the repo is at https://github.com/BluefinDigital/Merchello.Plugins.SagePay

    I am working on it as we speak, but as of last night the form integration method is working.  Good timing!  NB My client only needs form integration, but if you like we can collaborate, so it is more useful for your needs and those of the wider Merchelo comunity.  SagePay integration methods: http://www.sagepay.co.uk/support/integration-kits-protocols-document

    Instructions:

    1. Clone the repo and build the solution
    2. Drop the App_Plugins/Merchello.SagePay folder into /App_Plugins on your Umbraco site
    3. Copy or reference the Merchello.Plugin.Payments.SagePay.dll and SagePay.IntegrationKit.DotNet.dll to your /bin
    4. Configure the provider in the Merchello backoffice (Gateways page) - you also need to add a payment method for SagePay in the Payments tab
    SagePay shoud then appear as an available payment method in your checkout.
    Let me know how you go!  I plan to have this set up as an Umbraco package (and hopefully nuget) in the next few weeks.
  • Chris Foot 61 posts 93 karma points
    Feb 25, 2015 @ 13:59
    Chris Foot
    0

    Hi Barry,

    That's great. I'll start looking this afternoon. My client needs direct integration so i'll have some work to do! I have no experience in merchello payment providers so I've got a bit of learning to do as well but I have done many SagePay direct integration in the past so that should help somewhat.

    Thanks

    Chris

  • Chris Foot 61 posts 93 karma points
    Feb 27, 2015 @ 17:59
    Chris Foot
    0

    Hi Barry,

    I have the sagepay direct integration working. I still have to write the 3D Secure part of it but for basic transactions, it's working. I have had to refactor a fair amount of code to support multiple payment providers which I have pushed to a fork of the project. I haven't actually worked on a git project collaboratively yet so please bear with me! Should I create a push request now so you can see where i'm at or should I wait until I have completed the 3D secure stuff?

    Thanks

    Chris

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Feb 28, 2015 @ 07:09
    Rusty Swayne
    0

    Chris,

    I'm interested in what you mean by multiple providers ... in Merchello terms I think this means multiple "Methods" for the SagePay provider. If I'm correct in my assumption, what I believe needs to happen is tweak with the existing SagePayGatewayProvider" code a bit.

    Is this what you meant?

    I'm off for uWestFest next week but really would like to make sure you two do not hit a wall with your efforts. Let me know if you need anything in particular - can even do a Skype call if you get stuck!

    Rusty

  • Chris Foot 61 posts 93 karma points
    Mar 02, 2015 @ 09:48
    Chris Foot
    0

    Hi Rusty,

    I mean multiple methods for the same provider! The version of the sagepay provider I have now supports sagepay form and sagepay direct. I've already tweaked the code so that there are two methods which inherit from a base method. I took the same approach as the braintree integration. I'm close to being finished with the code now, the direct method is putting through payments successfully, I just need to implement 3D secure on it but i'm waiting on sagepay to turn 3d secure on for the account I have access to. I'm just very new to working on git projects collaboratively so wanted to make sure it was ok to submit a push request with my updated code!

    Have a great time at uWestFest.

    Thanks

    Chris

  • Barry Fogarty 493 posts 1129 karma points
    Mar 02, 2015 @ 11:52
    Barry Fogarty
    0

    Hi Chris,

    Great work on the direct integration method.  I will be able to review your pull request tomorrow and check there are no conflicts with the form integration - absolutely no problem to keep pushing your updates and hopefully we can review with Rusty after he's done with uWestfest (BTW I'm also a Git noob re collaboration :-).

  • David Greasley 15 posts 97 karma points
    Mar 05, 2015 @ 19:00
    David Greasley
    0

    Hi guys, I'm currently working on an eCommerce solution using Merchello and my client wants to use SagePay. We're going to be using the Server Integration method and I'd be interested adding Server Integration as a method in this provider.

    I just pulled down the repository https://github.com/BluefinDigital/Merchello.Plugins.SagePay and it only seems to contain the Forms integration method. Is there any way I can see what you've been working on Chris to see how you've refactored things and to make sure what I do is compatible with your changes...

  • Chris Foot 61 posts 93 karma points
    Mar 06, 2015 @ 10:12
    Chris Foot
    0

    Hi David,

    My fork should be listed under the forks for the repository. Alternatively the direct url is here: https://github.com/chris64digital/Merchello.Plugins.SagePay

    It would definitely be better to add the extra method to my updated version as the original doesn't support multiple methods. Fingers crossed Barry will be able to accept my pull request though there are a lot of changes so it might take a little while to review!

    Chris

  • Barry Fogarty 493 posts 1129 karma points
    Mar 06, 2015 @ 11:01
    Barry Fogarty
    0

    Hi Guys,

    I am reviewing this at the mo.  Apologies for the delay.  Looks good so far hopefully will have it merged in an hour.

    Barry

  • Barry Fogarty 493 posts 1129 karma points
    Mar 06, 2015 @ 12:54
    Barry Fogarty
    0

    OK Guys - I have merged the PR and pushed up to master.

    https://github.com/BluefinDigital/Merchello.Plugins.SagePay

    Great work Chris thanks for your input!  One thing I'd like to check with you is if the all settings saved with the Gateway provider are in the right place e.g. ReturnUrl, CancelUrl etc.  If not, a refactor could be in order so to separate settings that pertain to the payment METHOD as opposed to global stuff (like VendorName and Encryption password).   This is my first Sagepay integration and I havent touched anyhting other than the basic FORM process so I'd like to get your thoughts - if so lets move the conversation over to GitHub please.

  • Chris Foot 61 posts 93 karma points
    Mar 06, 2015 @ 13:15
    Chris Foot
    0

    Hi Barry,

    I'm happy to continue code discussion on github but i'm not really sure where code discussions actually go! Feel free to get it started and i'll give you my input.

    Chris

  • Barry Fogarty 493 posts 1129 karma points
    Mar 06, 2015 @ 13:28
  • Chris Foot 61 posts 93 karma points
    Apr 20, 2015 @ 16:53
    Chris Foot
    0

    Hi Barry,

    I'm now working on adding Paypal to the supported methods for sagepay direct. Unfortunately, unlike the normal sagepay direct, the paypal integration relies on sending the customer to paypal then getting a callback from sagepay once complete. I believe that it is very similar to the way that the sagepay form integration works. At the moment i'm struggling to work out how your form integration completes the callback. I can see where it gets the url from sagepay to send the customer to but I can't spot the code for responding to the callback. Would this part be implemented in front-end code?

    Thanks

    Chris

  • Barry Fogarty 493 posts 1129 karma points
    Apr 27, 2015 @ 11:47
    Barry Fogarty
    0

    Hi Chris, 

     

    Sorry for the delay I have been away on holiday.  The code that responds to the callback is in the SagePayApiController class:

    https://github.com/BluefinDigital/Merchello.Plugins.SagePay/blob/master/src/Merchello.Plugin.Payments.SagePay/Controllers/SagePayApiController.cs

    There are 2 methods in here, SuccessPayment and AbortPayment.  The URLs to these methods are called by SagePay after they process the payment via Form Integration.  Hope this helps.

  • Gordon Saxby 1444 posts 1855 karma points
    Jun 27, 2015 @ 11:35
    Gordon Saxby
    0

    Can't get the settings tab to work - details here https://github.com/BluefinDigital/Merchello.Plugins.SagePay/issues/8

  • Chris Foot 61 posts 93 karma points
    Jul 10, 2015 @ 17:01
    Chris Foot
    0

    I'm working on fixing this issue right now but am hoping that Rusty can shed some light on why it's not working!

    At the moment, when the system does the GetResolvedPaymentGatewayProviders call it returns the sagepay provider with no extended data but I can't work out why. I'm away for a couple of days now so will hopefully have this working when I get back since I also need it working on a 1.9 site!

    Rusty: Is there something we haven't implemented on this provider that should be populating the extended data? I can see it working for the smtp notification provider but I can't see what is different with this provider!

    Thanks

    Chris

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Jul 10, 2015 @ 17:07
    Rusty Swayne
    0

    I'll have to checkout the provider to be certain, but my first thought is there probably needs to be an event handler setup to create some default extended data values when the provider is "Activated". Is there an event handler setup?

  • Chris Foot 61 posts 93 karma points
    Jul 14, 2015 @ 10:08
    Chris Foot
    0

    Rusty,

    That sounds quite likely and gives me a starting point to look into. What is called when the provider is activated?

    Thanks

    Chris

  • Gordon Saxby 1444 posts 1855 karma points
    Jul 12, 2015 @ 12:24
    Gordon Saxby
    0

    @Chris Foot ... I hope you're talking about my issue!?! :-)

    I am starting to get rather worried now, my project has to be working before the end of July ... and that is fast approaching!

  • Chris Foot 61 posts 93 karma points
    Jul 14, 2015 @ 10:06
    Chris Foot
    0

    Mine has to be working by yesterday so you can trust me when I say i'm looking at it ;)

    Should have something in the git repository today.

  • Chris Foot 61 posts 93 karma points
    Jul 14, 2015 @ 10:57
    Chris Foot
    0

    I have a fix for issue 8 and have updated my pull request for the update. If you need this before the request is accepted then you can get the source from my fork of the repository. It should compile easily enough. I have not tested the checkout process yet, it may just work but i'll let you know later!

    Chris

  • Gordon Saxby 1444 posts 1855 karma points
    Jul 14, 2015 @ 10:59
    Gordon Saxby
    0

    Right in the middle of another project at the moment, but will take a look this afternoon.

  • Gordon Saxby 1444 posts 1855 karma points
    Jul 14, 2015 @ 13:56
    Gordon Saxby
    0

    Umm, downloaded code from your repository and compiled OK. removed previous SagePay gateway code and copied over the new version (including DLLs).

    The SagePay gateway configuration now appears to work (it displays correctly and saves), but I can't add a Payment Provider. It is there to be added (I need the Forms version), but when I save I get:

    Received an error from the server
    

    Failed to payment provider methods for: 31fda06c-a9d3-4dfb-9773-63724e0977b4

    EXCEPTION DETAILS:

    : STACKTRACE:

  • Chris Foot 61 posts 93 karma points
    Jul 14, 2015 @ 14:13
    Chris Foot
    0

    I'm just looking into that one! Should have something later this afternoon but i'll go through the whole payment process before I commit again.

  • Chris Foot 61 posts 93 karma points
    Jul 14, 2015 @ 15:32
    Chris Foot
    0

    Looks like the PaymentGatewayMethod attribute needed updating to include the two new payment editors. I'm going to continue testing and commit/push at the end of the day once i'm convinced it's all working correctly.

  • Gordon Saxby 1444 posts 1855 karma points
    Jul 14, 2015 @ 15:34
    Gordon Saxby
    0

    Great stuff, I'll be waiting :-)

  • Chris Foot 61 posts 93 karma points
    Jul 14, 2015 @ 19:13
    Chris Foot
    0

    Ok, my latest commit appears to be working for me. I did have to clean the project before it started working but it all looks good now. I've also successfully submitted a test payment. I have further testing to do but feel free to give it a try and let me know how you get on.

    Cheers

    Chris

  • Gordon Saxby 1444 posts 1855 karma points
    Jul 14, 2015 @ 20:15
    Gordon Saxby
    0

    Darn ... got all the way to the end of checkout and when I select SagePay ... the Confirm button disappears :-(

  • Chris Foot 61 posts 93 karma points
    Jul 15, 2015 @ 16:24
    Chris Foot
    0

    Hi Gordon,

    This is definitely working for me now. Which method are you using, form or direct?

    Chris

  • Gordon Saxby 1444 posts 1855 karma points
    Jul 15, 2015 @ 16:34
    Gordon Saxby
    0

    Form

    The Confirm button is there for Cash sale, but disappears when I select SagePay.

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Jul 15, 2015 @ 18:06
    Rusty Swayne
    0

    @Gordon

    In your web.config try setting the Bazaar:ResolvePaymentForms to false if the controller you are using is not inheriting from PaymentMethodUiController{T} with a GatewayMethodUiAttribute

        <add key="Bazaar:ResolvePaymentForms" value="false" />
    
  • Gordon Saxby 1444 posts 1855 karma points
    Jul 15, 2015 @ 22:06
    Gordon Saxby
    0

    I tried that and it didn't help.

    I am using the SagePay plugin - I haven't looked at the code in detail so don't what inheritance is happening.

  • Gordon Saxby 1444 posts 1855 karma points
    Jul 15, 2015 @ 22:20
    Gordon Saxby
    0

    @Chris - are the instructions above still correct and complete? (As given to you by Barry)

    Where is the code for that page, how can I debug what is going wrong?

    Oh yes, setting the Bazaar:ResolvePaymentForms config value to True stops the SagePay option appearing in the dropdown on the payment form.

  • Chris Foot 61 posts 93 karma points
    Jul 16, 2015 @ 07:59
    Chris Foot
    0

    Hi Gordon,

    The instructions should still be valid. I haven't really tested the form integration but have applied the same updates as to the direct so it should work the same. However, I write my own forms and controllers so i'm not sure how much help I can be with it. Are there any errors in the logs or if you are using ajax, any errors in the console?

    Chris

  • Gordon Saxby 1444 posts 1855 karma points
    Jul 16, 2015 @ 22:09
    Gordon Saxby
    0

    I am trying to figure out how to add a controller / form (?) - does anyone have any example code of how I would write a controller that inherits from PaymentMethodUiController{T} with a GatewayMethodUiAttribute?

  • Gordon Saxby 1444 posts 1855 karma points
    Jul 19, 2015 @ 18:12
    Gordon Saxby
    0

    @Chris - I am still stuck on getting my "Confirm" button to actually open up the SagePay payment form :-(

    I know you are using "direct" mode, but maybe your controller code might give me some clues as to what I need to do? (How to call the plugin code to make the Sage form page appear).

  • Dan 1285 posts 3917 karma points c-trib
    Jul 20, 2015 @ 14:10
    Dan
    0

    I'm in the exact same position as Gordon. It's on a fresh 'combined' Merchello 1.9.0/Bazaar install on Umbraco 7.2.8.

    I've pulled down Chris Foot's latest fork, built it (had a copule of issues with Nuget pulling in Merchello 1.8.0 instead of 1.9.0 so had to manually copy over 1.9.0 Merchello dlls to get it to build), copied 'Merchello.SagePay' into App_Plugins in my site, activated the SagePay payment provider in the Merchello Gateway Providers section and entered the configuration details, then added it in the 'Payment' tab too.

    Now when I check out on the front-end I see both the cash and SagePay payment options in a drop-down but selecting 'SagePay' makes the 'Confirm sale' button disappear.

    Can anyone offer any advice as to what to do now?

    Thanks

  • Biagio Paruolo 1594 posts 1825 karma points c-trib
    Jul 20, 2015 @ 15:27
    Biagio Paruolo
    0

    Hi,

    I had the same problem with Braintree gw. I delete the old Merchello reference and recreate again with the new version.

    PS: check into packages folder of Sagepay solution

  • Dan 1285 posts 3917 karma points c-trib
    Jul 20, 2015 @ 15:37
    Dan
    0

    Thanks Biagio, but I'm not entirely sure what you mean? I already updated the references to 'Merchello.Core', 'Merchello.Examine' and 'Merchello.Web' in SagePay plug-in solution, to reference the dlls from Merchello 1.9.0 (rather than 1.8.0 which it was looking for).

  • Gordon Saxby 1444 posts 1855 karma points
    Jul 20, 2015 @ 16:12
    Gordon Saxby
    0

    @Dan - to make the button appear, I needed to create a controller (in my project, called it "SagePayPaymentMethodController")

        [PluginController("MerchelloSagePay")]
    [GatewayMethodUi("SagePayIFrame")]
    public class SagePayPaymentMethodController : BazaarPaymentMethodFormControllerBase
    {
        public override ActionResult RenderForm(CheckoutConfirmationForm model)
        {
            return this.PartialView(PathHelper.GetThemePartialViewPath(model.ThemeName, "SagePayFormPaymentMethodForm"), model);
        }
    
       protected override IPaymentResult PerformProcessPayment(SalePreparationBase preparation, IPaymentMethod paymentMethod)
        {
        }
    }
    

    I also created a partial view in my Merchello Bazaar theme folder:

    @using System.Web.Mvc.Html
    @using Umbraco.Web
    @using VintageFineArms.site.Controllers
    @inherits Umbraco.Web.Mvc.UmbracoViewPage<Merchello.Bazaar.Models.CheckoutConfirmationForm>
    
    <!-- SagePay Form Payment Method -->
    @using (Html.BeginUmbracoForm<SagePayPaymentMethodController>("ConfirmSale", null, new { @id = "ConfirmSale" }))
    {
        @Html.AntiForgeryToken()
        @Html.HiddenFor(x => x.ShipMethodKey, new { @class = "selected-shipmethod-key" })
        @Html.HiddenFor(x => x.PaymentMethodKey, new { @class = "selected-paymentmethod-key" })
        @Html.HiddenFor(x => x.CustomerToken, new { @id = "customer-token" })
        @Html.HiddenFor(x => x.ReceiptPageId)
        <div class="control-group">
            <button type="submit" class="btn btn-primary">SagePay</button>
        </div>
    }
    

    That (I think!?) got me a button that appears when I select SagePay. The next problem is what to do when the button is clicked. You end up in "PerformProcessPayment" above...

    Because I have not got the actual button actually working, I cannot confirm yet if the view, above, is correct.

  • Chris Foot 61 posts 93 karma points
    Jul 21, 2015 @ 08:05
    Chris Foot
    0

    Hi Guys,

    I am still here! Unfortunately I have a project that I have to finish asap but when that is over i'll take a look at what is happening with this. Are there any errors in the log or console when you select sagepay from the dropdown?

  • Gordon Saxby 1444 posts 1855 karma points
    Jul 21, 2015 @ 08:29
    Gordon Saxby
    0

    Hi Chris, my problem (at least) is that I didn't know what code was required to show the button in the first place. That is now sorted (I hope) and the problem has moved onto the code required to actually make the SagePay payment pages appear (I am using the Form method).

    I cannot find any example code and code produced while talking with Rusty also does not work.

    my situation sounds the same as yours - this website needs to be live before the end of July! :-)

  • Biagio Paruolo 1594 posts 1825 karma points c-trib
    Jul 21, 2015 @ 08:45
    Biagio Paruolo
    0

    Hi,

    I think that you need to follow the same path as Paypal provider. Into Bazaar controller

    [PluginController("Bazaar")]
        public class SalePreparationOperationsController : SurfaceControllerBase
    

    you need create an action ( customize it for your needs ):

    [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);
        }
    

    and then into ~/App_Plugins/Merchello.Bazaar/Themes/Flatly/Views/Partials/CheckoutConfirmationForm.cshtml

    put in

     <!-- PayPal Payment Method -->
            <div id="PayPalPayment" class="payment-method-form">
                @using (Html.BeginUmbracoForm<SalePreparationOperationsController>("ConfirmPayPalSale", null, new { @id = "ConfirmPayPalSale" }))
                {
                    @Html.HiddenFor(x => x.ShipMethodKey, new { @class = "selected-shipmethod-key" })
                    @Html.HiddenFor(x => x.PaymentMethodKey, new { @class = "selected-paymentmethod-key" })
                    @Html.HiddenFor(x => x.CustomerToken, new { @id = "customer-token" })
                    @Html.HiddenFor(x => x.ReceiptPageId)
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary">Confirm Sale</button>
                    </div>
                }
            </div>
    

    I'm tring to follow this to made work Braintree.

    @Rusty : we need a better documentation to code payment plugin.

  • Gordon Saxby 1444 posts 1855 karma points
    Jul 21, 2015 @ 19:56
    Gordon Saxby
    0

    OK, this is now solved / working! :-)

    With MASSIVE thanks to Rusty, we got there in the end.

  • Dan 1285 posts 3917 karma points c-trib
    Jul 21, 2015 @ 21:34
    Dan
    0

    Great! How did you resolve it?

  • Gordon Saxby 1444 posts 1855 karma points
    Jul 21, 2015 @ 22:18
    Gordon Saxby
    1

    It is explained here our.umbraco.org/projects/collaboration/merchello/merchello/67750-help-with-sagepay-controller#comment-225096

    Let me know if anything is unclear and I will try to help.

  • Biagio Paruolo 1594 posts 1825 karma points c-trib
    Jul 22, 2015 @ 05:33
    Biagio Paruolo
    0

    Could you post your code, please?

  • Gordon Saxby 1444 posts 1855 karma points
    Jul 22, 2015 @ 06:53
    Gordon Saxby
    0

    I did post my code - follow the link in my post above.

Please Sign in or register to post replies

Write your reply to:

Draft