Skip to content

Instantly share code, notes, and snippets.

@chardcastle
Created December 5, 2012 22:36
Show Gist options
  • Save chardcastle/4220130 to your computer and use it in GitHub Desktop.
Save chardcastle/4220130 to your computer and use it in GitHub Desktop.
eCommerce order complete process
<?php
// Decode the Crypt field and extract the results
$sagePay = new SagePay_Util();
$strDecoded = $sagePay->decodeAndDecrypt($strCrypt);
$values = $sagePay->getToken($strDecoded);
// Fire a range of actions
$listeners = array(
"Application_Model_Order", // Add order to database
"SagePay_Order", // Update order with payment information
"Application_Model_User", // Email order details
"Application_Model_Basket", // Clear basket contents
"Application_Model_Product", // Decrease stock levels
);
foreach ($listeners as $listener)
{
$command = new $listener;
$command->orderComplete($values, $this->view->basket->getId());
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment