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);
     }
 }
$temp_data = $Checkout->get_all_data_from_temp_db($temp_orders_id);
//get all orders data
$icepay = new Icepay_Postback();
$icepay->setMerchantID($Icepay->instances[$temp_data[$temp_orders_id]['orders']['payment_method']]['merchant_id'])->setSecretCode($Icepay->instances[$temp_data[$temp_orders_id]['orders']['payment_method']]['secret_code'])->enableLogging()->logToFile(true, realpath("../logs"))->logToScreen();
$data = '';
foreach ($_POST as $key => $value) {
    $data .= $key . ': ' . "\n";
    $data .= $value . "\n\n";
}
tep_db_query('INSERT INTO payment_log (type, data, date) VALUES ("Icepay", "' . $data . '", NOW())');
tep_db_query('DELETE FROM payment_log WHERE date < DATE_SUB(NOW(), INTERVAL 30 DAY)');
try {
    if ($icepay->validate()) {
        if ($temp_data[$temp_orders_id]['orders']['processed_order_id'] > 0) {
            //Update order status
            switch ($icepay->getStatus()) {
                case Icepay_StatusCode::OPEN:
                    //do nothing
                    break;
                case Icepay_StatusCode::SUCCESS:
                    tep_db_query('UPDATE orders SET orders_status = 2 WHERE orders_id = "' . $temp_data[$temp_orders_id]['orders']['processed_order_id'] . '"');
                    Checkout::send_order_error_mail(Translate('Icepay betaling is goedgekeurd voor weborder') . ': ' . $temp_data[$temp_orders_id]['orders']['processed_order_id'], sprintf(Translate('De betaling voor weborder %s is goedgekeurd door Icepay.'), $temp_data[$temp_orders_id]['orders']['processed_order_id']));
                    break;
                case Icepay_StatusCode::ERROR:
                    //Redirect to cart
                    tep_db_query('UPDATE orders SET orders_status = 53 WHERE orders_id = "' . $temp_data[$temp_orders_id]['orders']['processed_order_id'] . '"');
                    Checkout::send_order_error_mail(Translate('Ongeldige Icepay betaling voor weborder') . ': ' . $temp_data[$temp_orders_id]['orders']['processed_order_id'], sprintf(Translate('De betaling voor weborder %s is ongeldig verklaard door Icepay.'), $temp_data[$temp_orders_id]['orders']['processed_order_id']));
                    break;
                case Icepay_StatusCode::CHARGEBACK:
                    //Redirect to cart
                    tep_db_query('UPDATE orders SET orders_status = 51 WHERE orders_id = "' . $temp_data[$temp_orders_id]['orders']['processed_order_id'] . '"');
Exemple #3
0
$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) {
    echo $e->getMessage();
}
/* Example Classes */
class Example_Order
{
    protected $status = "OPEN";
Exemple #4
0
 /**
  * Do the postback validation and finish payment
  * @return bool|\Icepay_Postback
  */
 public function doPostback()
 {
     try {
         $postback = new \Icepay_Postback();
         $postback->setMerchantID($this->merchantID)->setSecretCode($this->secretCode)->doIPCheck();
         if ($postback->validate() && $postback->getStatus() == \Icepay_StatusCode::SUCCESS) {
             return $postback;
         }
     } catch (\Exception $e) {
         \Yii::error($e->getMessage());
     }
     return false;
 }