gerencianet 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -1
- data/README.md +6 -1
- data/docs/carnet-create-history.md +27 -0
- data/docs/carnet-detailing.md +6 -6
- data/docs/carnet-resend-parcel.md +27 -0
- data/docs/carnet-resend.md +26 -0
- data/docs/carnet-update.md +3 -3
- data/docs/carnets.md +13 -32
- data/docs/charge-create-history.md +27 -0
- data/docs/charge-detailing.md +3 -3
- data/docs/charge-payment.md +52 -5
- data/docs/charge-resend-billet.md +26 -0
- data/docs/charge-update.md +2 -2
- data/docs/charge-with-marketplace.md +1 -1
- data/docs/examples/create_carnet_history.rb +19 -0
- data/docs/examples/create_charge_history.rb +19 -0
- data/docs/examples/resend_billet.rb +19 -0
- data/docs/examples/resend_carnet.rb +19 -0
- data/docs/examples/resend_parcel.rb +20 -0
- data/docs/examples/update_parcel.rb +2 -2
- data/gerencianet.gemspec +1 -1
- data/lib/gerencianet/constants.rb +16 -0
- data/lib/gerencianet/endpoints.rb +6 -2
- data/lib/gerencianet/version.rb +1 -1
- metadata +13 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ee4946e22787a2e68db5e903200acd21d2d557b
|
4
|
+
data.tar.gz: 28523c4cb5e7a860f1518b2ceeb119911a3bb7ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a3a420dd6927b996b5953a0c55396792be78b4714e72cfa7d13bfb8e29675bcf8b9b9c86827dc668c8061bd74fcb3592e5ed5a2be07a74e446a0399202d370e
|
7
|
+
data.tar.gz: c85f93432d5d2cfc3098716c35e6e960fa4b199b458afe48bc0a5c9f296be8e86449d975e8c536515ee9e8c1b585be0eac9b7623a60f5f5a35aa9959234cd61a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
# 0.0.6
|
2
|
+
|
3
|
+
- Added: Carnet resend/history endpoints mapping
|
4
|
+
- Updated: Docs and examples
|
5
|
+
|
6
|
+
# 0.0.5
|
7
|
+
|
8
|
+
- Added: Charge history endpoint mapping
|
9
|
+
- Updated: Docs and examples
|
10
|
+
|
1
11
|
# 0.0.4
|
2
12
|
|
3
13
|
- Added: Custom http header
|
@@ -13,4 +23,4 @@
|
|
13
23
|
|
14
24
|
# 0.0.1
|
15
25
|
|
16
|
-
- Initial release
|
26
|
+
- Initial release
|
data/README.md
CHANGED
@@ -87,12 +87,17 @@ $ guard -n false -c
|
|
87
87
|
- [Paying a charge](https://github.com/gerencianet/gn-api-sdk-ruby/tree/master/docs/charge-payment.md)
|
88
88
|
- [Detailing charges](https://github.com/gerencianet/gn-api-sdk-ruby/tree/master/docs/charge-detailing.md)
|
89
89
|
- [Updating informations](https://github.com/gerencianet/gn-api-sdk-ruby/tree/master/docs/charge-update.md)
|
90
|
+
- [Resending billet](https://github.com/gerencianet/gn-api-sdk-ruby/tree/master/docs/charge-resend-billet.md)
|
91
|
+
- [Adding information to charge's history](https://github.com/gerencianet/gn-api-sdk-ruby/tree/master/docs/charge-create-history.md)
|
90
92
|
|
91
93
|
### Carnets
|
92
94
|
|
93
95
|
- [Creating carnets](https://github.com/gerencianet/gn-api-sdk-ruby/tree/master/docs/carnets.md)
|
94
96
|
- [Detailing carnets](https://github.com/gerencianet/gn-api-sdk-ruby/tree/master/docs/carnet-detailing.md)
|
95
97
|
- [Updating informations](https://github.com/gerencianet/gn-api-sdk-ruby/tree/master/docs/carnet-update.md)
|
98
|
+
- [Resending the carnet](https://github.com/gerencianet/gn-api-sdk-ruby/tree/master/docs/carnet-resend.md)
|
99
|
+
- [Resending carnet parcel](https://github.com/gerencianet/gn-api-sdk-ruby/tree/master/docs/carnet-resend-parcel.md)
|
100
|
+
- [Adding information to carnet's history](https://github.com/gerencianet/gn-api-sdk-ruby/tree/master/docs/carnet-create-history.md)
|
96
101
|
|
97
102
|
### Subscriptions
|
98
103
|
|
@@ -127,4 +132,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/gerenc
|
|
127
132
|
|
128
133
|
## License
|
129
134
|
|
130
|
-
The gem is available as open source under the terms of the [MIT License](LICENSE).
|
135
|
+
The gem is available as open source under the terms of the [MIT License](LICENSE).
|
@@ -0,0 +1,27 @@
|
|
1
|
+
## Adding information to carnet's history
|
2
|
+
|
3
|
+
It is possible to add information to the history of a carnet. These informations will be listed when [detailing a carnet](https://github.com/gerencianet/gn-api-sdk-ruby/tree/master/docs/carnet-detailing.md).
|
4
|
+
|
5
|
+
The process to add information to history is shown below:
|
6
|
+
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
params = {
|
10
|
+
id: 1000
|
11
|
+
}
|
12
|
+
|
13
|
+
body = {
|
14
|
+
description: "Info that will be added to carnet history"
|
15
|
+
}
|
16
|
+
|
17
|
+
gerencianet = Gerencianet.new(options)
|
18
|
+
gerencianet.create_carnet_history(params: params, body: body)
|
19
|
+
```
|
20
|
+
|
21
|
+
If everything goes well, the return will be:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
{
|
25
|
+
"code": 200
|
26
|
+
}
|
27
|
+
```
|
data/docs/carnet-detailing.md
CHANGED
@@ -17,18 +17,18 @@ The response you'll receive contains all the information about the carnet:
|
|
17
17
|
{
|
18
18
|
"code": 200,
|
19
19
|
"data": {
|
20
|
-
"carnet_id":
|
20
|
+
"carnet_id": 1000,
|
21
21
|
"status": "active",
|
22
22
|
"repeats": 4,
|
23
23
|
"cover": "https://visualizacao.gerencianet.com.br/emissao/28333_2385_ZEMAL5/A5CC-28333-61428-LEENA9/28333-61428-LEENA9",
|
24
|
-
"value":
|
24
|
+
"value": 8000,
|
25
25
|
"split_items": false,
|
26
26
|
"charges": [{
|
27
27
|
"charge_id": 357,
|
28
28
|
"parcel": "1",
|
29
29
|
"status": "waiting",
|
30
30
|
"value": 2000,
|
31
|
-
"expire_at": '
|
31
|
+
"expire_at": '2020-12-12',
|
32
32
|
"url": "https://visualizacao.gerencianet.com.br/emissao/28333_2385_ZEMAL5/A5CL-28333-61428-LEENA9/28333-61428-LEENA9",
|
33
33
|
"barcode": "00190.00009 01523.894002 00061.428181 1 64780000002000"
|
34
34
|
}, {
|
@@ -36,7 +36,7 @@ The response you'll receive contains all the information about the carnet:
|
|
36
36
|
"parcel": "2",
|
37
37
|
"status": "waiting",
|
38
38
|
"value": 2000,
|
39
|
-
"expire_at": '
|
39
|
+
"expire_at": '2021-01-12',
|
40
40
|
"url": "https://visualizacao.gerencianet.com.br/emissao/28333_2385_ZEMAL5/A5CL-28333-61428-LEENA9/28333-61429-CORZE4",
|
41
41
|
"barcode": "00190.00009 01523.894002 00061.428181 8 65090000002000"
|
42
42
|
}, {
|
@@ -44,7 +44,7 @@ The response you'll receive contains all the information about the carnet:
|
|
44
44
|
"parcel": "3",
|
45
45
|
"status": "waiting",
|
46
46
|
"value": 2000,
|
47
|
-
"expire_at": '
|
47
|
+
"expire_at": '2021-02-12',
|
48
48
|
"url": "https://visualizacao.gerencianet.com.br/emissao/28333_2385_ZEMAL5/A5CL-28333-61428-LEENA9/28333-61430-HIRRA4",
|
49
49
|
"barcode": "00190.00009 01523.894002 00061.428181 7 65400000002000"
|
50
50
|
}, {
|
@@ -52,7 +52,7 @@ The response you'll receive contains all the information about the carnet:
|
|
52
52
|
"parcel": "4",
|
53
53
|
"status": "waiting",
|
54
54
|
"value": 2000,
|
55
|
-
"expire_at": '
|
55
|
+
"expire_at": '2021-03-12',
|
56
56
|
"url": "https://visualizacao.gerencianet.com.br/emissao/28333_2385_ZEMAL5/A5CL-28333-61428-LEENA9/28333-61431-HIRRA4",
|
57
57
|
"barcode": "00190.00009 01523.894002 00061.428181 5 65400000002000"
|
58
58
|
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
### Resending carnet parcel
|
2
|
+
|
3
|
+
To resend the carnet parcel, the parcel must have a `waiting` status.
|
4
|
+
|
5
|
+
If the parcel contemplates this requirement, you just have to provide the carnet id, the parcel number and a email to resend it:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
params = {
|
9
|
+
id: 1000,
|
10
|
+
parcel: 1
|
11
|
+
}
|
12
|
+
|
13
|
+
body = {
|
14
|
+
email: 'oldbuck@gerencianet.com.br'
|
15
|
+
}
|
16
|
+
|
17
|
+
gerencianet = Gerencianet.new(options)
|
18
|
+
puts gerencianet.resend_parcel(params: params, body: body)
|
19
|
+
```
|
20
|
+
|
21
|
+
If everything goes well, the return will be:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
{
|
25
|
+
"code": 200
|
26
|
+
}
|
27
|
+
```
|
@@ -0,0 +1,26 @@
|
|
1
|
+
### Resending the carnet
|
2
|
+
|
3
|
+
To resend the carnet, it must have a `active` status.
|
4
|
+
|
5
|
+
If the carnet contemplates this requirement, you just have to provide the carnet id and a email to resend it:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
params = {
|
9
|
+
id: 1000
|
10
|
+
}
|
11
|
+
|
12
|
+
body = {
|
13
|
+
email: 'oldbuck@gerencianet.com.br'
|
14
|
+
}
|
15
|
+
|
16
|
+
gerencianet = Gerencianet.new(options)
|
17
|
+
puts gerencianet.resend_carnet(params: params, body: body)
|
18
|
+
```
|
19
|
+
|
20
|
+
If everything goes well, the return will be:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
{
|
24
|
+
"code": 200
|
25
|
+
}
|
26
|
+
```
|
data/docs/carnet-update.md
CHANGED
@@ -8,7 +8,7 @@ It's important to keep in mind that all the charges of the carnet will be update
|
|
8
8
|
|
9
9
|
```ruby
|
10
10
|
params = {
|
11
|
-
id:
|
11
|
+
id: 1000
|
12
12
|
}
|
13
13
|
|
14
14
|
body = {
|
@@ -34,11 +34,11 @@ Only parcels with status `waiting` or `unpaid` can have expiration date set or u
|
|
34
34
|
|
35
35
|
```ruby
|
36
36
|
params = {
|
37
|
-
id:
|
37
|
+
id: 1000,
|
38
|
+
parcel: 1
|
38
39
|
}
|
39
40
|
|
40
41
|
body = {
|
41
|
-
parcel: 1,
|
42
42
|
expire_at: "2020-12-12"
|
43
43
|
}
|
44
44
|
|
data/docs/carnets.md
CHANGED
@@ -2,13 +2,12 @@
|
|
2
2
|
|
3
3
|
Carnet is a payment method that generates a bundle of charges with the same payment information and customer.
|
4
4
|
|
5
|
-
In order to generate a carnet, you'll need the items, the customer and the number of repeats (or parcels).
|
5
|
+
In order to generate a carnet, you'll need the items, the customer, the expiration date of the first charge and the number of repeats (or parcels).
|
6
6
|
|
7
7
|
The carnets can also be generated with the `metadata` attribute, just like in the banking billet, containing the `notification_url` and/or `custom_id`
|
8
8
|
|
9
9
|
There are other optional params:
|
10
10
|
|
11
|
-
- `expiration date` of the first charge
|
12
11
|
- `post_office_service`, which tells if the carnet must be sent via post office service (to you or to your clients)
|
13
12
|
- `split_items`, identifying if the total value must be splitted among the charges (defaults to `false`)
|
14
13
|
- The carnet `instructions`
|
@@ -17,7 +16,6 @@ There are other optional params:
|
|
17
16
|
|
18
17
|
```ruby
|
19
18
|
body = {
|
20
|
-
expire_at: tomorrow.strftime,
|
21
19
|
items: [{
|
22
20
|
name: "Carnet Item 1",
|
23
21
|
value: 1000,
|
@@ -30,8 +28,8 @@ body = {
|
|
30
28
|
birth: "1977-01-15",
|
31
29
|
phone_number: "5144916523"
|
32
30
|
},
|
33
|
-
repeats:
|
34
|
-
|
31
|
+
repeats: 4,
|
32
|
+
expire_at: "2020-12-12"
|
35
33
|
}
|
36
34
|
```
|
37
35
|
|
@@ -39,7 +37,6 @@ body = {
|
|
39
37
|
|
40
38
|
```ruby
|
41
39
|
body = {
|
42
|
-
expire_at: tomorrow.strftime,
|
43
40
|
items: [{
|
44
41
|
name: "Carnet Item 1",
|
45
42
|
value: 1000,
|
@@ -52,7 +49,8 @@ body = {
|
|
52
49
|
birth: "1977-01-15",
|
53
50
|
phone_number: "5144916523"
|
54
51
|
},
|
55
|
-
repeats:
|
52
|
+
repeats: 4,
|
53
|
+
expire_at: "2020-12-12",
|
56
54
|
metadata: {
|
57
55
|
custom_id: "my_id",
|
58
56
|
notification_url: "http://yourdomain.com"
|
@@ -62,26 +60,6 @@ body = {
|
|
62
60
|
|
63
61
|
The `notification_url` property will be used for sending notifications once things happen with charges statuses, as when it's payment was approved, for example. More about notifications [here](https://github.com/gerencianet/gn-api-sdk-node/tree/master/docs/notifications.md). The `custom_id` property can be used to set your own reference to the carnet.
|
64
62
|
|
65
|
-
### Required properties:
|
66
|
-
|
67
|
-
```ruby
|
68
|
-
body = {
|
69
|
-
items: [{
|
70
|
-
name: "Carnet Item 1",
|
71
|
-
value: 1000,
|
72
|
-
amount: 2
|
73
|
-
}],
|
74
|
-
customer: {
|
75
|
-
name: "Gorbadoc Oldbuck",
|
76
|
-
email: "oldbuck@gerencianet.com.br",
|
77
|
-
cpf: "04267484171",
|
78
|
-
birth: "1977-01-15",
|
79
|
-
phone_number: "5144916523"
|
80
|
-
},
|
81
|
-
repeats: 4,
|
82
|
-
expire_at: "2020-12-12"
|
83
|
-
}
|
84
|
-
```
|
85
63
|
|
86
64
|
### Required properties plus post office service information **(optional)**:
|
87
65
|
|
@@ -102,6 +80,7 @@ body = {
|
|
102
80
|
phone_number: "5144916523"
|
103
81
|
},
|
104
82
|
repeats: 4,
|
83
|
+
expire_at: "2020-12-12",
|
105
84
|
post_office_service: {
|
106
85
|
send_to: "customer"
|
107
86
|
}
|
@@ -130,6 +109,7 @@ var body = {
|
|
130
109
|
phone_number: "5144916523"
|
131
110
|
},
|
132
111
|
repeats: 4,
|
112
|
+
expire_at: "2020-12-12",
|
133
113
|
split_items: true
|
134
114
|
}
|
135
115
|
```
|
@@ -153,6 +133,7 @@ body = {
|
|
153
133
|
phone_number: "5144916523"
|
154
134
|
},
|
155
135
|
repeats: 4,
|
136
|
+
expire_at: "2020-12-12",
|
156
137
|
instructions: [
|
157
138
|
"Pay only with money",
|
158
139
|
"Do not pay with gold"
|
@@ -172,14 +153,14 @@ Check out the response:
|
|
172
153
|
{
|
173
154
|
"code": 200,
|
174
155
|
"data": {
|
175
|
-
"carnet_id":
|
156
|
+
"carnet_id": 1000,
|
176
157
|
"cover": "https://visualizacao.gerencianet.com.br/emissao/28333_2385_ZEMAL5/A5CC-28333-61428-LEENA9/28333-61428-LEENA9",
|
177
158
|
"charges": [{
|
178
159
|
"charge_id": 357,
|
179
160
|
"parcel": "1",
|
180
161
|
"status": "waiting",
|
181
162
|
"value": 2000,
|
182
|
-
"expire_at": "
|
163
|
+
"expire_at": "2020-12-12",
|
183
164
|
"url": "https://visualizacao.gerencianet.com.br/emissao/28333_2385_ZEMAL5/A5CL-28333-61428-LEENA9/28333-61428-LEENA9",
|
184
165
|
"barcode": "00190.00009 01523.894002 00061.428181 1 64780000002000"
|
185
166
|
}, {
|
@@ -187,7 +168,7 @@ Check out the response:
|
|
187
168
|
"parcel": "2",
|
188
169
|
"status": "waiting",
|
189
170
|
"value": 2000,
|
190
|
-
"expire_at": "
|
171
|
+
"expire_at": "2021-01-12",
|
191
172
|
"url": "https://visualizacao.gerencianet.com.br/emissao/28333_2385_ZEMAL5/A5CL-28333-61428-LEENA9/28333-61429-CORZE4",
|
192
173
|
"barcode": "00190.00009 01523.894002 00061.428181 8 65090000002000"
|
193
174
|
}, {
|
@@ -195,7 +176,7 @@ Check out the response:
|
|
195
176
|
"parcel": "3",
|
196
177
|
"status": "waiting",
|
197
178
|
"value": 2000,
|
198
|
-
"expire_at": "
|
179
|
+
"expire_at": "2021-02-12",
|
199
180
|
"url": "https://visualizacao.gerencianet.com.br/emissao/28333_2385_ZEMAL5/A5CL-28333-61428-LEENA9/28333-61430-HIRRA4",
|
200
181
|
"barcode": "00190.00009 01523.894002 00061.428181 7 65400000002000"
|
201
182
|
}, {
|
@@ -203,7 +184,7 @@ Check out the response:
|
|
203
184
|
"parcel": "4",
|
204
185
|
"status": "waiting",
|
205
186
|
"value": 2000,
|
206
|
-
"expire_at": "
|
187
|
+
"expire_at": "2021-03-12",
|
207
188
|
"url": "https://visualizacao.gerencianet.com.br/emissao/28333_2385_ZEMAL5/A5CL-28333-61428-LEENA9/28333-61431-HIRRA4",
|
208
189
|
"barcode": "00190.00009 01523.894002 00061.428181 5 65400000002000"
|
209
190
|
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
## Adding information to charge's history
|
2
|
+
|
3
|
+
It is possible to add information to the history of a charge. These informations will be listed when [detailing a charge](https://github.com/gerencianet/gn-api-sdk-ruby/tree/master/docs/charge-detailing.md).
|
4
|
+
|
5
|
+
The process to add information to history is shown below:
|
6
|
+
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
params = {
|
10
|
+
id: 1253
|
11
|
+
}
|
12
|
+
|
13
|
+
body = {
|
14
|
+
description: "Info that will be added to charges history"
|
15
|
+
}
|
16
|
+
|
17
|
+
gerencianet = Gerencianet.new(options)
|
18
|
+
gerencianet.create_charge_history(params: params, body: body)
|
19
|
+
```
|
20
|
+
|
21
|
+
If everything goes well, the return will be:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
{
|
25
|
+
"code": 200
|
26
|
+
}
|
27
|
+
```
|
data/docs/charge-detailing.md
CHANGED
@@ -4,7 +4,7 @@ It's very simple to get details from a charge. You just need the id:
|
|
4
4
|
|
5
5
|
```ruby
|
6
6
|
params = {
|
7
|
-
id:
|
7
|
+
id: 1300
|
8
8
|
}
|
9
9
|
|
10
10
|
gerencianet = Gerencianet.new(options)
|
@@ -17,7 +17,7 @@ As response, you will receive all the information about the charge (including if
|
|
17
17
|
{
|
18
18
|
"code": 200,
|
19
19
|
"data": {
|
20
|
-
"charge_id":
|
20
|
+
"charge_id": 1300,
|
21
21
|
"subscription_id": 12,
|
22
22
|
"total": 2000,
|
23
23
|
"status": "new",
|
@@ -33,7 +33,7 @@ As response, you will receive all the information about the charge (including if
|
|
33
33
|
],
|
34
34
|
"history": [
|
35
35
|
{
|
36
|
-
"
|
36
|
+
"message": "Cobrança criada",
|
37
37
|
"created_at": "2015-05-14 15:39:14"
|
38
38
|
}
|
39
39
|
]
|
data/docs/charge-payment.md
CHANGED
@@ -13,7 +13,7 @@ require "date"
|
|
13
13
|
tomorrow = Date.today + 1
|
14
14
|
|
15
15
|
params = {
|
16
|
-
id:
|
16
|
+
id: 1253
|
17
17
|
}
|
18
18
|
|
19
19
|
body = {
|
@@ -41,7 +41,7 @@ You'll receive the payment info in the callback, such as the barcode and the bil
|
|
41
41
|
{
|
42
42
|
"code": 200,
|
43
43
|
"data": {
|
44
|
-
"charge_id":
|
44
|
+
"charge_id": 1253,
|
45
45
|
"total": 1150,
|
46
46
|
"payment": "banking_billet",
|
47
47
|
"barcode": "00190.00009 01523.894002 00059.161182 9 64350000001150",
|
@@ -108,7 +108,7 @@ body = {
|
|
108
108
|
}
|
109
109
|
|
110
110
|
params = {
|
111
|
-
id:
|
111
|
+
id: 1253
|
112
112
|
}
|
113
113
|
|
114
114
|
gerencianet = Gerencianet.new(options)
|
@@ -121,7 +121,7 @@ If everything went well, the response will come with the total value, installmen
|
|
121
121
|
{
|
122
122
|
"code": 200,
|
123
123
|
"data": {
|
124
|
-
"charge_id":
|
124
|
+
"charge_id": 1253,
|
125
125
|
"total": 1150,
|
126
126
|
"payment": "credit_card",
|
127
127
|
"installments": 1,
|
@@ -140,4 +140,51 @@ When in production, it will depend if your project is a web app or a mobile app.
|
|
140
140
|
|
141
141
|
For web apps you should follow this [guide](https://api.gerencianet.com.br/checkout/card). It basically consists of copying/pasting a script tag in your checkout page.
|
142
142
|
|
143
|
-
For mobile apps you should use this [SDK for Android](https://github.com/gerencianet/gn-api-sdk-android) or this [SDK for iOS](https://github.com/gerencianet/gn-api-sdk-ios).
|
143
|
+
For mobile apps you should use this [SDK for Android](https://github.com/gerencianet/gn-api-sdk-android) or this [SDK for iOS](https://github.com/gerencianet/gn-api-sdk-ios).
|
144
|
+
|
145
|
+
### 3. Discount by payment method
|
146
|
+
|
147
|
+
It is possible to set discounts based on payment. You just need to add an `discount` attribute within `banking_billet` or `credit_card` tags.
|
148
|
+
|
149
|
+
The snipet below shows how to do this for credit card payments.
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
|
153
|
+
body = {
|
154
|
+
payment: {
|
155
|
+
credit_card: {
|
156
|
+
installments: 1,
|
157
|
+
payment_token: "5739b06925244dd1ab8e0afa62389d5fb4ea2945",
|
158
|
+
billing_address: {
|
159
|
+
street: "Av. JK",
|
160
|
+
number: 909,
|
161
|
+
neighborhood: "Bauxita",
|
162
|
+
zipcode: "35400000",
|
163
|
+
city: "Ouro Preto",
|
164
|
+
state: "MG"
|
165
|
+
},
|
166
|
+
customer: {
|
167
|
+
name: "Gorbadoc Oldbuck",
|
168
|
+
email: "oldbuck@gerencianet.com.br",
|
169
|
+
cpf: "04267484171",
|
170
|
+
birth: "1977-01-15",
|
171
|
+
phone_number: "5144916523"
|
172
|
+
},
|
173
|
+
discount: {
|
174
|
+
type: "currency",
|
175
|
+
value: 1000
|
176
|
+
}
|
177
|
+
}
|
178
|
+
}
|
179
|
+
}
|
180
|
+
```
|
181
|
+
|
182
|
+
Discounts for banking billets works similar to credit cards. You just need to add the `discount` attribute.
|
183
|
+
|
184
|
+
The discount may be applied as percentage or with a previous calculated value.
|
185
|
+
|
186
|
+
The `type` property is used to specify how the discount will work. It may be set as *currency* or *percentage*.
|
187
|
+
|
188
|
+
The former will discount the amount specified in `value` property as *cents*, so, in the example above the amount paid by the customer will be `(Charge's value) - R$ 10,00`.
|
189
|
+
|
190
|
+
If the discount type is set to *percentage*, the amount will be `(Charge's value) - 10%`.
|
@@ -0,0 +1,26 @@
|
|
1
|
+
### Resending billet
|
2
|
+
|
3
|
+
To resend the charge's billet, the charge must have a `waiting` status, and the payment method chosen must be `banking_billet`.
|
4
|
+
|
5
|
+
If the charge contemplates these requirements, you just have to provide the charge id and a email to resend the billet:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
params = {
|
9
|
+
id: 1253
|
10
|
+
}
|
11
|
+
|
12
|
+
body = {
|
13
|
+
email: 'oldbuck@gerencianet.com.br'
|
14
|
+
}
|
15
|
+
|
16
|
+
gerencianet = Gerencianet.new(options)
|
17
|
+
puts gerencianet.resend_billet(params: params, body: body)
|
18
|
+
```
|
19
|
+
|
20
|
+
If everything goes well, the return will be:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
{
|
24
|
+
"code": 200
|
25
|
+
}
|
26
|
+
```
|
data/docs/charge-update.md
CHANGED
@@ -6,7 +6,7 @@ You can update the `custom_id` or the `notification_url` of a charge:
|
|
6
6
|
|
7
7
|
```ruby
|
8
8
|
params = {
|
9
|
-
id:
|
9
|
+
id: 1253
|
10
10
|
}
|
11
11
|
|
12
12
|
body = {
|
@@ -32,7 +32,7 @@ Only charges with status `waiting` or `unpaid` and with payment method `banking_
|
|
32
32
|
|
33
33
|
```ruby
|
34
34
|
params = {
|
35
|
-
id:
|
35
|
+
id: 1253
|
36
36
|
}
|
37
37
|
|
38
38
|
body = {
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "gerencianet"
|
2
|
+
require_relative "./credentials"
|
3
|
+
|
4
|
+
options = {
|
5
|
+
client_id: CREDENTIALS::CLIENT_ID,
|
6
|
+
client_secret: CREDENTIALS::CLIENT_SECRET,
|
7
|
+
sandbox: true
|
8
|
+
}
|
9
|
+
|
10
|
+
params = {
|
11
|
+
id: 1000
|
12
|
+
}
|
13
|
+
|
14
|
+
body = {
|
15
|
+
description: "This carnet is about a service"
|
16
|
+
}
|
17
|
+
|
18
|
+
gerencianet = Gerencianet.new(options)
|
19
|
+
puts gerencianet.create_carnet_history(params: params, body: body)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "gerencianet"
|
2
|
+
require_relative "./credentials"
|
3
|
+
|
4
|
+
options = {
|
5
|
+
client_id: CREDENTIALS::CLIENT_ID,
|
6
|
+
client_secret: CREDENTIALS::CLIENT_SECRET,
|
7
|
+
sandbox: true
|
8
|
+
}
|
9
|
+
|
10
|
+
params = {
|
11
|
+
id: 1000
|
12
|
+
}
|
13
|
+
|
14
|
+
body = {
|
15
|
+
description: "This charge was not fully paid"
|
16
|
+
}
|
17
|
+
|
18
|
+
gerencianet = Gerencianet.new(options)
|
19
|
+
puts gerencianet.create_charge_history(params: params, body: body)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "gerencianet"
|
2
|
+
require_relative "./credentials"
|
3
|
+
|
4
|
+
options = {
|
5
|
+
client_id: CREDENTIALS::CLIENT_ID,
|
6
|
+
client_secret: CREDENTIALS::CLIENT_SECRET,
|
7
|
+
sandbox: true
|
8
|
+
}
|
9
|
+
|
10
|
+
params = {
|
11
|
+
id: 1000
|
12
|
+
}
|
13
|
+
|
14
|
+
body = {
|
15
|
+
email: 'oldbuck@gerencianet.com.br'
|
16
|
+
}
|
17
|
+
|
18
|
+
gerencianet = Gerencianet.new(options)
|
19
|
+
puts gerencianet.resend_billet(params: params, body: body)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "gerencianet"
|
2
|
+
require_relative "./credentials"
|
3
|
+
|
4
|
+
options = {
|
5
|
+
client_id: CREDENTIALS::CLIENT_ID,
|
6
|
+
client_secret: CREDENTIALS::CLIENT_SECRET,
|
7
|
+
sandbox: true
|
8
|
+
}
|
9
|
+
|
10
|
+
params = {
|
11
|
+
id: 1000
|
12
|
+
}
|
13
|
+
|
14
|
+
body = {
|
15
|
+
email: 'oldbuck@gerencianet.com.br'
|
16
|
+
}
|
17
|
+
|
18
|
+
gerencianet = Gerencianet.new(options)
|
19
|
+
puts gerencianet.resend_carnet(params: params, body: body)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "gerencianet"
|
2
|
+
require_relative "./credentials"
|
3
|
+
|
4
|
+
options = {
|
5
|
+
client_id: CREDENTIALS::CLIENT_ID,
|
6
|
+
client_secret: CREDENTIALS::CLIENT_SECRET,
|
7
|
+
sandbox: true
|
8
|
+
}
|
9
|
+
|
10
|
+
params = {
|
11
|
+
id: 1000,
|
12
|
+
parcel: 1
|
13
|
+
}
|
14
|
+
|
15
|
+
body = {
|
16
|
+
email: 'oldbuck@gerencianet.com.br'
|
17
|
+
}
|
18
|
+
|
19
|
+
gerencianet = Gerencianet.new(options)
|
20
|
+
puts gerencianet.resend_parcel(params: params, body: body)
|
data/gerencianet.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.description = "A ruby gem for integration of your backend with the
|
17
17
|
payment services provided by Gerencianet"
|
18
18
|
|
19
|
-
spec.homepage = "
|
19
|
+
spec.homepage = "http://gerencianet.github.io/gn-api-sdk-ruby"
|
20
20
|
spec.license = "MIT"
|
21
21
|
|
22
22
|
spec.files = files
|
@@ -94,6 +94,22 @@ module Gerencianet
|
|
94
94
|
resend_billet: {
|
95
95
|
route: "/charge/:id/billet/resend",
|
96
96
|
method: "post"
|
97
|
+
},
|
98
|
+
create_charge_history: {
|
99
|
+
route: "/charge/:id/history",
|
100
|
+
method: "post"
|
101
|
+
},
|
102
|
+
resend_carnet: {
|
103
|
+
route: "/carnet/:id/resend",
|
104
|
+
method: "post"
|
105
|
+
},
|
106
|
+
resend_parcel: {
|
107
|
+
route: "/carnet/:id/parcel/:parcel/resend",
|
108
|
+
method: "post"
|
109
|
+
},
|
110
|
+
create_carnet_history: {
|
111
|
+
route: "/carnet/:id/history",
|
112
|
+
method: "post"
|
97
113
|
}
|
98
114
|
}
|
99
115
|
end
|
@@ -63,9 +63,14 @@ module Gerencianet
|
|
63
63
|
|
64
64
|
def authenticate
|
65
65
|
url = get_url({}, @endpoints[:authorize][:route])
|
66
|
+
headers = {
|
67
|
+
"accept" => "application/json",
|
68
|
+
"api-sdk" => "ruby-#{Gerencianet::VERSION}"
|
69
|
+
}
|
66
70
|
|
67
71
|
response =
|
68
72
|
HTTP
|
73
|
+
.headers(headers)
|
69
74
|
.basic_auth(auth_headers)
|
70
75
|
.post(url, json: auth_body)
|
71
76
|
|
@@ -79,8 +84,7 @@ module Gerencianet
|
|
79
84
|
def auth_headers
|
80
85
|
{
|
81
86
|
user: @options[:client_id],
|
82
|
-
pass: @options[:client_secret]
|
83
|
-
"api-sdk" => "ruby-#{Gerencianet::VERSION}"
|
87
|
+
pass: @options[:client_secret]
|
84
88
|
}
|
85
89
|
end
|
86
90
|
|
data/lib/gerencianet/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gerencianet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francisco Carvalho
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -171,11 +171,16 @@ files:
|
|
171
171
|
- bin/console
|
172
172
|
- bin/setup
|
173
173
|
- docs/all-in-one.md
|
174
|
+
- docs/carnet-create-history.md
|
174
175
|
- docs/carnet-detailing.md
|
176
|
+
- docs/carnet-resend-parcel.md
|
177
|
+
- docs/carnet-resend.md
|
175
178
|
- docs/carnet-update.md
|
176
179
|
- docs/carnets.md
|
180
|
+
- docs/charge-create-history.md
|
177
181
|
- docs/charge-detailing.md
|
178
182
|
- docs/charge-payment.md
|
183
|
+
- docs/charge-resend-billet.md
|
179
184
|
- docs/charge-update.md
|
180
185
|
- docs/charge-with-marketplace.md
|
181
186
|
- docs/charges.md
|
@@ -186,7 +191,9 @@ files:
|
|
186
191
|
- docs/examples/create_billet_payment.rb
|
187
192
|
- docs/examples/create_card_payment.rb
|
188
193
|
- docs/examples/create_carnet.rb
|
194
|
+
- docs/examples/create_carnet_history.rb
|
189
195
|
- docs/examples/create_charge.rb
|
196
|
+
- docs/examples/create_charge_history.rb
|
190
197
|
- docs/examples/create_plan.rb
|
191
198
|
- docs/examples/create_subscription.rb
|
192
199
|
- docs/examples/create_subscription_payment.rb
|
@@ -198,6 +205,9 @@ files:
|
|
198
205
|
- docs/examples/get_installments.rb
|
199
206
|
- docs/examples/get_notification.rb
|
200
207
|
- docs/examples/get_plans.rb
|
208
|
+
- docs/examples/resend_billet.rb
|
209
|
+
- docs/examples/resend_carnet.rb
|
210
|
+
- docs/examples/resend_parcel.rb
|
201
211
|
- docs/examples/update_billet.rb
|
202
212
|
- docs/examples/update_carnet_metadata.rb
|
203
213
|
- docs/examples/update_charge_metadata.rb
|
@@ -215,7 +225,7 @@ files:
|
|
215
225
|
- lib/gerencianet/endpoints.rb
|
216
226
|
- lib/gerencianet/status.rb
|
217
227
|
- lib/gerencianet/version.rb
|
218
|
-
homepage:
|
228
|
+
homepage: http://gerencianet.github.io/gn-api-sdk-ruby
|
219
229
|
licenses:
|
220
230
|
- MIT
|
221
231
|
metadata: {}
|