$flat = "TemplateType=OrderCancellation\tVersion=1.0/1.0.1\tThis row for Amazon.com use only. Do not modify or delete.\n";
$flat .= "order-id\tmerchant-order-id\tcancellation-reason-code\tamazon-order-item-code\n";
foreach ($order['products'] as $product) {
$flat .= $order['amazon_order_id'] . "\t\tGeneralAdjustment\t" . $product['amazon_order_item_code'] . "\n";
}
$headers = array(
'Content-Type: text/xml',
'Content-MD5: ' . base64_encode(md5($flat, true)),
);
$args = $this->getCommonParameters();
$args['Merchant'] = $this->getMerchantId();
$args['Action'] = 'SubmitFeed';
$args['Version'] = '2009-01-01';
$args['FeedType'] = '_POST_FLAT_FILE_ORDER_ACKNOWLEDGEMENT_DATA_';
$response = $this->getMwsResponse('POST', '/', $args, array(), $flat, $headers);
$response_xml = simplexml_load_string($response);
$cba_log = new Log('cba.log');
$cba_log->write('Marked order ' . $order['amazon_order_id'] .' as canceled. Response ' . print_r($response_xml, 1));