-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.php
73 lines (66 loc) · 1.7 KB
/
demo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
require __DIR__ . '/vendor/autoload.php';
use MissEvanGame\Client;
use MissEvanGame\Signature;
$app_id = '8';
$merchant_id = '3000';
$access_id = 'access_id';
$access_secret = 'access_secret';
$getway_url = 'http://127.0.0.1:8999';
// 初始化配置
$client = new Client($app_id, $merchant_id, $access_id, $access_secret);
// 设置网关地址
$client->setGatewayURL($getway_url);
// 查询用户信息
$result = $client->queryUserInfo(['token' => '2|5d809a482f66aa4f4f93b110|33037d3bf648260c|1568709192|4237748454c9daf2589a59cbfbbbd686432968068f14646b']);
var_export($result);
// 返回示例
/*
array (
'code' => 0,
'info' =>
array (
'uid' => 6,
'username' => 'chenhao1234569',
'avatar' => 'http://static.missevan.com/avatars/201812/17/131eefbfd4b463f7038ff3ce8d2fe8c7144631.jpg',
'realname_verified' => true,
),
'request_id' => '12312321',
'timestamp' => 1568709216,
)
*/
// 查询订单
$result = $client->queryOrder(['tr_no' => '12345678901234567890123456789012', 'uid' => '3013620']);
var_export($result);
// 返回示例
/*
array (
'code' => 0,
'info' =>
array (
'subject' => '猫耳游戏-荣耀点',
'body' => '全职高手荣耀点',
'out_trade_no' => '10000000900000000090123456789012',
'total_fee' => 100,
'server_id' => 1,
'role_id' => 1,
'role' => '叶修',
'game_money' => 10,
'extension_info' => '',
'app_id' => 8,
'user_id' => 3013620,
'Type' => 2,
'Status' => -1,
),
'request_id' => '12312321',
'timestamp' => 1568702546,
)
*/
// 检验回调结果签名是否正确
$body = file_get_contents('php://input');
$bool = Signature::verifyCallbackSign($body, $access_secret);
var_export($bool);
// 返回示例
/*
true
*/