protected function AutoSubmit() { $oOrder = $this->_getOrder(); $oBilling = $oOrder->getBillingAddress(); $szHtml = ''; if ($oOrder) { try { $oPayment = new AllInOne(); $oPayment->ServiceURL = $this->_getConfigData('test_mode') ? 'http://payment-stage.allpay.com.tw/Cashier/AioCheckOut' : 'https://payment.allpay.com.tw/Cashier/AioCheckOut'; $oPayment->HashKey = $this->_getConfigData('hash_key'); $oPayment->HashIV = $this->_getConfigData('hash_iv'); $oPayment->MerchantID = $this->_getConfigData('merchant_id'); $oPayment->Send['ReturnURL'] = Mage::getUrl('alipay/processing/response'); $oPayment->Send['ClientBackURL'] = Mage::getUrl(''); $oPayment->Send['OrderResultURL'] = Mage::getUrl('alipay/processing/result'); $oPayment->Send['MerchantTradeNo'] = ($this->_getConfigData('test_mode') ? $this->_getConfigData('test_order_prefix') : '') . $oOrder->getIncrementId(); $oPayment->Send['MerchantTradeDate'] = date('Y/m/d H:i:s'); $oPayment->Send['TotalAmount'] = (int) $oOrder->getGrandTotal(); $oPayment->Send['TradeDesc'] = "AllPay_Magento_Module"; $oPayment->Send['ChoosePayment'] = PaymentMethod::Alipay; $oPayment->Send['Remark'] = ''; $oPayment->Send['ChooseSubPayment'] = PaymentMethodItem::None; $oPayment->Send['NeedExtraPaidInfo'] = ExtraPaymentInfo::No; $oPayment->Send['DeviceSource'] = DeviceType::PC; array_push($oPayment->Send['Items'], array('Name' => Mage::helper('alipay')->__('Commodity Group'), 'Price' => (int) $oOrder->getGrandTotal(), 'Currency' => Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(), 'Quantity' => 1, 'URL' => '')); $oPayment->SendExtend['Email'] = $oBilling->getEmail(); $oPayment->SendExtend['PhoneNo'] = $oBilling->getTelephone(); $oPayment->SendExtend['UserName'] = $oBilling->getName(); $szHtml = $oPayment->CheckOutString(); } catch (Exception $e) { Mage::throwException($e->getMessage()); } } return $szHtml; }
/** * @method hikashop 原生功能: 訂單確認後觸發 * @param object $order 訂單資訊 * @param array $methods 方法資訊 * @param int $method_id 方法 ID * @return boolean 執行結果 */ public function onAfterOrderConfirm(&$order, &$methods, $method_id) { if (!class_exists('AllInOne')) { require_once 'AllPay.Payment.Integration.php'; } try { # 設定服務參數 $aio = new AllInOne(); $allpay_param = $methods[$order->order_payment_id]->payment_params; $order_info = isset($order->cart) ? $order->cart : $order; if ($allpay_param->allpay_test_mode) { $service_url = 'http://payment-stage.allpay.com.tw/Cashier/AioCheckOut'; $merchant_trade_no = date('is') . $order_info->order_number; } else { $service_url = 'https://payment.allpay.com.tw/Cashier/AioCheckOut'; $merchant_trade_no = $order_info->order_number; } $aio->MerchantID = $allpay_param->allpay_merchant_id; $aio->HashKey = $allpay_param->allpay_hash_key; $aio->HashIV = $allpay_param->allpay_hash_iv; $aio->ServiceURL = $service_url; unset($allpay_param); # 設定基本參數 $aio->Send['ReturnURL'] = JURI::root() . 'plugins/hikashoppayment/allpay/response.php'; $aio->Send['ClientBackURL'] = JURI::root() . 'index.php/hikashop-menu-for-products-listing/order'; $aio->Send['MerchantTradeNo'] = $merchant_trade_no; $aio->Send['MerchantTradeDate'] = date('Y/m/d H:i:s'); # 設定訂單商品資訊 $order_total = round($order_info->full_total->prices[0]->price_value_with_tax, 0); $aio->Send['TotalAmount'] = $order_total; array_push($aio->Send['Items'], array('Name' => '網路商品一批', 'Price' => $order_total, 'Currency' => 'NTD', 'Quantity' => 1)); unset($order_info); $aio->Send['TradeDesc'] = 'Hikashop_Payment_Plugin_AllPay'; # 產生訂單 HTML Code $szHtml = $aio->CheckOutString(null); unset($aio); echo $szHtml; unset($szHtml); } catch (Exception $e) { JFactory::getApplication()->enqueueMessage('付款失敗<br />' . $e->getMessage(), 'error'); return false; } return true; }
public function redirect() { $this->load->model('checkout/order'); $this->load->model('payment/allpay'); $this->load->language('payment/allpay'); $this->model_payment_allpay->invokeExt(DIR_CATALOG . 'model/payment/'); try { $merchant_id = $this->config->get('allpay_merchant_id'); $choose_installment = 0; $AIO = new AllInOne(); $ACE = new AllpayCartExt($merchant_id); # 取得購物車資訊 $checkout_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); $order_id = $checkout_info['order_id']; # 檢查付款方式是否合法 $payment_type = $this->request->post['allpay_choose_payment']; $allpay_payment = $this->model_payment_allpay->getPaymentDesc(); if (!in_array($payment_type, $allpay_payment)) { throw new Exception($this->language->get('error_invalid_payment')); } # 設定串接allPay參數 $AIO->MerchantID = $merchant_id; $AIO->ServiceURL = $ACE->getServiceURL(URLType::CREATE_ORDER); $AIO->Send['MerchantTradeNo'] = $ACE->getMerchantTradeNo($order_id); $AIO->HashKey = $this->config->get('allpay_hash_key'); $AIO->HashIV = $this->config->get('allpay_hash_iv'); $AIO->Send['ReturnURL'] = $this->url->link('payment/allpay/response', '', 'SSL'); $AIO->Send['ClientBackURL'] = $this->url->link('common/home', '', 'SSL'); $AIO->Send['MerchantTradeDate'] = date('Y/m/d H:i:s'); $AIO->Send['TradeDesc'] = 'allpay_module_mijoshop_1_0_2'; # 小數點金額處理 $order_total = $ACE->roundAmt($checkout_info['total'], $this->config->get('allpay_round_method')); # 設定商品資訊 $AIO->Send['TotalAmount'] = $order_total; $AIO->Send['Items'] = array(); array_push($AIO->Send['Items'], array('Name' => $this->language->get('des_product_name'), 'Price' => $AIO->Send['TotalAmount'], 'Currency' => $checkout_info['currency_code'], 'Quantity' => 1, 'URL' => '')); unset($checkout_info); # 取得付款方式(與分期期數) $type_pieces = explode('_', $payment_type); $AIO->Send['ChoosePayment'] = $type_pieces[0]; if (isset($type_pieces[1])) { $choose_installment = $type_pieces[1]; } # 設定串接allPay參數 $params = array('Installment' => $type_pieces[1], 'TotalAmount' => $AIO->Send['TotalAmount'], 'ReturnURL' => $AIO->Send['ReturnURL']); $AIO->SendExtend = $ACE->setSendExt($AIO->Send['ChoosePayment'], $params); # 取得歐付寶轉導頁 $red_html = $AIO->CheckOutString(); # 清空購物車 $this->cart->clear(); # 建立訂單 $this->model_checkout_order->confirm($order_id, $this->config->get('allpay_order_status_id'), true); # 輸出歐付寶轉導頁 echo $red_html; exit; } catch (Exception $e) { $this->data['heading_title'] = $this->language->get('text_title'); $this->data['text_warning'] = $e->getMessage(); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/allpay_error.tpl')) { $this->template = $this->config->get('config_template') . '/template/payment/allpay_error.tpl'; } else { $this->template = 'default/template/payment/allpay_error.tpl'; } $this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header'); $this->response->setOutput($this->render()); } }
public function payment($id, $token) { $this->load->model('model_booking'); $booking = $this->model_booking->getBooking($id, $token, $this->input->post('password')); if (empty($booking)) { return show_404(); } if (empty($booking->card_image)) { return; } $this->load->library('user_agent'); $this->load->helper('allpay_payment'); include APPPATH . 'config/allpay_payment.php'; try { $aio = new AllInOne(); $aio->ServiceURL = $allpay_config['ServiceURL'] . 'Cashier/AioCheckOut'; $aio->HashKey = $allpay_config['HashKey']; $aio->HashIV = $allpay_config['HashIV']; $aio->MerchantID = $allpay_config['MerchantID']; $aio->Send['ReturnURL'] = site_url("event/payment_return/{$id}/{$token}"); $aio->Send['ClientBackURL'] = site_url("event/review/{$id}/{$token}"); $aio->Send['OrderResultURL'] = site_url("event/payment_return/{$id}/{$token}") . '?is_browser=true'; $aio->Send['MerchantTradeNo'] = $booking->created_at . $booking->id; $aio->Send['MerchantTradeDate'] = date('Y/m/d H:i:s'); switch ($this->input->post('method')) { case 'credit': $aio->Send['ChoosePayment'] = PaymentMethod::Credit; $fee = self::AMOUNT / 0.972 - self::AMOUNT; if ($fee < 5) { $fee = 5; } $fee = round($fee); break; case 'webatm': $aio->Send['ChoosePayment'] = PaymentMethod::WebATM; $fee = self::AMOUNT / 0.99 - self::AMOUNT; if ($fee > 30) { $fee = 30; } if ($fee < 1) { $fee = 1; } $fee = round($fee); break; case 'atm': $aio->Send['ChoosePayment'] = PaymentMethod::ATM; $fee = self::AMOUNT / 0.99 - self::AMOUNT; if ($fee > 30) { $fee = 30; } if ($fee < 1) { $fee = 1; } $fee = round($fee); break; case 'cvs': $aio->Send['ChoosePayment'] = PaymentMethod::CVS; $fee = 25; break; case 'barcode': $aio->Send['ChoosePayment'] = PaymentMethod::BARCODE; $fee = 30; break; default: return show_404(); break; } $aio->Send['TotalAmount'] = self::AMOUNT + $fee; $aio->Send['TradeDesc'] = '開源!資訊萌芽營!報名費'; $aio->Send['Remark'] = ''; $aio->Send['ChooseSubPayment'] = PaymentMethodItem::None; $aio->Send['NeedExtraPaidInfo'] = ExtraPaymentInfo::No; $aio->Send['DeviceSource'] = $this->agent->is_mobile() ? DeviceType::Mobile : DeviceType::PC; $aio->Send['Items'][] = ['Name' => '報名費', 'Price' => self::AMOUNT, 'Currency' => '元', 'Quantity' => 1, 'URL' => '']; $aio->Send['Items'][] = ['Name' => '金流手續費', 'Price' => $fee, 'Currency' => '元', 'Quantity' => 1, 'URL' => '']; $aio->SendExtend['PaymentInfoURL'] = site_url("event/payment_return/{$id}/{$token}"); $this->output->set_output($aio->CheckOutString()); } catch (Exception $e) { } }