我正在使用分条收费功能,我已经从信用卡详细信息中创建了客户,并将该客户存储在数据库中,然后我试图通过客户ID向该客户收费,但是我在尝试这样做时我遇到了错误,Cannot charge a customer that has no active card
,在这里我已经添加了我的整个代码,有人可以告诉我为什么我遇到此错误
\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;
}
答案 0 :(得分:0)
之所以发生这种情况,是因为您在呼叫客户ID为 测试帐户,反之亦然,或者您添加的客户卡已 已过期或未立即进行身份验证。