AddedFeaturesAuto»Post Shipment URL Handler

Post Shipment URL Handler

Post Shipment URL Handler

Upon successful shipment, NRGship can invoke a user-defined URL to return shipment details to your website.

NRGship will pass the following fields of data via GET parameters so that the data can be utilized to update ship data in external systems.

Fields passed via URL handler
Ship_ID
User_ID
User_Field01.User_Field19
Status
Service
Response_BillingWeight
Response_BillingWeightUOM
Response_Description
Response_ServiceOptionsCharges
Response_ServiceOptionsChargesCurrency
Response_ShipmentIdentificationNumber
Response_StatusCode
Response_TotalCharges
Response_TotalChargesCurrency
Response_TransportationCharges
Response_TransportationChargesCurrency
Response_NegotiatedRates_NetSummaryCharge_GrandTotal_MonetaryValue
Response_NegotiatedRates_NetSummaryCharge_GrandTotal_CurrencyCode
Package_InvoiceNumber
Package_ReferenceNumber
Package_Weight
Package_Packaging

To activate, select "Invoke URL Handler" and enter the URL path for order updates.


The sample PHP code below can be used as the basis for post shipment processing to update an "orders" table to update a column named tracking_num post shipment. Download Sample Code

<?php

/*

this page is used for post-shipment processing to update a mysql order
with tracking information via NRGship's post-ship URL handler

params passed include User_ID, Status, Response_ShipmentIdentificationNumber (tracknum)

*/

// set mysql info
$dbhost = "hostname"; // database hostname
$dbuser = "user"; // database username
$dbpassword = "pass"; // database password
$dbname = "yourdbname"; // database name
$dbtable = "orders" ; // table name

// connect to mysql
$conn=mysql_connect($dbhost, $dbuser, $dbpassword);
@mysql_select_db($dbname) or die( "ERR: Unable to select database");

$id = $_REQUEST['User_ID'];
$status = $_REQUEST['Status'];
$tracknum = $_REQUEST['Response_ShipmentIdentificationNumber'];

if ($id == ) {
echo '<Error>Invalid ID</Error>';
die ();
}

if ($tracknum ==
) {
echo '<Error>Invalid Tracknum</Error>';
die ();
}

if ($status != 'Shipped' ) {
echo '<Error>Invalid Status</Error>';
die ();
}

// update order
$sql = 'update `'.$dbtable.'` set tracking_num = \''.$tracknum.'\' where order_id = '.$id;
$result = mysql_query($sql) or die(mysql_error());

?>