gerencianet 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/README.md +4 -45
  4. data/{docs/examples → examples}/.gitignore +0 -0
  5. data/{docs/examples → examples}/all_in_one.rb +0 -0
  6. data/{docs/examples → examples}/cancel_carnet.rb +0 -0
  7. data/{docs/examples → examples}/cancel_charge.rb +0 -0
  8. data/{docs/examples → examples}/cancel_parcel.rb +0 -0
  9. data/{docs/examples → examples}/cancel_subscription.rb +0 -0
  10. data/{docs/examples → examples}/create_billet_payment.rb +0 -0
  11. data/{docs/examples → examples}/create_card_payment.rb +0 -0
  12. data/{docs/examples → examples}/create_carnet.rb +0 -0
  13. data/{docs/examples → examples}/create_carnet_history.rb +0 -0
  14. data/{docs/examples → examples}/create_charge.rb +0 -0
  15. data/{docs/examples → examples}/create_charge_history.rb +0 -0
  16. data/{docs/examples → examples}/create_plan.rb +0 -0
  17. data/{docs/examples → examples}/create_subscription.rb +0 -0
  18. data/{docs/examples → examples}/create_subscription_payment.rb +0 -0
  19. data/{docs/examples → examples}/credentials.rb +0 -0
  20. data/{docs/examples → examples}/delete_plan.rb +0 -0
  21. data/{docs/examples → examples}/detail_carnet.rb +0 -0
  22. data/{docs/examples → examples}/detail_charge.rb +0 -0
  23. data/{docs/examples → examples}/detail_subscription.rb +0 -0
  24. data/{docs/examples → examples}/get_installments.rb +0 -0
  25. data/{docs/examples → examples}/get_notification.rb +0 -0
  26. data/{docs/examples → examples}/get_plans.rb +0 -0
  27. data/examples/link_charge.rb +27 -0
  28. data/{docs/examples → examples}/resend_billet.rb +0 -0
  29. data/{docs/examples → examples}/resend_carnet.rb +0 -0
  30. data/{docs/examples → examples}/resend_parcel.rb +0 -0
  31. data/{docs/examples → examples}/update_billet.rb +0 -0
  32. data/{docs/examples → examples}/update_carnet_metadata.rb +0 -0
  33. data/{docs/examples → examples}/update_charge_metadata.rb +0 -0
  34. data/{docs/examples → examples}/update_parcel.rb +0 -0
  35. data/{docs/examples → examples}/update_subscription_metadata.rb +0 -0
  36. data/gerencianet.gemspec +1 -0
  37. data/lib/gerencianet/constants.rb +4 -0
  38. data/lib/gerencianet/version.rb +1 -1
  39. metadata +54 -55
  40. data/docs/all-in-one.md +0 -92
  41. data/docs/carnet-cancel-parcel.md +0 -21
  42. data/docs/carnet-cancel.md +0 -20
  43. data/docs/carnet-create-history.md +0 -27
  44. data/docs/carnet-detailing.md +0 -61
  45. data/docs/carnet-resend-parcel.md +0 -27
  46. data/docs/carnet-resend.md +0 -26
  47. data/docs/carnet-update.md +0 -55
  48. data/docs/carnets.md +0 -165
  49. data/docs/charge-create-history.md +0 -27
  50. data/docs/charge-detailing.md +0 -42
  51. data/docs/charge-payment.md +0 -190
  52. data/docs/charge-resend-billet.md +0 -26
  53. data/docs/charge-update.md +0 -52
  54. data/docs/charge-with-marketplace.md +0 -54
  55. data/docs/charges.md +0 -75
  56. data/docs/installments.md +0 -108
  57. data/docs/notifications.md +0 -105
  58. data/docs/subscription-detailing.md +0 -56
  59. data/docs/subscription-payment.md +0 -100
  60. data/docs/subscription-update.md +0 -29
  61. data/docs/subscriptions.md +0 -69
@@ -1,190 +0,0 @@
1
- ## Paying charges
2
-
3
- There are two ways of giving sequence to a charge. You can generate a banking billet so it is payable until its due date, or can use the customer's credit card to submit the payment.
4
-
5
- ### 1. Banking billets
6
-
7
- Setting banking billet as a charge's payment method is simple. You have to use `banking_billet` as the payment method and inform the `charge_id`.
8
-
9
- ```ruby
10
- require "gerencianet"
11
- require "date"
12
-
13
- tomorrow = Date.today + 1
14
-
15
- params = {
16
- id: 1253
17
- }
18
-
19
- body = {
20
- payment: {
21
- banking_billet: {
22
- expire_at: tomorrow.strftime,
23
- customer: {
24
- name: "Gorbadoc Oldbuck",
25
- email: "oldbuck@gerencianet.com.br",
26
- cpf: "04267484171",
27
- birth: "1977-01-15",
28
- phone_number: "5144916523"
29
- }
30
- }
31
- }
32
- }
33
-
34
- gerencianet = Gerencianet.new(options)
35
- gerencianet.pay_charge(params: params, body: body)
36
- ```
37
-
38
- You'll receive the payment info in the callback, such as the barcode and the billet link:
39
-
40
- ```ruby
41
- {
42
- "code": 200,
43
- "data": {
44
- "charge_id": 1253,
45
- "total": 1150,
46
- "payment": "banking_billet",
47
- "barcode": "00190.00009 01523.894002 00059.161182 9 64350000001150",
48
- "link": "https://visualizacao.gerencianet.com.br/emissao/28333_2139_RRABRA7/A4XB-28333-59161-BRANAE4",
49
- "expire_at": "2015-05-21"
50
- }
51
- }
52
- ```
53
-
54
- If you want the banking billet to have extra instructions, it's possible to send a maximum of 4 different instructions with a maximum of 90 caracters, just as follows:
55
-
56
- ```ruby
57
- var body = {
58
- payment: {
59
- banking_billet: {
60
- expire_at: tomorrow.strftime,
61
- customer: {
62
- name: "Gorbadoc Oldbuck",
63
- email: "oldbuck@gerencianet.com.br",
64
- cpf: "04267484171",
65
- birth: "1977-01-15",
66
- phone_number: "5144916523"
67
- },
68
- instructions: [
69
- "Pay only with money",
70
- "Do not pay with gold"
71
- ]
72
- }
73
- }
74
- }
75
- ```
76
-
77
- ### 2. Credit card
78
-
79
- The most common payment method is to use a credit card in order to make things happen faster. Paying a charge with a credit card in Gerencianet is as simples as generating a banking billet, as seen above.
80
-
81
- The difference here is that we need to provide some extra information, as a `billing_address` and a `payment_token`. The former is used to make an anti-fraud analyze before accepting/appoving the payment, the latter identifies a credit card at Gerencianet, so that you don't need to bother about keeping track of credit card numbers. The `installments` attribute is self-explanatory.
82
-
83
- We'll talk about getting payment tokens later. For now, let's take a look at the snipet that does the work we're aiming for:
84
-
85
- ```ruby
86
- body = {
87
- payment: {
88
- credit_card: {
89
- installments: 1,
90
- payment_token: "5739b06925244dd1ab8e0afa62389d5fb4ea2945",
91
- billing_address: {
92
- street: "Av. JK",
93
- number: 909,
94
- neighborhood: "Bauxita",
95
- zipcode: "35400000",
96
- city: "Ouro Preto",
97
- state: "MG"
98
- },
99
- customer: {
100
- name: "Gorbadoc Oldbuck",
101
- email: "oldbuck@gerencianet.com.br",
102
- cpf: "04267484171",
103
- birth: "1977-01-15",
104
- phone_number: "5144916523"
105
- }
106
- }
107
- }
108
- }
109
-
110
- params = {
111
- id: 1253
112
- }
113
-
114
- gerencianet = Gerencianet.new(options)
115
- gerencianet.pay_charge(params: params, body: body)
116
- ```
117
-
118
- If everything went well, the response will come with the total value, installments number and the value of each installment:
119
-
120
- ```ruby
121
- {
122
- "code": 200,
123
- "data": {
124
- "charge_id": 1253,
125
- "total": 1150,
126
- "payment": "credit_card",
127
- "installments": 1,
128
- "installment_value": 1150
129
- }
130
- }
131
- ```
132
-
133
- ##### Payment tokens
134
-
135
- A `payment_token` represents a credit card number at Gerencianet.
136
-
137
- For testing purposes, you can go to your application playground in your Gerencianet's account. At the payment endpoint you'll see a button that generates one token for you. This payment token will point to a random test credit card number.
138
-
139
- When in production, it will depend if your project is a web app or a mobile app.
140
-
141
- For web apps you should follow this [guide](https://docs.gerencianet.com.br/#!/charges/checkout/card). It basically consists of copying/pasting a script tag in your checkout page.
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).
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%`.
@@ -1,26 +0,0 @@
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
- ```
@@ -1,52 +0,0 @@
1
- ## Updating charges
2
-
3
- ### Changing the metadata
4
-
5
- You can update the `custom_id` or the `notification_url` of a charge:
6
-
7
- ```ruby
8
- params = {
9
- id: 1253
10
- }
11
-
12
- body = {
13
- notification_url: "http://yourdomain.com",
14
- custom_id: "my_new_id"
15
- }
16
-
17
- gerencianet = Gerencianet.new(options)
18
- gerencianet.update_charge_metadata(params: params, body: body)
19
- ```
20
-
21
- If everything goes well, the return will be:
22
-
23
- ```ruby
24
- {
25
- "code": 200
26
- }
27
- ```
28
-
29
- ### Updating the expiration date of a billet
30
-
31
- Only charges with status `waiting` or `unpaid` and with payment method `banking_billet` can have the `expire_at` changed:
32
-
33
- ```ruby
34
- params = {
35
- id: 1253
36
- }
37
-
38
- body = {
39
- expire_at: "2020-12-12"
40
- }
41
-
42
- gerencianet = Gerencianet.new(options)
43
- gerencianet.update_billet(params: params, body: body)
44
- ```
45
-
46
- If everything goes well, the return will be:
47
-
48
- ```ruby
49
- {
50
- "code": 200
51
- }
52
- ```
@@ -1,54 +0,0 @@
1
- ## Creating charges with marketplace
2
-
3
- What if your web store contains products from many different sellers from many different segments? The user can complete a single purchase with products from more than one seller, right? Here enters marketplace.
4
-
5
- With some extra attributes, you can tell Gerencianet to pass on a percentage amount of the purchase total value to someone else.
6
-
7
- Create the input data:
8
-
9
- ```ruby
10
- body = {
11
- items: [{
12
- name: "Product A",
13
- value: 1000,
14
- amount: 1,
15
- marketplace: {
16
- repasses: [{
17
- payee_code: "GEZTAMJYHA3DAMBQGAYDAMRYGMZTGM",
18
- percentage: 2500
19
- },{
20
- payee_code: "AKSLJI3DAMBQGSKLJDYDAMRTGOPWKS",
21
- percentage: 2500
22
- }]
23
- }
24
- }],
25
- metadata: {
26
- notification_url: "http://yourdomain.com"
27
- }
28
- }
29
- ```
30
-
31
- Create the charge:
32
-
33
- ```ruby
34
- gerencianet.create_charge(body: body)
35
- ```
36
-
37
- The attribute `payee_code` identifies a Gerencianet account, just like in [creating charges with shippings](https://github.com/gerencianet/gn-api-sdk-node/tree/master/docs/charge-with-shippings.md). In order to get someone else's `payee_code` you need to ask the account owner. There is no other way. To visualize yours, log in your Gerencianet account and search for *Identificador de Conta* under *Dados Cadastrais*.
38
-
39
- In the example above, there are two repasses, both of 25%, but each one for a different account, whereas the `payee_code` differs. The integrator account will receive, at the end, 50% of the total value. Disregarding the rates, the integrator account would receive R$5,00. The other two accounts would receive R$ 2,50 each.
40
-
41
- The response is the sames as usual:
42
-
43
- ```ruby
44
- {
45
- "code": 200,
46
- "data": {
47
- "charge_id": 1254,
48
- "total": 10000,
49
- "status": "new",
50
- "custom_id": null,
51
- "created_at": "2015-05-18"
52
- }
53
- }
54
- ```
@@ -1,75 +0,0 @@
1
- ## Creating charges
2
-
3
- Charges have one or more items. That's it.
4
-
5
- ```ruby
6
- body = {
7
- items: [{
8
- name: "Product 1",
9
- value: 1000,
10
- amount: 2
11
- }]
12
- }
13
- ```
14
-
15
-
16
- ### Adding shipping costs to a charge **(optional)**:
17
-
18
- In order to be the most agnostic as possible about how the user handles shippings, the API just receives an array with the values. You can add as many as you want. Sometimes you'll want a shipping cost to be received by another person/account. In this case, you must provide the `payee_code`. The *Additional Shipping* in the example below will be passed on to the referenced account after the payment.
19
-
20
- ```ruby
21
- body = {
22
- items: [{
23
- name: "Product A",
24
- value: 1000,
25
- amount: 2
26
- }],
27
- shippings: [{
28
- name: "Default Shipping",
29
- value: 100
30
- }, {
31
- name: "Additional Shipping",
32
- value: 120,
33
- payee_code: "GEZTAMJYHA3DAMBQGAYDAMRYGMZTGMBRGI"
34
- }]
35
- }
36
- ```
37
-
38
- ### Charge `metadata` attribute:
39
-
40
- ```ruby
41
- body = {
42
- items: [{
43
- name: "Product A",
44
- value: 1000,
45
- amount: 2
46
- }],
47
- metadata: {
48
- custom_id: "my_id",
49
- notification_url: "http://yourdomain.com"
50
- }
51
- }
52
- ```
53
-
54
- 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 charge.
55
-
56
- ### Finally, create the charge:
57
-
58
- ```ruby
59
- gerencianet.create_charge(body: body)
60
- ```
61
-
62
- Check out the response:
63
-
64
- ```ruby
65
- {
66
- "code": 200,
67
- "data": {
68
- "charge_id": 1253,
69
- "total": 2000,
70
- "status": "new",
71
- "custom_id": null,
72
- "created_at": "2015-05-18 14:56:39"
73
- }
74
- }
75
- ```
@@ -1,108 +0,0 @@
1
- ## Listing installments
2
-
3
- If you ever need to get the total value for a charge, including rates and interests, as well as each installment value, even before the payment itself, you can.
4
-
5
- Why would I need this?
6
-
7
- Sometimes you need to check the total for making a discount, or simple to show a combobox with the installments for your users.
8
-
9
- Stop bragging about. Here is the code:
10
-
11
- ```ruby
12
- params = {
13
- brand: "visa",
14
- total: 5000
15
- }
16
-
17
- gerencianet = Gerencianet.new(options)
18
- gerencianet.get_installments(params: params)
19
- ```
20
-
21
- And the response:
22
-
23
- ```ruby
24
- {
25
- "code": 200,
26
- "data": {
27
- "rate": 150,
28
- "interest_percentage": 0,
29
- "name": "visa",
30
- "installments": [
31
- {
32
- "installment": 1,
33
- "has_interest": false,
34
- "value": 5150,
35
- "currency": "51,50"
36
- },
37
- {
38
- "installment": 2,
39
- "has_interest": true,
40
- "value": 2679,
41
- "currency": "26,79"
42
- },
43
- {
44
- "installment": 3,
45
- "has_interest": true,
46
- "value": 1821,
47
- "currency": "18,21"
48
- },
49
- {
50
- "installment": 4,
51
- "has_interest": true,
52
- "value": 1393,
53
- "currency": "13,93"
54
- },
55
- {
56
- "installment": 5,
57
- "has_interest": true,
58
- "value": 1137,
59
- "currency": "11,37"
60
- },
61
- {
62
- "installment": 6,
63
- "has_interest": true,
64
- "value": 966,
65
- "currency": "9,66"
66
- },
67
- {
68
- "installment": 7,
69
- "has_interest": true,
70
- "value": 845,
71
- "currency": "8,45"
72
- },
73
- {
74
- "installment": 8,
75
- "has_interest": true,
76
- "value": 754,
77
- "currency": "7,54"
78
- },
79
- {
80
- "installment": 9,
81
- "has_interest": true,
82
- "value": 683,
83
- "currency": "6,83"
84
- },
85
- {
86
- "installment": 10,
87
- "has_interest": true,
88
- "value": 627,
89
- "currency": "6,27"
90
- },
91
- {
92
- "installment": 11,
93
- "has_interest": true,
94
- "value": 581,
95
- "currency": "5,81"
96
- },
97
- {
98
- "installment": 12,
99
- "has_interest": true,
100
- "value": 544,
101
- "currency": "5,44"
102
- }
103
- ]
104
- }
105
- }
106
- ```
107
-
108
- Observe that the response comes with an installments array of 12 positions at maximum. Each position matches one possible option of installment number, containing its value in currency and integer forms. The number of installments will vary according to the selected brand. Use it any way that suits your needs.