function retrieveCallbackOS() { echo '-fnCBOS/' . (int) $_POST['status'] . '/' . $_POST['captured_amount']; $hipay = new HiPay_Tpp(); $orderState = _PS_OS_ERROR_; // Default to error; switch ((int) $_POST['status']) { // Do nothing - Just log the status and skip further processing case 101: // Created // Created case 103: // Cardholder Enrolled 3DSecure // Cardholder Enrolled 3DSecure case 104: // Cardholder Not Enrolled 3DSecure // Cardholder Not Enrolled 3DSecure case 105: // Unable to Authenticate 3DSecure // Unable to Authenticate 3DSecure case 106: // Cardholder Authenticate // Cardholder Authenticate case 107: // Authentication Attempted // Authentication Attempted case 108: // Could Not Authenticate // Could Not Authenticate case 109: // Authentication Failed // Authentication Failed case 120: // Collected // Collected case 150: // Acquirer Found // Acquirer Found case 151: // Acquirer not Found // Acquirer not Found case 161: // Risk Accepted // Risk Accepted default: $orderState = 'skip'; break; // Status _PS_OS_ERROR_ // Status _PS_OS_ERROR_ case 110: // Blocked // Blocked case 129: // Charged Back $orderState = _PS_OS_ERROR_; break; // Status HIPAY_DENIED // Status HIPAY_DENIED case 111: // Denied // Denied case 113: // Refused // Modif : passer en _PS_OS_ERROR_ puis en HIPAY_DENIED // $orderState = (Configuration::get ( 'HIPAY_DENIED' )) ? Configuration::get ( 'HIPAY_DENIED' ) : HipayClass::getConfiguration('HIPAY_DENIED'); $orderState = _PS_OS_ERROR_; break; // Status HIPAY_CHALLENGED // Status HIPAY_CHALLENGED case 112: // Authorized and Pending $orderState = Configuration::get('HIPAY_CHALLENGED') ? Configuration::get('HIPAY_CHALLENGED') : HipayClass::getConfiguration('HIPAY_CHALLENGED'); break; // Status HIPAY_PENDING // Status HIPAY_PENDING case 140: // Authentication Requested // Authentication Requested case 142: // Authorization Requested // Authorization Requested case 200: // Pending Payment $orderState = Configuration::get('HIPAY_PENDING') ? Configuration::get('HIPAY_PENDING') : HipayClass::getConfiguration('HIPAY_PENDING'); break; // Status HIPAY_EXPIRED // Status HIPAY_EXPIRED case 114: // Expired $orderState = Configuration::get('HIPAY_EXPIRED') ? Configuration::get('HIPAY_EXPIRED') : HipayClass::getConfiguration('HIPAY_EXPIRED'); break; // Status _PS_OS_CANCELED_ // Status _PS_OS_CANCELED_ case 115: // Cancelled $orderState = _PS_OS_CANCELED_; break; // Status HIPAY_AUTHORIZED // Status HIPAY_AUTHORIZED case 116: // Authorized $orderState = Configuration::get('HIPAY_AUTHORIZED') ? Configuration::get('HIPAY_AUTHORIZED') : HipayClass::getConfiguration('HIPAY_AUTHORIZED'); break; // Status HIPAY_CAPTURE_REQUESTED // Status HIPAY_CAPTURE_REQUESTED case 118: case 117: // Capture Requested //$orderState = (Configuration::get ( 'HIPAY_CAPTURE_REQUESTED' )) ? Configuration::get ( 'HIPAY_CAPTURE_REQUESTED' ) : HipayClass::getConfiguration('HIPAY_CAPTURE_REQUESTED'); $orderState = _PS_OS_PAYMENT_; if ($_POST['captured_amount'] < $_POST['authorized_amount']) { $orderState = Configuration::get('HIPAY_PARTIALLY_CAPTURED') ? Configuration::get('HIPAY_PARTIALLY_CAPTURED') : HipayClass::getConfiguration('HIPAY_PARTIALLY_CAPTURED'); } // FORCING PRIVATE MSG FOR CAPTURE HERE // STATUS 119 does not seem to be called at all, even for partially captured calls. // Check if message exists already $cart = new Cart((int) $_POST['order']->id); if ($cart->orderExists()) { $order_id = retrieveOrderId($cart->id); $order = new Order($order_id); captureOrder($order); $tag = 'HIPAY_CAPTURE '; $amount = $_POST['captured_amount']; $msgs = Message::getMessagesByOrderId($order_id, true); //true for private messages (got example from AdminOrdersController) $create_new_msg = true; if (count($msgs)) { foreach ($msgs as $msg) { $line = $msg['message']; if (startsWith($line, $tag)) { $create_new_msg = false; $to_update_msg = new Message($msg['id_message']); $to_update_msg->message = $tag . $amount; $to_update_msg->save(); break; } } } if ($create_new_msg) { // Create msg $msg = new Message(); $message = 'HIPAY_CAPTURE ' . $amount; $message = strip_tags($message, '<br>'); if (Validate::isCleanHtml($message)) { $msg->message = $message; $msg->id_order = intval((int) $order_id); $msg->private = 1; $msg->add(); } } } break; // Status HIPAY_PARTIALLY_CAPTURED // Status HIPAY_PARTIALLY_CAPTURED case 119: // Partially Captured $orderState = Configuration::get('HIPAY_PARTIALLY_CAPTURED') ? Configuration::get('HIPAY_PARTIALLY_CAPTURED') : HipayClass::getConfiguration('HIPAY_PARTIALLY_CAPTURED'); break; // Status HIPAY_REFUND_REQUESTED // Status HIPAY_REFUND_REQUESTED case 124: // Refund Requested $orderState = Configuration::get('HIPAY_REFUND_REQUESTED') ? Configuration::get('HIPAY_REFUND_REQUESTED') : HipayClass::getConfiguration('HIPAY_REFUND_REQUESTED'); break; // Status HIPAY_REFUNDED // Status HIPAY_REFUNDED case 125: // Refunded $orderState = Configuration::get('HIPAY_REFUNDED') ? Configuration::get('HIPAY_REFUNDED') : HipayClass::getConfiguration('HIPAY_REFUNDED'); break; // Status HIPAY_CHARGED BACK // Status HIPAY_CHARGED BACK case 129: // Charged back $orderState = Configuration::get('HIPAY_CHARGEDBACK') ? Configuration::get('HIPAY_CHARGEDBACK') : HipayClass::getConfiguration('HIPAY_CHARGEDBACK'); break; // Status HIPAY_CAPTURE_REFUSED // Status HIPAY_CAPTURE_REFUSED case 173: // Capture Refused $orderState = Configuration::get('HIPAY_CAPTURE_REFUSED') ? Configuration::get('HIPAY_CAPTURE_REFUSED') : HipayClass::getConfiguration('HIPAY_CAPTURE_REFUSED'); break; } return $orderState; }
if (changeStatusOrder($order_exist, $id_order, $orderState, $objOrder, $callback_arr)) { // on modifie la transaction de commande pour la référence commande captureOrder($callback_arr, $objOrder); } // si pas de commande existante, on créé la commande createOrderByHipay($order_exist, $callback_arr, $hipay, $cart, $orderState); break; // Status HIPAY_PARTIALLY_CAPTURED // Status HIPAY_PARTIALLY_CAPTURED case 119: // Partially Captured $orderState = $stt_partially; // on change de statut de la commande tous les critères sont ok if (changeStatusOrder($order_exist, $id_order, $orderState, $objOrder)) { // on modifie la transaction de commande pour la référence commande captureOrder($callback_arr, $objOrder); } // si pas de commande existante, on créé la commande createOrderByHipay($order_exist, $callback_arr, $hipay, $cart, $orderState); break; // Status HIPAY_REFUND_REQUESTED // Status HIPAY_REFUND_REQUESTED case 124: // Refund Requested $orderState = $stt_refunded_rq; // si commande existante, on modifie le statut de la commande if (changeStatusOrder($order_exist, $id_order, $orderState, $objOrder)) { $statuts = array('refund_requested' => $orderState); addMessageRefund($objOrder, $callback_arr, $hipay, $statuts); } break;