三行简单的代码:
$input = @file_get_contents("php://input");
$event_json = json_decode($input,true);
print_r($event_json);
我已经使用前两行将json数据转换为php中的数组,第三行打印出以下数组(我在这里展示的部分):
Array
(
[created] => 1326853478
[livemode] =>
[id] => evt_00000000000000
[type] => charge.succeeded
[object] => event
[request] =>
[pending_webhooks] => 1
[api_version] => 2014-07-26
[data] => Array
(
[object] => Array
(
[id] => ch_00000000000000
[object] => charge
[amount] => 100
[amount_refunded] => 0
我的问题是:如何回显金额(100)或金额退款(0)?
答案 0 :(得分:1)
echo $event_json['data']['object']['amount'];
echo $event_json['data']['object']['amount_refunded'];