我正在编写 php 代码来使用 Stripe 向信用卡收费
这是一个示例代码:
<?
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);
?>
此代码将向客户收取 100 美分的费用!
现在如果我想向客户收取 10.99 美元怎么办
我试图将其更改为 10.99
我收到此错误:
'Stripe_InvalidRequestError' with message 'Invalid integer: 10.99' in
最佳答案
strip API documentation声明只接受美分的金额。10.99
是一个浮点值,而不是一个整数。要获得金额,请将美元数字乘以 100 以将其转换为美分。10.99 * 100 = 1099 = amount
关于php - 如何在stripe php代码中设置数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27372430/