2016-12-31 21 views
0

我想在我的網站上使用Stripe捕獲客戶的銀行卡號碼,以便在我的網站上進行驗證並將其保存到中的條帶。但不收費。相反,我想在未來收費。是否可以通過Stripe API?怎麼樣?捕獲客戶的銀行卡詳細信息,而無需向Stripe收取款項

更新

這是否做我想做什麼?

# 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" 
) 
+0

從條紋常見問題:https://support.stripe.com/questions/can-i-save-a-card-and-charge-it-later –

+0

@JeremyJStarcher,因爲它說「#向客戶收費而不是卡「。它會創建一個客戶並向他們收費。但如何「不收費」? – ako25

+0

@JeremyJStarcher,或當我捕捉到的信用卡資料,我怎麼能救他們?該鏈接沒有描述。 – ako25

回答

2

至於講到這裏的條紋文檔中:

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, # $15.00 this time 
    currency="usd", 
    customer=customer_id # Previously stored, then retrieved 
) 

編輯基於COMMENT

這確實你問什麼了。它捕獲的信用卡詳細資料,讓他們對帶鋼,然後當你需要,你可以訪問它們。

特別要注意這行:

# 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 
) 

當是時候進行充電,檢索令牌並執行收費。

+0

這不回答我的問題。我不想自己保留卡信息。重新閱讀我的問題。 – ako25

+0

看看我的更新。 – ako25

+0

我不明白,爲什麼「#代碼:當它的時間給客戶重新充電」 - 爲什麼「又」? – ako25