我使用Stripe webhook来存储客户在Stripe收取费用时收取的美元金额。
我已经得到了webhook工作良好,可以通过电子邮件发送收费金额,但似乎无法将其存储在WordPress user_meta字段。
下面是我的代码:// Retrieve the request's body and parse it as JSON
$input = @file_get_contents("php://input");
$event_json = json_decode($input);
// Check against Stripe to confirm that the ID is valid
$event = 'Stripe'Event::retrieve($event_json->id);
// If charge is successful, store in user meta
if (isset($event) && $event->type == "charge.succeeded") {
$amount = $event->data->object->amount / 100;
}
$payment_user_id = 9192321;
update_user_meta($payment_user_id, 'payment_history', $amount);
这是因为从条纹收到的json是在一种格式,需要转换成东西之前,我可以存储它吗?如果我尝试使用intval($amount)将其转换为整数,它只是将其存储为0。
提前感谢!
原来我很笨,只需要把"update_user_meta"放在"if"语句中