捕获客户的银行卡详细信息,而无需在Stripe中收费

时间:2016-12-31 02:25:58

标签: python stripe-payments

我想使用Stripe在我的网站上注册时捕获客户的银行卡号,以验证并将其保存在Stripe 。但不要充电。相反,我希望将来收取费用。是否可以通过Stripe API?怎么样?

更新

这样做我想要的吗?

# Get the credit card details submitted by the form
token = request.POST['stripeToken']

# Create a Customer
customer = stripe.Customer.create(
  source=token,
  description="Example customer"
)

1 个答案:

答案 0 :(得分:2)

正如条纹文档中所述:

huge book

简而言之:您实际上并未自己保留信用卡信息。您确实不想这样做,因为它会创建您想要避免的安全环境。认真。 PCI合规性为{{3}}。

相反,他们会记住信用卡信息并为您提供一个令牌,您可以使用该令牌随后引用该数据。

从他们的例子中,在Ruby中:

# Set your secret key: remember to change this to your live secret key in production
# See your keys here: https://dashboard.stripe.com/account/apikeys
stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"

# Get the credit card details submitted by the form
token = request.POST['stripeToken']

# Create a Customer
customer = stripe.Customer.create(
  source=token,
  description="Example customer"
)

# Charge the Customer instead of the card
stripe.Charge.create(
  amount=1000, # in cents
  currency="usd",
  customer=customer.id
)

# YOUR CODE: Save the customer ID and other info in a database for later!

# YOUR CODE: When it's time to charge the customer again, retrieve the customer ID!

stripe.Charge.create(
  amount=1500, # $15.00 this time
  currency="usd",
  customer=customer_id # Previously stored, then retrieved
)

基于评论的编辑

这完全符合您的要求。它捕获卡的详细信息,将它们保存在Strip上,然后您可以在需要时访问它们。

特别注意这一行:

# YOUR CODE: Save the customer ID and other info in a database for later!

# YOUR CODE: When it's time to charge the customer again, retrieve the customer ID!

stripe.Charge.create(
  amount=1500, # $15.00 this time
  currency="usd",
  customer=customer_id # Previously stored, then retrieved
)

什么时候充电,检索令牌并进行充电。