Three simple lines of code:
$input = @file_get_contents("php://input");
$event_json = json_decode($input,true);
print_r($event_json);
I have used first 2 lines to convert json data into array in php, and third line prints the following array (a portion I show here):
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
My question is: How do I echo amount (which is 100) or amount_refunded (which is 0)?
echo $event_json['data']['object']['amount'];
echo $event_json['data']['object']['amount_refunded'];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.