worldpay class not working with namespace in WordPress

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 libWorldpay;

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 ‘libWorldpay’ 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.

Read more here: worldpay class not working with namespace in WordPress

Leave a Reply

Your email address will not be published. Required fields are marked *