【问题标题】:Stripe charge existing customerStripe 向现有客户收费
【发布时间】: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


【解决方案1】:

然后您的服务器端代码应该被授权,例如只有登录的客户本人或管理员才能触发该操作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-27
    • 1970-01-01
    • 2017-03-12
    • 2015-03-13
    • 1970-01-01
    • 1970-01-01
    • 2022-10-21
    • 2020-04-07
    相关资源
    最近更新 更多