【发布时间】:2019-12-09 15:21:18
【问题描述】:
我正在检查 stripe webhook 发送的支付金额与我的数据库中的应付发票金额的值。
在我的数据库中,发票金额存储为 decimal(10,2)
我有 10 张发票,每张 33.60 = 336.00
//i.e.
$invoices_amount = 336.00;
Stripe 正确发送的金额为 336
{
"gateway_transaction_id":"ch_xxxxxxxxxxxxxx",
"internal_transaction_id":"22",
"transaction_amount":336,
"transaction_currency":"usd",
"transaction_status":"passed"
}
//i.e.
$transaction_amount = 336;
但是,当我执行验证逻辑以检查支付的金额是否等于发票总额时,比较结果返回 false
if($transaction_amount >= $invoices_amount){
//passed
}else{
//failed
}
我在上述检查中失败了。
我已经使用 gettype 检查了变量类型:
gettype($transaction_amount) = integer
gettype($invoices_amount) = double
更奇怪的是,这用于验证一直都很好。
【问题讨论】:
标签: php comparison gettype