Using the same library to process payment with 2 paymongo account
davidnjuko opened this issue · comments
Describe the bug
We are using this library to process payment with different paymongo account in the same application runtime. Cause of the Singleton design pattern we sometime don't have the ref to the expected Paymongo instance.
To Reproduce
paymongo1 = new Paymongo("secretKey1");
...
paymongo2 = new Paymongo("another_secretKey");
...
Expected behavior
The constructor should double check the existing instance API Key to avoid this
export default class Paymongo {
constructor (secret) {
if (!secret) throw new Error('API key is required!');
if (Paymongo.instance instanceof Paymongo) {
if (Paymongo.instance.secret === secret) {
return Paymongo.instance;
}
}
this.secret = secret;
Hi @davidnjuko this make sense, thank you for posting an issue. I'll see to it as soon as possible.
Hi @jofftiquez
Any news on this ?
@jofftiquez Do you plan to update this library or not ?
@jofftiquez Do you plan to update this library or not ?
PRs are welcome, thank you.