Author Topic: Sage Pay (protx) server integration Joomla 1.5  (Read 58598 times)

Yellow Cherry

  • Beginner
  • *
  • Posts: 43
    • Yellow Cherry Digital
Sage Pay (protx) server integration Joomla 1.5
« on: August 03, 2009, 17:10:42 pm »
Hi I hope someone can point me in the right direction...

my client has set up a SagePay Go account and wants to do an integration with Joomla v1.5.12.

They do not want to go down the direct route as want to avoid an SSL cert so want a server integration.

This is my first attempt at this and I could do with some help, has anyone got any step by steps, I can only find reference to a direct payment module.

Thanks!!
Internet Marketing // Website Development

andpatton

  • Beginner
  • *
  • Posts: 32
    • acusti.ca
Re: Sage Pay (protx) server integration Joomla 1.5
« Reply #1 on: September 11, 2009, 16:53:03 pm »
I also have a client who wishes to do a sagepay server integration. I was hoping someone would respond to your post, but based upon the month of silence since your post, I suppose I'll have to develop the payment module myself.

I expect it to be done in a few days -- so, with the weekend, hopefully I'll be posting back here with a new sagepay payment module by September 16.

craftyweb

  • Beginner
  • *
  • Posts: 31
    • web design
Joomla: 2.5.20
VirtueMart 2.0.26d

andpatton

  • Beginner
  • *
  • Posts: 32
    • acusti.ca
Re: Sage Pay (protx) server integration Joomla 1.5
« Reply #3 on: October 20, 2009, 20:53:31 pm »
That link is for the 'form' integration of sagepay, which is not what my client wanted. Sagepay has three integration types: form, server, and direct. Form is similar to paypal -- the user's details are collected in virtuemart, then they are transferred to payment pages hosted by sagepay. Server, on the other hand, actually serves the payment pages to your website through an iframe (nice because the user stays on your page with your url in their address bar, but it stills puts most of the security responsibilities on sagepay). It's a different protocol and involves a significantly different process. Direct means that you collect all of the payment information on your site, which requires you to be PCI compliant and all the rest, so it puts a lot of responsibility on the client, but for those willing to take that on, there is a module available for it here: SagePay Direct module

I wound up doing a custom server integration, but I also decided to implement the Payment Patch that makes sure that the confirmation email is only sent out and the basket only emptied after a confirmed payment has taken place. The good news is, it works great! The bad news is that my code is filled with different hacks that depend on each other, so I don't think it would really help anyone who didn't have my specific collection of hacks in place. If someone is still interested, contact me (or reply to this thread) and I'd be happy to try to put together a package that they can try using, but be forewarned, it will involve some significant core hacks. Still, it's a very good solution I believe, so if you're not too worried about updating VM in the future, you can give it a try.

alpertheidiot

  • Jr. Member
  • **
  • Posts: 103
Re: Sage Pay (protx) server integration Joomla 1.5
« Reply #4 on: November 19, 2009, 16:53:23 pm »
hi andpatton,

Im very suprised sage pay is not supported as a default payment system by joomla. while looking for a solution, I came accross your post and interested in trying your code, if thats ok with you.

I designed a zencart site in the past but its design is a bit out of date, and you are very limited what you can do with zencart. joomla (virtuemart), however, is much more modern. So Im thinking of moving everything to virtuemart. It is going to be hard, but I think it is worth it. and of course, payment module is the biggest concern.

Please can you post how to implement sage pay server?

many thanks
alper

erichartley

  • Beginner
  • *
  • Posts: 7
Re: Sage Pay (protx) server integration Joomla 1.5
« Reply #5 on: November 19, 2009, 17:09:42 pm »
Coincidence - I was just typing the same question alpertheidiot when your post appeared!

I have a client who wants to use Sagepay Server and I'm not sure how to proceed.

andpatton - would really appreciate your help here as you seem to have this sorted. I could use the form integration option but would much rather go for server with the advantage if iframe integration etc.

Thanks in advance.
Eric

andpatton

  • Beginner
  • *
  • Posts: 32
    • acusti.ca
Re: Sage Pay (protx) server integration Joomla 1.5
« Reply #6 on: November 19, 2009, 17:38:17 pm »
Coincidence indeed -- what are the chances that in the over four weeks since my last post, two people would reply with the same request within minutes of each other?

But cosmic convergence aside, I'll try to get around to this in the next few days. I'll need to try to weed out the unrelated hacks and mods I made to the system so that it's portable, and clean up some of the config stuff so it's installable, and then I'll write a brief explanation of how to get it up and running. All of which is to say don't expect a reply before next week, but rest assured, I'll get to it eventually.

alpertheidiot

  • Jr. Member
  • **
  • Posts: 103
Re: Sage Pay (protx) server integration Joomla 1.5
« Reply #7 on: November 21, 2009, 02:07:42 am »
your effort is much appreciated, thanks in advance!

we will be waiting for your post..

erichartley

  • Beginner
  • *
  • Posts: 7
Re: Sage Pay (protx) server integration Joomla 1.5
« Reply #8 on: November 21, 2009, 17:35:56 pm »
Thanks andpatton - your expertise is much appreciated. Look forward to seeing the post.

erichartley

  • Beginner
  • *
  • Posts: 7
Re: Sage Pay (protx) server integration Joomla 1.5
« Reply #9 on: December 07, 2009, 10:28:34 am »
Did anyone get any further on this issue? Thanks!

alpertheidiot

  • Jr. Member
  • **
  • Posts: 103
Re: Sage Pay (protx) server integration Joomla 1.5
« Reply #10 on: December 14, 2009, 23:25:18 pm »
nope, still waiting

andpatton

  • Beginner
  • *
  • Posts: 32
    • acusti.ca
Re: Sage Pay (protx) server integration Joomla 1.5
« Reply #11 on: December 15, 2009, 18:13:30 pm »
EDIT: I have made a couple fixes/updates to this package since I first posted it (last fix was on 23 May 2010). The latest package will always be in this post, so if you see fixes or changes mentioned later in the thread, just be sure to download the latest package at the bottom of this post and you will be good to go.

CHANGELOG:
  • 23 May 2010: Fixed bug which prevented thank you page from displaying when using SagePay's "LOW" profile (loading payment pages in an iframe), fixed order processing so that it now changes order status to "Confirmed" after successful payment
  • 11 Jan 2010: Fixed bug in sagepay_paymentextrainfo.php file (the code that goes in the payment extra info field in your payment method in the VirtueMart backend)
  • 08 Jan 2010: Updated the package in order to add a missing file (modify_temp_order_table.sql) and update notify_sagepay.php. If you downloaded this package before then, I recommend redownloading it and reviewing the changes mentioned in the instructions
  • 02 Apr 2010: Updated the package to set the order status correctly as confirmed at the end of the payment process (though in the email that is sent to the customer, it still appears as Pending)

Sorry it took so long to get this code out there -- it turned out that I still had to do a lot of work to clean it up and make it portable.

Also, I originally set up the payment module to work with the patch that is used to only complete the transaction in VirtueMart after receiving confirmation from the payment processor (originally the patch was set up for use with paypal, but I adapted it for a SagePay server integration). I started trying to adapt the code to work without that patch, but I realized first of all, that it works much better with the patch (does it make any sense to receive an email confirming your order before you've even gone to the payment page?) and second, that a lot of the code I wrote is already too tied up in that patch, so it would take too long to untangle and refactor the code.

So, this version of the payment module implements (and requires) this patch: VirtueMart PayPal Patch, which is first introduced in this message: Re: Order confirmation email sent before PayPal payment processed. There are extensive instructions for implementing that patch on the page I linked to, but be forewarned that it requires the ability to run a script on your database (you can use any mysql admin tool like phpMyAdmin).

Now, instructions for this payment module:

Note: the files in the package are organized based upon where they should appear within the administrator/components/com_virtuemart directory (with the exception of sagepay_paymentextrainfo.php and modify_temp_order_table.sql).

  • Apply the VirtueMart PayPal patch, based on the instructions in the link above (always remember to first back up your site, both the DB and the physical directory!)
  • Go back into phpMyAdmin or similar tool (as you did when applying the VirtueMart PayPal patch) and run an sql query on your DB using the code in the modify_temp_order_table.sql file (this code recreates the temp order table used in the PayPal patch to include the extra columns necessary to store all the info you receive from SagePay during the payment process)
  • upload "classes/payment/ps_sagepay.cfg.php" to /administrator/components/com_virtuemart/classes/payment/
  • upload "classes/payment/ps_sagepay.php" to /administrator/components/com_virtuemart/classes/payment/
  • upload "html/checkout.sagepay_error.php" to /administrator/components/com_virtuemart/html/
  • upload "html/checkout.sagepay_post.php" to /administrator/components/com_virtuemart/html/
  • upload "html/checkout.sagepay_success.php" to /administrator/components/com_virtuemart/html/
  • upload "notify_sagepay.php" to /administrator/components/com_virtuemart/
  • In VM Administration / Store create a new payment method. Call it what ever you want to show on screen when a customer chooses it. Give it a code of 'SAGE' and choose 'ps_sagepay' from the drop down list of "Payment class name". For "Payment method type" choose 'HTML-Form based (e.g. PayPal)'.
  • Save it and then open it again. In the Configuration tab, configure all of the options to your liking (if you don't get any of them, ask and I'll try to explain further), and then copy in all of the code from the file "sagepay_paymentextrainfo.php" into the "Payment Extra Info:" textbox

A few notes:

  • If you choose to use the LOW Profile option (and so want the payment page loaded in an iframe), you can style the iframe block that contains the payment page using CSS on the id "sagepay_iframe" [so it would look like: iframe#sagepay_iframe { ... } ] (you should use the 'iframe' element selector to make sure those styles override the simple default styles I already included)
  • The notify_sagepay.php will have to be directly accessed by SagePay after the payment has been completed, so make sure that http://yoursite.com/administrator/components/com_virtuemart/notify_sagepay.php can be accessed from the browser (it should just show a blank page, but it shouldn't show an access forbidden or 404 Not Found error)

If you have any questions or issues, you can reply to this post, email me, or message me and I'll try to help you out. Good luck!



[attachment cleanup by admin]

alpertheidiot

  • Jr. Member
  • **
  • Posts: 103
Re: Sage Pay (protx) server integration Joomla 1.5
« Reply #12 on: January 07, 2010, 01:21:13 am »
many thanks for your efforts andpatton.. Im now working on my site.

Im however, receiving this error when I confirm order:

HTTP Status Code:      500
HTTP Status Message:    The request was unsuccessful due to an unexpected condition encountered by the server.
Error Code :    5006
Error Description :    Unable to redirect to Vendor's web site. The Vendor failed to provide a RedirectionURL.


Ive found this page https://support.sagepay.com/forum/Topic2472-21-1.aspx#bm2540 on forums but I couldnt find any file to alter those settings. please can you advise?

regards
alper

andpatton

  • Beginner
  • *
  • Posts: 32
    • acusti.ca
Re: Sage Pay (protx) server integration Joomla 1.5
« Reply #13 on: January 07, 2010, 17:59:31 pm »
Hmm... well, if we take the error description at face value ("Unable to redirect to Vendor's web site. The Vendor failed to provide a RedirectionURL."), it would suggest that either the code is, in fact, not sending a RedirectionURL (which I can say pretty definitely is not the case, because it does send one), or that the problem has something to do with SagePay being unable to reach that page (like because of an internal testing environment/firewall type of an issue). However, if SagePay is able to reach the notify file (by the way, the equivalent of the file you referred to in the post you found is notify_sagepay.php), then that is unlikely to be the issue.

So, I'm guessing that the error description is inaccurate in this case. Re: the forum page you found, according to what the author (bhorisk) wrote, that problem seems to be something specifically to do with the ColdFusion integration kit (and this code is based, of course, on the PHP integration kit, which seems to handle this quite differently). This kit does not return any server errors even if there are errors in the transaction, it just sends a normal response with the error information inside it. However, I haven't messed with using 3D Secure, so I have no idea if the integration kit will work with that. In case it makes any difference, I've attached a copy of the notify_sagepay.php file without the CAVV values included in the processing (as suggested in that forum post), though it's very hard for me to imagine how that could help solve this problem and I would expect it, in fact, to break the signature check used for fraud detection. Anywho, feel free to give it a shot.

There are a couple questions that could help with debugging:

  • First of all, when using Simulator mode, does simulator show you a redirection URL for the last step and then correctly redirect you to the sagepay_success or sagepay_error page (whichever applies to the situation you simulate)?
  • Secondly, are you using Test mode when this problem occurs?
  • Lastly, are you using 3D Secure?

My last suggestion is to contact SagePay support -- you can give them access to all the integration files and they might be able to spot any problems from that (if you are using 3D Secure, I think it's very possible that your problem has something to do with that, because I have confirmed that at least on my install of joomla and virtuemart, this integration works without 3D Secure).

EDIT: I removed the notify_sagepay.php attachment because it was wrong in a number of ways (I accidentally took an older copy and updated it), plus I'm pretty confident this is not the issue

alpertheidiot

  • Jr. Member
  • **
  • Posts: 103
Re: Sage Pay (protx) server integration Joomla 1.5
« Reply #14 on: January 08, 2010, 01:50:08 am »
- Ive not tried simulator mode
- Live mode
- not using 3d

could it be anything to do with paypal fix? could this orders_temp table might be causing the problem?

1# When customer confirms the order on the 4th step, it proceeds to sagepay payment page, no problems.. then, if the customer cancels the transaction (or if card details are not accepted, shortly if payment fails for whatever reason)then above error message is displayed.if there is no failure during payment, then again receive the same error on final page (authorasion).

2# customer adds products in to cart, tries to pay, cancels or at the last stage receives the same error. if tries to buy it, keep receiving same error. if however, adds or removes a producs from cart then receives this error:

Failed to store SagePay status and status detail. MySQL Error message: DB function failed with error number 1054
Unknown column 'SagepayStatus' in 'field list' SQL=UPDATE jos_vm_orders_temp SET SagepayStatus='MALFORMED - 4002 : An active transaction with this VendorTxCode has been found but the Amount is different.' WHERE id = '3'