Updated SagePay Plugin for v2.65

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
Hi,

I forgot to add: Have you considered using the authorise/capture model?

Basically in the SagePay plugin you can change the payment type from Payment to Authorise.

When SagePay processes the payment, it authorises it but does not debit the funds.
Then in the admin area of nopCommerce you click the Capture button to capture the funds.

This has a number of benefits:
If the customer completes the SagePay process, then the order fails (as in the behaviour you are seeing), no money leaves their account.

If a customer places an order you are unable to fulfil for any reason, you don't need to issue a refund as no money will be debited until the Capture button is pressed.

Hope this all makes sense - obviously it's not a solution to your problem, but it is a useful alternative way of handling your SagePay payments that I know a number of our clients use.

Regards,

Nick
11 years ago
Hi Nick

It appears to be this code in the orderprocessingservice of nopcommerce

   IPaymentMethod paymentMethod = null;
                if (!skipPaymentWorkflow)
                {


                    paymentMethod = _paymentService.LoadPaymentMethodBySystemName(processPaymentRequest.PaymentMethodSystemName);
                    if (paymentMethod == null)
                        throw new NopException("Payment method couldn't be loaded");

                    //ensure that payment method is active
                    if (!paymentMethod.IsPaymentMethodActive(_paymentSettings))
                        throw new NopException("Payment method is not active");
                }
                else
                    processPaymentRequest.PaymentMethodSystemName = "";

If you look at this code it doesnt actually do anything and is redundant code so I have taken this out and fingers crossed we have just put 4 or 5 payments through with no problems

Tell your guys to test against nop with the plugin and look in the PlaceOrder Method of OrderProcessingService.cs for the code above. It appears that the LoadPaymentMethodBySystemName is returning a null - probably due to processPaymentRequest.PaymentMethodSystemName being empty. I have taken this code out as it doesnt actually do anything but it would definately be worth digging into this to ascertain why this is happening with roughly half the orders
11 years ago
Thanks - I'll pass on to the team and get them to take a look.

Regards,

Nick
11 years ago
Hi Nick

Hope you had a good christmas. One final question on the sagepay plugin - have you any idea of how we can get Google Analytics ecommerce tracking enabled using this plugin ?

We have used the nopcommerce standard Google Analytics widget which comes enabled with ecommerce tracking however I am not sure whether we can use this with Sagepay as the users are taken to a seperate web page outside of the site hosted by Sagepay
11 years ago
Hi John,

Happy new year.

Although the users leave nopCommerce to go to SagePay, they do return to nop for the final order confirmation page once the SagePay transaction is complete, so I think the e-Commerce tracking should be OK.

Happy for someone to correct me as I haven't tried it for myself.

Regards,

Nick
11 years ago
Hi Nick,

Just fixed a bug on the Nop 1.7 version of this and having taken a look at your code spotted the same issue can occur and potentially others.

The fields BillingPhone & DeliveryPhone are limited to 20 characters, if you pass a longer string the payment will fail despite these being optional.

Doing something like should fix it

data.Add("DeliveryPhone", _workContext.CurrentCustomer.ShippingAddress.PhoneNumber.Substring(0,19);


I'm sure other fields have a max length as well and should really be checked/trimmed before they sent to Sagepay.

Also while I can see you have commented out the code to send the basket contents up to Sagepay their is a problem with that code in that any product name can contain a colon and if it does this will cause the payment to fail.

Fix for this is to replace colons in the product name before building the basket string (I've chosen a semicolon as it will look almost identical) eg

 item.ProductVariant.FullProductName.Replace(':', ';')


Anyway hope that helps and thanks for doing this.
11 years ago
Hi Guys

When I switch to one page checkout the sagepay payment screen hangs after the payment is processed

Do you have to configure the plugin differently for one page checkout ?

Thanks
11 years ago
Hi Dave,

Thanks for the recommended code changes - we've implemented the phone number length restrictions and they'll be in the next release.

I'm not sure why the basket items code is commented out - pretty sure it was commented out in the version of the code we started with from Appnova. Either way I've applied the fix for the colons inside the comment block in case we uncomment it in future. (Perhaps a config option to specify whether the basket should be passed to SagePay?)

Regards,

Nick
11 years ago
Just had to fix my implementation because if you substring(0,19) a string shorter than 20 it throws an exception >.<

Should have used the built in helper (not sure if it's still available in later versions? )

eg

cryptBuilder.AppendFormat("&DeliveryPhone={0}", CommonHelper.EnsureMaximumLength(order.ShippingPhoneNumber, 20));


HTH
11 years ago
Hi,

I'm not sure if the helper's still there - we did something different:

        private const int MaxPhoneNumberLength = 19;
...
data.Add("BillingPhone", (_workContext.CurrentCustomer.BillingAddress.PhoneNumber.Length > MaxPhoneNumberLength) ? _workContext.CurrentCustomer.BillingAddress.PhoneNumber.Substring(0, MaxPhoneNumberLength) : _workContext.CurrentCustomer.BillingAddress.PhoneNumber);

Regards,

Nick
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.