case ‘sir’:
$donor_title=’個人’;
break;
case ‘company’:
$donor_title=’公司或團體’;
break;
}
//$need_receipt = htmlspecialchars($_POST[‘need_receipt’]);
//$need_receipt = str_replace(“‘”,”,$wpdb->prepare( “%d”, $need_receipt ));
switch ($_POST[‘donor_country’]) {
case ‘l’:
$donor_country=’本國籍’;
break;
case ‘f’:
$donor_country=’外國籍’;
break;
}
switch ($_POST[‘donor_gender’]) {
case ‘1’:
$donor_gender=’男’;
break;
case ‘0’:
$donor_gender=’女’;
break;
}
$donor_county = htmlspecialchars(strtoupper($_POST[‘county’]));
$donor_county = str_replace(“‘”,”,$wpdb->prepare( “%s”, $donor_county ));
$donor_district = htmlspecialchars(strtoupper($_POST[‘district’]));
$donor_district = str_replace(“‘”,”,$wpdb->prepare( “%s”, $donor_district ));
if($donor_county==’新竹市’) {$donor_district=”;}
$donor_zipcode= htmlspecialchars(strtoupper($_POST[‘zipcode’]));
$donor_zipcode= str_replace(“‘”,”,$wpdb->prepare( “%d”, $donor_zipcode));
if(!$donor_zipcode) $donor_zipcode = ”;
$donor_pid = htmlspecialchars(strtoupper($_POST[‘donor_pid’]));
$donor_pid = str_replace(“‘”,”,$wpdb->prepare( “%s”, $donor_pid ));
$donor_address = htmlspecialchars($_POST[‘address’]);
$donor_address = str_replace(“‘”,”,$wpdb->prepare( “%s”, $donor_address ));
$donor_address = $donor_zipcode.’ ‘.$donor_county.$donor_district.$donor_address;
//$donor_birth = htmlspecialchars($_POST[‘birth’]);
//$donor_birth = str_replace(“‘”,”,$wpdb->prepare( “%s”, $donor_birth ));
$donor_email = htmlspecialchars($_POST[’email’]);
$donor_email = str_replace(“‘”,”,$wpdb->prepare( “%s”, $donor_email ));
$donor_tel_m = htmlspecialchars($_POST[‘tel_m’]);
$donor_tel_m = str_replace(“‘”,”,$wpdb->prepare( “%s”, $donor_tel_m ));
//$donor_tel_h = htmlspecialchars($_POST[‘tel_h’]);
//$donor_tel_h = str_replace(“‘”,”,$wpdb->prepare( “%s”, $donor_tel_h ));
//$donor_tel_o = htmlspecialchars($_POST[‘tel_o’]);
//$donor_tel_o = str_replace(“‘”,”,$wpdb->prepare( “%s”, $donor_tel_o ));
try
{
$oPayment = new ECPay_AllInOne();
$oPayment->Send = $data;
unset($oPayment->Send[‘PeriodAmount’],$oPayment->Send[‘PeriodType’],$oPayment->Send[‘Frequency’] ,$oPayment->Send[‘ExecTimes’]);
$oPayment->SendExtend[‘PeriodAmount’] = $data[‘PeriodAmount’] ;
$oPayment->SendExtend[‘PeriodType’] = $data[‘PeriodType’] ;
$oPayment->SendExtend[‘Frequency’] = $data[‘Frequency’] ;
$oPayment->SendExtend[‘ExecTimes’] = $data[‘ExecTimes’] ;
$oPayment->Send[‘Remark’] = $oPayment->Send[‘TradeDesc’];
$oPayment->Send[‘ClientBackURL’] = ‘http://’.$_SERVER[‘HTTP_HOST’].$_SERVER[‘REQUEST_URI’];
/* 服務參數 */
if($current_fix_page==’donate_test’) {
//$oPayment->ServiceURL =”https://payment-stage.allpay.com.tw/Cashier/AioCheckOut “;
$oPayment->ServiceURL =”https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V2”;//綠界測試環境
$oPayment->HashKey = “5294y06JbISpM5x9”;//這是測試帳號專用的不用改它
$oPayment->HashIV = “v77hoKGq4kWxNNIS”;//這是測試帳號專用的不用改它
$oPayment->MerchantID = “2000132”;//這是測試帳號專用的不用改它
$oPayment->Send[‘ReturnURL’] = “https://www.aaot.tw/getDonatePaymentReturn_test/”;
$oPayment->Send[‘PeriodReturnURL’] = ‘https://www.aaot.tw/getperioddonatepaymentreturn_test’;
$oPayment->SendExtend[‘PeriodReturnURL’] = ‘https://www.aaot.tw/getperioddonatepaymentreturn_test’;
$mail_title_prefix = ‘(測試頁面)’;
}
else {
//$oPayment->ServiceURL =”https://payment.allPay.com.tw/Cashier/AioCheckOut/V2″;
$oPayment->ServiceURL =”https://payment.ecpay.com.tw/Cashier/AioCheckOut/V2″;//綠界正式環境
$oPayment->HashKey = “b5kgRWuZ8VcKyMxm”;
$oPayment->HashIV = “dTEjn2GgbAMrg9tu”;
$oPayment->MerchantID = “1054642”;
$oPayment->Send[‘ReturnURL’] = “https://www.aaot.tw/getDonatePaymentReturn/”;
$oPayment->Send[‘PeriodReturnURL’] = ‘https://www.aaot.tw/getperioddonatepaymentreturn/’;
$oPayment->SendExtend[‘PeriodReturnURL’] = ‘https://www.aaot.tw/getperioddonatepaymentreturn/’;
}
$time=time();
/* 基本參數 */
$oPayment->Send[‘PaymentType’] = ‘aio’;
//$oPayment->Send[‘MerchantTradeNo’] = $time;//這邊是店家端所產生的訂單編號
$oPayment->Send[‘MerchantTradeNo’] = $data[‘MerchantTradeNo’];
$oPayment->Send[‘MerchantTradeDate’] = date(“Y/m/d H:i:s”);
//$oPayment->Send[‘TotalAmount’] = “1000”;//付款總金額
//$oPayment->Send[‘TradeDesc’] = “年終慶大特賣”;//交易敘述
//$oPayment->Send[‘ChoosePayment’] = PaymentMethod::ALL;//付款方式 這邊是開啟所有付款方式讓消費者自行選擇
//$oPayment->Send[‘ReturnURL’] = “http://192.168.1.1/return.php”;//請填入你主機要接受訂單付款後狀態 回傳的程式名稱 記住 該網址需能對外
//$oPayment->Send[‘IgnorePayment’] =”Alipay”;//把不的付款方式取消掉
//$oPayment->Send[‘DeviceSource’] =”M”;//參數M表示使用行動版的頁面 不設定此參數 預設就是電腦版顯示
//$oPayment->SendExtend[‘PaymentInfoURL’]=”http://192.168.1.1/payment_info.php”;//接受訂單狀態 回傳程式名稱 可在此程式內將付款方式寫入你的訂單中 payment_info.php 與 return.php 程式內容一樣
// 加入選購商品資料。
foreach($data[‘Items’] as $k=>$v) {
array_push($oPayment->Send[‘Items’], array(‘Name’ => $v[‘Name’], ‘Price’ => (int)($v[‘Price’]), ‘Currency’ => ‘元’, ‘Quantity’ => (int) ($v[‘Quantity’]), ‘URL’ => $v[‘URL’]));
}
/* 產生產生訂單 Html Code 的方法 */
//$szHtml = $oPayment->CheckOutString();
if($data[‘PeriodType’]) {
$donate_type_str = “定期捐款”;
$donate_exec_times = $data[‘ExecTimes’].’次’;
} else {
$donate_type_str = “單筆捐款”;
$oPayment->Send[‘PeriodReturnURL’] = null;
$oPayment->SendExtend[‘PeriodReturnURL’] = null;
unset($oPayment->Send[‘PeriodReturnURL’], $oPayment->SendExtend[‘PeriodReturnURL’]);
}
$mail= new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = “ssl”;
$mail->Host = “smtp.gmail.com”;
$mail->Port = 465;
$mail->CharSet = “UTF-8″;
$mail->Username = SMTP_USER_EMAIL;
$mail->Password = SMTP_USER_PASSWORD;
$mail->From = SMTP_USER_EMAIL;
$mail->FromName = ‘社團法人臺中市線上家教促進協會’;
$mail_title=$mail_title_prefix.’協會捐款編號【’.$data[‘MerchantTradeNo’].’】姓名【’.$donor_name.’】/【’.$donor_title.’】正準備前往綠界金流輸入卡號’;
$mail_tile = mb_encode_mimeheader($mail_tile,’UTF-8′);
$send_html = ”;
foreach($oPayment->Send as $pk=>$pv) {
if(is_array($pv)) {
$send_html.= $pk.’=’.serialize($pv).”
\r\n”;
}
else {
$send_html.= $pk.’=’.$pv.”
\r\n”;
}
}
foreach($oPayment->SendExtend as $pk=>$pv) {
if(is_array($pv)) {
$send_html.= $pk.’=’.serialize($pv).”
\r\n”;
}
else {
$send_html.= $pk.’=’.$pv.”
\r\n”;
}
}
$mail_content = ‘
本次傳送給金流系統的捐款參數如下:
‘.$send_html.’
‘;
$mail->Subject = $mail_title;
$mail->Body = $mail_content;
$mail->IsHTML(true);
if($mail_title_prefix) {
$mail->AddAddress(“service@aaot.tw”, “社團法人臺中市線上家教促進協會”);
}
else {
$mail->AddAddress(“service@aaot.tw”, “社團法人臺中市線上家教促進協會”);
$mail->AddAddress(“neo@aaot.tw”, “Neo”);
}
$mail->Send();
/* 產生訂單 */
$oPayment->CheckOut();
}
catch (Exception $e)
{ // 例外錯誤處理。
//throw $e;
return false;
}
return $szHtml;
}
}
$tradeRandcode = sprintf(“%03d”, rand(1,999));
$donateCreditPaymentData[‘ChoosePayment’] = ‘Credit’;
$donateCreditPaymentData[‘MerchantTradeNo’] = time().$tradeRandcode;
$donateCreditPaymentData[‘NeedExtraPaidInfo’] = ‘N’;
$donateCreditPaymentData[‘ReturnURL’] = ‘https://www.aaot.tw/’;
switch($creditTypeValue) {
case ‘single’:
if($singleAmountValue > 0 || $singleAmountValue ==-1)
{
/*
if(!in_array($singleAmountValue,array(500,1000,2000))) {
$submitCheckErrors[] = ‘偵測到非預期選項,基於安全考量,請重新操作’;
}
*/
$donateCreditPaymentData[‘TradeDesc’] = ‘信用卡單筆捐款’;
$donateCreditPaymentData[‘TotalAmount’] = $singleAmountValue;
$donateCreditPaymentData[‘Redeem’] = ‘Y’;
$currentOrderItem[‘Name’] = $donateCreditPaymentData[‘TradeDesc’];
$currentOrderItem[‘Price’] = $donateCreditPaymentData[‘TotalAmount’];
if($singleAmountValue ==-1 && $customSingleAmountTextValue >0 )
{
$donateCreditPaymentData[‘TotalAmount’] = $customSingleAmountTextValue ;
}
else if($singleAmountValue ==-1 && $customSingleAmountTextValue <=0 ) { $submitCheckErrors[] = ‘請輸入信用卡單筆捐款金額’; } } else { $submitCheckErrors[] = ‘請選擇信用卡單筆捐款金額’; } break; case ‘period’: if($PeriodAmountValue >0 || $PeriodAmountValue==-1 || $ExecTimesValue==-1)
{
/*
if(!in_array($PeriodAmountValue,array(200,500))) {
$submitCheckErrors[] = ‘偵測到非預期選項,基於安全考量,請重新操作’;
}
*/
$donateCreditPaymentData[‘TotalAmount’] = $donateCreditPaymentData[‘PeriodAmount’] = $PeriodAmountValue;
$donateCreditPaymentData[‘PeriodType’] = ‘M’;
$donateCreditPaymentData[‘Frequency’] = 1;
//if($ExecTimesValue==-1) {$ExecTimesValue = $ExecTimesTextValue;}
if($PeriodAmountValue==-1 && $customPeriodAmountTextValue>0 )
{
$donateCreditPaymentData[‘TotalAmount’] = $donateCreditPaymentData[‘PeriodAmount’] = $customPeriodAmountTextValue;
}
else if($PeriodAmountValue==-1 && $customPeriodAmountTextValue<=0 ) { $submitCheckErrors[] = ‘請輸入信用卡每月捐款金額’; } if($ExecTimesValue > 0 ) {
$donateCreditPaymentData[‘ExecTimes’] = (int)$ExecTimesValue;
} else if($ExecTimesValue==-1 && $ExecTimesTextValue > 0){
$donateCreditPaymentData[‘ExecTimes’] = (int)$ExecTimesTextValue ;
} else if($ExecTimesValue==-1 && ($ExecTimesTextValue>99 || $ExecTimesTextValue<=0)) { $submitCheckErrors[] = ‘請輸入小於99且大於1的定期捐款持續期數’; } else if($ExecTimesValue==-1) { $submitCheckErrors[] = ‘請輸入信用卡定期捐款持續期數’; } else { $submitCheckErrors[] = ‘請選擇信用卡定期捐款持續期數’; } } else { $submitCheckErrors[] = ‘請選擇信用卡定期捐款金額’; } /* if($donateCreditPaymentData[‘ExecTimes’]>99 || $donateCreditPaymentData[‘ExecTimes’]<=0 ) { $submitCheckErrors[] = ‘請輸入小於99且大於1的定期捐款持續期數’; } else if($donateCreditPaymentData[‘ExecTimes’] > 0){
$donateCreditPaymentData[‘TradeDesc’] = ‘信用卡’.$donateCreditPaymentData[‘ExecTimes’].’個月定期定額捐款’;
}
*/
$donateCreditPaymentData[‘TradeDesc’] = ‘信用卡’.$donateCreditPaymentData[‘ExecTimes’].’個月定期定額捐款’;
break;
}
if(!$submitCheckErrors) {
$currentOrderItem[‘Name’] = $donateCreditPaymentData[‘TradeDesc’];
$currentOrderItem[‘Price’] = $donateCreditPaymentData[‘TotalAmount’];
$currentOrderItem[‘Quantity’] = 1;
$donateCreditPaymentData[‘Items’][]= $currentOrderItem;
$paymentSendRs = donateCreditPaymentProc($donateCreditPaymentData);
if($paymentSendRs===false) {
$submitCheckErrors[] = “傳送失敗,請檢査選擇項目或通知系統人員。”;
}
}
}
else if($_POST[‘creditDonateSubmit’])
{
$submitCheckErrors[] = ‘請選擇信用卡捐款方式’;
}
$donate_page_content = file_get_contents(‘http://’.$_SERVER[‘HTTP_HOST’].’/donate_page_content/’);
$payment_content = ‘
‘;
$donate_page_content = str_replace(‘‘,$payment_content,
$donate_page_content);
$donate_page_content = str_replace(‘捐款專區靜態區塊(非程式人員請在此頁面修改內容_請勿更改此頁面標題)’,’捐款專區’,$donate_page_content);
echo $donate_page_content ;
exit;