Пример #1
0
 public function paypal_notify()
 {
     $crypt = Loader::helper('encryption');
     $paypal = new \Concrete\Package\PaypalExpressVividStore\Src\VividStore\Payment\Methods\PaypalExpress\Helpers\PaypalExpressHelper();
     if (Config::get('vividstore.paypalExpressMode') == 'test') {
         $type = 'sandbox';
     } else {
         $type = 'live';
     }
     $conf = ['type' => $type];
     $paypal->setConfig($conf);
     if ($paypal->validateIPN()) {
         if (Config::get('vividstore.paypalExpressTransactionType') == "Authorization") {
             $status_message = strtolower($_REQUEST['auth_status']);
         } else {
             $status_message = strtolower($_REQUEST['payment_status']);
         }
         if ($status_message == 'completed') {
             $status = OrderStatus::getByHandle('complete');
         } elseif ($status_message == 'denied' || $status_message == 'reversed') {
             $status = OrderStatus::getByHandle('complete');
         }
         $crypt = Loader::helper('encryption');
         $invoice = $crypt->decrypt($_REQUEST['invoice']);
         $oID = Invoice::getOrderID($invoice);
         $order = Order::getById($oID);
         if ($order) {
             $order->updateStatus($status);
         }
     }
 }
Пример #2
0
 private static function recordStatusChange(Order $order, $statusHandle)
 {
     $db = Database::get();
     $newOrderStatus = OrderStatus::getByHandle($statusHandle);
     $user = new user();
     $statusHistorySql = "INSERT INTO " . self::$table . " SET oID=?, oshStatus=?, uID=?";
     $statusHistoryValues = array($order->getOrderID(), $newOrderStatus->getHandle(), $user->uID);
     $db->Execute($statusHistorySql, $statusHistoryValues);
     $updateOrderSql = "UPDATE VividStoreOrders SET oStatus = ? WHERE oID = ?";
     $updateOrderValues = array($newOrderStatus->getHandle(), $order->getOrderID());
     $db->Execute($updateOrderSql, $updateOrderValues);
     return $newOrderStatus->getHandle();
 }