Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gn-api-sdk-node

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gn-api-sdk-node - npm Package Compare versions

Comparing version 0.0.3 to 0.0.5

CHANGELOG.md

16

docs/associate-customer.md

@@ -24,8 +24,12 @@ ## Associating customers to existing charges

.createCustomer(customerInput)
.then(function (customer) {
console.log('Response:', customer);
})
.catch(function (err) {
console.log('Error:', err);
});
.then(console.log)
.catch(console.log);
```
If everything went well, the return is just a response with code 200:
```js
{
"code": 200
}
```

@@ -39,10 +39,21 @@ ## Creating charge with a customer associated

.createCharge(chargeInput)
.then(function(charge) {
console.log('Response:', charge);
})
.catch(function(err) {
console.log('Error:', err);
});
.then(console.log)
.catch(console.log);
```
Check out the response:
```js
{
"code": 200,
"charge": {
"id": 253,
"total": 2000,
"status": "new",
"custom_id": null,
"created_at": "2015-05-18"
}
}
```
Observe that charges have an optional param inside `metadata` called `notification_url`. Each charge can have it's own `notification_url` that will be used for notifications once things happen with charges status, as when it's payment was approved, for example. More about notifications [here](https://github.com/franciscotfmc/gn-api-sdk-node/tree/master/docs/notifications.md).

@@ -37,8 +37,19 @@ ## Creating charges including shipping costs

.createCharge(chargeInput)
.then(function(charge) {
console.log('Response:', charge);
})
.catch(function(err) {
console.log('Error:', err);
});
.then(console.log)
.catch(console.log);
```
Check out the response:
```js
{
"code": 200,
"charge": {
"id": 252,
"total": 2220,
"status": "new",
"custom_id": null,
"created_at": "2015-05-18"
}
}
```

@@ -18,11 +18,38 @@ ## Detailing charges

.then(function (charge) {
console.log('Response:',
util.inspect(charge, false, null));
console.log(util.inspect(charge, false, null));
})
.catch(function (err) {
console.log('Error:', err);
})
.catch(console.log)
.done();
```
Check out the response:
```js
{
"code": 200,
"charge": {
"id": 233,
"subscription_id": 12,
"total": 2000,
"status": "new",
"custom_id": null,
"created_at": "2015-05-14",
"notification_url": "http://google.com",
"items": [
{
"name": "Product 1",
"value": 1000,
"amount": 2
}
],
"history": [
{
"status": "new",
"created_at": "2015-05-14 15:39:14"
}
]
}
}
```
## Detailing subscriptions

@@ -41,8 +68,29 @@

})
.catch(function (err) {
console.log('Error:', err);
})
.catch(console.log)
.done();
```
```js
{
"code": 200,
"subscription": {
"id": 12,
"value": 2000,
"status": "new",
"payment_method": null,
"interval": 1,
"repeats": 2,
"processed_amount": 0,
"created_at": "2015-05-14 15:39:14",
"history": [
{
"charge_id": 233,
"status": "new",
"created_at": "2015-05-14 15:39:14"
}
]
}
}
```
Note that if you detail a charge that belongs to a subscription, the response will have a subscription_id. If you need the subscription information, you can concat the calls like this:

@@ -49,0 +97,0 @@

@@ -46,3 +46,3 @@ 'use strict';

parcels: 1,
payment_token: '8047d6ee4633ad33d6db70ffd403d74bc70fb707',
payment_token: 'fec500b1f3eb16615ca61f7c4781f51dcde49131',
billing_address: {

@@ -63,11 +63,19 @@ street: 'Street 3',

var createCustomer = function (response) {
console.log('Charge:', response);
customerInput.charge_id = response.charge.id;
paymentInput.charge_id = response.charge.id;
return gerencianet.createCustomer(customerInput);
console.log(response);
if (response.code === 200) {
customerInput.charge_id = response.charge.id;
paymentInput.charge_id = response.charge.id;
return gerencianet.createCustomer(customerInput);
} else {
throw new Error();
}
}
var createPayment = function (response) {
console.log('Client', response);
return gerencianet.createPayment(paymentInput)
console.log(response);
if (response.code === 200) {
return gerencianet.createPayment(paymentInput)
} else {
throw new Error();
}
}

@@ -79,7 +87,3 @@

.then(createPayment)
.then(function (payment) {
console.log('Payment:', payment);
})
.catch(function (err) {
console.log('Error:', err);
});
.then(console.log)
.catch(console.log);

@@ -21,11 +21,16 @@ ## Notifications

.then(function (notification) {
console.log('Response:',
util.inspect(notification, false, null));
console.log(util.inspect(notification, false, null));
})
.catch(function (err) {
console.log('Error:', err);
})
.catch(console.log)
.done();
```
Response:
```js
{
"code": 200
}
```
Given that a charge has a valid `notification_url`, when the notification time comes you'll receive a post with a `token`. This token must be used to get the notification payload data.

@@ -44,10 +49,28 @@

.then(function (notification) {
console.log('Response:',
util.inspect(notification, false, null));
console.log(util.inspect(notification, false, null));
})
.catch(function (err) {
console.log('Error:', err);
})
.catch(console.log)
.done();
});
```
Response:
```js
{
"code": 200,
"charge": {
"id": 233,
"subscription_id": 12,
"total": 2000,
"status": "new",
"custom_id": null,
"created_at": "2015-05-14",
"history": [
{
"status": "new",
"timestamp": "2015-05-14 15:39:14"
}
]
}
}

@@ -30,4 +30,2 @@ ## Paying charges

var gerencianet = new Gerencianet(options);
gerencianet

@@ -94,4 +92,2 @@ .createPayment(paymentInput)

var gerencianet = new Gerencianet(options);
gerencianet

@@ -98,0 +94,0 @@ .createPayment(paymentInput)

@@ -35,10 +35,20 @@ ## Creating subscriptions

.createCharge(chargeInput)
.then(function(charge) {
console.log('Response:', charge);
})
.catch(function(err) {
console.log('Error:', err);
});
.then(console.log)
.catch(console.log);
```
```js
{
"code": 200,
"charge": {
"id": 259,
"subscription_id": 15,
"total": 1000,
"status": "new",
"custom_id": null,
"created_at": "2015-05-18"
}
}
```
## Canceling subscriptions

@@ -54,11 +64,13 @@

})
.then(function (subscription) {
console.log(subscription);
})
.catch(function (err) {
console.log('Error:', err);
})
.then(console.log)
.catch(console.log)
.done();
```
```js
{
"code": 200
}
```
The `customer` attribute above indicates who is triggering the cancellation, the customer or the one providing the service. In this case, the customer decided not to continue with the subscription.

@@ -5,4 +5,4 @@ 'use strict';

URL: {
production: 'http://localhost:4400',
sandbox: 'http://localhost:4400'
production: 'https://api.gerencianet.com.br',
sandbox: 'https://sandbox.gerencianet.com.br'
},

@@ -9,0 +9,0 @@ ENDPOINTS: {

{
"name": "gn-api-sdk-node",
"description": "Module for integration with Gerencianet API",
"version": "0.0.3",
"version": "0.0.5",
"author": "Francisco Carvalho <f.thiene@gmail.com>",

@@ -6,0 +6,0 @@ "license": "MIT",

# gn-api-sdk-node
A nodejs module for integration of your backend with the payment services
> A nodejs module for integration of your backend with the payment services
provided by [Gerencianet](http://gerencianet.com.br).

@@ -60,8 +60,5 @@

.createCharge(chargeInput)
.then(function(charge) {
console.log('Response:', charge);
})
.catch(function(err) {
console.log('Error:', err);
});
.then(console.log)
.catch(console.log)
.done();
```

@@ -107,2 +104,3 @@

- [Creating charges associated to customers](https://github.com/franciscotfmc/gn-api-sdk-node/tree/master/docs/charge-with-customer.md)
- [Creating charges with marketplace](https://github.com/franciscotfmc/gn-api-sdk-node/tree/master/docs/charge-with-marketplace.md)
- [Associating customers to charges subsequently](https://github.com/franciscotfmc/gn-api-sdk-node/tree/master/docs/associate-customer.md)

@@ -114,5 +112,10 @@ - [Subscriptions](https://github.com/franciscotfmc/gn-api-sdk-node/tree/master/docs/subscriptions.md)

- [Notifications](https://github.com/franciscotfmc/gn-api-sdk-node/tree/master/docs/notifications.md)
- [All in one](https://github.com/franciscotfmc/gn-api-sdk-node/tree/master/docs/all-in-one.md)
## Changelog
[CHANGELOG](https://github.com/franciscotfmc/gn-api-sdk-node/tree/master/CHANGELOG.md)
## License
[MIT](LICENSE)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc