@ -18,12 +18,13 @@ class IPayLinksService extends CI_Controller
public function __construct(){
public function __construct(){
parent::__construct();
parent::__construct();
$this->config->load('iPayLinks');
$this->config->load('iPayLinks');
// $this->config->load('dev_iPayLinks'); // test
$this->load->model('IPayLinks_model');
$this->load->model('IPayLinks_model');
$this->load->model('Note_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->return_url = $this->config->item('returnUrl');
$this->notify_url = $this->config->item('noticeUrl');
$this->notify_url = $this->config->item('noticeUrl');
@ -89,7 +90,7 @@ class IPayLinksService extends CI_Controller
public function get_url_string()
public function get_url_string()
{
{
$param = $this->input->get_post('param');
$param = ( $this->input->get_post('param') );
return base64_decode($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['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['securityCode'] = trim(str_replace(" ","",$this->input->get_post('securityCode')));
$this->card_info_arr['cardHolderEmail'] = trim($this->input->get_post('cardHolderEmail'));
$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()
public function order_pay()
@ -209,8 +216,11 @@ class IPayLinksService extends CI_Controller
return;
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);
$this->order_done($ret);
return;
return;
@ -384,8 +394,9 @@ class IPayLinksService extends CI_Controller
mb_strtoupper($item->IPL_currencyCode),
mb_strtoupper($item->IPL_currencyCode),
$item->IPL_completeTime,
$item->IPL_completeTime,
$item->IPL_completeTime,
$item->IPL_completeTime,
$item->IPL_acquiringTime, '',
$item->IPL_acquiringTime,
NULL,
$item->IPL_payerName,
$item->IPL_payerEmail,
$item->IPL_dealId,
$item->IPL_dealId,
$ht_memo
$ht_memo
);
);
@ -402,8 +413,9 @@ class IPayLinksService extends CI_Controller
mb_strtoupper($item->IPL_currencyCode),
mb_strtoupper($item->IPL_currencyCode),
$item->IPL_completeTime,
$item->IPL_completeTime,
$item->IPL_completeTime,
$item->IPL_completeTime,
$item->IPL_acquiringTime, '',
$item->IPL_acquiringTime,
NULL,
$item->IPL_payerName,
$item->IPL_payerEmail,
$item->IPL_dealId,
$item->IPL_dealId,
$ht_memo
$ht_memo
);
);
@ -438,7 +450,10 @@ class IPayLinksService extends CI_Controller
$this->Note_model->update_send($item->IPL_dealId, 'send');
$this->Note_model->update_send($item->IPL_dealId, 'send');
$int++;
$int++;
}
}
echo "done. recorde count:".$int;
// 批量结果
if (empty($pn_txn_id)) {
echo "done. recorde count:".$int;
}
return;
return;
}
}
@ -549,8 +564,14 @@ class IPayLinksService extends CI_Controller
echo "200";
echo "200";
return;
return;
}
}
// dealId
$dealId = trim($asyns_resp->data->dealId) ;
$dealId = trim($asyns_resp->data->dealId) ;
$tmp_deal = $dealId ? $dealId : $this->create_guid();
$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);
bcscale(2);
// 支付成功
// 支付成功
// 查询支付结果;入库处理
// 查询支付结果;入库处理
@ -568,6 +589,8 @@ class IPayLinksService extends CI_Controller
,strval("pay")
,strval("pay")
,strval($asyns_resp->data->resultCode)
,strval($asyns_resp->data->resultCode)
,strval($asyns_resp->data->resultMsg)
,strval($asyns_resp->data->resultMsg)
,strval($payer_name)
,strval($payer_email)
);
);
$query = $this->query_pay_result($asyns_resp->data);
$query = $this->query_pay_result($asyns_resp->data);
}
}
@ -754,11 +777,17 @@ class IPayLinksService extends CI_Controller
* @param [type] $code [description]
* @param [type] $code [description]
* @return [type] [description]
* @return [type] [description]
*/
*/
protected function result_2_return_url($code)
protected function result_2_return_url($code,$msg )
{
{
$ret['code'] = 0;
$ret['code'] = 0;
$ret['msg'] = "";
$ret['msg'] = "";
$ret['error_code'] = $code ? $code : "Unknow";
$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) {
switch ($code) {
case '0000':
case '0000':
$ret['code'] = 0;
$ret['code'] = 0;
@ -767,7 +796,7 @@ class IPayLinksService extends CI_Controller
default:
default:
$ret['code'] = $code;
$ret['code'] = $code;
$ret['msg'] = "Payment Failed";
$ret['msg'] = "Payment Failed. ";
break;
break;
}
}
return $ret;
return $ret;