This package is not official, it's a personal work but you can use it freely.
This project is deprecated since the official SDK for NodeJS has been released by MangoPay, please use the official MangoPay NodeJS SDK to have the latest features and security fixes.
To install the package, execute this command in the root of your project :
meteor add jalik:mangopay
If later you want to remove the package :
meteor remove jalik:mangopay
Execute once the code below using your own credentials and before any call to the API.
// Define which environment to use (sandbox or live)
MangoPaySDK.production = true;
// Define which version of the API to use
MangoPaySDK.apiVersion = 'v2';
// Define your credentials
MangoPaySDK.authenticate(clientId, clientPass);
MangoPaySDK.user.create(new MangoPaySDK.user.NaturalUser({
Birthday: timestamp,
Nationality: 'FR',
CountryOfResidence: 'FR',
Email: 'buyer@gmail.com',
FirstName: 'Big',
LastName: 'Buyer'
}), function (err, user) {
if (err || !user) {
console.error(err);
} else {
console.log(user);
}
});
MangoPaySDK.user.create(new MangoPaySDK.user.LegalUser({
Email: 'seller@gmail.com',
Name: 'Seller',
LegalPersonType: MangoPaySDK.user.personTypes.BUSINESS,
LegalRepresentativeFirstName: 'Big',
LegalRepresentativeLastName: 'Seller',
LegalRepresentativeBirthday: timestamp,
LegalRepresentativeNationality: 'FR',
LegalRepresentativeCountryOfResidence: 'FR'
}), function (err, user) {
if (err || !user) {
console.error(err);
} else {
console.log(user);
}
});
MangoPaySDK.user.update(userId, {
Email: 'newmail@gmail.com'
}, function (err, user) {
if (err || !user) {
console.error(err);
} else {
console.log(user);
}
});
MangoPaySDK.user.fetch(userId, function (err, user) {
if (err || !user) {
console.error(err);
} else {
console.log(user);
}
});
MangoPaySDK.user.list(params, function (err, list) {
if (err || !list) {
console.error(err);
} else {
console.log(list);
}
});
MangoPaySDK.user.bankAccounts(userId, params, function (err, list) {
if (err || !list) {
console.error(err);
} else {
console.log(list);
}
});
MangoPaySDK.user.cards(userId, params, function (err, list) {
if (err || !list) {
console.error(err);
} else {
console.log(list);
}
});
MangoPaySDK.user.documents(userId, params, function (err, list) {
if (err || !list) {
console.error(err);
} else {
console.log(list);
}
});
MangoPaySDK.user.transactions(userId, params, function (err, list) {
if (err || !list) {
console.error(err);
} else {
console.log(list);
}
});
MangoPaySDK.user.wallets(userId, params, function (err, list) {
if (err || !list) {
console.error(err);
} else {
console.log(list);
}
});
MangoPaySDK.wallet.create(new MangoPaySDK.wallet.Wallet({
Owners: [userId],
Currency: 'EUR',
Description: 'Buyer\'s wallet'
}), function (err, wallet) {
if (err || !wallet) {
console.error(err);
} else {
console.log(wallet);
}
});
MangoPaySDK.wallet.update(walletId, {
Description: 'Seller\'s wallet'
}, function (err, wallet) {
if (err || !wallet) {
console.error(err);
} else {
console.log(wallet);
}
});
MangoPaySDK.wallet.fetch(walletId, function (err, wallet) {
if (err || !wallet) {
console.error(err);
} else {
console.log(wallet);
}
});
MangoPaySDK.wallet.transactions(params, function (err, list) {
if (err || !list) {
console.error(err);
} else {
console.log(list);
}
});
MangoPaySDK.transfer.create(new MangoPaySDK.transfer.Transfer({
AuthorId: authorId,
DebitedWalletID: fromWalletId,
CreditedWalletID: toWalletId,
DebitedFunds: {Currency: "EUR", Amount: 50},
Fees: {Currency: "EUR", Amount: 10}
}), function (err, transfer) {
if (err || !transfer) {
console.error(err);
} else {
console.log(transfer);
}
});
MangoPaySDK.card.create(new MangoPaySDK.card.Card({
Currency: 'EUR',
CardType: MangoPaySDK.card.type.VISA_MASTERCARD,
UserId: userId,
CardNumber: 3569990000000140,
CardExpirationDate: 1016,
CardCvx: 123
}), function (err, cardRegistration) {
if (err || !cardRegistration || cardRegistration.Status !== MangoPaySDK.cardRegistraton.status.VALIDATED) {
console.error(err);
} else {
console.log(cardRegistration.CardId);
}
});
MangoPaySDK.card.update(cardId, {
Active: false
}, function (err, card) {
if (err || !card) {
console.error(err);
} else {
console.log(card);
}
});
MangoPaySDK.card.fetch(cardId, function (err, card) {
if (err || !card) {
console.error(err);
} else {
console.log(card);
}
});
MangoPaySDK.event.list(params, function (err, list) {
if (err || !list) {
console.error(err);
} else {
console.log(list);
}
});
MangoPaySDK.payin.create(new MangoPaySDK.payin.BankWire({
AuthorId: authorId,
CreditedWalletId: walletId,
DeclaredDebitedFunds: {
Currency: 'EUR',
Amount: 5000
},
DeclaredFees: {
Currency: 'EUR',
Amount: 0
}
}), function (err, payin) {
if (err || !payin) {
console.error(err);
} else {
console.log(payin);
}
});
MangoPaySDK.payin.create(new MangoPaySDK.payin.DirectDebit({
AuthorId: 8837505,
CreditedWalletId: 8837797,
ReturnUrl:'https://www.domain.com/return',
Culture:'FR',
DebitedFunds: {
Currency: 'EUR',
Amount: 5000
},
DeclaredFees: {
Currency: 'EUR',
Amount: 0
}
}), function (err, payin) {
if (err || !payin) {
console.error(err);
} else {
console.log(payin);
}
});
MangoPaySDK.payin.create(new MangoPaySDK.payin.PreAuthorizedAmount({
AuthorId: authorId,
PreauthorizationId: preAuthId,
CreditedWalletId: walletId,
DebitedFunds: {
Currency: 'EUR',
Amount: 5000
},
Fees: {
Currency: 'EUR',
Amount: 0
}
}), function (err, payin) {
if (err || !payin) {
console.error(err);
} else {
console.log(payin);
}
});
MangoPaySDK.payin.create(new MangoPaySDK.payin.TokenizedCard({
AuthorId: authorId,
CardId: cardId,
CreditedWalletId: walletId,
SecureModeReturnURL: 'https://www.domain.com/return',
DebitedFunds: {
Currency: 'EUR',
Amount: 5000
},
Fees: {
Currency: 'EUR',
Amount: 0
}
}), function (err, payin) {
if (err || !payin) {
console.error(err);
} else {
console.log(payin);
}
});
MangoPaySDK.payin.create(new MangoPaySDK.payin.WebForm({
AuthorId: authorId,
CreditedWalletId: walletId,
ReturnUrl: 'https://www.domain.com/return',
Culture: 'FR',
CardType: MangoPaySDK.card.type.VISA_MASTERCARD,
DebitedFunds: {
Currency: 'EUR',
Amount: 5000
},
Fees: {
Currency: 'EUR',
Amount: 1000
}
}), function (err, payin) {
if (err || !payin) {
console.error(err);
} else {
console.log(payin);
}
});
MangoPaySDK.payout.create(new MangoPaySDK.payout.BankWire({
AuthorId: authorId,
BankWireRef: 'Reward',
BankAccountId: bankAccountId,
DebitedWalletId: walletId,
DebitedFunds: {
Currency: 'EUR',
Amount: 6000
},
Fees: {
Currency: 'EUR',
Amount: 1000
}
}), function (err, payout) {
if (err || !payout) {
console.error(err);
} else {
console.log(payout);
}
});
MangoPaySDK.payout.fetch(payoutId, function (err, payout) {
if (err || !payout) {
console.error(err);
} else {
console.log(payout);
}
});
MangoPaySDK.hook.create(new MangoPaySDK.hook.Hook({
Url: 'http://www.domain.com/myhook',
EventType: MangoPaySDK.hook.eventType.PAYIN_NORMAL_CREATED
}), function (err, hook) {
if (err || !hook) {
console.error(err);
} else {
console.log(hook);
}
});
MangoPaySDK.hook.update(hookId, {
Tag: 'edited'
}, function (err, hook) {
if (err || !hook) {
console.error(err);
} else {
console.log(hook);
}
});
MangoPaySDK.hook.fetch(hookId, function (err, hook) {
if (err || !hook) {
console.error(err);
} else {
console.log(hook);
}
});
MangoPaySDK.hook.list(params, function (err, list) {
if (err || !list) {
console.error(err);
} else {
console.log(list);
}
});
https://docs.mangopay.com/api-references/pagination/ You can paginate list results like below.
var params = {page: 5, per_page: 25};
MangoPaySDK.hook.list(params, function (err, list) {
if (err || !list) {
console.error(err);
} else {
console.log(list);
}
});
https://docs.mangopay.com/api-references/sort-lists/ You can sort and filter list results like below.
var params = {Status: 'SUCCEEDED', Type: 'PAYIN'};
MangoPaySDK.user.transactions(userId, params, function (err, list) {
if (err || !list) {
console.error(err);
} else {
console.log(list);
}
});