Example #1
0
 private function setupWorldpay()
 {
     require_once Mage::getModuleDir('', 'Worldpay_Payments') . DS . 'lib' . DS . 'worldpay.php';
     $mode = Mage::getStoreConfig('payment/worldpay_mode', Mage::app()->getStore()->getStoreId());
     $sslDisabled = Mage::getStoreConfig('payment/worldpay_cc/ssl_disabled', Mage::app()->getStore()->getStoreId());
     if ($mode == 'Test Mode') {
         $service_key = Mage::getStoreConfig('payment/worldpay/test_service_key', Mage::app()->getStore()->getStoreId());
     } else {
         $service_key = Mage::getStoreConfig('payment/worldpay/live_service_key', Mage::app()->getStore()->getStoreId());
     }
     $worldpay = new Worldpay($service_key);
     if ($mode == 'Test Mode' && $sslDisabled) {
         $worldpay->disableSSLCheck(true);
     }
     return $worldpay;
 }
 public function indexAction()
 {
     $logger = Mage::helper('worldpay/logger');
     if (!$this->getRequest()->isPost()) {
         $logger->log('Auth/Capture notifications must be POST');
         echo '[OK]';
         return;
     }
     $worldpay = Mage::getModel('worldpay/paymentMethods_creditCards')->setupWorldpay();
     try {
         $response = file_get_contents('php://input');
         $originalNotification = Worldpay::handleResponse($response);
     } catch (Exception $e) {
         http_response_code(500);
         $logger->log('Error getting webhook');
         echo '[OK]';
         return;
     }
     try {
         $notification = $worldpay->getOrder($originalNotification['orderCode']);
     } catch (Exception $e) {
         http_response_code(500);
         $logger->log('Error validating webhook');
         echo '[OK]';
         return;
     }
     if ($originalNotification['paymentStatus'] != $notification['paymentStatus']) {
         http_response_code(500);
         $logger->log('Order status does not match');
         echo '[OK]';
         return;
     }
     //Get order by quote id, add payment as success
     $order = Mage::getModel('sales/order')->loadByAttribute('ext_order_id', $notification['orderCode']);
     $payment = $order->getPayment();
     if (!$payment->getId()) {
         $payment = Mage::getModel('sales/order_payment')->getCollection()->addAttributeToFilter('last_trans_id', array('eq' => $notification['orderCode']))->getFirstItem();
         $order = Mage::getModel('sales/order')->load($payment->getParentId(), 'entity_id');
     }
     if (!$payment->getId()) {
         http_response_code(500);
         $logger->log('Payment ' . $notification['orderCode'] . ' not found!');
         echo '[OK]';
         return;
     }
     if (!$order) {
         http_response_code(500);
         $logger->log('Order ' . $notification['orderCode'] . ' not found!');
         echo '[OK]';
         return;
     }
     $amount = false;
     if ($notification['amount']) {
         $amount = $notification['amount'] / 100;
     }
     Mage::getModel('worldpay/paymentMethods_creditCards')->updateOrder($notification['paymentStatus'], $notification['orderCode'], $order, $payment, $amount);
     // give worldpay confirmation
     echo '[OK]';
 }
Example #3
0
 public function setupWorldpay()
 {
     require_once Mage::getModuleDir('', 'Worldpay_Payments') . DS . 'lib' . DS . 'worldpay.php';
     $mode = Mage::getStoreConfig('payment/worldpay_mode', Mage::app()->getStore()->getStoreId());
     $sslDisabled = Mage::getStoreConfig('payment/worldpay/ssl_disabled', Mage::app()->getStore()->getStoreId());
     if ($mode == 'Test Mode') {
         $service_key = Mage::getStoreConfig('payment/worldpay/test_service_key', Mage::app()->getStore()->getStoreId());
     } else {
         $service_key = Mage::getStoreConfig('payment/worldpay/live_service_key', Mage::app()->getStore()->getStoreId());
     }
     $worldpay = new Worldpay($service_key);
     $worldpay->endpoint = Mage::getStoreConfig('payment/worldpay/api_endpoint', Mage::app()->getStore()->getStoreId());
     if (!$worldpay->endpoint) {
         $worldpay->endpoint = 'https://api.worldpay.com/v1/';
     }
     if ($mode == 'Test Mode' && $sslDisabled) {
         $worldpay->disableSSLCheck(true);
     }
     return $worldpay;
 }
<?php

namespace Worldpay;

?>


<?php 
/**
 * PHP library version: 2.1.0
 */
require_once '../init.php';
// Initialise Worldpay class with your SERVICE KEY
$worldpay = new Worldpay("your-service-key");
// Sometimes your SSL doesnt validate locally
// DONT USE IN PRODUCTION
$worldpay->disableSSLCheck(true);
$worldpayOrderCode = $_POST['orderCode'];
$amount = $_POST['amount'];
include "header.php";
// Try catch
try {
    // Refund the order using the Worldpay order code
    $worldpay->refundOrder($worldpayOrderCode, $amount * 100);
    $response = 'Order <span id="order-code">' . $worldpayOrderCode . '</span> has been refunded for ';
    $response .= !empty($amount) ? '<span id="amount">' . $amount . '</span>' : 'the full amount';
    echo $response;
} catch (WorldpayException $e) {
    // Worldpay has thrown an exception
    echo 'Error code: ' . $e->getCustomCode() . '<br/>
    HTTP status code:' . $e->getHttpStatusCode() . '<br/>
<?php

namespace Worldpay;

?>

<?php 
/**
 * PHP library version: 2.0.0
 */
require_once '../init.php';
// Initialise Worldpay class with your SERVICE KEY
$worldpay = new Worldpay("your-service-key");
// Sometimes your SSL doesnt validate locally
// DONT USE IN PRODUCTION
$worldpay->disableSSLCheck(true);
$directOrder = isset($_POST['direct-order']) ? $_POST['direct-order'] : false;
$token = isset($_POST['token']) ? $_POST['token'] : null;
$name = $_POST['name'];
$shopperEmailAddress = $_POST['shopper-email'];
$amount = 0;
if (isset($_POST['amount']) && !empty($_POST['amount'])) {
    $amount = is_numeric($_POST['amount']) ? $_POST['amount'] * 100 : -1;
}
$orderType = $_POST['order-type'];
$_3ds = isset($_POST['3ds']) ? $_POST['3ds'] : false;
$authorizeOnly = isset($_POST['authorizeOnly']) ? $_POST['authorizeOnly'] : false;
$customerIdentifiers = !empty($_POST['customer-identifiers']) ? json_decode($_POST['customer-identifiers']) : array();
include 'header.php';
// Try catch
try {
<?php 
/**
 * PHP library version: v1.6
 */
require_once '../lib/worldpay.php';
// Initialise Worldpay class with your SERVICE KEY
$worldpay = new Worldpay("your-service-key");
// Sometimes your SSL doesnt validate locally
// DONT USE IN PRODUCTION
$worldpay->disableSSLCheck(true);
$worldpayOrderCode = $_POST['orderCode'];
include "header.php";
// Try catch
try {
    // Cancel the authorised order using the Worldpay order code
    $worldpay->cancelAuthorisedOrder($worldpayOrderCode);
    echo 'Authorised order <span id="order-code">' . $worldpayOrderCode . '</span>
        has been cancelled';
} catch (WorldpayException $e) {
    // PHP 5.3+
    // Worldpay has thrown an exception
    echo 'Error code: ' . $e->getCustomCode() . '<br/> 
    HTTP status code:' . $e->getHttpStatusCode() . '<br/> 
    Error description: ' . $e->getDescription() . ' <br/>
    Error message: ' . $e->getMessage();
} catch (Exception $e) {
    // PHP 5.2
    echo 'Error message: ' . $e->getMessage();
}
Example #7
0
function espresso_display_worldpay($payment_data)
{
    extract($payment_data);
    include_once 'Worldpay.php';
    global $wpdb, $org_options;
    $myworldpay = new Worldpay();
    // initiate an instance of the class
    echo '<!-- Event Espresso WorldPay Gateway Version ' . $myworldpay->worldpay_gateway_version . '-->';
    $worldpay_settings = get_option('event_espresso_worldpay_settings');
    $use_sandbox = $worldpay_settings['use_sandbox'];
    if ($use_sandbox) {
        $myworldpay->enableTestMode();
    }
    if ($use_sandbox) {
        // Enable test mode if needed
        $myworldpay->addField('testMode', '100');
    }
    $myworldpay->addField('instId', $worldpay_settings['worldpay_id']);
    $myworldpay->addField('cartId', 'wp-' . event_espresso_session_id());
    $myworldpay->addField('amount', $event_cost);
    $myworldpay->addField('MC_id', $attendee_id);
    $myworldpay->addField('MC_registration_id', $registration_id);
    $myworldpay->addField('MC_type', 'worldpay');
    $myworldpay->addField('currency', $worldpay_settings['currency_format']);
    if (!empty($worldpay_settings['bypass_payment_page'])) {
        $myworldpay->submitPayment();
        //Enable auto redirect to payment site
    } else {
        if (empty($worldpay_settings['button_url'])) {
            if (file_exists(EVENT_ESPRESSO_GATEWAY_DIR . "/worldpay/worldpay-logo.png")) {
                $button_url = EVENT_ESPRESSO_GATEWAY_DIR . "/worldpay/worldpay-logo.png";
            } else {
                $button_url = EVENT_ESPRESSO_PLUGINFULLURL . "gateways/worldpay/worldpay-logo.png";
            }
        } elseif (file_exists($worldpay_settings['button_url'])) {
            $button_url = $worldpay_settings['button_url'];
        } else {
            //If no other buttons exist, then use the default location
            $button_url = EVENT_ESPRESSO_PLUGINFULLURL . "gateways/worldpay/worldpay-logo.png";
        }
        $myworldpay->submitButton($button_url, 'worldpay');
        //Display payment button
    }
    if ($use_sandbox) {
        echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __('WorldPay Debug Mode Is Turned On', 'event_espresso') . '</h3>';
        $myworldpay->dump_fields();
        // for debugging, output a table of all the fields
    }
}
Example #8
0
 /**
  * Use external library to do JSON decode
  * @param bool $external
  * */
 public function setExternalJSONDecode($external = false)
 {
     self::$use_external_JSON = $external;
 }
 /**
  *
  */
 public function indexAction()
 {
     $logger = Mage::helper('worldpay/logger');
     if (!$this->getRequest()->isPost()) {
         $logger->log('Auth/Capture notifications must be POST');
         /**
          * send OK to whoever tries to play with us
          */
         echo '[OK]';
         return;
     }
     require_once Mage::getModuleDir('', 'Worldpay_Payments') . DS . 'lib' . DS . 'worldpay.php';
     try {
         $response = file_get_contents('php://input');
         $notification = Worldpay::handleResponse($response);
     } catch (Exception $e) {
         http_response_code(500);
         $logger->log('Error getting webhook');
         echo '[OK]';
         return;
     }
     $payment = Mage::getModel('sales/order_payment')->getCollection()->addAttributeToFilter('last_trans_id', array('eq' => $notification['orderCode']))->getFirstItem();
     if (!$payment) {
         http_response_code(500);
         $logger->log('Payment ' . $notification['orderCode'] . ' not found!');
         echo '[OK]';
         return;
     }
     $order = Mage::getModel('sales/order')->load($payment->getParentId(), 'entity_id');
     if (!$order) {
         http_response_code(500);
         $logger->log('Order ' . $notification['orderCode'] . ' not found!');
         echo '[OK]';
         return;
     }
     $payment = $order->getPayment();
     $amount = $order->getGrandTotal();
     if ($notification['paymentStatus'] === 'REFUNDED') {
         $payment->setIsTransactionClosed(1);
         $payment->setStatus(Worldpay_Payments_Model_PaymentMethods_Abstract::STATUS_VOID);
         $order->setSate(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, true, 'Payment Refunded');
     } else {
         if ($notification['paymentStatus'] === 'FAILED') {
             $order->cancel()->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'Gateway has declined the payment.')->save();
             $payment->setStatus(Worldpay_Payments_Model_PaymentMethods_Abstract::STATUS_DECLINED);
         } else {
             if ($notification['paymentStatus'] === 'SETTLED') {
                 $payment->setIsTransactionClosed(1);
                 $payment->setStatus(Worldpay_Payments_Model_PaymentMethods_Abstract::STATUS_SUCCESS);
             } else {
                 if ($notification['paymentStatus'] === 'SUCCESS') {
                     $payment->setTransactionId($notification['orderCode'])->setShouldCloseParentTransaction(1)->setIsTransactionClosed(1)->registerCaptureNotification($amount);
                 } else {
                     // Other status, magento doesn't handle.
                     $payment->setStatus(Worldpay_Payments_Model_PaymentMethods_Abstract::STATUS_UNKNOWN);
                     $order->addStatusHistoryComment('Worldpay Payment Status:' . $notification['paymentStatus']);
                     $order->setSate(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, true, $notification['paymentStatus']);
                 }
             }
         }
     }
     $order->save();
     // give worldpay confirmation
     echo '[OK]';
 }
<?php

namespace Worldpay;

?>

<?php 
/**
 * PHP library version: 2.1.0
 */
require_once '../init.php';
// Initialise Worldpay class with your SERVICE KEY
$worldpay = new Worldpay("your-service-key");
// Sometimes your SSL doesnt validate locally
// DONT USE IN PRODUCTION
$worldpay->disableSSLCheck(true);
include 'header.php';
try {
    $response = $worldpay->authorize3DSOrder($_SESSION['orderCode'], $_POST['PaRes']);
    if (isset($response['paymentStatus']) && ($response['paymentStatus'] == 'SUCCESS' || $response['paymentStatus'] == 'AUTHORIZED')) {
        echo 'Order Code: ' . $_SESSION['orderCode'] . ' has been authorized <br/>';
    } else {
        var_dump($response);
        echo 'There was a problem authorizing 3DS order <br/>';
    }
} catch (WorldpayException $e) {
    // Worldpay has thrown an exception
    echo 'Error code: ' . $e->getCustomCode() . '<br/>
    HTTP status code:' . $e->getHttpStatusCode() . '<br/>
    Error description: ' . $e->getDescription() . ' <br/>
    Error message: ' . $e->getMessage() . ' <br/>' . 'PaRes: ' . print_r($_POST, true) . '<br/>';
<?php

namespace Worldpay;

?>


<?php 
/**
 * PHP library version: 2.1.0
 */
require_once '../init.php';
// Initialise Worldpay class with your SERVICE KEY
$worldpay = new Worldpay("your-service-key");
// Sometimes your SSL doesnt validate locally
// DONT USE IN PRODUCTION
$worldpay->disableSSLCheck(true);
$worldpayOrderCode = $_POST['orderCode'];
$amount = $_POST['amount'];
include "header.php";
// Try catch
try {
    // Capture the authorized order using the Worldpay order code
    $worldpay->captureAuthorizedOrder($worldpayOrderCode, $amount * 100);
    $response = 'Authorized order <span id="order-code">' . $worldpayOrderCode . '</span> has been captured for ';
    $response .= !empty($amount) ? '<span id="amount">' . $amount . '</span>' : 'the full amount';
    echo $response;
} catch (WorldpayException $e) {
    // Worldpay has thrown an exception
    echo 'Error code: ' . $e->getCustomCode() . '<br/>
    HTTP status code:' . $e->getHttpStatusCode() . '<br/>
Example #12
0
<?php 
/**
 * PHP library version: v1.6
 */
require_once '../lib/worldpay.php';
// Initialise Worldpay class with your SERVICE KEY
$worldpay = new Worldpay("your-service-key");
// Sometimes your SSL doesnt validate locally
// DONT USE IN PRODUCTION
$worldpay->disableSSLCheck(true);
$token = $_POST['token'];
include 'header.php';
try {
    $cardDetails = $worldpay->getStoredCardDetails($token);
    echo '<p>Name: <span id="name">' . $cardDetails['name'] . '</span></p>';
    echo '<p>Expiry Month: <span id="expiration-month">' . $cardDetails['expiryMonth'] . '</span></p>';
    echo '<p>Expiry Year: <span id="expiration-year">' . $cardDetails['expiryYear'] . '</span></p>';
    echo '<p>Card Type: <span id="card-type">' . $cardDetails['cardType'] . '</span></p>';
    echo '<p>Masked Card Number: <span id="masked-card-number">' . $cardDetails['maskedCardNumber'] . '</span></p>';
    echo '<pre>' . print_r($cardDetails, true) . '</pre>';
} catch (WorldpayException $e) {
    // PHP 5.3+
    echo 'Error code: ' . $e->getCustomCode() . '<br/> 
    HTTP status code:' . $e->getHttpStatusCode() . '<br/> 
    Error description: ' . $e->getDescription() . ' <br/>
    Error message: ' . $e->getMessage();
} catch (Exception $e) {
    // PHP 5.2
    echo 'Error message: ' . $e->getMessage();
}
Example #13
0
<?php 
/**
 * PHP library version: v1.7
 */
require_once '../lib/worldpay.php';
// Initialise Worldpay class with your SERVICE KEY
$worldpay = new Worldpay("your-service-key");
// Sometimes your SSL doesnt validate locally
// DONT USE IN PRODUCTION
$worldpay->disableSSLCheck(true);
$worldpayOrderCode = $_POST['orderCode'];
include 'header.php';
// Try catch
try {
    // Refund the order using the Worldpay order code
    $worldpay->refundOrder($worldpayOrderCode);
    echo 'Order <span id="order-code">' . $worldpayOrderCode . '</span> has been refunded!';
} catch (WorldpayException $e) {
    // PHP 5.3+
    // Worldpay has thrown an exception
    echo 'Error code: ' . $e->getCustomCode() . '<br/> 
    HTTP status code:' . $e->getHttpStatusCode() . '<br/> 
    Error description: ' . $e->getDescription() . ' <br/>
    Error message: ' . $e->getMessage();
} catch (Exception $e) {
    // PHP 5.2
    echo 'Error message: ' . $e->getMessage();
}
Example #14
0
<?php 
/**
 * PHP library version: v1.7
 */
require_once '../lib/worldpay.php';
// Initialise Worldpay class with your SERVICE KEY
$worldpay = new Worldpay("your-service-key");
// Sometimes your SSL doesnt validate locally
// DONT USE IN PRODUCTION
$worldpay->disableSSLCheck(true);
$token = $_POST['token'];
$name = $_POST['name'];
$amount = $_POST['amount'];
$_3ds = isset($_POST['3ds']) ? $_POST['3ds'] : false;
$authoriseOnly = isset($_POST['authoriseOnly']) ? $_POST['authoriseOnly'] : false;
$customerIdentifiers = !empty($_POST['customer-identifiers']) ? json_decode($_POST['customer-identifiers']) : array();
include 'header.php';
// Try catch
try {
    // Customers billing address
    $billing_address = array("address1" => $_POST['address1'], "address2" => $_POST['address2'], "address3" => $_POST['address3'], "postalCode" => $_POST['postcode'], "city" => $_POST['city'], "state" => '', "countryCode" => $_POST['countryCode']);
    // Customers delivery address
    $delivery_address = array("firstName" => $_POST['delivery-firstName'], "lastName" => $_POST['delivery-lastName'], "address1" => $_POST['delivery-address1'], "address2" => $_POST['delivery-address2'], "address3" => $_POST['delivery-address3'], "postalCode" => $_POST['delivery-postcode'], "city" => $_POST['delivery-city'], "state" => '', "countryCode" => $_POST['delivery-countryCode']);
    $response = $worldpay->createOrder(array('token' => $token, 'orderDescription' => $_POST['description'], 'amount' => $amount * 100, 'is3DSOrder' => $_3ds, 'authoriseOnly' => $authoriseOnly, 'orderType' => $_POST['order-type'], 'currencyCode' => $_POST['currency'], 'settlementCurrency' => $_POST['settlement-currency'], 'name' => $_3ds ? '3D' : $name, 'billingAddress' => $billing_address, 'deliveryAddress' => $delivery_address, 'customerIdentifiers' => !is_null($customerIdentifiers) ? $customerIdentifiers : array(), 'statementNarrative' => $_POST['statement-narrative'], 'customerOrderCode' => 'A123'));
    if ($response['paymentStatus'] === 'SUCCESS' || $response['paymentStatus'] === 'AUTHORIZED') {
        // Create order was successful!
        $worldpayOrderCode = $response['orderCode'];
        echo '<p>Order Code: <span id="order-code">' . $worldpayOrderCode . '</span></p>';
        echo '<p>Token: <span id="token">' . $response['token'] . '</span></p>';
        echo '<p>Payment Status: <span id="payment-status">' . $response['paymentStatus'] . '</span></p>';
<?php 
/**
 * PHP library version: v1.7
 */
require_once '../lib/worldpay.php';
// Initialise Worldpay class with your SERVICE KEY
$worldpay = new Worldpay("your-service-key");
// Sometimes your SSL doesnt validate locally
// DONT USE IN PRODUCTION
$worldpay->disableSSLCheck(true);
$token = $_POST['token'];
$name = $_POST['name'];
$amount = $_POST['amount'];
$protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
$redirect_url = $protocol . $_SERVER['HTTP_HOST'] . "/apm";
$customerIdentifiers = !empty($_POST['customer-identifiers']) ? json_decode($_POST['customer-identifiers']) : array();
include 'header.php';
// Try catch
try {
    // Customers billing address
    $billing_address = array("address1" => $_POST['address1'], "address2" => $_POST['address2'], "address3" => $_POST['address3'], "postalCode" => $_POST['postcode'], "city" => $_POST['city'], "state" => '', "countryCode" => $_POST['countryCode']);
    // Customers delivery address
    $delivery_address = array("firstName" => $_POST['delivery-firstName'], "lastName" => $_POST['delivery-lastName'], "address1" => $_POST['delivery-address1'], "address2" => $_POST['delivery-address2'], "address3" => $_POST['delivery-address3'], "postalCode" => $_POST['delivery-postcode'], "city" => $_POST['delivery-city'], "state" => '', "countryCode" => $_POST['delivery-countryCode']);
    $response = $worldpay->createApmOrder(array('token' => $token, 'orderDescription' => $_POST['description'], 'amount' => $amount * 100, 'currencyCode' => $_POST['currency'], 'settlementCurrency' => $_POST['settlement-currency'], 'name' => $name, 'billingAddress' => $billing_address, 'deliveryAddress' => $delivery_address, 'customerIdentifiers' => !is_null($customerIdentifiers) ? $customerIdentifiers : array(), 'statementNarrative' => $_POST['statement-narrative'], 'customerOrderCode' => 'A123', 'successUrl' => $redirect_url . '/success.php', 'pendingUrl' => $redirect_url . '/pending.php', 'failureUrl' => $redirect_url . '/error.php', 'cancelUrl' => $redirect_url . '/cancel.php'));
    if ($response['paymentStatus'] === 'PRE_AUTHORIZED') {
        // Redirect to URL
        $_SESSION['orderCode'] = $response['orderCode'];
        ?>
            <script>
                window.location.replace("<?php 
Example #16
0
<?php

namespace Worldpay;

?>

<?php 
/**
 * PHP library version: 2.0.0
 */
require_once '../init.php';
// Initialise Worldpay class with your SERVICE KEY
$worldpay = new Worldpay("your-service-key");
// Sometimes your SSL doesnt validate locally
// DONT USE IN PRODUCTION
$worldpay->disableSSLCheck(true);
$orderCode = $_POST['orderCode'];
include 'header.php';
// Try catch
try {
    $response = $worldpay->getOrder($orderCode);
    echo '<pre>' . print_r($response, true) . '</pre>';
} catch (WorldpayException $e) {
    // Worldpay has thrown an exception
    echo 'Error code: ' . $e->getCustomCode() . '<br/>
    HTTP status code:' . $e->getHttpStatusCode() . '<br/>
    Error description: ' . $e->getDescription() . ' <br/>
    Error message: ' . $e->getMessage();
}
Example #17
0
<?php 
/**
 * PHP library version: v1.6
 */
require_once '../lib/worldpay.php';
// Initialise Worldpay class with your SERVICE KEY
$worldpay = new Worldpay("your-service-key");
// Sometimes your SSL doesnt validate locally
// DONT USE IN PRODUCTION
$worldpay->disableSSLCheck(true);
$token = $_POST['token'];
$name = $_POST['name'];
$amount = $_POST['amount'];
$_3ds = isset($_POST['3ds']) ? $_POST['3ds'] : false;
$authoriseOnly = isset($_POST['authoriseOnly']) ? $_POST['authoriseOnly'] : false;
include 'header.php';
// Try catch
try {
    // Customers billing address
    $billing_address = array("address1" => $_POST['address1'], "address2" => $_POST['address2'], "address3" => $_POST['address3'], "postalCode" => $_POST['postcode'], "city" => $_POST['city'], "state" => '', "countryCode" => $_POST['countryCode']);
    $response = $worldpay->createOrder(array('token' => $token, 'orderDescription' => $_POST['description'], 'amount' => $amount * 100, 'is3DSOrder' => $_3ds, 'authoriseOnly' => $authoriseOnly, 'orderType' => $_POST['order-type'], 'currencyCode' => $_POST['currency'], 'name' => $_3ds ? '3D' : $name, 'billingAddress' => $billing_address, 'customerIdentifiers' => array('my-customer-ref' => 'customer-ref'), 'customerOrderCode' => 'A123'));
    if ($response['paymentStatus'] === 'SUCCESS' || $response['paymentStatus'] === 'AUTHORIZED') {
        // Create order was successful!
        $worldpayOrderCode = $response['orderCode'];
        echo '<p>Order Code: <span id="order-code">' . $worldpayOrderCode . '</span></p>';
        echo '<p>Token: <span id="token">' . $response['token'] . '</span></p>';
        echo '<p>Payment Status: <span id="payment-status">' . $response['paymentStatus'] . '</span></p>';
        echo '<pre>' . print_r($response, true) . '</pre>';
        // TODO: Store the order code somewhere..
    } elseif ($response['is3DSOrder']) {