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);
     }
 }
    $object = glob(DIR_FS_CATALOG . 'includes/modules/checkout/modules/Icepay/*_module.php');
    require_once $object[0];
}
$temp_orders_id = $_POST['Reference'];
// @TODO End Of Delete
require_once 'includes/application_top.php';
$Analytics = new Analytics();
if (!is_object($Modules)) {
    //start modules class
    $Modules = new Modules();
}
$Checkout = Checkout::instance(false);
$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;
Esempio n. 3
0
 *
 */
/*  Define your ICEPAY Merchant ID and Secret code. The values below are sample values and will not work, Change them to your own merchant settings. */
define('MERCHANTID', 12345);
//<--- Change this into your own merchant ID
define('SECRETCODE', "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
//<--- 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()));
        }
Esempio n. 4
0
 public function postback()
 {
     $logger = OW::getLogger('ocsbillingicepay');
     $logger->addEntry(print_r($_REQUEST, true), 'postback.data-array');
     if (empty($_REQUEST['Reference'])) {
         $logger->addEntry("Empty reference", 'postback.reference');
         $logger->writeLog();
         exit;
     }
     require_once OW::getPluginManager()->getPlugin('ocsbillingicepay')->getClassesDir() . 'api' . DS . 'icepay_api_basic.php';
     $gwKey = OCSBILLINGICEPAY_CLASS_IcepayAdapter::GATEWAY_KEY;
     $billingService = BOL_BillingService::getInstance();
     $merchantId = $billingService->getGatewayConfigValue($gwKey, 'merchantId');
     $encryptionCode = $billingService->getGatewayConfigValue($gwKey, 'encryptionCode');
     $icepay = new Icepay_Postback();
     $icepay->setMerchantID($merchantId)->setSecretCode($encryptionCode)->doIPCheck();
     try {
         if ($icepay->validate()) {
             $hash = trim($_REQUEST['Reference']);
             $transId = trim($_REQUEST['TransactionID']);
             $sale = $billingService->getSaleByHash($hash);
             if (!$sale || !mb_strlen($transId)) {
                 $logger->addEntry("Sale not found", 'postback.sale');
                 $logger->writeLog();
                 exit;
             }
             $adapter = new OCSBILLINGICEPAY_CLASS_IcepayAdapter();
             if (!$billingService->saleDelivered($transId, $sale->gatewayId)) {
                 $sale->transactionUid = $transId;
                 if ($billingService->verifySale($adapter, $sale)) {
                     $sale = $billingService->getSaleById($sale->id);
                     $productAdapter = $billingService->getProductAdapter($sale->entityKey);
                     if ($productAdapter) {
                         $billingService->deliverSale($productAdapter, $sale);
                     }
                 }
             }
             $logger->addEntry("Validated!", 'validate-status');
         } else {
             $logger->addEntry("Unable to validate postback data", 'validate-status');
         }
     } catch (Exception $e) {
         $logger->addEntry($e->getMessage(), 'validate-exception');
     }
     $logger->writeLog();
     exit;
 }
Esempio n. 5
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;
 }