Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ldy
/
payment
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ec0fa8d7
authored
Feb 03, 2023
by
丁铜欣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微诺付支付
1 parent
ec821ad6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
7 deletions
src/Common/WNFpay/Data/Charge/ChargeData.php
src/Common/WNFpay/WNFBaseStrategy.php
src/Utils/Curl.php
src/Common/WNFpay/Data/Charge/ChargeData.php
View file @
ec0fa8d
...
@@ -24,7 +24,10 @@ class ChargeData extends WNFBaseData
...
@@ -24,7 +24,10 @@ class ChargeData extends WNFBaseData
'appid'
=>
$this
->
appid
,
'appid'
=>
$this
->
appid
,
'payType'
=>
$this
->
payType
,
'payType'
=>
$this
->
payType
,
'callbackUrl'
=>
$this
->
callbackUrl
,
'callbackUrl'
=>
$this
->
callbackUrl
,
'goodsListItem '
=>
$this
->
goodsListItem
//商品列表,此处应该是数组
'goodsListItem'
=>
$this
->
goodsListItem
,
//商品列表,此处应该是数组
'taxNo'
=>
$this
->
taxNo
??
''
,
'appKey'
=>
$this
->
appKey
??
''
,
'deptId'
=>
$this
->
deptId
??
''
];
];
$this
->
retData
=
$data
;
$this
->
retData
=
$data
;
}
}
...
...
src/Common/WNFpay/WNFBaseStrategy.php
View file @
ec0fa8d
...
@@ -59,8 +59,9 @@ abstract class WNFBaseStrategy implements BaseStrategy
...
@@ -59,8 +59,9 @@ abstract class WNFBaseStrategy implements BaseStrategy
{
{
$curl
=
new
Curl
();
$curl
=
new
Curl
();
return
$curl
->
set
([
return
$curl
->
set
([
'CURLOPT_HEADER'
=>
0
'CURLOPT_HEADER'
=>
0
,
])
->
post
(
$body
,
$url
)
->
submit
(
$url
);
'CURLOPT_HTTPHEADER'
=>
[
'Content-Type: application/json'
]
])
->
post
(
$body
,
$url
)
->
submit
(
$url
,
false
,
true
);
}
}
/**
/**
...
@@ -83,9 +84,12 @@ abstract class WNFBaseStrategy implements BaseStrategy
...
@@ -83,9 +84,12 @@ abstract class WNFBaseStrategy implements BaseStrategy
$this
->
reqData
->
setSign
();
$this
->
reqData
->
setSign
();
$body
=
$this
->
reqData
->
getData
();
$body
=
$this
->
reqData
->
getData
();
debug
([
'title'
=>
'请求参数'
,
'body'
=>
$body
]);
$ret
=
$this
->
sendReq
(
$body
);
$ret
=
$this
->
sendReq
(
$body
);
return
$this
->
retData
(
$ret
);
return
$this
->
retData
(
$ret
);
}
}
...
@@ -107,7 +111,7 @@ abstract class WNFBaseStrategy implements BaseStrategy
...
@@ -107,7 +111,7 @@ abstract class WNFBaseStrategy implements BaseStrategy
*/
*/
protected
function
retData
(
array
$ret
)
protected
function
retData
(
array
$ret
)
{
{
return
$ret
;
return
$ret
[
'body'
]
;
}
}
}
}
\ No newline at end of file
src/Utils/Curl.php
View file @
ec0fa8d
...
@@ -17,6 +17,7 @@ class Curl
...
@@ -17,6 +17,7 @@ class Curl
private
$default
;
private
$default
;
private
$download
;
private
$download
;
private
$isJsonStr
=
false
;
private
$isJsonStr
=
false
;
private
$isWnfJson
=
false
;
private
static
$instance
;
private
static
$instance
;
public
function
__construct
()
public
function
__construct
()
...
@@ -122,7 +123,7 @@ class Curl
...
@@ -122,7 +123,7 @@ class Curl
* @param string $url
* @param string $url
* @return array
* @return array
*/
*/
public
function
submit
(
$url
,
$isJsonStr
=
false
)
public
function
submit
(
$url
,
$isJsonStr
=
false
,
$isWnfJson
=
false
)
{
{
if
(
!
$this
->
post
)
{
if
(
!
$this
->
post
)
{
return
array
(
return
array
(
...
@@ -131,6 +132,7 @@ class Curl
...
@@ -131,6 +132,7 @@ class Curl
);
);
}
}
$this
->
isJsonStr
=
$isJsonStr
;
$this
->
isJsonStr
=
$isJsonStr
;
$this
->
isWnfJson
=
$isWnfJson
;
return
$this
->
set
(
'CURLOPT_URL'
,
$url
)
->
exec
();
return
$this
->
set
(
'CURLOPT_URL'
,
$url
)
->
exec
();
}
}
...
@@ -222,6 +224,8 @@ class Curl
...
@@ -222,6 +224,8 @@ class Curl
curl_setopt
(
$ch
,
CURLOPT_POST
,
true
);
curl_setopt
(
$ch
,
CURLOPT_POST
,
true
);
if
(
$this
->
isJsonStr
){
if
(
$this
->
isJsonStr
){
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
json_encode
(
$this
->
postFieldsBuild
(
$this
->
post
)));
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
json_encode
(
$this
->
postFieldsBuild
(
$this
->
post
)));
}
elseif
(
$this
->
isWnfJson
){
//微诺付json字符串不能一维化
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
json_encode
(
$this
->
post
));
}
else
{
}
else
{
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$this
->
postFieldsBuild
(
$this
->
post
));
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$this
->
postFieldsBuild
(
$this
->
post
));
}
}
...
@@ -233,6 +237,13 @@ class Curl
...
@@ -233,6 +237,13 @@ class Curl
// 检查错误
// 检查错误
$errno
=
curl_errno
(
$ch
);
$errno
=
curl_errno
(
$ch
);
debug
([
'title'
=>
'结果'
,
'body'
=>
$body
,
'http_code'
=>
$info
[
'http_code'
],
'errno'
=>
$errno
,
'post'
=>
json_encode
(
$this
->
postFieldsBuild
(
$this
->
post
))
]);
if
(
$errno
===
0
&&
$info
[
'http_code'
]
>=
400
)
{
if
(
$errno
===
0
&&
$info
[
'http_code'
]
>=
400
)
{
$errno
=
$info
[
'http_code'
];
$errno
=
$info
[
'http_code'
];
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment