簡體   English   中英

Stripe:Source vs. Card vs. Bank vs Payment Method 有什么不同?

[英]Stripe: Whats the different between Source vs. Card vs. Bank vs Payment Method?

我是第一次使用 Stripe,對它們提供的不同 API 有點困惑。 有一個 Payment Method API,它是推薦用於處理客戶付款方式的 API,但目前它只支持信用卡,如果我理解正確的話......

但我需要不同的付款方式,例如銀行賬戶。 所以對於那個 Stripe 提供了 Card、Bank 和 Source 對象。 他們之間有什么不同?

我嘗試了他們中的每一個,但看不出他們的行為有任何不同。 我的主要問題是,如果客戶需要,我想更改付款的默認來源。 所以客戶對象提供了一個 default_source 參數,但是當我更改它時它不會更改默認源。 我試圖將默認卡從卡更改為銀行,但它不起作用。 所以我想我誤解了 Payment Method、Sources、Card 和 Bank 對象的概念。

那么誰能解釋一下我必須如何使用這些不同的對象?

我在下面為您提供我的代碼。

我用於設置默認源的代碼(不會更改任何內容是 Stripe 儀表板):

 const customer = req.body.customer; const token = req.body.token; stripe.customers.update( customer, { default_source: token //token looks like btok_231disjaohq0dj21sp } ).then(customer => { res.send(customer); }).catch(err => { res.send(err); });

儀表板中沒有任何變化: 在此處輸入圖片說明

我創建銀行帳戶的代碼(有效):

 stripe.tokens.create({ bank_account: { country: 'US', currency: 'usd', account_holder_name: decoded.account_holder_name, account_holder_type: 'individual', routing_number: '110000000', account_number: '000123456789' } }).then(token => { stripe.customers.createSource( //there is .create and .createSource whats the difference? decoded.userId, { source: token.id } ).then(bank_account => { res.send(bank_account); }).catch(err => { res.send(err); }) }).catch(err => { res.send(err); });

我創建信用卡的代碼(有效):

 stripe.paymentMethods.create({ type: "card", card: { number: decoded.number, exp_month: decoded.month, exp_year: decoded.year, cvc: decoded.cvc } }).then(token => { stripe.paymentMethods.attach( token.id, { customer: decoded.customer, } ).then(card => { res.send(card); }).catch(err => { res.send(err); }); }).catch(err => { res.send(err); });

這些只是 Stripe 隨着時間的推移創建的不同對象/API。 支付方式是當前關注新產品和功能開發的 API。

如果您想了解一些進展背后的歷史和思想,這篇博文是一個很好的資源。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM