Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to choose accepting card types #20

Open
Jafferwaffer opened this issue Nov 2, 2016 · 4 comments
Open

Ability to choose accepting card types #20

Jafferwaffer opened this issue Nov 2, 2016 · 4 comments

Comments

@Jafferwaffer
Copy link

Jafferwaffer commented Nov 2, 2016

The functionality to allow setting of which cards can be used already exists in Payment.js, see this commit jessepollak/payment@d9ddf82. Can we please get this exposed?

@JohnyDays
Copy link
Owner

You can require("payment") and call those functions yourself 😄

@Jafferwaffer
Copy link
Author

This doesn't seem to work.

The Payment card array has the cards removed that I remove in the constructor, but the Card component doesn't use this Payment and so these cards still show.

Here is a snippet of my code:

import React from 'react';
import Card from 'react-credit-card';
import Payment from 'payment';

class CreditCard extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      currentFocus: null
    };

    Payment.removeFromCardArray('dinersclub');
    Payment.removeFromCardArray('laser');
    Payment.removeFromCardArray('jcb');
    Payment.removeFromCardArray('unionpay');
    Payment.removeFromCardArray('discover');
  }

  render() {
    return (
      <Card
       cvc={securityCode}
       name={name}
       number={number}
       focused={this.state.currentFocus}
       expiry={expiry}
       />
    );
  }
}

export default CreditCard;

@JohnyDays
Copy link
Owner

I'll test it out later, though if that doesn't work I'm not sure what can be done, since I assume Payment is a shared singleton.

@JohnyDays JohnyDays reopened this Nov 4, 2016
@Jafferwaffer
Copy link
Author

For anyone having a similar problem you can simply override the CSS for the classes of card types you do not accept.
As this solved my issue feel free to close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants