dongshan8953 2014-12-09 06:02
浏览 4
已采纳

如何在条带PHP代码中设置数量

I am writing php code to charge credit card using stripe

Here is an example code:

<?
require_once('lib/Stripe.php');

Stripe::setApiKey("sk_test_your_key_here");
if(isset($_POST)) {
$payment = Stripe_Charge::create(array(
'amount'        => '100',

'currency'      => 'usd',

'card'          => array(
'number'=> '4242424242424242',,
'exp_month' => '12',//,
'exp_year'=> '14',//,
'cvc'=> ''),//$_POST['cvc']),
'description'   => 'Test payment'
)); }

print_r($payment);
?>

This code will charge the customer for 100 cent! Now what if i want to charge the customer with 10.99 dollar I tried to change it to 10.99 I got this error:

'Stripe_InvalidRequestError' with message 'Invalid integer: 10.99' in 
  • 写回答

1条回答 默认 最新

  • doupu3635 2014-12-09 06:07
    关注

    The stripe API documentation states that accepts the amount as cents only.

    10.99 is a float value, not an integer. To get the amount, multiply the dollar figure by 100 to convert it to cents.

    10.99 * 100 = 1099 = amount

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法