在 Stripe 中捕获客户的银行卡详细信息而不收费
Capture a customer's bank card details without charging them in Stripe
我想使用 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"
)
正如 stripe 文档中所说:
https://stripe.com/docs/charges
简而言之:您实际上并没有自己保存信用卡信息。您真的不想这样做,因为它会创建您想要避免的安全环境。严重地。 PCI 合规性 huge book.
相反,他们会记住信用卡信息并给您一个令牌,您可以在以后使用该令牌来引用该数据。
从他们的例子中,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, # .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, # .00 this time
currency="usd",
customer=customer_id # Previously stored, then retrieved
)
当需要充电时,取回令牌并进行充电。
我想使用 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"
)
正如 stripe 文档中所说:
https://stripe.com/docs/charges
简而言之:您实际上并没有自己保存信用卡信息。您真的不想这样做,因为它会创建您想要避免的安全环境。严重地。 PCI 合规性 huge book.
相反,他们会记住信用卡信息并给您一个令牌,您可以在以后使用该令牌来引用该数据。
从他们的例子中,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, # .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, # .00 this time
currency="usd",
customer=customer_id # Previously stored, then retrieved
)
当需要充电时,取回令牌并进行充电。