Mangopay / mangopay2-nodejs-sdk

Node.js SDK for MANGOPAY
https://www.npmjs.com/package/mangopay2-nodejs-sdk
MIT License
51 stars 38 forks source link

Initialising the SDK more than once overwrites previous init #222

Open cbarlow1993 opened 3 years ago

cbarlow1993 commented 3 years ago

When I initialise the MangoPay SDK more than once such as in the example below, all requests to the APIs using SDK will use the credentials of the last initiated object even if they are saved in different variables.

Here, I will always talk to the MangoPayOld account even when using the reference to the first variable. This prevents me from supporting more than 1 mangopay account with this SDK.

var mangopay = require('mangopay2-nodejs-sdk');

const MangoPay = new mangopay({
    clientId: process.env.MANGO_PAY_CLIENT,
    clientApiKey: process.env.MANGO_PAY_API_KEY,
    // Set the right production API url. If testing, omit the property since it defaults to sandbox URL
    baseUrl: process.env.MANGO_PAY_URL
});

export const MangoPayOld = new mangopay({
    clientId: process.env.OLD_MANGO_PAY_CLIENT,
    clientApiKey: process.env.OLD_MANGO_PAY_API_KEY,
    // Set the right production API url. If testing, omit the property since it defaults to sandbox URL
    baseUrl: process.env.MANGO_PAY_URL
});

export default MangoPay
mangomaxoasis commented 3 years ago

Hey @cbarlow1993 We're looking into it

cbarlow1993 commented 3 years ago

Hi @mangomaxoasis , did you manage to reproduce?

mangomaxoasis commented 3 years ago

Hi @cbarlow1993, The current config if meant for a sandbox/prod account set-up, To date it won't be possible to use several accounts with it at once Is this blocking for you?

SoloJr commented 3 years ago

Hi @cbarlow1993

Please refer to the question @mangomaxoasis asked above

Mircea