<?php
require_once __DIR__ . '/vendor/autoload.php';
// TODO: Replace YOUR KEY HERE with an Application API Key that has read permission to the order resource.
// Configure API key authorization: ultraCartSimpleApiKey
ultracart\v2\Configuration::getDefaultConfiguration()->setApiKey('x-ultracart-simple-key', 'YOUR API KEY HERE');
// Disable SSL verification if we're having issues with this PHP install not having the proper CA installed. Fix your CA for a production environment!
// Set debug to true if you need more information on request/response
$client = new GuzzleHttp\Client(['verify' => false, 'debug' => false]);
$api_instance = new ultracart\v2\Apiapi\OrderApi(
$client,
ultracart\v2\Configuration::getDefaultConfiguration(),
new ultracart\v2\HeaderSelector("2016-10-01")
);
// Extract the token from the parameters passed to our URL
$orderToken = $_GET["orderToken"];
// Setup the query object
$orderByTokenQuery = new ultracart\v2\models\OrderByTokenQuery();
$orderByTokenQuery->setOrderToken($orderToken);
/*
Determine how much data that you need to expand. Valid values are:
affiliate
affiliate.ledger
auto_order
billing
buysafe
channel_partner
checkout
coupon
customer_profile
digital_order
edi
fraud_score
gift
gift_certificate
internal
item
linked_shipment
marketing
payment
payment.transaction
quote
salesforce
shipping
summary
taxes
*/
$_expand = "billing,coupon,digital_order,item,payment,shipping,summary,taxes";
// Grab the order
$result = $api_instance->getOrderByToken($orderByTokenQuery, $_expand);
if ($result->getSuccess()) {
$order = $result->getOrder();
// Dump the result for debug
// var_dump($order);
// TODO: If you want to get rally fancy you can take the $order object and output your entirely custom HTML DOM instead of using our formatter method
// Generate a text formatted version of the order for display.
$formatOptions = new \ultracart\v2\models\OrderFormat();
$formatOptions->setFormat("text"); // Valid options are: text, div, table
$formattedOrder = $api_instance->format($order->getOrderId(), $formatOptions);
echo $formattedOrder->getFormattedResult();
}
?> |