node-mangopay
Version:
mangopay package for payment implementation with nodejs
398 lines (334 loc) • 7.27 kB
Markdown
### What is this repository for? ###
* node-mangopay is npm package for implement payment gateway mangopay implementation.
### Documentation
* See documentation <a href="https://docs.mangopay.com/endpoints/v2.01/">https://docs.mangopay.com/endpoints/v2.01/</a>
### How do I get set up? ###
* npm install node-mangopay --save
* Two way of create instance of node-mangopay object
```javascript
var mangopay=require("node-mangopay")({
clientid:"*******", // Client id of mangopay
passphrase:"************************", //passphrase string
production:false, //optional by default is false
version:"v2.01" //optional by defaulr version is 2.01
});
* OR
var mangopay=require("node-mangopay");
var mango=new mangopay({
clientid:"*******",
passphrase:"************************",
production:false, //optional by default is false
version:"v2.01" //optional by defaulr version is 2.01
});
```
### Method used for mangopay implementation ###
* Create natural user
```javascript
var data={
FirstName: "Happy" // Required
,
LastName: "kaur" // Required
,
Birthday: 1300186358 // Required
,
Nationality: "FR" // Required - default: 'FR'
,
CountryOfResidence: "FR" // Required - default: 'FR'
,
Occupation: "Devoeloper",
IncomeRange: "6",
ProofOfIdentity: "",
ProofOfAddress: "",
PersonType: "NATURAL",
Email: "harry@gmail.com",
Tag: "custom tag",
Address: {
AddressLine1: "4101 Reservoir Rd NW",
AddressLine2: "",
City: "Washington",
Region: "District of Columbia",
PostalCode: "20007",
Country: "US"
}
};
mango.createNaturalUser(data,function(err,result){
if(err)
console.log(err);
else
console.log(result);
});
```
* Update natural user
```javascript
mango.updateNaturalUser({mangoPayId:"39273181",LastName:"xyz"},function(err,result){
if(err)
console.log(err);
else
console.log(result);
});
```
* view user
```javascript
mango.viewUser({
"mangoPayId": "1463440221",
},function(err,result){
if(err)
console.log(err);
else
console.log(result);
})
```
* get all user
```javascript
mango.listUsers({
"Page": 1,
"Per_Page": 25,
"Sort": "CreationDate:ASC",
"BeforeDate": 1463440221,
"AfterDate": 1431817821
},function(err,result){
if(err)
console.log(err);
else
console.log(result);
})
```
* create legal user
```javascript
var data={
"Tag": "custom meta",
"HeadquartersAddress": {
"AddressLine1": "1 test Street",
"AddressLine2": "The Loop",
"City": "Paris",
"Region": "Ile de France",
"PostalCode": "75001",
"Country": "FR"
},
"LegalPersonType": "BUSINESS",
"Name": "Test Ltd",
"LegalRepresentativeAddress": {
"AddressLine1": "1 test Street",
"AddressLine2": "The Loop",
"City": "Paris",
"Region": "Ile de France",
"PostalCode": "75001",
"Country": "FR"
},
"LegalRepresentativeBirthday": 1463496101,
"LegalRepresentativeCountryOfResidence": "ES",
"LegalRepresentativeNationality": "FR",
"LegalRepresentativeEmail": "test@gmail.com",
"LegalRepresentativeFirstName": "Joe",
"LegalRepresentativeLastName": "Blogs",
"Email": "test@gmail.com",
"CompanyNumber": "LU72HN11"
};
mango.createLegalUser(data,function(err,result){
if(err)
console.log(err);
else
console.log(result);
})
```
* update legal user
```javascript
var data={
"legalUserId":"1245211",
"Tag": "custom meta",
"Name":"Jon"
};
mango.updateLegalUser(data,function(err,result){
if(err)
console.log(err);
else
console.log(result);
})
```
* wallet functions
```javascript
mango.createWallet({
"Tag": "custom meta",
"Owners": [ "39273181" ], //mangopayID
"Description": "wallet description",
"Currency": "EUR"
},function(err,result){
if(err)
console.log(err);
else
console.log(result);
});
mango.viewWallet({
"walletId": "39280469",
},function(err,result){
if(err)
console.log(err);
else
console.log(result);
});
mango.updateWallet({
"walletId": "39280469",
"Tag": "custom meta",
},function(err,result){
if(err)
console.log(err);
else
console.log(result);
});
mango.listWallets({
"mangoPayId": "39280469",
},function(err,result){
if(err)
console.log(err);
else
console.log(result);
});
```
* card related functions (create card from node end)
```javascript
var data={
Tag:"create card",
mangoPayId:"39273181",
currency:"EUR",
cardType:"CB_VISA_MASTERCARD",
cardNumber:"497010000000015",
cardExpirationDate:"1020",
cardCvx:"123"
};
mango.createCardAuto(data,function(err,result){
if(err)
console.log(err);
else
console.log(result);
});
mango.viewCard({cardId:"39285307"},function(err,result){
if(err)
console.log(err);
else
console.log(result);
});
mango.userCards({mangoPayId:"39273181"},function(err,result){
if(err)
console.log(err);
else
console.log(result);
});
mango.deactivateCard({cardId:"39285307",active:false},function(err,result){
if(err)
console.log(err);
else
console.log(result);
});
```
* payin function
1 Create a Card Direct PayIn
```javascript
var data={
"Tag": "custom meta",
"AuthorId": "38976011",
"CreditedUserId": "38976011",
"CreditedWalletId": "38980242",
"DebitedFunds": {
"Currency": "EUR",
"Amount": 12
},
"Fees": {
"Currency": "EUR",
"Amount": 1
},
"SecureModeReturnURL": "http://www.my-site.com/returnURL",
"CardId": "38978448",
"SecureMode": "DEFAULT",
"StatementDescriptor": "Mar2017"
}
mango.cardDirectPayin(data,function(err,result){
if(err)
console.log(err);
else
console.log(result);
});
```
* Transfer Wallet to wallet
```javascript
var data={
"Tag": "custom meta",
"AuthorId": "38976011",
"CreditedUserId": "38976011",
"DebitedFunds": {
"Currency": "EUR",
"Amount": 12
},
"Fees": {
"Currency": "EUR",
"Amount": 12
},
"DebitedWalletId": "38980242",
"CreditedWalletId": "39280469"
}
mango.transferWallet(data,function(err,result){
if(err)
console.log(err);
else
console.log(result);
});
```
* add bank account
```javascript
mango.addBankIban({
"mangopayId":"38976011",
"Tag": "custom meta",
"OwnerAddress": {
"AddressLine1": "1 Mangopay Street",
"AddressLine2": "The Loop",
"City": "Paris",
"Region": "Ile de France",
"PostalCode": "75001",
"Country": "FR"
},
"OwnerName": "Joe Blogs",
"IBAN": "FR3020041010124530725S03383",
"BIC": "CRLYFRPP"
},function(err,result){
if(err)
console.log(err);
else
console.log(result);
});
```
* view bank detail
```javascript
mango.viewBank({
bankId:"39797690", // bankid
mangopayId:"38976011" // mango pay id
},function(err,result){
if(err)
console.log(err);
else
console.log(result);
});
```
* tranfer money from wallet to bank acount or payouts bankwire
```javascript
var opt={
"Tag": "Transferred money from wallet to your bank account",
"AuthorId": "38976011", //mangopay id
"DebitedFunds": {
"Currency": "EUR",
"Amount": 10
},
"Fees": {
"Currency": "EUR",
"Amount": 0
},
"BankAccountId": 39797690, //bank account id
"DebitedWalletId": 38980242, // wallet id
"BankWireRef": "invoice"
};
mango.bankPayout(opt,function(err,result){
if(err)
console.log(err);
else
console.log(result);
});
```
* owner or admin: Hermenpreet singh