node.js - Stripe : Whats the different between Source vs. 卡 vs. 银行 vs 付款方式?

标签 node.js stripe-payments payment-gateway

我是第一次使用 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);
});


仪表板中没有任何变化:
enter image description here

我创建银行帐户的代码(有效):

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。
如果您想了解一些进展背后的历史和思想,this blog post 是一个很好的资源。

关于node.js - Stripe : Whats the different between Source vs. 卡 vs. 银行 vs 付款方式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57273558/

相关文章:

mysql - 'Escaping query values'在sql中如何安全? (或者为什么它是危险的?)[SQL 注入(inject)]

javascript - 在 Ember/handlebars 应用程序中显示 JS 脚本组件

paypal - 如何使用 Paypal 或 Stripe 自动为帐户充值

node.js - 响应 5002 : PDF damaged

node.js - Express 框架和 Promises - 从路由处理程序返回什么?

javascript - 将配置文件添加到我的 JavaScript 项目

stripe-payments - LIVE 模式下的 strip 测试

ios7 - iOS 7 是否支持 Apple pay 或 iOS 中是否有任何其他基于支付的良好 API?

payment-gateway - 使用支付网关和 PCI 合规性

forms - 使用带有 Paypal API 的 Drupal Form 为选定的计划类型单独支付集成