Authored by 郝肖肖

单击已完成支付 发送一次支付确认接口

... ... @@ -6,6 +6,8 @@ use WebPlugin\Pay\PayAbstract;
use WebPlugin\Pay\Reqparams;
use WebPlugin\Pay\Rspparams;
use WebPlugin\PhpLog;
use WebPlugin\Helpers;
use Api\Yohobuy;
class Service extends PayAbstract
{
... ... @@ -77,7 +79,6 @@ class Service extends PayAbstract
public function getPayRequestPars(Reqparams $params)
{
$front_notify_url = SDK_FRONT_NOTIFY_URL . '?order_code=' . $params->orderCode;
$requestParams = array(
'version' => '5.0.0', //版本号
'encoding' => 'utf-8', //编码方式
... ... @@ -85,8 +86,8 @@ class Service extends PayAbstract
'txnType' => '01', //交易类型
'txnSubType' => '01', //交易子类
'bizType' => '000201', //业务类型
'frontUrl' => $front_notify_url, //前台通知地址
'backUrl' => SDK_BACK_NOTIFY_URL, //后台通知地址
'frontUrl' => Helpers::url('/pay/payreturn/unionpaywebreturn', array('order_code' => $params->orderCode)), //前台通知地址--同步地址
'backUrl' => Yohobuy::SERVICE_URL . '/payment/unionpay_newnotify',//后台通知地址--异步地址
'signMethod' => '01', //签名方法
'channelType' => '07', //渠道类型,07-PC,08-手机
'accessType' => '0', //接入类型
... ...
<?php
namespace WebPlugin;
/**
* 发送短信
*/
class SendSms
{
private static $url = 'http://www.ztsms.cn/sendSms.do';
private static $username = 'youhuo';
private static $password = '22b5d8454c5cea4d972b1b4958227d8f';
private static $productid = '333333';
protected static $code = array(
'-1' => '用户名或者密码不正确或用户禁用或者是管理账户',
'1' => '发送短信成功',
'0' => '发送短信失败',
'2' => '余额不够或扣费错误',
'3' => '扣费失败异常',
'5' => '短信定时成功',
'6' => '有效号码为空',
'7' => '短信内容为空',
'8' => '无签名,必须,格式:【签名】',
'9' => '没有Url提交权限',
'10' => '发送号码过多,最多支持2000个号码',
'11' => '产品ID异常或产品禁用',
'12' => '参数异常',
'15' => 'Ip验证失败',
'19' => '短信内容过长,最多支持500个,或提交编码异常导致',
);
/**
* 发送普通短信
* @param type array $mobiles 手机号
* @param type string $content 内容
* @return type []
*/
public static function ordinarySms($mobiles, $content)
{
if (empty($mobiles)) {
return self::$code[6];
}
if (empty($content)) {
return self::$code[7];
}
if (is_string($mobiles)) {
$mobiles = array($mobiles);
}
$mobiles = array_unique($mobiles);
$data = array(
'mobile' => implode(',', $mobiles),
'content' => $content
);
$result = self::post($data);
if (isset($result[0]) && $result[0] * 1 === 1) {
return array('code' => 200, 'msg' => self::$code[$result[0]]);
}
return array('code' => 400, 'msg' => isset(self::$code[$result[0]]) ? self::$code[$result[0]] : '发送失败');
}
private static function post($data = array(), $timeout = 50)
{
$ch = curl_init(self::$url);
$data['username'] = self::$username;
$data['password'] = self::$password;
$data['productid'] = self::$productid;
$data['content'] = $data['content'];
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 YOHOWEB');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
if (!empty($data)) {
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data, null, '&'));
}
$result = curl_exec($ch);
if (!empty($result)) {
$result = explode(',', $result);
}
curl_close($ch);
unset($ch, $data);
return $result;
}
}
... ...
... ... @@ -71,7 +71,7 @@
<p>完成付款后请根据您的情况点击下面的按钮</p>
</div>
<div class="btns">
<a href="{{ordersUrl}}" class="over">已完成付款</a>
<a href="javascript:void(0);" data-url = "{{ordersUrl}}"class="pay-over over">已完成付款</a>
<a href="#" class="change">更换支付方式</a>
</div>
<a href="#" class="close">x</a>
... ...
... ... @@ -18,7 +18,8 @@ var $ = require('yoho.jquery'),
showDiv,
imgAlt,
imgSrc,
orderCode;
orderCode,
payment;
$.jqtab = function(tabtit, tabcon) {
... ... @@ -77,24 +78,37 @@ $('.change').click(function() {
});
//支付方式选择按钮
function getData(payment,orderCode){
$.ajax({
type:"get",
url:"/common/addpaymentinterval",
dataType:'json',
data:{
orderCode:orderCode,
payment:payment
}
});
function getData(payment, orderCode) {
$.ajax({
type: 'get',
url: '/common/addpaymentinterval',
dataType: 'json',
data: {
orderCode: orderCode,
payment: payment
}
});
}
$("#btnby").click(function(){
payment = $(".choose-type").attr("data-id");
orderCode = $('.order-num').text();
getData(payment,orderCode);
$('#btnby').click(function() {
payment = $('.choose-type').attr('data-id');
orderCode = $('.order-num').text();
getData(payment, orderCode);
window.open($payUrl + '?order_code=' + orderCode + '&payment_type=' + $showValue);
$lightBox.show();
})
});
//发送支付确认
$('.pay-over').unbind('click').bind('click', function() {
var _this = this;
$.post('/shopping/pay/sendPay',
{
orderCode: orderCode,
paymentId: payment
},
function() {
window.location.href = $(_this).data('url');
}
);
});
\ No newline at end of file
... ...
... ... @@ -409,26 +409,25 @@ class PaymentModel
return $uid;
}
/**
* 支付成功后--确认接口
* @param type object $payResult 订单号
* 支付成功后--发送支付确认接口
* @param type object $orderCode 订单号
* @param type int $paymentId 支付方式id
* @param type int $uid 用户ID
* @return type []
*/
public static function payConfirm($payResult, $paymentId, $uid)
public static function sendPayConfirm($orderCode, $paymentId, $uid)
{
// UdpLog::info("【支付成功-发送确认接口】,function:payConfirm,支付方式ID:{$paymentId},参数", $payResult);
if (empty($payResult->orderCode)) {
// UdpLog::info("【支付成功-发送确认接口】,function:sendPayConfirm,支付方式ID:{$paymentId},参数", $payResult);
if (empty($orderCode)) {
return self::$code;
}
$orderCode = $payResult->orderCode;
//如果uid,为空,则从缓存中取uid,但还是不排除uid为空的情况下。
$uid = empty($uid) ? self::getUid($orderCode) : $uid;
$confirm = PayData::payConfirm($orderCode, $paymentId, $uid);
// UdpLog::info(
// "【支付成功-发送确认接口】,function:payConfirm,orderCode:{$orderCode},支付方式ID:{$paymentId},接口返回",
// "【支付成功-发送确认接口】,function:sendPayConfirm,orderCode:{$orderCode},支付方式ID:{$paymentId},接口返回",
// array('confirm' => $confirm, '$payResult' => $payResult)
// );
return $confirm;
... ...
... ... @@ -63,6 +63,18 @@ class PayreturnController extends WebAction
$this->commonShowResult($dealResult);
}
/**
* 银联web支付返回
*/
public function unionpaywebreturnAction()
{
$payment = PayModel::getPaymentById(25);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_REQUEST);
$dealResult = $this->payResultProc($res, 25);
$dealResult['payData'] = array('payWay' => '银联在线支付');
$this->commonShowResult($dealResult);
}
/**
* 通用显示结果的方法
* @param array $dealResult
*/
... ... @@ -100,9 +112,11 @@ class PayreturnController extends WebAction
);
if ($payResult->payResult == 200) {
//支付成功,发送一次支付确认
$uid = $this->getUid(true);
PaymentModel::payConfirm($payResult, $payment, $uid);
if (!empty($payResult->orderCode)) {
//支付成功,发送一次支付确认
$uid = $this->getUid(true);
PaymentModel::sendPayConfirm($payResult, $payment, $uid);
}
//支付成功
$result = PaymentModel::procOrderData($payResult, $payment);
... ...
... ... @@ -71,7 +71,25 @@ class PayController extends WebAction
'payPage' => true
));
}
/**
* 单击已完成支付按钮--发送一次支付确认
*/
public function sendPayAction()
{
$result = array('code' => 400, 'message' => '操作失败!');
if ($this->isAjax()) {
do {
$uid = $this->getUid(true);
$orderCode = $this->post('orderCode', 0);
$paymentId = $this->post('paymentId', 0);
if (empty($orderCode) || empty($uid) || empty($paymentId)) {
break;
}
$result = PaymentModel::sendPayConfirm($orderCode, $paymentId, $uid);
} while (false);
}
$this->echoJson($result);
}
}
... ...