PHP SDK for Worldpay API
You can use composer to use this library in other projects. As this package is not on packagist, you have to add this github repo to your repositories in your projects composer.json:
"repositories": [
{
"type": "vcs",
"url": "git@github.com:2525VenturesBV/Worldpay-API.git"
}
]
Then you can add it as a normal requirement:
composer require 2525ventures/worldpay-api:dev-develop
For detailed information on requests, see the Worldpay docs
-
Create a client with your credentials
$worldpay = new \Worldpay\Core\WorldPay($config);
-
Make a request with your data
$response = $worldpay->sendOrderRequest($data); -
Read the response:
If the call was successful you retrieve aWorldpay\Responses\OrderResponse.Use
$response->getRawResponse()to retrieve the original Guzzle response. You can find more info on Guzzle response hereWith
$response->getTransactionId()and$response->getRedirectUrl()you can directly get the important values from the response.On error you will get a
WorldpayException.
- Make a more sophisticated error handling
- Improve configuration setup, this is now done through an array, which doesn't feel right
- Implement other calls from Worldpay
- Callback URL: the callback URL is not set, so a user cannot be redirected back to litebit if the payment is successful
- Change PHPUnit to Codeception