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.


use lib\Worldpay;

    //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"> 


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.


Have you tried:

require_once(__DIR__ .'/init.php');
| improve this answer | |
  • Still I am getting the same error. I Think i am missing something here or problem with namespace – Kvvaradha May 8 '17 at 10:38
  • does init.php includes namespace ? – T.Todua May 8 '17 at 16:15
  • no, but the required files inside init has this namespace Worldpay. Any idea, How to use namespace here in my plugin file. – Kvvaradha May 11 '17 at 11:39
  • AFAIK, while using use command, there should be present namespace somewhere in the top. However, as that in StackOverflow, because it not related to wp directly, but Namespacing/classes. – T.Todua May 14 '17 at 10:49
  • Can you give me an example.? – Kvvaradha May 16 '17 at 4:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.