mercadopago-sdk 1.3.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +10 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +28 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.md +19 -0
  5. data/.github/workflows/ruby.yml +35 -0
  6. data/.rubocop.yml +1 -0
  7. data/.rubocop_todo.yml +104 -0
  8. data/.ruby-version +1 -0
  9. data/CODE_OF_CONDUCT.md +74 -0
  10. data/CODING_GUIDELINES.md +70 -0
  11. data/CONTRIBUTING.md +57 -0
  12. data/Gemfile +6 -1
  13. data/Gemfile.lock +45 -17
  14. data/LICENSE.txt +21 -0
  15. data/README.md +51 -27
  16. data/Rakefile +3 -1
  17. data/docs/CODE_OF_CONDUCT_md.html +154 -0
  18. data/docs/CODING_GUIDELINES_md.html +188 -0
  19. data/docs/CONTRIBUTING_md.html +165 -0
  20. data/docs/LICENSE_txt.html +96 -0
  21. data/docs/Mercadopago.html +123 -0
  22. data/docs/Mercadopago/AdvancedPayment.html +279 -0
  23. data/docs/Mercadopago/Card.html +204 -0
  24. data/docs/Mercadopago/CardToken.html +160 -0
  25. data/docs/Mercadopago/Config.html +266 -0
  26. data/docs/Mercadopago/Customer.html +228 -0
  27. data/docs/Mercadopago/DisbursementRefund.html +183 -0
  28. data/docs/Mercadopago/HttpClient.html +249 -0
  29. data/docs/Mercadopago/IdentificationType.html +136 -0
  30. data/docs/Mercadopago/MPBase.html +316 -0
  31. data/docs/Mercadopago/MerchantOrder.html +209 -0
  32. data/docs/Mercadopago/Payment.html +208 -0
  33. data/docs/Mercadopago/PaymentMethods.html +136 -0
  34. data/docs/Mercadopago/Preference.html +184 -0
  35. data/docs/Mercadopago/Refund.html +160 -0
  36. data/docs/Mercadopago/RequestOptions.html +433 -0
  37. data/docs/Mercadopago/SDK.html +528 -0
  38. data/docs/Mercadopago/User.html +136 -0
  39. data/docs/README_md.html +181 -0
  40. data/docs/created.rid +25 -0
  41. data/docs/css/fonts.css +167 -0
  42. data/docs/css/rdoc.css +619 -0
  43. data/docs/fonts/Lato-Light.ttf +0 -0
  44. data/docs/fonts/Lato-LightItalic.ttf +0 -0
  45. data/docs/fonts/Lato-Regular.ttf +0 -0
  46. data/docs/fonts/Lato-RegularItalic.ttf +0 -0
  47. data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
  48. data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
  49. data/docs/images/add.png +0 -0
  50. data/docs/images/arrow_up.png +0 -0
  51. data/docs/images/brick.png +0 -0
  52. data/docs/images/brick_link.png +0 -0
  53. data/docs/images/bug.png +0 -0
  54. data/docs/images/bullet_black.png +0 -0
  55. data/docs/images/bullet_toggle_minus.png +0 -0
  56. data/docs/images/bullet_toggle_plus.png +0 -0
  57. data/docs/images/date.png +0 -0
  58. data/docs/images/delete.png +0 -0
  59. data/docs/images/find.png +0 -0
  60. data/docs/images/loadingAnimation.gif +0 -0
  61. data/docs/images/macFFBgHack.png +0 -0
  62. data/docs/images/package.png +0 -0
  63. data/docs/images/page_green.png +0 -0
  64. data/docs/images/page_white_text.png +0 -0
  65. data/docs/images/page_white_width.png +0 -0
  66. data/docs/images/plugin.png +0 -0
  67. data/docs/images/ruby.png +0 -0
  68. data/docs/images/tag_blue.png +0 -0
  69. data/docs/images/tag_green.png +0 -0
  70. data/docs/images/transparent.png +0 -0
  71. data/docs/images/wrench.png +0 -0
  72. data/docs/images/wrench_orange.png +0 -0
  73. data/docs/images/zoom.png +0 -0
  74. data/docs/index.html +109 -0
  75. data/docs/js/darkfish.js +84 -0
  76. data/docs/js/navigation.js +105 -0
  77. data/docs/js/navigation.js.gz +0 -0
  78. data/docs/js/search.js +110 -0
  79. data/docs/js/search_index.js +1 -0
  80. data/docs/js/search_index.js.gz +0 -0
  81. data/docs/js/searcher.js +229 -0
  82. data/docs/js/searcher.js.gz +0 -0
  83. data/docs/table_of_contents.html +562 -0
  84. data/lib/mercadopago.rb +24 -295
  85. data/lib/mercadopago/config/config.rb +42 -0
  86. data/lib/mercadopago/config/request_options.rb +85 -0
  87. data/lib/mercadopago/core/mp_base.rb +77 -0
  88. data/lib/mercadopago/http/http_client.rb +74 -0
  89. data/lib/mercadopago/resources/advanced_payment.rb +48 -0
  90. data/lib/mercadopago/resources/card.rb +31 -0
  91. data/lib/mercadopago/resources/card_token.rb +19 -0
  92. data/lib/mercadopago/resources/customer.rb +36 -0
  93. data/lib/mercadopago/resources/disbursement_refund.rb +24 -0
  94. data/lib/mercadopago/resources/identification_type.rb +13 -0
  95. data/lib/mercadopago/resources/merchant_order.rb +32 -0
  96. data/lib/mercadopago/resources/payment.rb +35 -0
  97. data/lib/mercadopago/resources/payment_methods.rb +13 -0
  98. data/lib/mercadopago/resources/preference.rb +26 -0
  99. data/lib/mercadopago/resources/refund.rb +24 -0
  100. data/lib/mercadopago/resources/user.rb +13 -0
  101. data/lib/mercadopago/sdk.rb +85 -0
  102. data/mercadopago.gemspec +11 -11
  103. data/tests/test_card.rb +79 -0
  104. data/tests/test_card_token.rb +39 -0
  105. data/tests/test_customer.rb +54 -0
  106. data/tests/test_identification_type.rb +16 -0
  107. data/tests/test_merchant_order.rb +94 -0
  108. data/tests/test_payment.rb +102 -0
  109. data/tests/test_payment_methods.rb +14 -0
  110. data/tests/test_preference.rb +49 -0
  111. data/tests/test_refund.rb +88 -0
  112. data/tests/test_user.rb +17 -0
  113. data/tests/tests.rb +12 -56
  114. metadata +127 -24
  115. data/.travis.yml +0 -14
  116. data/examples/checkout-buttons/basic_preference/button.rb +0 -28
  117. data/examples/instant-payment-notifications/receive-ipn.rb +0 -25
  118. data/examples/payment-search/search-approved-payments.rb +0 -23
  119. data/examples/payment-search/search-creditcard-payments.rb +0 -23
  120. data/examples/payment-search/search-funded-payments-by-name.rb +0 -23
  121. data/examples/payment-search/search-payments-from-email-and-date.rb +0 -23
  122. data/examples/payment-search/search-payments.rb +0 -23
  123. data/examples/preapproval-payments/button.rb +0 -42
  124. data/lib/ssl_options_patch.rb +0 -15
  125. data/lib/version.rb +0 -2
  126. data/travis_Gemfile +0 -4
@@ -0,0 +1,88 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../lib/mercadopago'
5
+ require 'minitest/autorun'
6
+
7
+ ##
8
+ # TestRefund
9
+ class TestRefund < Minitest::Test
10
+ def test_method_list
11
+ sdk = Mercadopago::SDK.new('APP_USR-558881221729581-091712-44fdc612e60e3e638775d8b4003edd51-471763966')
12
+ result = sdk.refund.list(12_678_120_979)
13
+ assert_equal 200, result[:status]
14
+ end
15
+
16
+ def test_method_post
17
+ sdk = Mercadopago::SDK.new('APP_USR-558881221729581-091712-44fdc612e60e3e638775d8b4003edd51-471763966')
18
+ card_token_object = {
19
+ card_number: '4235647728025682',
20
+ expiration_year: 2025,
21
+ expiration_month: 11,
22
+ security_code: '123',
23
+ cardholder: {
24
+ name: 'APRO'
25
+ }
26
+ }
27
+ result_card_token = sdk.card_token.create(card_token_object)
28
+
29
+ payment_object = {
30
+ token: result_card_token[:response]['id'],
31
+ installments: 1,
32
+ transaction_amount: 58.80,
33
+ description: 'Point Mini a maquininha que dá o dinheiro de suas vendas na hora',
34
+ payment_method_id: 'visa',
35
+ payer: {
36
+ email: 'test_user_123456@testuser.com',
37
+ identification: {
38
+ number: '19119119100',
39
+ type: 'CPF'
40
+ }
41
+ },
42
+ notification_url: 'https://www.suaurl.com/notificacoes/',
43
+ binary_mode: false,
44
+ external_reference: 'MP0001',
45
+ statement_descriptor: 'MercadoPago',
46
+ additional_info: {
47
+ items: [
48
+ {
49
+ id: 'PR0001',
50
+ title: 'Point Mini',
51
+ description: 'Producto Point para cobros con tarjetas mediante bluetooth',
52
+ picture_url: 'https://http2.mlstatic.com/resources/frontend/statics/growth-sellers-landings/device-mlb-point-i_medium@2x.png',
53
+ category_id: 'electronics',
54
+ quantity: 1,
55
+ unit_price: 58.80
56
+ }
57
+ ],
58
+ payer: {
59
+ first_name: 'Nome',
60
+ last_name: 'Sobrenome',
61
+ address: {
62
+ zip_code: '06233-200',
63
+ street_name: 'Av das Nacoes Unidas',
64
+ street_number: 3003
65
+ },
66
+ registration_date: '2019-01-01T12:01:01.000-03:00',
67
+ phone: {
68
+ area_code: '011',
69
+ number: '987654321'
70
+ }
71
+ },
72
+ shipments: {
73
+ receiver_address: {
74
+ street_name: 'Av das Nacoes Unidas',
75
+ street_number: 3003,
76
+ zip_code: '06233200',
77
+ city_name: 'Buzios',
78
+ state_name: 'Rio de Janeiro'
79
+ }
80
+ }
81
+ }
82
+ }
83
+ result_payment = sdk.payment.create(payment_object)
84
+ result = sdk.refund.create(result_payment[:response]['id'])
85
+ assert_equal 201, result[:status]
86
+ assert_equal 'approved', result[:response]['status']
87
+ end
88
+ end
@@ -0,0 +1,17 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../lib/mercadopago'
5
+ require 'minitest/autorun'
6
+
7
+ ##
8
+ # Test User
9
+ class TestUser < Minitest::Test
10
+ def test_method_get
11
+ sdk = Mercadopago::SDK.new('APP_USR-558881221729581-091712-44fdc612e60e3e638775d8b4003edd51-471763966')
12
+ sdk.request_options = Mercadopago::RequestOptions.new(corporation_id: 'abc')
13
+ result = sdk.user.get(request_options: Mercadopago::RequestOptions.new(connection_timeout: 100.0))
14
+
15
+ assert_equal 200, result[:status]
16
+ end
17
+ end
data/tests/tests.rb CHANGED
@@ -1,56 +1,12 @@
1
- $LOAD_PATH << '../lib'
2
-
3
- require 'test/unit'
4
- require 'mercadopago'
5
- require 'logger'
6
-
7
- class MercadoPagoTest < Test::Unit::TestCase
8
- def setup
9
- @mp = MercadoPago.new("CLIENT_ID", "CLIENT_SECRET")
10
- end
11
-
12
- # Call preference added through button flow
13
- def test_long_live_access_token
14
- @mp = MercadoPago.new("LONG_LIVE_ACCESS_TOKEN")
15
-
16
- assert_equal(@mp.get_access_token(), "LONG_LIVE_ACCESS_TOKEN")
17
- end
18
-
19
- # Call preference added through button flow
20
- def test_get_preference
21
- preferenceData = {"items" => ["title"=>"testCreate", "quantity"=>1, "unit_price"=>10.2, "currency_id"=>"ARS"]}
22
-
23
- preference = @mp.create_preference(preferenceData)
24
-
25
- preference = @mp.get_preference(preference['response']['id']);
26
-
27
- assert_equal("#{preference['status']}","200")
28
- end
29
-
30
- # Create a new preference and verify that data result are ok
31
- def test_create_preference
32
- preference_data = {"items" => ["title"=>"testCreate", "quantity"=>1, "unit_price"=>10.2, "currency_id"=>"ARS"]}
33
-
34
- preference = @mp.create_preference(preference_data)
35
- assert_equal "201", "#{preference['status']}"
36
- assert_equal "testCreate", "#{preference['response']["items"][0]["title"]}"
37
- end
38
-
39
- # We create a new preference, we modify this one and then we verify that data are ok.
40
- def test_update_preference
41
- preference_data = {"items" => ["title"=>"testUpdate", "quantity"=>1, "unit_price"=>10.2, "currency_id"=>"ARS"]}
42
- preference_created = @mp.create_preference(preference_data)
43
- preference_to_update = @mp.get_preference("#{preference_created['response']['id']}")
44
-
45
- preference_data_to_update = {"items" => ["title"=>"testUpdated", "quantity"=>1, "unit_price"=>2]}
46
- preference_update = @mp.update_preference("#{preference_created['response']['id']}", preference_data_to_update)
47
- assert_equal "200", "#{preference_update['status']}"
48
-
49
- preference_to_update = @mp.get_preference("#{preference_created['response']['id']}")
50
-
51
- assert_equal "testUpdated", "#{preference_to_update['response']["items"][0]["title"]}"
52
- assert_equal "2", "#{preference_to_update['response']["items"][0]["unit_price"]}"
53
- assert_equal "1", "#{preference_to_update['response']["items"][0]["quantity"]}"
54
- assert_equal "ARS", "#{preference_to_update['response']["items"][0]["currency_id"]}"
55
- end
56
- end
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ require_relative './test_card_token'
5
+ require_relative './test_card'
6
+ require_relative './test_identification_type'
7
+ require_relative './test_merchant_order'
8
+ require_relative './test_payment_methods'
9
+ require_relative './test_payment'
10
+ require_relative './test_preference'
11
+ require_relative './test_refund'
12
+ require_relative './test_user'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mercadopago-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
- - maticompiano
8
- autorequire:
7
+ - Mercado Pago
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-29 00:00:00.000000000 Z
11
+ date: 2021-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -52,37 +52,130 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: MercadoPago Ruby SDK
55
+ description: Mercado Pago Ruby SDK
56
56
  email:
57
- - matias.compiano@mercadolibre.com
58
57
  executables: []
59
58
  extensions: []
60
59
  extra_rdoc_files: []
61
60
  files:
61
+ - ".editorconfig"
62
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
63
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
64
+ - ".github/workflows/ruby.yml"
62
65
  - ".gitignore"
63
- - ".travis.yml"
66
+ - ".rubocop.yml"
67
+ - ".rubocop_todo.yml"
68
+ - ".ruby-version"
69
+ - CODE_OF_CONDUCT.md
70
+ - CODING_GUIDELINES.md
71
+ - CONTRIBUTING.md
64
72
  - Gemfile
65
73
  - Gemfile.lock
74
+ - LICENSE.txt
66
75
  - README.md
67
76
  - Rakefile
68
- - examples/checkout-buttons/basic_preference/button.rb
69
- - examples/instant-payment-notifications/receive-ipn.rb
70
- - examples/payment-search/search-approved-payments.rb
71
- - examples/payment-search/search-creditcard-payments.rb
72
- - examples/payment-search/search-funded-payments-by-name.rb
73
- - examples/payment-search/search-payments-from-email-and-date.rb
74
- - examples/payment-search/search-payments.rb
75
- - examples/preapproval-payments/button.rb
77
+ - docs/CODE_OF_CONDUCT_md.html
78
+ - docs/CODING_GUIDELINES_md.html
79
+ - docs/CONTRIBUTING_md.html
80
+ - docs/LICENSE_txt.html
81
+ - docs/Mercadopago.html
82
+ - docs/Mercadopago/AdvancedPayment.html
83
+ - docs/Mercadopago/Card.html
84
+ - docs/Mercadopago/CardToken.html
85
+ - docs/Mercadopago/Config.html
86
+ - docs/Mercadopago/Customer.html
87
+ - docs/Mercadopago/DisbursementRefund.html
88
+ - docs/Mercadopago/HttpClient.html
89
+ - docs/Mercadopago/IdentificationType.html
90
+ - docs/Mercadopago/MPBase.html
91
+ - docs/Mercadopago/MerchantOrder.html
92
+ - docs/Mercadopago/Payment.html
93
+ - docs/Mercadopago/PaymentMethods.html
94
+ - docs/Mercadopago/Preference.html
95
+ - docs/Mercadopago/Refund.html
96
+ - docs/Mercadopago/RequestOptions.html
97
+ - docs/Mercadopago/SDK.html
98
+ - docs/Mercadopago/User.html
99
+ - docs/README_md.html
100
+ - docs/created.rid
101
+ - docs/css/fonts.css
102
+ - docs/css/rdoc.css
103
+ - docs/fonts/Lato-Light.ttf
104
+ - docs/fonts/Lato-LightItalic.ttf
105
+ - docs/fonts/Lato-Regular.ttf
106
+ - docs/fonts/Lato-RegularItalic.ttf
107
+ - docs/fonts/SourceCodePro-Bold.ttf
108
+ - docs/fonts/SourceCodePro-Regular.ttf
109
+ - docs/images/add.png
110
+ - docs/images/arrow_up.png
111
+ - docs/images/brick.png
112
+ - docs/images/brick_link.png
113
+ - docs/images/bug.png
114
+ - docs/images/bullet_black.png
115
+ - docs/images/bullet_toggle_minus.png
116
+ - docs/images/bullet_toggle_plus.png
117
+ - docs/images/date.png
118
+ - docs/images/delete.png
119
+ - docs/images/find.png
120
+ - docs/images/loadingAnimation.gif
121
+ - docs/images/macFFBgHack.png
122
+ - docs/images/package.png
123
+ - docs/images/page_green.png
124
+ - docs/images/page_white_text.png
125
+ - docs/images/page_white_width.png
126
+ - docs/images/plugin.png
127
+ - docs/images/ruby.png
128
+ - docs/images/tag_blue.png
129
+ - docs/images/tag_green.png
130
+ - docs/images/transparent.png
131
+ - docs/images/wrench.png
132
+ - docs/images/wrench_orange.png
133
+ - docs/images/zoom.png
134
+ - docs/index.html
135
+ - docs/js/darkfish.js
136
+ - docs/js/navigation.js
137
+ - docs/js/navigation.js.gz
138
+ - docs/js/search.js
139
+ - docs/js/search_index.js
140
+ - docs/js/search_index.js.gz
141
+ - docs/js/searcher.js
142
+ - docs/js/searcher.js.gz
143
+ - docs/table_of_contents.html
76
144
  - lib/mercadopago.rb
77
- - lib/ssl_options_patch.rb
78
- - lib/version.rb
145
+ - lib/mercadopago/config/config.rb
146
+ - lib/mercadopago/config/request_options.rb
147
+ - lib/mercadopago/core/mp_base.rb
148
+ - lib/mercadopago/http/http_client.rb
149
+ - lib/mercadopago/resources/advanced_payment.rb
150
+ - lib/mercadopago/resources/card.rb
151
+ - lib/mercadopago/resources/card_token.rb
152
+ - lib/mercadopago/resources/customer.rb
153
+ - lib/mercadopago/resources/disbursement_refund.rb
154
+ - lib/mercadopago/resources/identification_type.rb
155
+ - lib/mercadopago/resources/merchant_order.rb
156
+ - lib/mercadopago/resources/payment.rb
157
+ - lib/mercadopago/resources/payment_methods.rb
158
+ - lib/mercadopago/resources/preference.rb
159
+ - lib/mercadopago/resources/refund.rb
160
+ - lib/mercadopago/resources/user.rb
161
+ - lib/mercadopago/sdk.rb
79
162
  - mercadopago.gemspec
163
+ - tests/test_card.rb
164
+ - tests/test_card_token.rb
165
+ - tests/test_customer.rb
166
+ - tests/test_identification_type.rb
167
+ - tests/test_merchant_order.rb
168
+ - tests/test_payment.rb
169
+ - tests/test_payment_methods.rb
170
+ - tests/test_preference.rb
171
+ - tests/test_refund.rb
172
+ - tests/test_user.rb
80
173
  - tests/tests.rb
81
- - travis_Gemfile
82
174
  homepage: http://github.com/mercadopago/sdk-ruby
83
- licenses: []
175
+ licenses:
176
+ - MIT
84
177
  metadata: {}
85
- post_install_message:
178
+ post_install_message:
86
179
  rdoc_options: []
87
180
  require_paths:
88
181
  - lib
@@ -90,16 +183,26 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
183
  requirements:
91
184
  - - ">="
92
185
  - !ruby/object:Gem::Version
93
- version: '0'
186
+ version: 2.3.0
94
187
  required_rubygems_version: !ruby/object:Gem::Requirement
95
188
  requirements:
96
189
  - - ">="
97
190
  - !ruby/object:Gem::Version
98
191
  version: '0'
99
192
  requirements: []
100
- rubygems_version: 3.0.3
101
- signing_key:
193
+ rubygems_version: 3.1.4
194
+ signing_key:
102
195
  specification_version: 4
103
- summary: MercadoPago Ruby SDK
196
+ summary: Mercado Pago Ruby SDK
104
197
  test_files:
198
+ - tests/test_card.rb
199
+ - tests/test_card_token.rb
200
+ - tests/test_customer.rb
201
+ - tests/test_identification_type.rb
202
+ - tests/test_merchant_order.rb
203
+ - tests/test_payment.rb
204
+ - tests/test_payment_methods.rb
205
+ - tests/test_preference.rb
206
+ - tests/test_refund.rb
207
+ - tests/test_user.rb
105
208
  - tests/tests.rb
data/.travis.yml DELETED
@@ -1,14 +0,0 @@
1
- sudo: required
2
- language: ruby
3
- rvm:
4
- - 1.9.3
5
- - 2.0.0
6
- - 2.1
7
- - 2.2
8
- - 2.3.0
9
- - jruby-19mode
10
- - jruby-9.0.5.0
11
- gemfile:
12
- travis_Gemfile
13
- script:
14
- bundle exec rake test ./tests/tests.rb
@@ -1,28 +0,0 @@
1
- require 'rubygems'
2
- require 'rack'
3
- $LOAD_PATH << '../../../lib'
4
- require 'mercadopago.rb'
5
-
6
- class Button
7
-
8
- def call(env)
9
- mp = MercadoPago.new('CLIENT_ID', 'CLIENT_SECRET')
10
- preferenceData = {"items" => ["title"=>"testCreate", "quantity"=>1, "unit_price"=>10.2, "currency_id"=>"ARS"]}
11
- preference = mp.create_preference(preferenceData)
12
-
13
- html = '<!doctype html>
14
- <html>
15
- <head>
16
- <title>MercadoPago SDK - Create Preference and Show Checkout Example</title>
17
- </head>
18
- <body>
19
- <a href="' + preference['response']['init_point'] + '" name="MP-Checkout" class="orange-ar-m-sq-arall">Pay</a>
20
- <script type="text/javascript" src="//resources.mlstatic.com/mptools/render.js"></script>
21
- </body>
22
- </html>'
23
-
24
- return [200, {'Content-Type' => 'text/html'}, [html]]
25
- end
26
- end
27
-
28
- Rack::Handler::WEBrick.run(Button.new, :Port => 9000)
@@ -1,25 +0,0 @@
1
- require 'rubygems'
2
- require 'rack'
3
- $LOAD_PATH << '../../lib'
4
- require 'mercadopago.rb'
5
-
6
- class IPN
7
- def call(env)
8
- mp = MercadoPago.new('CLIENT_ID', 'CLIENT_SECRET')
9
-
10
- # Get the payment reported by the IPN. Glossary of attributes response in https://developers.mercadopago.com
11
- payment_info = mp.get_payment_info('ID');
12
-
13
- html = ""
14
- # Show payment information
15
- if (payment_info['status'] == 200)
16
- html = payment_info['response'].inspect
17
- else
18
- html = payment_info['response'].inspect
19
- end
20
-
21
- return [200, {'Content-Type' => 'text/html'}, [html]]
22
- end
23
- end
24
-
25
- Rack::Handler::WEBrick.run(IPN.new, :Port => 9000)
@@ -1,23 +0,0 @@
1
- require 'rubygems'
2
- require 'rack'
3
- $LOAD_PATH << '../../lib'
4
- require 'mercadopago.rb'
5
-
6
- class IPN
7
- def call(env)
8
- mp = MercadoPago.new('CLIENT_ID', 'CLIENT_SECRET')
9
-
10
- # Sets the filters you want
11
- filters = Hash["range"=>"date_created", "begin_date"=>"NOW-1MONTH", "end_date"=>"NOW", "status"=>"approved", "operation_type"=>"regular_payment"]
12
-
13
- # Search payment data according to filters
14
- searchResult = mp.search_payment(filters)
15
-
16
- # Show payment information
17
- html = searchResult.inspect
18
-
19
- return [200, {'Content-Type' => 'text/html'}, [html]]
20
- end
21
- end
22
-
23
- Rack::Handler::WEBrick.run(IPN.new, :Port => 9000)