Closed masterofdaemon closed 8 years ago
hi @masterofdaemon could provide the code you're using ? Otherwise, I just noticed that I forgot to mention in the doc how to set the sandbox or live mode, use the credential adapted to the mode you want :
// Use Live mode
MangoPaySDK.production = true;
// Or Sandbox mode
MangoPaySDK.production = false;
// Then authenticate
MangoPaySDK.authenticate(user, pass);
ok MangoPaySDK.production = true; was added but the same error: Your authorization do not allow you to access to this information and no matter what password, always the same, i'm think this is because auth method is outdate, and support is end
same here https://www.npmjs.com/package/mangopay, maybe i don't understand something about this service or his settings, docs is so not user-friendly...
@masterofdaemon I am sorry but I have no problem connecting to the API, please provide some code so I could help you setting up the SDK. (but do not post you real credentials).
Just to be sure :
Please do all the stuff in sandbox mode first.
e.preventDefault();
MangoPaySDK.production = true;
MangoPaySDK.authenticate('username', 'passwd');
MangoPaySDK.user.create(new MangoPaySDK.user.NaturalUser({
Birthday: new Date(e.target.age.value).getTime(),
Nationality: 'FR',
CountryOfResidence: 'FR',
Email: e.target.email.value,
FirstName: 'Big',
LastName: 'Buyer'
}), function(err, user) {
if (err || !user) {
console.error(err);
} else {
console.log(user);
}
});
1 i think so, but i must ask my client first 2 no, i can't login to sandbox, i can login to https://dashboard.mangopay.com
Are you executing this code on the client or the server ?
I see a e.preventDefault();
, you should not authenticate on the client 's browser but only on the server for security reasons.
Second thing, if you're integrating the SDK in an app, always use the sandbox, then test your app (payins, payouts, refunds...) then when it's good switch to live mode, because you can't clean (remove) test users or wallets from the live mangopay account.
Please try to login to the https://dashboard.sandbox.mangopay.com/ with the sandbox user/pass, then if you succeed, retry to authenticate with the SDK using the MangoPaySDK.production = false;
and the same user/pass to check if its good.
If not contact the mangopay support because maybe your account is not activated (sandbox or live).
ok thanks
You can also set MangoPayClient.debug = true;
to display in the console all HTTP requests and check if they're correct.
@masterofdaemon There is a quick way to check if your credentials are good using the demo : https://www.mangopay.com/demo/index.php?stepId=1
MangoPayClient.debug = true; MangoPaySDK.production = false; MangoPaySDK.authenticate('demo', 'SRbaqf9kwpjOxAYtE9tVFVBWAh2waeF7TX4TEcZ4jVFKbm1uaD'); MangoPaySDK.user.create(new MangoPaySDK.user.NaturalUser({ Birthday: new Date(e.target.age.value).getTime(), Nationality: 'FR', CountryOfResidence: 'FR', Email: e.target.email.value, FirstName: 'Big', LastName: 'Buyer' }), function(err, user) { if (err || !user) { console.error(err); } else { console.log(user); } });
and the same:
Error: Your authorization do not allow you to access to this information — jalik_mangopay.js:162
can u try? with this user pass? if from client just for test? it should work? or just server?
It works :
MangoPayClient.debug = true;
MangoPaySDK.production = false;
MangoPaySDK.authenticate('demo', 'SRbaqf9kwpjOxAYtE9tVFVBWAh2waeF7TX4TEcZ4jVFKbm1uaD');
MangoPaySDK.user.create(new MangoPaySDK.user.NaturalUser({}), function (err, user) {
console.log(arguments);
});
I get this arguments in the callback (normal) because the user is missing required fields :
{ '0': [Error: FirstName: The FirstName field is required., LastName: The LastName field is required., Birthday: The Birthday field is required., Nationality: The Nationality field is required., CountryOfResidence: The CountryOfResidence field is required., Email: The Email field is required.] }
oh ok
thank you
You cannot/shouldn't execute any calls to the API from the client because this involves that you authenticate in clear on the client side so anyone has full access to your account, and I think it's not possible to execute calls on the client because of CORS limitations.
i get it
How did you solve it ?
server: Meteor.startup(function() {...});
and i see required fields, just need to fill it
That's strange, I don't setup my API config in a Meteor.startup
block and it works. But happy to know that you found a way to make it work ! If you need anything else ask me, I'll try to answer ASAP.
i mean put it on server and auth is done, thank you very much
var res = {
Address:{
AddressLine1: e.target.address.value,
AddressLine2: e.target.address2.value,
City:e.target.city.value,
Country:e.target.country.value,
PostalCode:e.target.zip.value
}};
///res.Birthday = new Date(e.target.age.value).getTime();
res.Birthday = Math.round(+new Date(e.target.age.value)/1000);
res.Email = e.target.email.value;
res.Tag = e.target.tag.value;
res.FirstName = e.target.firstname.value;
res.LastName = e.target.lastname.value;
res.Nationality = e.target.nationality.value;
res.CountryOfResidence = e.target.residence.value;
Meteor.call('mango.addUserNatural', res);
and i get { '0': [Error: Address: Error reading string. Unexpected token: StartObject. Path 'Address', line 1, position 12.] }
when address is empty all ok
here from nodejs(more info): err { [MangoPayError: [object Object]] name: 'MangoPayError', message: { Message: 'One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.', Type: 'param_error', Id: '99b35040-1362-4f36-a3a8-5608264be095#1460123359', Date: 1460123360, errors: { Address: 'Error reading string. Unexpected token: StartObject. Path \'Address\', line 1, position 226.' } } } user { Message: 'One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.', Type: 'param_error', Id: '99b35040-1362-4f36-a3a8-5608264be095#1460123359', Date: 1460123360, errors: { Address: 'Error reading string. Unexpected token: StartObject. Path \'Address\', line 1, position 226.' } } res 400
Okay, the problem is that you are using fields corresponding to the API version v2.01
, but currently the MangoPaySDK is pointing to the version v2
of the API.
So I upgraded the package to allow you to set the version you want to use.
Please do a meteor update jalik:mangopay
, then define the API version following the code below :
// Set the API version to use
MangoPaySDK.apiVersion = 'v2.01';
// Set sandbox credentials
MangoPaySDK.authenticate('user', 'pass');
// Test to create a natural user with version 2.01 of the API
var user = {
Address: {
AddressLine1: 'ADR1',
AddressLine2: 'ADR2',
City: 'city',
Country: 'FR',
PostalCode: 'postalCode'
},
Birthday: Math.round((Date.now() - 3600 * 24 * 360 * 28) / 1000),
Email: 'email@test.com',
Tag: 'tag',
FirstName: 'fname',
LastName: 'lname',
Nationality: 'FR',
CountryOfResidence: 'FR'
};
MangoPaySDK.user.create(new MangoPaySDK.user.NaturalUser(user), function (err, result) {
if (err) {
console.error('ERROR:', err);
} else if (result) {
console.info('RESULT:', result);
}
});
i get this errors: Failed to load resource: the server responded with a status of 401 (Unauthorized) Error: Your authorization do not allow you to access to this information
passhare or password the same...