Reputation: 107
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
Upvotes: 5
Views: 8683
Reputation: 41607
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
Upvotes: 21