【发布时间】:2017-01-09 21:22:27
【问题描述】:
我正在使用嵌入 stripe.js
表单完成后,表单重定向到:www.mydomain.com/doc-whatever/?action=payment
此 url 参数触发服务器端代码。缩写伪代码:
$token = $_POST['stripeToken'];
//check if customer ID exists in the DB.
//returns the stripe customer id of client attached to the document.
//May or may not be logged in.
$customers_stripe_id = get_customer_stripe_id()
if ( ! $customers_stripe_id ) {
$customer = \Stripe\Customer::create(array(
'email' => 'customer@example.com',
'source' => $token
));
$customers_stripe_id = $customer_id;
}
$charge = \Stripe\Charge::create(array(
'customer' => $customers_stripe_id,
'amount' => 5000,
'currency' => 'usd'
));
这很好用,但是这里有一个明显的安全问题。可以简单地导航到www.mydomain.com/doc-whatever/?action=payment,如果数据库中存储有条带客户ID,则将向持卡客户收费。
【问题讨论】:
-
如果您说的是我认为您所说的(即您想防止人们通过 url 导航到页面),请查看我在这里提出的问题:@987654321 @它有很多很好的答案。
标签: stripe-payments