As you can see below, when pulling the sources back it's being filtered by ['object' => 'card']. This means that it will not return bank accounts. The issue with this method is that it is consumed by the deleteCards() method. This means that bank accounts are not removed by the deleteCards method, and if a customer deletes an association to a bank account, and attempts to re-add it, an exception is thrown that the bank account already exists for that customer.
$stripeCards = $this->asStripeCustomer()->sources->all(
// Only cards are returned here, bank accounts are not pulled
['object' => 'card'] + $parameters
);
We should probably add something to Cashier for explicitly removing bank accounts. Add a bankAccounts method to the Billable trait, and add a deleteBankAccounts method.
You could also remove the filtering and handle all objects as an ExternalAccount instead of handling them as the typical StripeCard class. You still have all the same data and functions available, they abstracted the concept of a payment method to an abstract class called ExternalAccount. The only difference is the data coming back from Stripe, but that can be parsed out using the object type of either 'card' or 'bank_account'. I hope I'm making some sense here.
I don't really know how this problem can happen with Cashier itself as you only add cards and not bank accounts. Do you add bank accounts yourself through the Stripe API?
I am able to get a token that represents a bank account by using a third party called Plaid. I use their front-end, which securely generates me a token, and I use that through Cashier. I just wanted to point out that you could technically use bank accounts with Cashier, and that it does seem to be favoring only using credit cards. This could be changed to manage payment methods in a more abstract way, that way I can manage my customers who pay with ACH without having to dig up the underlying Stripe API objects.
Ah ok so this is more of a feature request. At the moment Cashier indeed only supports cards but I can see that bank accounts might be of use to more people as well. I'll mark this as a feature request.
If you could manage to implement this in a clean way for the next major version then we could consider merging a PR in.
Small update: we've moved to the Payment Methods API in Cashier. Support for different methods is planned by Stripe but not available atm: https://stripe.com/docs/payments/payment-methods
so the limitation is Stripe
as a work-around would the following be feasible?
not sure at which point the user has to pay .. I guess it depends on how stripe is configured, ie. if you allow people to be behind their payments and still allow the subscription to be active or not.
wdyt?
@lsmith77 not sure sorry. We're just going to wait until Stripe provides support for bank accounts in their payment methods api.
FYI https://stripe.com/docs/payments/payment-methods was just updated.
following payment methods are now supported via the new API
@lsmith77 don't you mean "now" instead of "not"?
yes .. sorry for the typo. fixed it in the comment
Would it be a clean way to add the possibility for other payment methods by passing the type as parameter to the functions?
For example in the paymentMethods function replace ...
$paymentMethods = StripePaymentMethod::all(
['customer' => $this->stripe_id, 'type' => 'card'] + $parameters,
$this->stripeOptions()
);
... with ...
$paymentMethods = StripePaymentMethod::all(
['customer' => $this->stripe_id] + $parameters + ['type' => 'card'],
$this->stripeOptions()
);
so if you pass ['type' => 'sepa_debit'] it won't be replaced by type card.
Of course you would have to adjust the other functions as well.
@ZiIMoIN I'm more thinking of passing a second parameter to that method in an upcoming release like so:
public function paymentMethods($parameters = [], $type = 'card')
But we'd need to make sure that the rest of the methods indeed would still work. Like updateDefaultPaymentMethodFromStripe & fillPaymentMethodDetails.
Most helpful comment
Ah ok so this is more of a feature request. At the moment Cashier indeed only supports cards but I can see that bank accounts might be of use to more people as well. I'll mark this as a feature request.
If you could manage to implement this in a clean way for the next major version then we could consider merging a PR in.