ChrisChinchilla / CiviCRM-eWay-recurring-payment-processor

CiviCRM eWay recurring payment processor
https://github.com/henare/CiviCRM-eWay-recurring-payment-processor#readme
0 stars 4 forks source link

Fatal error when submitting single payment for event #48

Open twomice opened 8 years ago

twomice commented 8 years ago

In CiviCRM 4.7.4, when submitting a payment for an event registration, through a payment processor of type ewayrecurring, upon clicking the "continue" button on the confirmation page, this error message is displayed:

Fatal error: Class 'GatewayRequest' not found in [extensions_directory]/com.chrischinchilla.ewayrecurring/CRM/Core/Payment/Ewayrecurring.php on line 614

This appears to be very similar to https://issues.civicrm.org/jira/browse/CRM-18070, in which it's been noticed that somehow the class constructor, where EWay class files are being included, is somehow never called. I've confirmed that such is the case here, though I can't quite understand how that's happening.

twomice commented 8 years ago

As a clumsy workaround, I've patched the code to include the files just before the classes are referenced:

index 810281d..ea8bf53 100644
--- a/CRM/Core/Payment/Ewayrecurring.php
+++ b/CRM/Core/Payment/Ewayrecurring.php
@@ -611,6 +611,10 @@ class CRM_Core_Payment_Ewayrecurring extends CRM_Core_Payment {
    * @throws \CRM_Core_Exception
    */
   protected function getEwayRequest(&$params) {
+
+    require_once 'packages/eWAY/eWAY_GatewayRequest.php';
+    require_once 'packages/eWAY/eWAY_GatewayResponse.php';
+
     $eWAYRequest = new GatewayRequest();

     if (($eWAYRequest == NULL) || (!($eWAYRequest instanceof GatewayRequest))) {
@@ -702,6 +706,10 @@ class CRM_Core_Payment_Ewayrecurring extends CRM_Core_Payment {
     if ($this->getDummySuccessResult()) {
       return $this->getDummySuccessResult();
     }
+
+    require_once 'packages/eWAY/eWAY_GatewayRequest.php';
+    require_once 'packages/eWAY/eWAY_GatewayResponse.php';
+
     $eWAYResponse = new GatewayResponse();

     if (($eWAYResponse == NULL) || (!($eWAYResponse instanceof GatewayResponse))) {
eileenmcnaughton commented 8 years ago

I'm happy to merge that here if you submit it as a patch

twomice commented 8 years ago

Yep, can do. But first, is it worth discussing why the class constructor is never firing? What's up with that?

eileenmcnaughton commented 8 years ago

I guess the object has been cached on the form & so it is not being re-substantiated. Putting the require_onces in the constructor is an unusual pattern - normally you would stick them at the top of the file.

As an aside the Omnipay extension has Eway in it now too - but a different version of the api. It doesn't have feature parity yet but at some point that is likely to take over

monishdeb commented 8 years ago

Submitted PR in this regard https://github.com/civicrm/civicrm-core/pull/8300