【发布时间】:2016-07-25 18:09:08
【问题描述】:
我正在使用 Stripe API 进行一次性付款,使用类似的东西可以很好地工作:
$stripe = array("secret_key" => "MY_SECRET_KEY", "publishable_key" => "MY_PUBLISHABLE_KEY");
Stripe::setApiKey($stripe['secret_key']);
try {
$charge = Stripe_Charge::create(array(
"amount" => round($_POST['amount'] * 100, 0),
"currency" => "USD",
"card" => array(
"number" => 111111111111111111,
"exp_month" => 10,
"exp_year" => 2017,
"cvc" => 321,
),
"description" => $_POST['item_name']));
$json = json_decode($charge);
$amount_charged = round(($json->{'amount'} / 100), 2);
//process payment here......
}
catch (Stripe_CardError $e) {
$body = $e->getJsonBody();
print json_encode($json);
}
现在我希望能够通过捕获用户信用卡信息并每月运行一次 cron 作业来进行定期付款。以上工作正常吗,还是我需要别的东西。我知道 Stripe 内置了定期付款功能,但在我的情况下,每个月的付款金额会有所不同。
【问题讨论】:
-
您真的应该不将用户的信用卡信息保存在您的数据库中。您可以使用 Strip 的 API change the amount of a subscription。
-
在您的终端上存储 CC 数据会使您遵守 PCI 合规性,这不是您想要参与的事情。让条带处理存储。
-
他们的文档中很好地涵盖了所有这些......
标签: php stripe-payments