Example #1
0
 private function _dealerAction($action, $param, $orderId)
 {
     $order = new Order($orderId);
     $webService = new BuysterWebService();
     $reference = BuysterOperation::getReferenceId($order->id_cart);
     $price = $order->total_paid;
     if ($action == "DUPLICATE") {
         $parametre = 'fromTransactionReference=' . $reference . ';';
         $result = $webService->operation($action, $param, $price, $parametre);
     } else {
         if ($action == "VALIDATE") {
             $parametre = 'operationCaptureNewDelay=' . $param . ';';
             $result = $webService->operation($action, $reference, $price, $parametre);
         } else {
             $parametre = NULL;
             $result = $webService->operation($action, $reference, $price, $parametre);
         }
     }
     if ($result['responseCode'] == "00") {
         $history = new OrderHistory();
         $history->id_order = (int) $orderId;
         if ($action == "DUPLICATE") {
             $operation = BuysterOperation::getOperationId($order->id_cart);
             if ($operation == 'paymentValidation') {
                 $history->changeIdOrderState((int) Configuration::get('BUYSTER_PAYMENT_STATE_VALIDATION'), (int) $orderId);
             } else {
                 $history->changeIdOrderState((int) Configuration::get('BUYSTER_PAYMENT_STATE'), (int) $orderId);
             }
             BuysterOperation::setReferenceReference($param, $reference);
             $reference = $param;
         }
         if ($action == "VALIDATE") {
             $history->changeIdOrderState((int) Configuration::get('PS_OS_PAYMENT'), (int) $orderId);
         }
         if ($action == "REFUND") {
             $history->changeIdOrderState((int) Configuration::get('PS_OS_REFUND'), (int) $orderId);
         }
         if ($action == "CANCEL") {
             $history->changeIdOrderState((int) Configuration::get('PS_OS_CANCELED'), (int) $orderId);
         }
         $history->addWithemail();
     }
     $return = '';
     if ($result['responseCode'] == "99") {
         $return = '<span style="color:red">Probl&egrave;me technique au niveau du serveur Buyster</span><br/>';
     }
     if ($result['responseCode'] == "00") {
         $return .= '<span style="color:green">L\'&eacute;tat de votre commande a &eacute;t&eacute; modifi&eacute;.</span><br/>';
     } else {
         if ($result['responseCode'] == "24") {
             $return = '<span style="color:red">Op&eacuteration impossible. L\'op&eacuteration que vous souhaitez r&eacute;aliser n\'est pas compatible avec l\'&eacute;tat de la transaction.</span><br/>';
         } else {
             $return .= $result['responseDescription'] . '<br/>';
         }
     }
     return $return;
 }