Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
$THROTTLE_TIME_PRODUCTMATCH = 1;
$THROTTLE_TIME_PRODUCTID = 4;
$THROTTLE_TIME_PRODUCTPRICE = 2;
$THROTTLE_TIME_PRODUCTFEE = 10;
//Requesting a Report
$THROTTLE_LIMIT_REPORTREQUEST = 15;
$THROTTLE_TIME_REPORTREQUEST = 60;
Expand Down
58 changes: 56 additions & 2 deletions includes/classes/AmazonFinancialEventList.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,29 @@ protected function parseXml($xml) {
$this->list['Adjustment'][] = $temp;
}
}
if (isset($xml->SAFETReimbursementEventList)) {
foreach($xml->SAFETReimbursementEventList->children() as $x) {
$temp = array();
$temp['PostedDate'] = (string)$x->PostedDate;
$temp['SAFETClaimId'] = (string)$x->SAFETClaimId;
$temp['Amount'] = (string)$x->ReimbursedAmount->CurrencyAmount;
$temp['CurrencyCode'] = (string)$x->ReimbursedAmount->CurrencyCode;
$temp['SAFETReimbursementItemList'] = array();
if (isset($x->SAFETReimbursementItemList)) {
foreach($x->SAFETReimbursementItemList->children() as $y) {
if (!isset($y->ItemChargeList)) {
continue;
}
$ztemp = array();
foreach($y->ItemChargeList->children() as $z) {
$ztemp['ItemChargeList'][] = $this->parseCharge($z);
}
$temp['SAFETReimbursementItemList'][] = $ztemp;
}
}
$this->list['SAFET'][] = $temp;
}
}
}

/**
Expand Down Expand Up @@ -542,8 +565,8 @@ protected function parseShipmentEvent($xml) {
/**
* Parses XML for a single charge into an array.
* This structure is used many times throughout shipment events.
* @param SimpleXMLElement $xml <p>The XML response from Amazon.</p>
* @return array parsed structure from XML
* @param SimpleXMLElement $xml <p>Charge node of the XML response from Amazon.</p>
* @return array Parsed structure from XML
*/
protected function parseCharge($xml) {
$r = array();
Expand Down Expand Up @@ -585,6 +608,7 @@ protected function parseFee($xml) {
* <li><b>DebtRecovery</b> - see <i>getDebtRecoveryEvents</i></li>
* <li><b>LoanServicing</b> - see <i>getLoanServicingEvents</i></li>
* <li><b>Adjustment</b> - see <i>getAdjustmentEvents</i></li>
* <li><b>SAFET</b> - see <i>getSafetEvents</i></li>
* </ul>
* @return array|boolean multi-dimensional array, or <b>FALSE</b> if list not filled yet
* @see getShipmentEvents
Expand All @@ -600,6 +624,7 @@ protected function parseFee($xml) {
* @see getDebtRecoveryEvents
* @see getLoanServicingEvents
* @see getAdjustmentEvents
* @see getSafetEvents
*/
public function getEvents(){
if (isset($this->list)){
Expand Down Expand Up @@ -991,4 +1016,33 @@ public function getAdjustmentEvents(){
}
}

/**
* Returns all SAFE-T reimbursement events.
*
* Each event array will have the following keys:
* <ul>
* <li><b>PostedDate</b> - ISO 8601 date format</li>
* <li><b>Amount</b> - number</li>
* <li><b>CurrencyCode</b> - ISO 4217 currency code</li>
* <li><b>SAFETClaimId</b></li>
* <li><b>SAFETReimbursementItemList</b> - multi-dimensional array, each array has the following keys:</li>
* <ul>
* <li><b>ItemChargeList</b> - multi-dimensional array, each array has the following keys:</li>
* <ul>
* <li><b>ChargeType</b></li>
* <li><b>Amount</b> - number</li>
* <li><b>CurrencyCode</b> - ISO 4217 currency code</li>
* </ul>
* </ul>
* </ul>
* @return array|boolean multi-dimensional array, or <b>FALSE</b> if list not filled yet
*/
public function getSafetEvents(){
if (isset($this->list['SAFET'])){
return $this->list['SAFET'];
} else {
return false;
}
}

}
97 changes: 75 additions & 22 deletions includes/classes/AmazonFulfillmentOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,28 +135,7 @@ protected function parseXML($xml) {
$this->order['Details']['DeliveryWindow']['StartDateTime'] = (string)$d->DeliveryWindow->StartDateTime;
$this->order['Details']['DeliveryWindow']['EndDateTime'] = (string)$d->DeliveryWindow->EndDateTime;
}
//Address
$this->order['Details']['DestinationAddress']['Name'] = (string)$d->DestinationAddress->Name;
$this->order['Details']['DestinationAddress']['Line1'] = (string)$d->DestinationAddress->Line1;
if (isset($d->DestinationAddress->Line2)){
$this->order['Details']['DestinationAddress']['Line2'] = (string)$d->DestinationAddress->Line2;
}
if (isset($d->DestinationAddress->Line3)){
$this->order['Details']['DestinationAddress']['Line3'] = (string)$d->DestinationAddress->Line3;
}
if (isset($d->DestinationAddress->DistrictOrCounty)){
$this->order['Details']['DestinationAddress']['DistrictOrCounty'] = (string)$d->DestinationAddress->DistrictOrCounty;
}
$this->order['Details']['DestinationAddress']['City'] = (string)$d->DestinationAddress->City;
$this->order['Details']['DestinationAddress']['StateOrProvinceCode'] = (string)$d->DestinationAddress->StateOrProvinceCode;
$this->order['Details']['DestinationAddress']['CountryCode'] = (string)$d->DestinationAddress->CountryCode;
if (isset($d->DestinationAddress->PostalCode)){
$this->order['Details']['DestinationAddress']['PostalCode'] = (string)$d->DestinationAddress->PostalCode;
}
if (isset($d->DestinationAddress->PhoneNumber)){
$this->order['Details']['DestinationAddress']['PhoneNumber'] = (string)$d->DestinationAddress->PhoneNumber;
}
//End of Address
$this->order['Details']['DestinationAddress'] = $this->parseAddress($d->DestinationAddress);
if (isset($d->FulfillmentAction)){
$this->order['Details']['FulfillmentAction'] = (string)$d->FulfillmentAction;
}
Expand Down Expand Up @@ -279,6 +258,78 @@ protected function parseXML($xml) {

$i++;
}

//Section 4: Return Items
if (isset($xml->ReturnItemList)) {
foreach ($xml->ReturnItemList->children() as $x) {
$temp = array();
$temp['SellerReturnItemId'] = (string)$x->SellerReturnItemId;
$temp['SellerFulfillmentOrderItemId'] = (string)$x->SellerFulfillmentOrderItemId;
$temp['AmazonShipmentId'] = (string)$x->AmazonShipmentId;
$temp['SellerReturnReasonCode'] = (string)$x->SellerReturnReasonCode;
if (isset($x->ReturnComment)) {
$temp['ReturnComment'] = (string)$x->ReturnComment;
}
if (isset($x->AmazonReturnReasonCode)) {
$temp['AmazonReturnReasonCode'] = (string)$x->AmazonReturnReasonCode;
}
$temp['Status'] = (string)$x->Status;
$temp['StatusChangedDate'] = (string)$x->StatusChangedDate;
if (isset($x->ReturnAuthorizationId)) {
$temp['ReturnAuthorizationId'] = (string)$x->ReturnAuthorizationId;
}
if (isset($x->ReturnReceivedCondition)) {
$temp['ReturnReceivedCondition'] = (string)$x->ReturnReceivedCondition;
}
if (isset($x->FulfillmentCenterId)) {
$temp['FulfillmentCenterId'] = (string)$x->FulfillmentCenterId;
}
$this->order['ReturnItems'][] = $temp;
}
}

//Section 5: Return Authorizations
if (isset($xml->ReturnAuthorizationList)) {
foreach ($xml->ReturnAuthorizationList->children() as $x) {
$temp = array();
$temp['ReturnAuthorizationId'] = (string)$x->ReturnAuthorizationId;
$temp['FulfillmentCenterId'] = (string)$x->FulfillmentCenterId;
$temp['ReturnToAddress'] = $this->parseAddress($x->ReturnToAddress);
$temp['AmazonRmaId'] = (string)$x->AmazonRmaId;
$temp['RmaPageURL'] = (string)$x->RmaPageURL;
$this->order['ReturnAuthorizations'][] = $temp;
}
}
}

/**
* Parses XML for an address into an array.
* @param SimpleXMLElement $xml <p>Address node of the XML response from Amazon.</p>
* @return array Parsed structure from XML
*/
public function parseAddress($xml) {
$r = array();
$r['Name'] = (string)$xml->Name;
$r['Line1'] = (string)$xml->Line1;
if (isset($xml->Line2)){
$r['Line2'] = (string)$xml->Line2;
}
if (isset($xml->Line3)){
$r['Line3'] = (string)$xml->Line3;
}
if (isset($xml->DistrictOrCounty)){
$r['DistrictOrCounty'] = (string)$xml->DistrictOrCounty;
}
$r['City'] = (string)$xml->City;
$r['StateOrProvinceCode'] = (string)$xml->StateOrProvinceCode;
$r['CountryCode'] = (string)$xml->CountryCode;
if (isset($xml->PostalCode)){
$r['PostalCode'] = (string)$xml->PostalCode;
}
if (isset($xml->PhoneNumber)){
$r['PhoneNumber'] = (string)$xml->PhoneNumber;
}
return $r;
}

/**
Expand Down Expand Up @@ -323,6 +374,8 @@ public function cancelOrder(){
* <li><b>Details</b> - array of general information, such as destination address</li>
* <li><b>Items</b> - multi-dimensional array of item data</li>
* <li><b>Shipments</b> - multi-dimensional array of shipment data</li>
* <li><b>ReturnItems</b> - multi-dimensional array of return item data</li>
* <li><b>ReturnAuthorizations</b> - multi-dimensional array of return authorization data</li>
* </ul>
* @return array|boolean data array, or <b>FALSE</b> if data not filled yet
*/
Expand Down
6 changes: 6 additions & 0 deletions includes/classes/AmazonMerchantServiceList.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,11 @@ protected function parseXML($xml){
$this->serviceList[$i]['ShippingServiceOptions']['DeclaredValue']['Amount'] = (string)$x->ShippingServiceOptions->DeclaredValue->Amount;
$this->serviceList[$i]['ShippingServiceOptions']['DeclaredValue']['CurrencyCode'] = (string)$x->ShippingServiceOptions->DeclaredValue->CurrencyCode;
}
if (isset($x->AvailableLabelFormats)) {
foreach ($x->AvailableLabelFormats as $z) {
$this->serviceList[$i]['AvailableLabelFormats'][] = (string)$z;
}
}

$i++;
}
Expand Down Expand Up @@ -594,6 +599,7 @@ protected function parseXML($xml){
* <li><b>LatestEstimatedDeliveryDate</b></li>
* <li><b>Rate</b></li>
* <li><b>ShippingServiceOptions</b></li>
* <li><b>AvailableLabelFormats</b></li>
* </ul>
* @return array|boolean multi-dimensional array, or <b>FALSE</b> if list not filled yet
*/
Expand Down
12 changes: 12 additions & 0 deletions includes/classes/AmazonMerchantShipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ protected function parseXML($xml) {
$this->data['Label']['FileContents']['Contents'] = (string)$d->Label->FileContents->Contents;
$this->data['Label']['FileContents']['FileType'] = (string)$d->Label->FileContents->FileType;
$this->data['Label']['FileContents']['Checksum'] = (string)$d->Label->FileContents->Checksum;
if (isset($d->Label->CustomTextForLabel)) {
$this->data['Label']['CustomTextForLabel'] = (string)$d->Label->CustomTextForLabel;
}
if (isset($d->Label->LabelFormat)) {
$this->data['Label']['LabelFormat'] = (string)$d->Label->LabelFormat;
}
if (isset($d->Label->StandardIdForLabel)) {
$this->data['Label']['StandardIdForLabel'] = (string)$d->Label->StandardIdForLabel;
}
}

$this->data['ItemList'] = array();
Expand Down Expand Up @@ -548,6 +557,9 @@ public function getDeclaredValue($only = false){
* <li><b>Checksum</b></li>
* </ul>
* </li>
* <li><b>CustomTextForLabel</b></li>
* <li><b>LabelFormat</b></li>
* <li><b>StandardIdForLabel</b></li>
* </ul>
* @param boolean $raw [optional] <p>Set to TRUE to get the raw, double-encoded file contents.</p>
* @return array|boolean multi-dimensional array, or <b>FALSE</b> if label not set yet
Expand Down
70 changes: 70 additions & 0 deletions includes/classes/AmazonMerchantShipmentCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,56 @@ public function setCarrierWillPickUp($b = true) {
$this->options['ShipmentRequestDetails.ShippingServiceOptions.CarrierWillPickUp'] = $v;
}

/**
* Sets the Label Format. (Optional)
*
* This method sets the label format to be sent in the next request.
* @param string $f <p>Label format (ex: "PNG")</p>
* @return boolean <b>FALSE</b> if improper input
*/
public function setLabelFormat($f) {
if (is_string($f)){
$this->options['ShipmentRequestDetails.ShippingServiceOptions.LabelFormat'] = $f;
} else {
$this->log("Tried to set LabelFormat to invalid value",'Warning');
return false;
}
}

/**
* Sets the Custom Text for the Label. (Optional)
*
* This method sets the custom text for the label to be sent in the next request.
* @param string $t <p>Up to 14 characters</p>
* @return boolean <b>FALSE</b> if improper input
*/
public function setCustomText($t) {
if (is_string($t)){
$this->options['ShipmentRequestDetails.LabelCustomization.CustomTextForLabel'] = $t;
} else {
$this->log("Tried to set CustomTextForLabel to invalid value",'Warning');
return false;
}
}

/**
* Sets the Standard ID for the Label. (Optional)
*
* This method sets the standard ID option for the label to be sent in the next request.
* @param string $id <p>"AmazonOrderId"</p>
*/
public function setLabelId($id) {
$options = array(
'AmazonOrderId'
);
if (in_array($id, $options)){
$this->options['ShipmentRequestDetails.LabelCustomization.StandardIdForLabel'] = $id;
} else {
$this->log("Tried to set StandardIdForLabel to invalid value",'Warning');
return false;
}
}

/**
* Sets the Shipping Service ID. (Required)
*
Expand Down Expand Up @@ -451,6 +501,26 @@ public function setServiceOffer($id) {
}
}

/**
* Sets the Hazmat Type. (Optional)
*
* This method sets the hazmat type to be sent in the next request.
* @param string $h <p>"None" or "LQHazmat"</p>
* @return boolean <b>FALSE</b> if improper input
*/
public function setHazmat($h) {
$options = array(
'None',
'LQHazmat'
);
if (in_array($h, $options)){
$this->options['HazmatType'] = $h;
} else {
$this->log("Tried to set HazmatType to invalid value",'Warning');
return false;
}
}

/**
* Fetches eligible services for the shipment from Amazon using the current options.
*
Expand Down
Loading