Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm using Stripe for the first time an I'm little confused about the different APIs they provide. There is the Payment Method API which is the recommended one for handling payment methods for a customer but currently it supports only credit cards if I understand it correctly...

But I need different payment methods for example bank accounts. So for that Stripe provides the Card, Bank and Source object. Whats the different between them?

I tried each of them and couldn't see any difference in their behaviour. My main problem is that I want to change the default source for the payment if customer wants. So the customer object provides a default_source parameter but it doesn't change the default source when I change it. I tried to change the default from card to bank but it doesn't work. So I think I misunderstood the concept of the Payment Method, Sources, Card and Bank objects.

So can anyone explain me how I have to use these different objects?

I provide you my code below.

My code for setting default source (doesn't change anything is Stripe dashboard):

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);
});

Nothing changed in dashboard: enter image description here

My code to create a bank account (this works):

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);
    });

My code to create a credit card (works):

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);
    });
like image 206
Funkberater Avatar asked Jul 30 '19 14:07

Funkberater


People also ask

What is the difference between stripe and PayPal?

Stripe and PayPal are both reliable and secure payment gateways. These tools connect vendors and payment networks. Basically, these allow merchants to collect online payments. But if we're going to be specific, Stripe works differently than PayPal.

Is stripe a merchant or a bank account?

Although Stripe is technically a merchant account, there are some major differences in how the Stripes and Squares are structured versus traditional merchant account providers like your bank. Stripe’s technical structure is what’s called a Payment Facilitator, or “PayFac” for short.

What is the difference between the payment methods API and tokens?

Learn about the differences compared to Sources and Tokens. The Payment Methods API replaces the existing Tokens and Sources APIs as the recommended way for integrations to collect and store payment information. It works with the Payment Intents API to create payments for a wide range of payment methods.

Is stripe a good payment gateway for your website?

But while Stripe is an excellent payment gateway, it does have its limitations. For example, you can charge recurring payments via Stripe. But it lacks the robust subscription management features to handle such payment method. Plus, Stripe doesn't have features that can help you increase your website conversions.


1 Answers

These are merely different objects/APIs Stripe has created over time. Payment Methods are the current API where new product and feature development is focused.

If you want to learn some of the history and thinking behind the progression, this blog post is an excellent resource.

like image 194
Nolan H Avatar answered Oct 23 '22 16:10

Nolan H