Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.
Munir Wanis edited this page Oct 25, 2015 · 5 revisions
<?php

try
{
    // Load Dependencies
    require_once(dirname(__FILE__) . '\vendor\autoload.php');

    // Load configuration file with URL and Merchant Key
    require_once(dirname(__FILE__) . '\config.php');

    // Define the used URL
    \Gateway\ApiClient::setBaseUrl(Config::URL);

    // Define the Merchant Key
    \Gateway\ApiClient::setMerchantKey(Config::MERCHANT_KEY);

    // Create request object
    $request = new \Gateway\One\DataContract\Request\CancelRequest();

    // Define all request data
    $request->setOrderKey("3016a3cb-90c0-4a22-863e-4e707ba7251d");

    // Create new ApiClient object
    $client = new Gateway\ApiClient();

    // Make the call
    $response = $client->cancel($request);

    // Print the response
    print "<pre>";
    print json_encode(array('success' => $response->isSuccess(), 'data' => $response->getData()), JSON_PRETTY_PRINT);
    print "</pre>";
}
catch (\Gateway\One\DataContract\Report\ApiError $error)
{
    // Print JSON
    print "<pre>";
    print json_encode($error, JSON_PRETTY_PRINT);
    print "</pre>";
}
catch (Exception $ex)
{
    // Print JSON
    print "<pre>";
    print json_encode($ex, JSON_PRETTY_PRINT);
    print "</pre>";
}