For one of the projects I am working on I need to limit to accept only debit cards refusing credit cards. I contacted Stripe and asked if they supported card type limitations and here is what they responded with:

While there’s no simple setting you can enable or API call that you can make to block certain card types, this can definitely be done with just a bit of programming in your back-end.

Once you’ve created a card token using Stripe.js (or Stripe Checkout), you’ll be able to see the card type by looking at the token object’s `funding` parameter. From here, you could programmatically decide if you want to charge that specific card based on the what that field is populated with. You can read more about token objects at:

https://stripe.com/docs/api#token_object-card-funding

I wonder if the module maintainers would be willing to accept my request for this new feature - to make it possible to limit payments based on the types of cards used by customers? If not I'd appreciate any hints on which exact function to override in a custom module to implement the above suggestion.

Comments

nickonom created an issue. See original summary.

nickonom’s picture

Issue summary: View changes

Removed personal information.

nickonom’s picture

Issue summary: View changes
nickonom’s picture

Here is simple patch for my use case:

534,548c534,540
< 
<     // According to https://stripe.com/docs/api#token_object-card-funding cards can be of credit, debit, prepaid and unknown types.
<     // For purpose of our project let's decline all card types except debit.
<     if ($card->funding != "debit") {
<       drupal_set_message(t('Only debit cards can be accepted. Please use a debit card.'), 'error');
<       drupal_goto('checkout');
<     } else {
<       // If the card is not declined or otherwise is error-free, we can save it.
<       if ($card && !empty($card->id)) {
<         $stripe_card_id = $card->id;
<         $stripe_customer_id = $card->customer;
<         $c['card'] = $stripe_card_id;
<         $c['customer'] = $stripe_customer_id;
<         $save_card = TRUE;
<       }
---
>     // If the card is not declined or otherwise is error-free, we can save it.
>     if ($card && !empty($card->id)) {
>       $stripe_card_id = $card->id;
>       $stripe_customer_id = $card->customer;
>       $c['card'] = $stripe_card_id;
>       $c['customer'] = $stripe_customer_id;
>       $save_card = TRUE;

which suffices for the purpose of our project. And I believe for general use case an admin section for setting card type limitation needs to be developed, so I am not filing the proper patch as it won't be accepted anyway.