paymongo icon indicating copy to clipboard operation
paymongo copied to clipboard

Using the same library to process payment with 2 paymongo account

Open davidnjuko opened this issue 2 years ago • 5 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

davidnjuko avatar May 11 '23 12:05 davidnjuko

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;

davidnjuko avatar May 11 '23 12:05 davidnjuko

Hi @davidnjuko this make sense, thank you for posting an issue. I'll see to it as soon as possible.

jofftiquez avatar May 11 '23 18:05 jofftiquez

Hi @jofftiquez

Any news on this ?

davidnjuko avatar Jul 24 '23 12:07 davidnjuko

@jofftiquez Do you plan to update this library or not ?

davidnjuko avatar Oct 18 '23 09:10 davidnjuko

@jofftiquez Do you plan to update this library or not ?

PRs are welcome, thank you.

jofftiquez avatar Oct 19 '23 23:10 jofftiquez