CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • RBS WorldPay payment gateway
Pages: [1] 2

Author Topic: RBS WorldPay payment gateway  (Read 9960 times)

idmacdonald

  • I post occasionally
  • **
  • Posts: 69
  • Karma: 1
RBS WorldPay payment gateway
September 16, 2010, 05:29:14 am
Hi,

User 'dougall' has kindly sent me the code he wrote for CiviCRM for the RBS WorldPay payment gateway.

I have put it into place and it largely appears to be working, although I have yet to test some features such as recurring payments.

The code takes the user to the WorldPay site, processes the payment, and then Worldpay posts a callback to the URL http://www.example.org/sites/all/modules/civicrm/extern/worldPayNotify.php. That script in turn calls the processing functions in civicrm/CRM/Core/Payment/WorldPayIPN.php. If I add a 'print' statement to the end of extern/worldPayNotify.php, then after processing of the payment, the user will be on an RBS worldpay URL and will see whatever text is printed. If I don't include a print statement, then the user is shown a default WorldPay result page that gives transaction number information.

However, what I want to do is to display the Thank You page after a successful payment. The POST date from WorldPay back to extern/worldPayNotify.php includes the parameter 'MC_civi_thankyou_url' with the value 'http://www.example.org/civicrm/contribute/transact?_qf_ThankYou_display=1&qfKey=295ecb4201ea62b0d80aa8ccc760ae09'. What is the best way to display that page in response to the IPN callback request to 'extern/worldPayNotify.php'? I have looked at other payment gateway code, and I can't quite see how it is done with the other payment modules.

Any advice would be greatly appreciated. It's really good to have this finally (almost!) working.

I'm attaching my files extern/worldPayNotify.php, CRM/Core/Payment/WorldPay.php and CRM/Core/Payment/WorldPayIPN.php

idmacdonald

  • I post occasionally
  • **
  • Posts: 69
  • Karma: 1
Re: RBS WorldPay payment gateway
September 17, 2010, 02:59:35 am
Hi,

Anyone want to lend me a hand with this? If I can get this last bit of the call-back to work, then I think we should have a working WorldPay module (for single payments, at least).

-Ian

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: RBS WorldPay payment gateway
September 17, 2010, 04:59:00 am

how about a simple redirect:

CRM_Utils_System::redirect( value of 'MC_civi_thankyou_url' );

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

idmacdonald

  • I post occasionally
  • **
  • Posts: 69
  • Karma: 1
Re: RBS WorldPay payment gateway
September 21, 2010, 06:07:32 am
That doesn't seem to work  :(

Whatever HTML is produced in response to the callback to civicrm/extern/worldPayNotify.php, WorldPay will display that. But the redirect function produces a 302 response that WorldPay doesn't seem to like.

In my IPN function, I can print a string like "Payment complete" and it will show up on the WorldPay response page, however I get just that string of text, without any other page elements or theme elements. What function can I use to take a string and 'wrap it' in the HTML code of my page theme? Something that would return the string with news of payment success or failure, but looking like any other page on the site, with menus, header, theming, etc?

Or, I supposed the other way would be to cause the civicrm/extern/worldPayNotify.php script to return the HTML of the thank you page itself. Is there a way to programmatically say 'Generate the HTML for the [ThankYouURL] Page, then store it to a variable, then echo it'? Maybe the CiviContribute thank you page needs to be a separate step...In which case, I just want my IPN function to return a status notification and link back to the thank you page, but properly themed, per my question above.

-Ian

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: RBS WorldPay payment gateway
September 21, 2010, 08:52:11 am

hey ian:

we use:

CRM_Utils_System::theme( 'page', $content, true, $this->_print );

however, when we are processing the IPN, we do NOT bootstrap drupal and hence cannot really theme the page.

Iv v3.2, we've added a function to bootstrap drupal for some cronjobs (like civimail.cronjob.php) which might invoke hooks. we could potentially do that for the ipn script also (but might need to tweak it to avoid the auth issue). the bootstrap code is:

    CRM_Utils_System::loadBootStrap(  );

since you are in the UK, would really be awesome if u can come attend the code sprint in bristol (oct 2-5): http://civicrm.org/civicrm/event/info?reset=1&id=87

there is also a paid training in London: http://civicrm.org/civicrm/event/info?reset=1&id=65 and there might be a few aspect that are of interest

lobo

there is also a paid deve
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

idmacdonald

  • I post occasionally
  • **
  • Posts: 69
  • Karma: 1
Re: RBS WorldPay payment gateway
September 22, 2010, 03:17:36 am
Thanks for that, Lobo.

However, the CRM_Utils_System::loadBootStrap(  ) function does't seem to be working for me. I've put it into civicrm/extern/worldPayNotify.php, but when WorldPay calls that scrip, I'm getting the following errors:

Quote
Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/var/includes/bootstrap.inc) is not within the allowed path(s): (/var/www/web218/:/usr/share/php) in /var/www/web218/web/sites/all/modules/civicrm/CRM/Utils/System/Drupal.php on line 365

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/var/www/includes/bootstrap.inc) is not within the allowed path(s): (/var/www/web218/:/usr/share/php) in /var/www/web218/web/sites/all/modules/civicrm/CRM/Utils/System/Drupal.php on line 365

Sorry, unrecognized username or password.

So, for some reason the function isn't finding the Drupal root path, and instead is looking for the Drupal includes directory in '/var'. Then there is the usename and password error, though that might be a consequence of not having bootstrapped Drupal correctly.

My config/bootstrapping code in worldPayNotify.php is as follows:

Code: [Select]
session_start( );

require_once '../civicrm.config.php';
require_once 'CRM/Core/Config.php';

CRM_Utils_System::loadBootStrap();

/* Cache the real UF, override it with the SOAP environment */
$config =& CRM_Core_Config::singleton();

require_once 'CRM/Utils/System.php';
CRM_Utils_System::loadBootStrap(  );

Maybe for now I'll just have to make due with a post-payment result page that doesn't match the overall site theme. It can then contain a link to the contribution thank you page. But if anyone has any suggestions about how properly bootstrap Drupal in this context, it would be much appreciated.

Many thanks,
-Ian

Piyush

  • I’m new here
  • *
  • Posts: 14
  • Karma: 0
    • Pecan Solutions
Re: RBS WorldPay payment gateway
January 04, 2011, 08:03:19 am
Hi Ian,

I just wanted to ask if you are now using the WorldPay gateway, and if it supports recurring contributions?

Is the code now available as a user contribution to test?

And lastly, do you know if it supports a logged in user setting up a recurring contribution manually for another contact?

Thanks!

idmacdonald

  • I post occasionally
  • **
  • Posts: 69
  • Karma: 1
Re: RBS WorldPay payment gateway
January 13, 2011, 09:22:12 am
Hi Piyush,

The WorldPay gateway code does work, though it's currently not being used on the site for which I developed it. (They still need to sort out their WorldPay accounts.) As such, I would say that more testing and work is needed before I would consider it to be stable production code.

I have not tested recurring contributions, but I suspect they do not work at the moment.

-Ian

mcdruid

  • I’m new here
  • *
  • Posts: 5
  • Karma: 0
  • CiviCRM version: 3.3
  • CMS version: Drupal 6
  • MySQL version: 5
  • PHP version: 5
Re: RBS WorldPay payment gateway
February 16, 2011, 05:43:38 am
Hi Ian,

just to repeat Piyush's question:

Quote
Is the code now available as a user contribution to test?

...I see you shared 3 files in the original post back in Sep 2010, but I presume the code you're using has been modified since then?

If you're able to share the code you have, we'd like to help with some "more testing and work" and get this to the point of being production-ready.

cheers,
Drew

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: RBS WorldPay payment gateway
February 16, 2011, 06:56:59 am
+1 for help with testing.  is it possible to put the code in a public repo like github to make it easier for us to help out with patches, testing etc.

that would be great - thanks

Michael
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

encircle

  • I’m new here
  • *
  • Posts: 12
  • Karma: 0
  • CiviCRM version: 4.1
  • CMS version: Drupal 6
  • MySQL version: 5
  • PHP version: 5.3
Re: RBS WorldPay payment gateway
January 29, 2013, 09:53:31 am
Did anyone managed to get WorldPay working?

I'm working with permaculture.org.uk and trying to hookup to their worldpay processor...

Cheers,
Darren

idmacdonald

  • I post occasionally
  • **
  • Posts: 69
  • Karma: 1
Re: RBS WorldPay payment gateway
February 05, 2013, 06:48:38 am
Hi,

I have WorldPay code which is currently used on a couple of sites. However, some of the code is probably suited to my client's particular needs and less suitable to more general use. For that reason, I have not packaged it up for distribution. That said, I will try to upload the code I have to GitHub so that others can check out and work on the code.

-Ian


encircle

  • I’m new here
  • *
  • Posts: 12
  • Karma: 0
  • CiviCRM version: 4.1
  • CMS version: Drupal 6
  • MySQL version: 5
  • PHP version: 5.3
Re: RBS WorldPay payment gateway
February 05, 2013, 09:49:07 am
Thanks,  Ian. Please let me know the GitHub details once uploaded.

I'd be happy to help add some configuration to the module to make it more generic, and help packaging it for other people to download...


idmacdonald

  • I post occasionally
  • **
  • Posts: 69
  • Karma: 1
Re: RBS WorldPay payment gateway
February 19, 2013, 08:41:49 am
Hi,

WorldPay payment gateway code is finally available at GitHub: https://github.com/idmacdonald/civicrm-worldpay.git

The code should be treated as experimental, although I have successfully used it on at least one live site for single payments via CiviContribute contribution pages.

I have not tested the 'FuturePay' multiple payments support, so use at your own risk. Contributions and improvements to the code are welcome, as this code meets the needs of one of my clients but may not be flexible enough for more general usage.

Hopefully this can eventually be tested and improved enough to be included in the main CiviCRM distribution. But the code probably needs lots more testing and work before that can happen.

Thanks to forum user dougall (Dougall Winship) for sending me his initial code a number of years ago. My version is heavily based upon the code he initially sent me.

-Ian

Upperholme

  • Administrator
  • Ask me questions
  • *****
  • Posts: 568
  • Karma: 8
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Re: RBS WorldPay payment gateway
March 21, 2014, 07:30:24 am
Has any work been done on this payment processor since the previous post in this thread? I'm looking at a project at the moment where the client uses Worldpay and it would be great to have a fully working processor.

There may be scope to fund the required development to get this processor to a full production-ready state.
Graham Mitchell
http://mc3.coop

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • RBS WorldPay payment gateway

This forum was archived on 2017-11-26.