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

Is Stripe SDK Classes compatible? #659

Closed
ledniy opened this issue Jul 21, 2019 · 1 comment
Closed

Is Stripe SDK Classes compatible? #659

ledniy opened this issue Jul 21, 2019 · 1 comment

Comments

@ledniy
Copy link

ledniy commented Jul 21, 2019

I just discovered that by default i can't extend Stripe Resources, it just keep the same behaviour. As i understand you don't using default prototype inheritance?

const Stripe = require('stripe');
const PaymentIntents = require('stripe/lib/resources/PaymentIntents');

class PaymentIntentsFloat extends PaymentIntents {
	create (data, options) {
		data.amount = convertAmountToSmallestDenomination(data.amount, data.currency);
		return super.create(data, options);
	}
}

class StripeWrapped extends Stripe {
	constructor(...args) {
		super(...args);
		this.paymentIntentsFloat = new PaymentIntentsFloat(this);
	}
}
@rattrayalex-stripe
Copy link
Contributor

Hi @ledniy ,

You are correct – you can't subclass stripe resources in this way currently. There are some other options for extending the stripe sdk, but I don't think I'd recommend them – probably better to create wrapper functions.

This may be possible when we add support for TS: #296

However, I don't anticipate that we will prioritize work here independently, so I'm going to close this. Will try to keep you posted here if we're able to move things to proper classes.

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