首页 文章

使条带网关接受变量作为收费金额

提问于
浏览
0

嗨,我有一个名为$ total的变量,它是从另一个页面上的表单中的隐藏字段设置的

$total = $_POST['myHiddenValue'];

在Stripe中,我试图将此变量用作数量参数

Stripe_Charge::create(array(
                            "amount" => $total,
                            "currency" => "gbp",
                            "card" => $_POST['stripeToken']));

这引发了'缺少金额参数'的错误

如果我事先设定$ total为:

$total = 5000;

它有效,但我不想硬编码 .

使用下面也不起作用,它抛出'无效正整数'错误

“amount”=>(int)$ total,

有没有人知道Stripe好给我一些帮助 .

谢谢

1 回答

  • 1

    'amount'以美分为单位,应该是整数而不是小数 .

    $ Total = '50 .43';

    'amount'=> $ Total * 100,

相关问题