コード例 #1
0
 function plgVmOnPaymentResponseReceived(&$html)
 {
     // the payment itself should send the parameter needed.
     $virtuemart_paymentmethod_id = JRequest::getInt('pm', 0);
     $vendorId = 0;
     if (!($method = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
         return null;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($method->payment_element)) {
         return false;
     }
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $payment_data = JRequest::get('post');
     $payment_name = $this->renderPluginName($method);
     $html = $this->_getPaymentResponseHtml($payment_data, $payment_name);
     if (!empty($payment_data)) {
         vmdebug('plgVmOnPaymentResponseReceived', $payment_data);
         $order_number = $payment_data['invoice'];
         $return_context = $payment_data['custom'];
         if (!class_exists('VirtueMartModelOrders')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php';
         }
         $virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number);
         $payment_name = $this->renderPluginName($method);
         $html = $this->_getPaymentResponseHtml($payment_data, $payment_name);
         if ($virtuemart_order_id) {
             // send the email ONLY if payment has been accepted
             if (!class_exists('VirtueMartModelOrders')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php';
             }
             $modelOrder = new VirtueMartModelOrders();
             $orderitems = $modelOrder->getOrder($virtuemart_order_id);
             $nb_history = count($orderitems['history']);
             //vmdebug('history', $orderitems);
             if (!class_exists('shopFunctionsF')) {
                 require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
             }
             if ($nb_history == 1) {
                 if (!class_exists('shopFunctionsF')) {
                     require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
                 }
                 shopFunctionsF::sentOrderConfirmedEmail($orderitems);
                 $this->logInfo('plgVmOnPaymentResponseReceived, sentOrderConfirmedEmail ' . $order_number, 'message');
                 $order['order_status'] = $orderitems['items'][$nb_history - 1]->order_status;
                 $order['virtuemart_order_id'] = $virtuemart_order_id;
                 $order['customer_notified'] = 0;
                 $order['comments'] = JText::sprintf('VMPAYMENT_PAYPAL_EMAIL_SENT');
                 $modelOrder->updateStatusForOneOrder($virtuemart_order_id, $order, true);
             }
         }
     }
     //We delete the old stuff
     // get the correct cart / session
     $cart = VirtueMartCart::getCart();
     $cart->emptyCart();
     return true;
 }