我正在为网站启用付款。我使用 Stripe 作为提供者。我想知道如果 2 个条件为真,我如何为卡充电。当用户付款时,我想更改数据库中的一个值,然后向卡收费。但是如果数据库查询失败,我不想对该卡收费。同样,我不想查询卡是否无效。我需要卡片有效和查询成功。我怎么做?
这是充值卡的代码
try {
$charge = \Stripe\Charge::create(array(
"amount" => $amount, // amount in cents, again
"currency" => "cad",
"source" => $token,
"description" => $description)
);
} catch(\Stripe\Error\Card $e) {
// The card has been declined
}
Run Code Online (Sandbox Code Playgroud)