Commit d05e5fdf by yeran

update some bugs

1 parent 92425b2b
......@@ -2,7 +2,6 @@
namespace Payment\Charge\Sw;
use Payment\Common\Sw\Data\BackBarChargeData;
use Payment\Common\Sw\Data\BackScanChargeData;
use Payment\Common\Sw\Data\Charge\BarChargeData;
use Payment\Common\Sw\SwBaseStrategy;
use Payment\Common\SwConfig;
......@@ -23,9 +22,9 @@ class SwBarCharge extends SwBaseStrategy
}
protected function getReqUrl(){
protected function getReqUrl($url=null){
return SwConfig::BARCODE_URL;
return parent::getReqUrl($url??SwConfig::BARCODE_URL);
}
/**
......
......@@ -24,9 +24,9 @@ class SwCancel extends SwBaseStrategy
}
protected function getReqUrl(){
protected function getReqUrl($url=null){
return SwConfig::CANCEL_URL;
return parent::getReqUrl($url??SwConfig::CANCEL_URL);
}
/**
......
......@@ -29,9 +29,10 @@ class SwClose extends SwBaseStrategy
}
protected function getReqUrl(){
protected function getReqUrl($url=null){
return SwConfig::CLOSE_URL;
return parent::getReqUrl($url??SwConfig::CLOSE_URL);
// return SwConfig::CLOSE_URL;
}
/**
......
......@@ -23,9 +23,9 @@ class SwFaceCharge extends SwBaseStrategy
}
protected function getReqUrl(){
protected function getReqUrl($url=null){
return SwConfig::FACEPAY_URL;
return parent::getReqUrl($url??SwConfig::FACEPAY_URL);
}
/**
......
......@@ -24,9 +24,9 @@ class SwFaceInfo extends SwBaseStrategy
}
protected function getReqUrl(){
protected function getReqUrl($url = null){
return SwConfig::FACEPAY_ACCESSTOKEN_URL;
return parent::getReqUrl($url??SwConfig::FACEPAY_ACCESSTOKEN_URL);
}
/**
......
......@@ -23,9 +23,9 @@ class SwLiteCharge extends SwBaseStrategy
}
protected function getReqUrl(){
protected function getReqUrl($url=null){
return SwConfig::LITEPAY_URL;
return parent::getReqUrl($url??SwConfig::LITEPAY_URL);
}
/**
......
......@@ -22,9 +22,9 @@ class SwScanCharge extends SwBaseStrategy
}
protected function getReqUrl(){
protected function getReqUrl($url=null){
return SwConfig::SCANPAY_URL;
return parent::getReqUrl($url??SwConfig::SCANPAY_URL);
}
/**
......
......@@ -95,6 +95,16 @@ abstract class BaseData
$this->data[$name] = $value;
}
public function __isset($name)
{
// TODO: Implement __isset() method.
if (isset($this->data[$name])) {
return (false === empty($this->data[$name]));
}
return null;
}
/**
* 设置签名
*
......@@ -129,7 +139,7 @@ abstract class BaseData
//添加令牌,参数由makesign函数自由控制
$values = ArrayUtil::removeKeys($data, ['key_sign']);
$values = ArrayUtil::arraySort($values);
// $values = ArrayUtil::arraySort($values);
$signStr = ArrayUtil::createLinkstring($values);
$this->makeSign($signStr);
......
......@@ -35,7 +35,7 @@ class CancelData extends ChargeBaseData
'terminal_id' => $this->terminal_id,
'terminal_trace' => $this->terminal_trace,
'terminal_time' => $this->terminal_time,
'total_fee' => $this->total_fee, // 金额,单位分
// 'total_fee' => $this->total_fee, // 金额,单位分
];
......
......@@ -47,23 +47,18 @@ class BarChargeData extends ChargeBaseData
'terminal_id' => $this->terminal_id,
'terminal_trace' => $this->terminal_trace,
'terminal_time' => $this->terminal_time,
'auth_no' =>$this->auth_no,//授权码,客户的付款码
'total_fee' => $this->total_fee, // 金额,单位分
'auth_no' =>$this->auth_no,//授权码,客户的付款码
];
if(isset($this->sub_appid)){
$signData['sub_appid'] = $this->sub_appid;
}
if(isset($this->open_id)){
$signData['open_id'] = $this->open_id;
}
if(isset($this->order_body)){
$signData['order_body'] = $this->order_body;
}
if(isset($this->notify_url)){
$signData['notify_url'] = $this->notify_url;
}
if(isset($this->attach)){
$signData['attach'] = $this->attach;
}
......
......@@ -44,9 +44,10 @@ class FaceChargeData extends ChargeBaseData
'terminal_id' => $this->terminal_id,
'terminal_trace'=> $this->terminal_trace,
'terminal_time' => $this->terminal_time,
'total_fee' => $this->total_fee, // 金额,单位分
'auth_no' =>$this->auth_no,
];
if(isset($this->out_trade_no)){//利楚订单号,来自自助收银SDK调用凭证获取接口,仅微信刷脸支付必传。
$signData['out_trade_no'] = $this->out_trade_no;
......@@ -54,6 +55,8 @@ class FaceChargeData extends ChargeBaseData
if(isset($this->open_id)){//用户标识(微信openid),用于调起微信刷脸SDK
$signData['open_id'] = $this->open_id;
}
$signData['total_fee'] = $this->total_fee; // 金额,单位分
if(isset($this->order_body)){
$signData['order_body'] = $this->order_body;
}
......
......@@ -52,9 +52,9 @@ class ScanChargeData extends ChargeBaseData
if(isset($this->sub_appid)){
$signData['sub_appid'] = $this->sub_appid;
}
if(isset($this->open_id)){
$signData['open_id'] = $this->open_id;
}
// if(isset($this->open_id)){
// $signData['open_id'] = $this->open_id;
// }
if(isset($this->order_body)){
$signData['order_body'] = $this->order_body;
}
......
......@@ -51,7 +51,7 @@ class ChargeQueryData extends SwBaseData
'terminal_id' => $this->terminal_id,
'terminal_trace'=> $this->terminal_trace,//终端查询流水号,填写商户系统的查询流水号
'terminal_time' => $this->terminal_time,
'out_trade_no' => $this->out_trade_no, // 金额,单位分
];
if(isset($this->pay_trace)){//用户标识(微信openid),用于调起微信刷脸SDK
......@@ -61,6 +61,8 @@ class ChargeQueryData extends SwBaseData
$signData['pay_time'] = $this->pay_time;
}
$signData['out_trade_no'] = $this->out_trade_no; // 金额,单位分
$this->retData = ArrayUtil::paraFilter($this->retData);
}
......
......@@ -75,8 +75,10 @@ abstract class SwBaseStrategy implements BaseStrategy
protected function curlPost($body, $url)
{
$curl = new Curl();
$this_header = array("content-type: application/json;charset=UTF-8");
return $curl->set([
'CURLOPT_HEADER' => 0,
'CURLOPT_HEADER' => 0,
'CURLOPT_HTTPHEADER' => $this_header
])->post($body, $url)->submit($url,true);
}
......@@ -84,11 +86,17 @@ abstract class SwBaseStrategy implements BaseStrategy
* 获取需要的url 默认返回下单的url,根据实际情况,需要被覆写
* 默认是h5支付
*
* @return string|null
* @param null $url
* @return null|string
*/
protected function getReqUrl()
protected function getReqUrl($url=null)
{
return SwConfig::UNIFIED_URL;
if(!empty($this->base_url)){
$_pre = $this->base_url;
}else{
$_pre = SwConfig::BASE_URL;
}
return $_pre.($url??SwConfig::UNIFIED_URL);
}
/**
......
<?php
/**
* Created by PhpStorm.
*
* Date: 2017/4/26
* Time: 下午5:39
*/
namespace Payment\Common\Weixin;
use Payment\Common\PayException;
use Payment\Common\Weixin\Data\WxBaseData;
use Payment\Common\WxConfig;
use Payment\Utils\Curl;
use Payment\Utils\DataParser;
class WechatHelper extends WxBaseData
{
public function getSandboxSignKey()
{
$this->setSign();
$xml = DataParser::toXml($this->getData());
$url = WxConfig::SANDBOX_URL;
$curl = new Curl();
$responseTxt = $curl->set([
'CURLOPT_HEADER' => 0
])->post($xml)->submit($url);
if ($responseTxt['error']) {
throw new PayException('网络发生错误,请稍后再试curl返回码:' . $responseTxt['message']);
}
// 格式化为数组
$retData = DataParser::toArray($responseTxt['body']);
if ($retData['return_code'] != 'SUCCESS') {
throw new PayException('微信返回错误提示:' . $retData['return_msg']);
}
return $retData['sandbox_signkey'];
}
protected function buildData()
{
$this->retData = [
'mch_id' => $this->mchId,
'nonce_str' => $this->nonceStr,
];
}
protected function checkDataParam()
{
// TODO: Implement checkDataParam() method.
}
}
\ No newline at end of file
......@@ -28,37 +28,37 @@ final class SwConfig extends ConfigInterface
public $notify_url;
const BASE_URL = '';
const BASE_URL = 'http://test.lcsw.cn:8045/lcsw';
const UNIFIED_URL = self::BASE_URL.'/pay/100/jspay'; // 公众号支付统一下单url
const UNIFIED_URL = '/pay/100/jspay'; // 公众号支付统一下单url
const LITEPAY_URL = self::BASE_URL.'/pay/100/minipay';// 小程序支付url
const LITEPAY_URL = '/pay/100/minipay';// 小程序支付url
const FACEPAY_URL = self::BASE_URL.'/pay/110/facepay';//自助收银
const FACEPAY_URL = '/pay/110/facepay';//自助收银
const SCANPAY_URL = self::BASE_URL.'/pay/100/prepay';//扫码支付(预支付)
const SCANPAY_URL = '/pay/100/prepay';//扫码支付(预支付)
const BARCODE_URL = self::BASE_URL.'/pay/100/barcodepay';//刷卡(条码)支付
const BARCODE_URL = '/pay/100/barcodepay';//刷卡(条码)支付
const FACEPAY_ACCESSTOKEN_URL = self::BASE_URL.'/pay/110/faceinfo';//自助收银SDK调用凭证获取接口
const FACEPAY_ACCESSTOKEN_URL = '/pay/110/faceinfo';//自助收银SDK调用凭证获取接口
const AUTH_OPENID = self::BASE_URL.'/wx/jsapi/authopenid';//用于服务商通道获取微信openid,Method:GET
const AUTH_OPENID = '/wx/jsapi/authopenid';//用于服务商通道获取微信openid,Method:GET
const AUTHCODE_TO_OPENID_URL = self::BASE_URL.'/pay/110/authcodetoopenid';//授权码查询 OPENID 接口
const AUTHCODE_TO_OPENID_URL = '/pay/110/authcodetoopenid';//授权码查询 OPENID 接口
const CHARGE_QUERY_URL = self::BASE_URL.'/pay/100/query'; // 支付查询url
const CHARGE_QUERY_URL = '/pay/100/query'; // 支付查询url
const REFUND_URL = self::BASE_URL.'/pay/100/refund'; // 申请退款url
const REFUND_URL = '/pay/100/refund'; // 申请退款url
const CANCEL_URL = self::BASE_URL.'/pay/100/cancel';//撤销交易(只针对刷卡支付)
const CANCEL_URL = '/pay/100/cancel';//撤销交易(只针对刷卡支付)
const CLOSE_URL = self::BASE_URL.'/pay/100/close';//关闭订单(仅限服务商模式商户且为微信支付时可用)
const CLOSE_URL = '/pay/100/close';//关闭订单(仅限服务商模式商户且为微信支付时可用)
const SIGN_URL = self::BASE_URL.'/pay/100/sign';//注册终端(获取access_token),一台机器只有一次调用机会,遗失请联系客服申请重置
const SIGN_URL = '/pay/100/sign';//注册终端(获取access_token),一台机器只有一次调用机会,遗失请联系客服申请重置
/**
* 初始化微信配置文件
......
......@@ -27,12 +27,12 @@ class SwChargeQuery extends SwBaseStrategy
/**
* 返回微信查询的url
* @param null $url
* @return string
*
*/
protected function getReqUrl()
protected function getReqUrl($url=null)
{
return SwConfig::CHARGE_QUERY_URL;
return parent::getReqUrl($url??SwConfig::CHARGE_QUERY_URL);
}
/**
......
......@@ -33,12 +33,12 @@ class SwRefund extends SwBaseStrategy
/**
* 返回微信查询的url
* @param null $url
* @return string
*
*/
protected function getReqUrl()
protected function getReqUrl($url=null)
{
return SwConfig::REFUND_URL;
return parent::getReqUrl($url??SwConfig::REFUND_URL);
}
/**
......
......@@ -11,16 +11,17 @@ namespace Payment\Utils;
class ArrayUtil
{
/**
* 移除空值的key
* @param $para
* @return array
*
* @author helei
*/
public static function paraFilter($para)
{
$paraFilter = [];
while (list($key, $val) = each($para)) {
foreach ($para as $key => $val) {
if ($val === '' || $val === null) {
continue;
} else {
......@@ -89,13 +90,13 @@ class ArrayUtil
*/
public static function createLinkstring($para)
{
if (!is_array($para)) {
if (! is_array($para)) {
throw new \Exception('必须传入数组参数');
}
reset($para);
$arg = '';
while (list($key, $val) = each($para)) {
foreach ($para as $key => $val) {
if (is_array($val)) {
continue;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!