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.

  • 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
    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
    Jan 27, 2021 at 5:48

1 Answer 1


Have you tried:

require_once(__DIR__ .'/init.php');
  • Still I am getting the same error. I Think i am missing something here or problem with namespace
    – Kvvaradha
    May 8, 2017 at 10:38
  • does init.php includes namespace ?
    – T.Todua
    May 8, 2017 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, 2017 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, 2017 at 10:49
  • Can you give me an example.?
    – Kvvaradha
    May 16, 2017 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.