<?php
	session_start();
	
	/**
	 * @author Jan Wehrs (jan.wehrs@billpay.de)
	 * @copyright Copyright 2010 Billpay GmbH
	 * @license commercial 
	 */
	require_once '../../api/ipl_xml_api.php';
	require_once '../../api/php5/ipl_edit_cart_content_request.php';
	
	// This is the order reference from the capture request
	$ref = $_GET["ref"];

	$req = new ipl_edit_cart_content_request($_SESSION['api-url-base']);
	$req->set_default_params($_SESSION['mid'], $_SESSION['pid'], $_SESSION['security-key']);
	$req->set_total(500, 595, "Express-Versand", 500, 650, 5300, 7905, "EUR", $ref);
	$req->add_article("article003", 3, "Kaffetasse 07/11", "", 1200, 1950);
	$req->add_article("article004", 2, "Kuchenteller 007", "", 850, 1000);
	
	try {
		$req->send();

		if ($req->has_error()) {
			echo "Error occured!<br />";
			echo "Error code: " . $req->get_error_code() . "<br />";
			echo "Merchant msg: " . utf8_decode($req->get_merchant_error_message()) . "<br />";
			echo "Customer msg: " . utf8_decode($req->get_customer_error_message()) . "<br />";
		}
		else {
			echo "Edit cart content successful<br />";
		}
		
		echo "<br /><br />";
		echo "<strong>Request XML:</strong> " . htmlentities($req->get_request_xml());
		echo "<br /><br />";
		echo "<strong>Response XML:</strong> " . htmlentities($req->get_response_xml());
	}
	catch(Exception $e) {
		echo $e->getMessage();
	}
?>