admin管理员组

文章数量:1122846

I am trying to create Worldpay gateway with help of Worldpay library and my own extending code. Here is my code which I tried and failed to work on.

require_once('init.php');

use lib\Worldpay;

if($_POST == $_SERVER['REQUEST_METHOD']) {
    //Form Submit Actions, Here i have called Worldpay class to create object.
 $worldpay = new Worldpay('Key');   //line no:  25
}  ?>
<script src=".js"></script>
<form  action="" method="post"> 


</form>

I have tried to find similar question and answer. I found this. Eventhough i can't make it work, when form is submitted to the same page. Here is the error message how it looks like.

Fatal error: Class 'lib\Worldpay' not found in /var/www/wp/kvcodes/wp-content/plugins/kvcodes-worldpay/WorldPay.php on line 25

How do I fix this issue, when form is submitted.

I am trying to create Worldpay gateway with help of Worldpay library and my own extending code. Here is my code which I tried and failed to work on.

require_once('init.php');

use lib\Worldpay;

if($_POST == $_SERVER['REQUEST_METHOD']) {
    //Form Submit Actions, Here i have called Worldpay class to create object.
 $worldpay = new Worldpay('Key');   //line no:  25
}  ?>
<script src="https://cdn.worldpay.com/v1/worldpay.js"></script>
<form  action="" method="post"> 


</form>

I have tried to find similar question and answer. I found this. Eventhough i can't make it work, when form is submitted to the same page. Here is the error message how it looks like.

Fatal error: Class 'lib\Worldpay' not found in /var/www/wp/kvcodes/wp-content/plugins/kvcodes-worldpay/WorldPay.php on line 25

How do I fix this issue, when form is submitted.

Share Improve this question edited May 8, 2017 at 10:59 fuxia 107k38 gold badges255 silver badges459 bronze badges asked May 8, 2017 at 10:20 KvvaradhaKvvaradha 9363 gold badges12 silver badges24 bronze badges 2
  • The error indicates that the lib\Worldpay class is not included correctly - via include, require or autoloading - you need to ensure that library is available. – Q Studio Commented Jan 26, 2021 at 21:19
  • its been 3 years ago i asked this question, and it was fixed and i forget the solution as well. but it was fixed. thank you for the contribution even after 3 years, you have an intention to comment about it. – Kvvaradha Commented Jan 27, 2021 at 5:48
Add a comment  | 

1 Answer 1

Reset to default 0

Have you tried:

require_once(__DIR__ .'/init.php');

本文标签: pluginsworldpay class not working with namespace in WordPress