diff --git a/webht/third_party/pay/controllers/iPayLinksService.php b/webht/third_party/pay/controllers/iPayLinksService.php index d4973ffc..bf8eb5ec 100644 --- a/webht/third_party/pay/controllers/iPayLinksService.php +++ b/webht/third_party/pay/controllers/iPayLinksService.php @@ -18,12 +18,13 @@ class IPayLinksService extends CI_Controller public function __construct(){ parent::__construct(); $this->config->load('iPayLinks'); + // $this->config->load('dev_iPayLinks'); // test $this->load->model('IPayLinks_model'); $this->load->model('Note_model'); - $this->gatewayUrl = $this->config->item('gatewayUrl'); + $this->gatewayUrl = $this->config->item('gatewayUrl'); - $this->queryUrl = $this->config->item('queryUrl'); + $this->queryUrl = $this->config->item('queryUrl'); $this->return_url = $this->config->item('returnUrl'); $this->notify_url = $this->config->item('noticeUrl'); @@ -89,7 +90,7 @@ class IPayLinksService extends CI_Controller public function get_url_string() { - $param = $this->input->get_post('param'); + $param = ($this->input->get_post('param')); return base64_decode($param); } @@ -191,6 +192,12 @@ class IPayLinksService extends CI_Controller $this->card_info_arr['cardExpirationYear'] = substr(trim($this->input->get_post('cardExpirationYear')),2,2); $this->card_info_arr['securityCode'] = trim(str_replace(" ","",$this->input->get_post('securityCode'))); $this->card_info_arr['cardHolderEmail'] = trim($this->input->get_post('cardHolderEmail')); + // 记录付款人联系信息 + $card_holder_arr = array( + "n" => substr($this->card_info_arr['cardHolderFirstName']." ".$this->card_info_arr['cardHolderLastName'],0,50), + "e" => substr($this->card_info_arr['cardHolderEmail'],0,50) + ); + $this->card_info_arr['remark'] = json_encode($card_holder_arr); } public function order_pay() @@ -209,8 +216,11 @@ class IPayLinksService extends CI_Controller return; } + // test + // $this->ipaylinks_notice($resp); + // 返回结果 - $ret = $this->result_2_return_url($respWellFormed->data->resultCode); + $ret = $this->result_2_return_url($respWellFormed->data->resultCode,$respWellFormed->data->resultMsg); $this->order_done($ret); return; @@ -384,8 +394,9 @@ class IPayLinksService extends CI_Controller mb_strtoupper($item->IPL_currencyCode), $item->IPL_completeTime, $item->IPL_completeTime, - $item->IPL_acquiringTime, '', - NULL, + $item->IPL_acquiringTime, + $item->IPL_payerName, + $item->IPL_payerEmail, $item->IPL_dealId, $ht_memo ); @@ -402,8 +413,9 @@ class IPayLinksService extends CI_Controller mb_strtoupper($item->IPL_currencyCode), $item->IPL_completeTime, $item->IPL_completeTime, - $item->IPL_acquiringTime, '', - NULL, + $item->IPL_acquiringTime, + $item->IPL_payerName, + $item->IPL_payerEmail, $item->IPL_dealId, $ht_memo ); @@ -438,7 +450,10 @@ class IPayLinksService extends CI_Controller $this->Note_model->update_send($item->IPL_dealId, 'send'); $int++; } - echo "done. recorde count:".$int; + // 批量结果 + if (empty($pn_txn_id)) { + echo "done. recorde count:".$int; + } return; } @@ -549,8 +564,14 @@ class IPayLinksService extends CI_Controller echo "200"; return; } + // dealId $dealId = trim($asyns_resp->data->dealId) ; $tmp_deal = $dealId ? $dealId : $this->create_guid(); + // payer info + $payer_info = json_decode($asyns_resp->data->remark); + $payer_name = $payer_info->n; + $payer_email = $payer_info->e; + bcscale(2); // 支付成功 // 查询支付结果;入库处理 @@ -568,6 +589,8 @@ class IPayLinksService extends CI_Controller ,strval("pay") ,strval($asyns_resp->data->resultCode) ,strval($asyns_resp->data->resultMsg) + ,strval($payer_name) + ,strval($payer_email) ); $query = $this->query_pay_result($asyns_resp->data); } @@ -754,11 +777,17 @@ class IPayLinksService extends CI_Controller * @param [type] $code [description] * @return [type] [description] */ - protected function result_2_return_url($code) + protected function result_2_return_url($code,$msg) { $ret['code'] = 0; $ret['msg'] = ""; $ret['error_code'] = $code ? $code : "Unknow"; + $ret["error_code"] .= "."; + + $tmp_msg = $msg ? strstr($msg,":",true)."." : false; // result msg的英文部分 + $code_msg = $tmp_msg ? $tmp_msg : "Please contact your advisor."; + $ret['error_code'] .= $code_msg; + switch ($code) { case '0000': $ret['code'] = 0; @@ -767,7 +796,7 @@ class IPayLinksService extends CI_Controller default: $ret['code'] = $code; - $ret['msg'] = "Payment Failed"; + $ret['msg'] = "Payment Failed."; break; } return $ret; diff --git a/webht/third_party/pay/models/note_model.php b/webht/third_party/pay/models/note_model.php index bc71c5d8..efe06ff0 100644 --- a/webht/third_party/pay/models/note_model.php +++ b/webht/third_party/pay/models/note_model.php @@ -89,15 +89,15 @@ class Note_model extends CI_Model { * @author LYT * @date 2017-08-29 */ - public function save_ipl($IPL_dealId,$IPL_orderId,$IPL_currencyCode,$IPL_orderAmount,$IPL_payAmount,$IPL_stateCode,$IPL_acquiringTime,$IPL_completeTime,$IPL_memo,$IPL_payType,$IPL_resultCode,$IPL_resultMsg) { + public function save_ipl($IPL_dealId,$IPL_orderId,$IPL_currencyCode,$IPL_orderAmount,$IPL_payAmount,$IPL_stateCode,$IPL_acquiringTime,$IPL_completeTime,$IPL_memo,$IPL_payType,$IPL_resultCode=null,$IPL_resultMsg=null,$IPL_payerName=null,$IPL_payerEmail=NULL) { $sql = " INSERT INTO IPayLinksLog ( - IPL_dealId,IPL_orderId,IPL_currencyCode,IPL_orderAmount,IPL_payAmount,IPL_stateCode,IPL_acquiringTime,IPL_completeTime,IPL_memo,IPL_sent,IPL_noticeTime,IPL_payType,IPL_resultCode,IPL_resultMsg + IPL_dealId,IPL_orderId,IPL_currencyCode,IPL_orderAmount,IPL_payAmount,IPL_stateCode,IPL_acquiringTime,IPL_completeTime,IPL_memo,IPL_sent,IPL_noticeTime,IPL_payType,IPL_resultCode,IPL_resultMsg,IPL_payerName,IPL_payerEmail ) VALUES ( - ?,?,?,?,?,?,?,?,?,'unsend', GETDATE(),?,?,N? + ?,?,?,?,?,?,?,?,?,'unsend', GETDATE(),?,?,N?,N?,N? ) "; $query = $this->INFO->query($sql, @@ -113,6 +113,8 @@ class Note_model extends CI_Model { ,$IPL_payType ,$IPL_resultCode ,$IPL_resultMsg + ,$IPL_payerName + ,$IPL_payerEmail )); $insertid = $this->INFO->last_id('IPayLinksLog'); return $query; @@ -136,6 +138,8 @@ class Note_model extends CI_Model { ,pn.IPL_sent ,pn.IPL_payType ,pn.IPL_noticeTime + ,pn.IPL_payerName + ,pn.IPL_payerEmail FROM IPayLinksLog pn WHERE 1=1 ";