Reputation: 119
I am working on stripe charge functionality, i have created customer from credit card details, and stored that customer in the database, and then i am trying to charge to that customer by customer id, but i when i am trying to do that i am getting error, Cannot charge a customer that has no active card
, here i have added my whole code, can anyone please tell me why i am getting this error
\Stripe\Stripe::setApiKey("sk_test_p7WuwfVhQGpu4zb6IZC3MI0b");
\Stripe\Stripe::setApiVersion("2018-05-21");
$amount = 100;
try {
$charge = \Stripe\Charge::create(array(
"amount" => $amount,
"currency" => "usd",
"description" => "",
"customer" => 'cus_DWuoLfjJBSQsWt',
)
);
echo "<pre>";
print_r($charge);
die;
} catch (Exception $ex) {
echo $ex->getMessage(); die;
}
Upvotes: 2
Views: 1972
Reputation: 1579
This is happening because of either you are calling customer id of test account or vise versa OR your added customer's card has been expired or not authenticating now.
Upvotes: 2