Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pocesar/node-moip2
Typescript para Moip API 2.0
https://github.com/pocesar/node-moip2
Last synced: 17 days ago
JSON representation
Typescript para Moip API 2.0
- Host: GitHub
- URL: https://github.com/pocesar/node-moip2
- Owner: pocesar
- License: gpl-3.0
- Created: 2015-04-27T00:05:16.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-12-03T17:49:55.000Z (almost 6 years ago)
- Last Synced: 2024-10-18T06:28:14.242Z (27 days ago)
- Language: TypeScript
- Size: 92.8 KB
- Stars: 5
- Watchers: 2
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![npm version](https://badge.fury.io/js/%40pocesar%2Fmoip2.svg)](https://badge.fury.io/js/%40pocesar%2Fmoip2)
# Moip 2
Typescript Moip API 2.0 para Node.js
## Install
```
$ npm install @pocesar/moip2 --save
```## Usage
```js
var Moip = require('@pocesar/moip2').Moip;var moip = new Moip('token', 'chave', true);
moip.createCustomer({
birthDate: '0000-00-00',
email: '[email protected]',
fullname: 'Full Name',
ownId: 'ownUserId',
phone: {
areaCode: '00',
countryCode: '00',
number: '00000000'
},
taxDocument: {
number: '00000000',
type: 'CPF'
},
shippingAddress:{
city: 'Cidade',
complement: 'Complemento',
country: 'BRA',
district: 'Bairro',
state: 'XX',
street: 'RUA',
streetNumber: 'NUMERO',
zipCode: '00000000'
}
}).then(function(customer){
delete customer._links;return this.createOrder({
amount: {
currency: 'BRL',
subtotals: {}
},
customer: customer,
items: [{
detail: '',
price: 50000,
product: 'Compra',
quantity: 1
}],
ownId: 'ownOrderId'
});
}).then(function(order){return this.createPayment({
fundingInstrument: {
method: 'BOLETO',
boleto: {
expirationDate: '2015-05-12',
instructionLines: {
first: 'first',
second: 'second',
third: 'thid'
}
}
}
}, order.id);
}).then(function(payment){
console.log('Sucesso!', payment);
}).catch('MoipError', function(err){
err.errors.forEach(function(e){
console.log(e.code + ' > ' + e.path + ' > ' + e.description);
});
}).catch(console.error.bind(console));
```## Debug
Setting the `DEBUG=moip2,moip2:full` environment variable will make the library display all the requests being made
## License
GPLv3