Skip to content
This repository has been archived by the owner on Mar 19, 2022. It is now read-only.

Creating a standard order

Alexander Vizhanov edited this page Apr 27, 2017 · 6 revisions
use Omnipay\Omnipay;

// A unique token which the WorldPay.js library added to your checkout form
$token = 'SOME_TOKEN' 

// Create a gateway for the WorldPay Gateway
$gateway = Omnipay::create('\\lembdev\\WorldPay\\Gateway');

// Initialise the gateway
$gateway->initialize([
    'serviceKey' => 'MyServiceKey',
    'clientKey'  => 'MyClientKey',
]);

// Do a purchase transaction on the gateway
$transaction = $gateway->purchase([
    'amount'      => '10.00',
    'currency'    => 'USD',
    'description' => 'Order description',
    'token'       => $token
]);

$response = $transaction->send();
if ($response->isSuccessful()) {
    $orderCode = $response->getOrderCode();

    echo "Purchase transaction was successful!\n";
    echo "Order code = {$orderCode}\n";
} else {
    echo $response->getMessage();
}
Clone this wiki locally