public function loadPost()
 {
     $result = new \Icepay_Postback();
     $result->setMerchantID((string) $this->merchantId)->setSecretCode((string) $this->secretCode);
     try {
         if ($result->validate()) {
             $this->status = new ResponseStatus($result->getStatus());
             $this->statusDescription = $result->getPostback()->statusCode;
             $this->orderId = $result->getOrderID();
             $this->parameters = (array) $result->getPostback();
         } else {
             throw new InvalidResponseException('Could not verify post response data');
         }
     } catch (\Exception $e) {
         throw new ApiException('There was a problem validating the post response', 0, $e);
     }
 }
Exemple #2
0
//<--- Change this into your own merchant ID
define('EMAIL', "*****@*****.**");
//<--- Change this into your own e-mail address
require_once '../src/icepay_api_basic.php';
/* Apply logging rules */
$logger = Icepay_Api_Logger::getInstance();
$logger->enableLogging()->setLoggingLevel(Icepay_Api_Logger::LEVEL_ALL)->logToFile()->setLoggingDirectory(realpath("../logs"))->setLoggingFile("postback.txt")->logToScreen();
/* Start the postback class */
$icepay = new Icepay_Postback();
$icepay->setMerchantID(MERCHANTID)->setSecretCode(SECRETCODE);
$order = new Example_Order();
// This is a dummy class to depict a sample usage.
try {
    if ($icepay->validate()) {
        // In this example the ICEPAY OrderID is identical to the Order ID used in our project
        $order->loadByOrderID($icepay->getOrderID());
        /* Only update the status if it's a new order (NEW)
         * or update the status if the statuscode allowes it.
         * In this example the project order status is an ICEPAY statuscode.
         */
        if ($order->getStatus() == "NEW" || $icepay->canUpdateStatus($order->getStatus())) {
            $order->saveStatus($icepay->getStatus());
            //Update the status of your order
            $order->sendMail(sprintf("icepay_status_update_to_%s", $order->getStatus()));
        }
        $order->updateStatusHistory($icepay->getTransactionString());
        echo "Validated!";
    } else {
        die("Unable to validate postback data");
    }
} catch (Exception $e) {