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 feb3ef25
authored
Nov 05, 2018
by
yeran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update getNotifyData for MiNotify by yeran
1 parent
c86cffc0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
7 deletions
examples/mipay/cancel.php
src/Common/MiConfig.php
src/Common/MiPay/MiBaseStrategy.php
src/Notify/MiNotify.php
examples/mipay/cancel.php
View file @
feb3ef2
<?php
<?php
date_default_timezone_set
(
'Asia/Shanghai'
);
//die(date('Y-m-d H:i:s', '1541417375'));
require_once
__DIR__
.
'/../../autoload.php'
;
require_once
__DIR__
.
'/../../autoload.php'
;
use
Payment\Common\PayException
;
use
Payment\Common\PayException
;
use
Payment\Client\Charge
;
use
Payment\Client\Charge
;
use
Payment\Config
;
use
Payment\Config
;
date_default_timezone_set
(
'Asia/Shanghai'
);
$miConfig
=
require_once
'MiConfig.php'
;
$miConfig
=
require_once
'MiConfig.php'
;
...
...
src/Common/MiConfig.php
View file @
feb3ef2
...
@@ -108,6 +108,10 @@ final class MiConfig extends ConfigInterface
...
@@ -108,6 +108,10 @@ final class MiConfig extends ConfigInterface
$this
->
trade_type
=
'MINIAPP'
;
// 默认是小程序支付
$this
->
trade_type
=
'MINIAPP'
;
// 默认是小程序支付
}
}
if
(
key_exists
(
'return_raw'
,
$config
))
{
$this
->
returnRaw
=
filter_var
(
$config
[
'return_raw'
],
FILTER_VALIDATE_BOOLEAN
);
}
// 检查 异步通知的url
// 检查 异步通知的url
if
(
key_exists
(
'notify_url'
,
$config
)
&&
!
empty
(
$config
[
'notify_url'
]))
{
if
(
key_exists
(
'notify_url'
,
$config
)
&&
!
empty
(
$config
[
'notify_url'
]))
{
$this
->
notifyUrl
=
trim
(
$config
[
'notify_url'
]);
$this
->
notifyUrl
=
trim
(
$config
[
'notify_url'
]);
...
...
src/Common/MiPay/MiBaseStrategy.php
View file @
feb3ef2
...
@@ -66,7 +66,7 @@ abstract class MiBaseStrategy implements BaseStrategy{
...
@@ -66,7 +66,7 @@ abstract class MiBaseStrategy implements BaseStrategy{
if
(
$responseTxt
[
'error'
]
!=
0
)
{
//通信标识
if
(
$responseTxt
[
'error'
]
!=
0
)
{
//通信标识
throw
new
PayException
(
'支付平台返回错误提示
0
:'
.
$responseTxt
[
'message'
]);
throw
new
PayException
(
'支付平台返回错误提示
3
:'
.
$responseTxt
[
'message'
]);
}
}
// 格式化为数组
// 格式化为数组
...
@@ -79,7 +79,7 @@ abstract class MiBaseStrategy implements BaseStrategy{
...
@@ -79,7 +79,7 @@ abstract class MiBaseStrategy implements BaseStrategy{
// }
// }
if
(
$retData
[
'result_code'
]
!=
'SUCCESS'
)
{
//交易标识
if
(
$retData
[
'result_code'
]
!=
'SUCCESS'
)
{
//交易标识
$msg
=
$retData
[
'errmsg'
]
?:
'交易失败-系统繁忙'
;
$msg
=
$retData
[
'errmsg'
]
?:
'交易失败-系统繁忙'
;
throw
new
PayException
(
'支付平台返回错误提示
2
:'
.
$msg
);
throw
new
PayException
(
'支付平台返回错误提示
3
:'
.
$msg
);
}
}
return
$retData
;
return
$retData
;
...
...
src/Notify/MiNotify.php
View file @
feb3ef2
...
@@ -42,9 +42,9 @@ class MiNotify extends NotifyStrategy
...
@@ -42,9 +42,9 @@ class MiNotify extends NotifyStrategy
public
function
getNotifyData
()
public
function
getNotifyData
()
{
{
$params
=
array
();
$params
=
array
();
foreach
(
$_POST
as
$key
=>
$val
)
{
//动态遍历获取所有收到的参数,此步非常关键
//
foreach($_POST as $key=>$val) {//动态遍历获取所有收到的参数,此步非常关键
$params
[
$key
]
=
$val
;
//
$params[$key] = $val;
}
//
}
//支持直接读取input流
//支持直接读取input流
$data
=
@
file_get_contents
(
'php://input'
);
$data
=
@
file_get_contents
(
'php://input'
);
...
@@ -125,7 +125,7 @@ class MiNotify extends NotifyStrategy
...
@@ -125,7 +125,7 @@ class MiNotify extends NotifyStrategy
'buyer_id'
=>
$data
[
'sub_openid'
],
'buyer_id'
=>
$data
[
'sub_openid'
],
'order_no'
=>
$data
[
'out_trade_sn'
],
//平台
'order_no'
=>
$data
[
'out_trade_sn'
],
//平台
'meepay_trade_no'
=>
$data
[
'meepay_trade_no'
],
//米付
'meepay_trade_no'
=>
$data
[
'meepay_trade_no'
],
//米付
// 'pay_time' => date('Y-m-d H:i:s', strtotime($data['time_end'])
),// 支付完成时间
'pay_time'
=>
date
(
'Y-m-d H:i:s'
,
$data
[
'pay_time'
]
),
// 支付完成时间
'amount'
=>
$data
[
'total_amount'
],
'amount'
=>
$data
[
'total_amount'
],
'trade_type'
=>
$data
[
'trade_type'
],
'trade_type'
=>
$data
[
'trade_type'
],
'transaction_id'
=>
$data
[
'transaction_id'
],
//微信
'transaction_id'
=>
$data
[
'transaction_id'
],
//微信
...
...
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