Пример #1
0
 public function notifyAction()
 {
     $data = array();
     Mage::log("China pay callback");
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         $method = 'post';
     } else {
         if ($this->getRequest()->isGet()) {
             $data = $this->getRequest()->getQuery();
             $method = 'get';
         } else {
             return;
         }
     }
     $chinapay = Mage::getModel('chinapay/payment');
     Mage::log($data);
     $dirfds42 = dirname(__FILE__);
     include_once $dirfds42 . "/netpayclient.class.php";
     $netpay = new Chinapay();
     $merid = $netpay->buildKey("PgPubk.key");
     if (!$merid) {
     }
     $chkvalue = $data['ChkValue'];
     $plain = "";
     //verify($plain, $checkvalue);
     $orderId = $data['OrdId'];
     if ($orderId) {
         $order = Mage::getModel('sales/order');
         $order->loadByIncrementId($orderId);
         $order->setStatus("processing");
         $order->addStatusToHistory("processing", Mage::helper('chinapay')->__('Payment Gateway Nodify'));
         try {
             $order->sendNewOrderEmail();
             $order->save();
         } catch (Exception $e) {
             Mage::log("Set Order Status: Processing Error");
         }
     }
     Mage::log("Set Order Status: Processing");
     Mage::log("Order Status:" . $order->getStatus());
     echo "eduok";
 }
Пример #2
0
 /**
  *  Return Standard Checkout Form Fields for request to Chinapay
  *
  *  @return	  array Array of hidden form fields
  */
 public function getStandardCheckoutFormFields()
 {
     $session = Mage::getSingleton('checkout/session');
     $customerSession = Mage::getSingleton('customer/session');
     $dirfds42 = dirname(__FILE__);
     include_once $dirfds42 . "/netpayclient.class.php";
     $netpay = new Chinapay();
     $merid = $netpay->buildKey("MerPrK.key");
     if (!$merid) {
         //echo "import error;";
     }
     $order = $this->getOrder();
     if (!$order instanceof Mage_Sales_Model_Order) {
         Mage::throwException($this->_getHelper()->__('Cannot retrieve order object'));
     }
     //convert to CNY
     //$currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
     //$converted_final_price = Mage::helper('directory')->currencyConvert($order->getBaseGrandTotal(), $currency_code, 'CNY');
     //if($converted_final_price){
     //	$converted_final_price=$converted_final_price;
     //}else{
     //	$converted_final_price=$order->getBaseGrandTotal();
     //}
     $parameter = array('MerId' => $merid, 'OrdId' => $order->getRealOrderId(), 'OrdAmt' => $order->getBaseGrandTotal() * 100, 'CuryId' => '156', 'Version' => '20100401', 'BgRetUrl' => $this->getNotifyURL(), 'PageRetUrl' => $this->getSuccessURL(), 'Param1' => $customerSession->getCustomer()->getEmail(), 'Param2' => $customerSession->getCustomer()->getId(), 'Param3' => $order->getQuoteId(), 'Param4' => $order->getId(), 'ShareType' => '0001', 'ShareData' => $this->getConfigData('branch_id') . "^" . $order->getBaseGrandTotal() * 100, 'ChkValue' => 'CHKVALUE');
     $plain = "";
     foreach ($parameter as $key => $value) {
         if ($key != "ChkValue") {
             $plain .= $value;
         }
     }
     $base_64_string = base64_encode($plain);
     $chkvalue = $netpay->sign($base_64_string);
     //echo $chkvalue;
     $parameter['ChkValue'] = $chkvalue;
     Mage::log("Send Data to Chinapay");
     Mage::log($parameter);
     return $parameter;
 }