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

Using the same library to process payment with 2 paymongo account #50

Open
davidnjuko opened this issue May 11, 2023 · 5 comments · May be fixed by #54
Open

Using the same library to process payment with 2 paymongo account #50

davidnjuko opened this issue May 11, 2023 · 5 comments · May be fixed by #54
Assignees
Labels
asap enhancement New feature or request

Comments

@davidnjuko
Copy link

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
Copy link
Author

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;

@jofftiquez
Copy link
Member

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

@jofftiquez jofftiquez self-assigned this May 11, 2023
@jofftiquez jofftiquez added enhancement New feature or request asap labels May 11, 2023
@davidnjuko
Copy link
Author

Hi @jofftiquez

Any news on this ?

@davidnjuko
Copy link
Author

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

@jofftiquez
Copy link
Member

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

PRs are welcome, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
asap enhancement New feature or request
Projects
None yet
2 participants