<?php

// Include required library files.
require_once '../includes/config.php';
require_once '../autoload.php';
// Create PayPal object.
$PayPalConfig = array('Sandbox' => $sandbox, 'APIUsername' => $api_username, 'APIPassword' => $api_password, 'APISignature' => $api_signature, 'PrintHeaders' => $print_headers, 'LogResults' => $log_results, 'LogPath' => $log_path);
$PayPal = new angelleye\PayPal\PayPal($PayPalConfig);
// Prepare request arrays
$BMSetInventoryFields = array('hostedbuttonid' => '3J9D98TNZHJDC', 'trackinv' => '1', 'trackpnl' => '1', 'optionnameindex' => '', 'soldouturl' => 'http://www.domain.com/soldout', 'reusedigitaldownloadkeys' => '0', 'appenddigitaldownloadkeys' => '1');
// One or more digital downloads keys, up to a max of 1k.
$DigitalDownloadKeys = array('key1', 'key2', 'etc');
$ItemTrackingDetails = array('itemnumber' => '123ABC', 'itemqty' => '25', 'itemqtydelta' => '', 'itemalert' => '5', 'itemcost' => '1.00');
// Here we can have up to 10 $OptionTrackingDetail arrays loaded into $OptionTrackingDetails
$OptionTrackingDetails = array();
$OptionTrackingDetail = array('number' => '123ABC-Blue', 'qty' => '10', 'select' => 'Blue', 'qtydelta' => '', 'alert' => '3', 'cost' => '1.00');
array_push($OptionTrackingDetails, $OptionTrackingDetail);
$OptionTrackingDetail = array('number' => '123ABC-Red', 'qty' => '10', 'select' => 'Red', 'qtydelta' => '', 'alert' => '3', 'cost' => '1.00');
array_push($OptionTrackingDetails, $OptionTrackingDetail);
$OptionTrackingDetail = array('number' => '123ABC-Green', 'qty' => '5', 'select' => 'Green', 'qtydelta' => '', 'alert' => '3', 'cost' => '1.00');
array_push($OptionTrackingDetails, $OptionTrackingDetail);
$PayPalRequestData = array('BMSetInventoryFields' => $BMSetInventoryFields, 'DigitalDownloadKeys' => $DigitalDownloadKeys, 'ItemTrackingDetails' => $ItemTrackingDetails, 'OptionTrackingDetails' => $OptionTrackingDetails);
// Pass data into class for processing with PayPal and load the response array into $PayPalResult
$PayPalResult = $PayPal->BMSetInventory($PayPalRequestData);
// Write the contents of the response array to the screen for demo purposes.
echo '<pre />';
print_r($PayPalResult);