PHP code example of philipbrown / worldpay

1. Go to this page and download the library: Download philipbrown/worldpay library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

philipbrown / worldpay example snippets


use PhilipBrown\WorldPay\Environment;

$env = Environment::set('production');
$env->asInt(); // 0

$env = Environment::set('development');
$env->asInt(); // 100

$env = Environment::set('local');
$env->asInt(); // 100

use PhilipBrown\WorldPay\Currency;

$currency = Currency::set('GBP');

$request = new Request(
  Environment::set('testing'),          // Environment
  '123',                                // InstId
  'My shop',                            // CartId
  'my secret',                          // Secret
  '10.00',                              // Value
  Currency::set('GBP'),                 // Currency
  http://shop.test/callbacks/worldpay', // Route
  ['name' => 'Philip Brown']            // Data
);

$request->setSignatureFields(['name']);

$request->send();

$body = $request->prepare();

use PhilipBrown\WorldPay\Response;

$response = new Response('qwerty', $_POST);

echo $response->name; // 'Philip Brown'

// Asserts the response is from WorldPay
$response->isValid();

// Asserts the transaction was successful
$response->isSuccess();

// Asserts the transaction was cancelled
$response->isCancelled();

// Asserts the transaction was in the production environment
$response->isProduction();

// Asserts the transaction was in the development environment
$response->isDevelopment();