I am creating a module that connects Drupal Commerce to Shipworks (a shipping management system). They communicate with each other using HTTP POSTs via a single endpoint URL on Drupal. One aspect I am trying to understand is how to handle the POST variables returned from Shipworks in a secure manner.
For example, when a shipment is created in Shipworks the corresponding order id ($_REQUEST['order']) and tracking number ($_REQUEST['tracking']) are posted to Drupal at the endpoint. How do I save the tracking number in a secure manner using the entity api? Can I use the following code?
if (is_int($_REQUEST['order'])) {
$order_id = $_REQUEST['order'];
}
else {
_outputError(40, "Not a valid order id.");
}
$order = commerce_order_load($order_id);
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$tracking = $_REQUEST['tracking'];
$tracking_number = str_replace(' ', '', strtoupper($tracking));
$order_wrapper->field_tracking_numbers->set($tracking_number);
$order_wrapper->save();