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.
- checksums.yaml +4 -4
- data/.editorconfig +10 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +28 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +19 -0
- data/.github/workflows/ruby.yml +35 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +104 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/CODING_GUIDELINES.md +70 -0
- data/CONTRIBUTING.md +57 -0
- data/Gemfile +6 -1
- data/Gemfile.lock +45 -17
- data/LICENSE.txt +21 -0
- data/README.md +51 -27
- data/Rakefile +3 -1
- data/docs/CODE_OF_CONDUCT_md.html +154 -0
- data/docs/CODING_GUIDELINES_md.html +188 -0
- data/docs/CONTRIBUTING_md.html +165 -0
- data/docs/LICENSE_txt.html +96 -0
- data/docs/Mercadopago.html +123 -0
- data/docs/Mercadopago/AdvancedPayment.html +279 -0
- data/docs/Mercadopago/Card.html +204 -0
- data/docs/Mercadopago/CardToken.html +160 -0
- data/docs/Mercadopago/Config.html +266 -0
- data/docs/Mercadopago/Customer.html +228 -0
- data/docs/Mercadopago/DisbursementRefund.html +183 -0
- data/docs/Mercadopago/HttpClient.html +249 -0
- data/docs/Mercadopago/IdentificationType.html +136 -0
- data/docs/Mercadopago/MPBase.html +316 -0
- data/docs/Mercadopago/MerchantOrder.html +209 -0
- data/docs/Mercadopago/Payment.html +208 -0
- data/docs/Mercadopago/PaymentMethods.html +136 -0
- data/docs/Mercadopago/Preference.html +184 -0
- data/docs/Mercadopago/Refund.html +160 -0
- data/docs/Mercadopago/RequestOptions.html +433 -0
- data/docs/Mercadopago/SDK.html +528 -0
- data/docs/Mercadopago/User.html +136 -0
- data/docs/README_md.html +181 -0
- data/docs/created.rid +25 -0
- data/docs/css/fonts.css +167 -0
- data/docs/css/rdoc.css +619 -0
- data/docs/fonts/Lato-Light.ttf +0 -0
- data/docs/fonts/Lato-LightItalic.ttf +0 -0
- data/docs/fonts/Lato-Regular.ttf +0 -0
- data/docs/fonts/Lato-RegularItalic.ttf +0 -0
- data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
- data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
- data/docs/images/add.png +0 -0
- data/docs/images/arrow_up.png +0 -0
- data/docs/images/brick.png +0 -0
- data/docs/images/brick_link.png +0 -0
- data/docs/images/bug.png +0 -0
- data/docs/images/bullet_black.png +0 -0
- data/docs/images/bullet_toggle_minus.png +0 -0
- data/docs/images/bullet_toggle_plus.png +0 -0
- data/docs/images/date.png +0 -0
- data/docs/images/delete.png +0 -0
- data/docs/images/find.png +0 -0
- data/docs/images/loadingAnimation.gif +0 -0
- data/docs/images/macFFBgHack.png +0 -0
- data/docs/images/package.png +0 -0
- data/docs/images/page_green.png +0 -0
- data/docs/images/page_white_text.png +0 -0
- data/docs/images/page_white_width.png +0 -0
- data/docs/images/plugin.png +0 -0
- data/docs/images/ruby.png +0 -0
- data/docs/images/tag_blue.png +0 -0
- data/docs/images/tag_green.png +0 -0
- data/docs/images/transparent.png +0 -0
- data/docs/images/wrench.png +0 -0
- data/docs/images/wrench_orange.png +0 -0
- data/docs/images/zoom.png +0 -0
- data/docs/index.html +109 -0
- data/docs/js/darkfish.js +84 -0
- data/docs/js/navigation.js +105 -0
- data/docs/js/navigation.js.gz +0 -0
- data/docs/js/search.js +110 -0
- data/docs/js/search_index.js +1 -0
- data/docs/js/search_index.js.gz +0 -0
- data/docs/js/searcher.js +229 -0
- data/docs/js/searcher.js.gz +0 -0
- data/docs/table_of_contents.html +562 -0
- data/lib/mercadopago.rb +24 -295
- data/lib/mercadopago/config/config.rb +42 -0
- data/lib/mercadopago/config/request_options.rb +85 -0
- data/lib/mercadopago/core/mp_base.rb +77 -0
- data/lib/mercadopago/http/http_client.rb +74 -0
- data/lib/mercadopago/resources/advanced_payment.rb +48 -0
- data/lib/mercadopago/resources/card.rb +31 -0
- data/lib/mercadopago/resources/card_token.rb +19 -0
- data/lib/mercadopago/resources/customer.rb +36 -0
- data/lib/mercadopago/resources/disbursement_refund.rb +24 -0
- data/lib/mercadopago/resources/identification_type.rb +13 -0
- data/lib/mercadopago/resources/merchant_order.rb +32 -0
- data/lib/mercadopago/resources/payment.rb +35 -0
- data/lib/mercadopago/resources/payment_methods.rb +13 -0
- data/lib/mercadopago/resources/preference.rb +26 -0
- data/lib/mercadopago/resources/refund.rb +24 -0
- data/lib/mercadopago/resources/user.rb +13 -0
- data/lib/mercadopago/sdk.rb +85 -0
- data/mercadopago.gemspec +11 -11
- data/tests/test_card.rb +79 -0
- data/tests/test_card_token.rb +39 -0
- data/tests/test_customer.rb +54 -0
- data/tests/test_identification_type.rb +16 -0
- data/tests/test_merchant_order.rb +94 -0
- data/tests/test_payment.rb +102 -0
- data/tests/test_payment_methods.rb +14 -0
- data/tests/test_preference.rb +49 -0
- data/tests/test_refund.rb +88 -0
- data/tests/test_user.rb +17 -0
- data/tests/tests.rb +12 -56
- metadata +127 -24
- data/.travis.yml +0 -14
- data/examples/checkout-buttons/basic_preference/button.rb +0 -28
- data/examples/instant-payment-notifications/receive-ipn.rb +0 -25
- data/examples/payment-search/search-approved-payments.rb +0 -23
- data/examples/payment-search/search-creditcard-payments.rb +0 -23
- data/examples/payment-search/search-funded-payments-by-name.rb +0 -23
- data/examples/payment-search/search-payments-from-email-and-date.rb +0 -23
- data/examples/payment-search/search-payments.rb +0 -23
- data/examples/preapproval-payments/button.rb +0 -42
- data/lib/ssl_options_patch.rb +0 -15
- data/lib/version.rb +0 -2
- data/travis_Gemfile +0 -4
data/mercadopago.gemspec
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
#
|
2
|
-
require File.dirname(__FILE__) + '/lib/version'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
3
|
Gem::Specification.new do |gem|
|
5
|
-
gem.name
|
6
|
-
gem.version
|
7
|
-
gem.
|
8
|
-
gem.
|
9
|
-
gem.description
|
10
|
-
gem.summary
|
11
|
-
gem.homepage
|
4
|
+
gem.name = 'mercadopago-sdk'
|
5
|
+
gem.version = '2.0.1'
|
6
|
+
gem.required_ruby_version = '>= 2.3.0'
|
7
|
+
gem.author = 'Mercado Pago'
|
8
|
+
gem.description = 'Mercado Pago Ruby SDK'
|
9
|
+
gem.summary = 'Mercado Pago Ruby SDK'
|
10
|
+
gem.homepage = 'http://github.com/mercadopago/sdk-ruby'
|
11
|
+
gem.license = 'MIT'
|
12
12
|
|
13
|
-
gem.files = `git ls-files`.split(
|
13
|
+
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
14
14
|
gem.test_files = gem.files.grep(%r{^(tests)/})
|
15
|
-
gem.require_paths =
|
15
|
+
gem.require_paths = ['lib']
|
16
16
|
|
17
17
|
gem.add_dependency 'json'
|
18
18
|
|
data/tests/test_card.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative '../lib/mercadopago'
|
5
|
+
|
6
|
+
require 'minitest/autorun'
|
7
|
+
|
8
|
+
class TestCard < Minitest::Test
|
9
|
+
def test_all
|
10
|
+
sdk = Mercadopago::SDK.new('TEST-783169576377080-082620-395ee7f82e0d55b1db606c118686c1db-464842924')
|
11
|
+
|
12
|
+
customer_object = {
|
13
|
+
email: 'test_payer_999944@testuser.com',
|
14
|
+
first_name: 'Rafa',
|
15
|
+
last_name: 'Williner',
|
16
|
+
phone: {
|
17
|
+
area_code: '03492',
|
18
|
+
number: '432334'
|
19
|
+
},
|
20
|
+
identification: {
|
21
|
+
type: 'DNI',
|
22
|
+
number: '29804555'
|
23
|
+
},
|
24
|
+
address: {
|
25
|
+
zip_code: '2300',
|
26
|
+
street_name: 'some street'
|
27
|
+
},
|
28
|
+
description: 'customer description'
|
29
|
+
}
|
30
|
+
|
31
|
+
customer_saved = sdk.customer.create(customer_object)
|
32
|
+
assert_equal 201, customer_saved[:status]
|
33
|
+
customer_id = customer_saved[:response]['id']
|
34
|
+
sleep(1)
|
35
|
+
|
36
|
+
card_token_object = {
|
37
|
+
card_number: '4235647728025682',
|
38
|
+
expiration_year: 2025,
|
39
|
+
expiration_month: 11,
|
40
|
+
security_code: '123',
|
41
|
+
cardholder: {
|
42
|
+
name: 'APRO'
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
begin
|
47
|
+
card_token = sdk.card_token.create(card_token_object)
|
48
|
+
|
49
|
+
card_object = {
|
50
|
+
token: card_token[:response]['id']
|
51
|
+
}
|
52
|
+
|
53
|
+
card_saved = sdk.card.create(customer_id, card_object)
|
54
|
+
assert !card_saved.nil?
|
55
|
+
assert !card_saved[:response].nil?
|
56
|
+
assert !card_saved[:response]['id'].nil?
|
57
|
+
sleep(1)
|
58
|
+
|
59
|
+
cards = sdk.card.list(customer_id)
|
60
|
+
assert !cards.nil?
|
61
|
+
assert !cards[:response].nil?
|
62
|
+
assert !cards[:response].empty?
|
63
|
+
sleep(1)
|
64
|
+
|
65
|
+
card_get = sdk.card.get(customer_id, card_saved[:response]['id'])
|
66
|
+
assert_equal 200, card_get[:status]
|
67
|
+
sleep(1)
|
68
|
+
|
69
|
+
card_deleted = sdk.card.delete(customer_id, card_saved[:response]['id'])
|
70
|
+
assert_equal 200, card_deleted[:status]
|
71
|
+
sleep(1)
|
72
|
+
ensure
|
73
|
+
if customer_saved.key?(:response) && customer_saved[:response].key?('id')
|
74
|
+
customer_deleted = sdk.customer.delete(customer_saved[:response]['id'])
|
75
|
+
assert_equal 200, customer_deleted[:status]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative '../lib/mercadopago'
|
5
|
+
|
6
|
+
require 'minitest/autorun'
|
7
|
+
|
8
|
+
class CardToken < Minitest::Test
|
9
|
+
def test_method_get_id
|
10
|
+
sdk = Mercadopago::SDK.new(access_token = 'APP_USR-558881221729581-091712-44fdc612e60e3e638775d8b4003edd51-471763966')
|
11
|
+
card_token_object = {
|
12
|
+
card_number: '4235647728025682',
|
13
|
+
expiration_year: 2025,
|
14
|
+
expiration_month: 11,
|
15
|
+
security_code: '123',
|
16
|
+
cardholder: {
|
17
|
+
name: 'APRO'
|
18
|
+
}
|
19
|
+
}
|
20
|
+
result_card_token = sdk.card_token.create(card_token_object)
|
21
|
+
result = sdk.card_token.get(result_card_token[:response]['id'])
|
22
|
+
assert_equal 200, result[:status]
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_method_post
|
26
|
+
sdk = Mercadopago::SDK.new('APP_USR-558881221729581-091712-44fdc612e60e3e638775d8b4003edd51-471763966')
|
27
|
+
card_token_object = {
|
28
|
+
card_number: '4235647728025682',
|
29
|
+
expiration_year: 2025,
|
30
|
+
expiration_month: 11,
|
31
|
+
security_code: '123',
|
32
|
+
cardholder: {
|
33
|
+
name: 'APRO'
|
34
|
+
}
|
35
|
+
}
|
36
|
+
result = sdk.card_token.create(card_token_object)
|
37
|
+
assert_equal 201, result[:status]
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative '../lib/mercadopago'
|
5
|
+
|
6
|
+
require 'minitest/autorun'
|
7
|
+
|
8
|
+
class TestCustomer < Minitest::Test
|
9
|
+
def test_all
|
10
|
+
sdk = Mercadopago::SDK.new('TEST-783169576377080-082620-395ee7f82e0d55b1db606c118686c1db-464842924')
|
11
|
+
|
12
|
+
customer_object = {
|
13
|
+
email: 'test_payer_999922@testuser.com',
|
14
|
+
first_name: 'Rafa',
|
15
|
+
last_name: 'Williner',
|
16
|
+
phone: {
|
17
|
+
area_code: '03492',
|
18
|
+
number: '432334'
|
19
|
+
},
|
20
|
+
identification: {
|
21
|
+
type: 'DNI',
|
22
|
+
number: '29804555'
|
23
|
+
},
|
24
|
+
address: {
|
25
|
+
zip_code: '2300',
|
26
|
+
street_name: 'some street'
|
27
|
+
},
|
28
|
+
description: 'customer description'
|
29
|
+
}
|
30
|
+
|
31
|
+
begin
|
32
|
+
customer_saved = sdk.customer.create(customer_object)
|
33
|
+
assert_equal 201, customer_saved[:status]
|
34
|
+
sleep(1)
|
35
|
+
|
36
|
+
customers = sdk.customer.search(filters: { email: 'test_payer_999922@testuser.com' })
|
37
|
+
assert_equal 200, customers[:status]
|
38
|
+
sleep(1)
|
39
|
+
|
40
|
+
customer_update = sdk.customer.update(customer_saved[:response]['id'], { last_name: 'Payer' })
|
41
|
+
assert_equal 200, customer_update[:status]
|
42
|
+
sleep(1)
|
43
|
+
|
44
|
+
customer_updated = sdk.customer.get(customer_saved[:response]['id'])
|
45
|
+
assert_equal 'Payer', customer_updated[:response]['last_name']
|
46
|
+
sleep(1)
|
47
|
+
ensure
|
48
|
+
if customer_saved.key?(:response) && customer_saved[:response].key?('id')
|
49
|
+
customer_deleted = sdk.customer.delete(customer_saved[:response]['id'])
|
50
|
+
assert_equal 200, customer_deleted[:status]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative '../lib/mercadopago'
|
5
|
+
|
6
|
+
require 'minitest/autorun'
|
7
|
+
|
8
|
+
class TestIdentificationType < Minitest::Test
|
9
|
+
def test_method_get
|
10
|
+
sdk = Mercadopago::SDK.new('APP_USR-558881221729581-091712-44fdc612e60e3e638775d8b4003edd51-471763966')
|
11
|
+
sdk.request_options = Mercadopago::RequestOptions.new(corporation_id: 'abc')
|
12
|
+
result = sdk.identification_type.get
|
13
|
+
|
14
|
+
assert_equal 200, result[:status]
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative '../lib/mercadopago'
|
5
|
+
|
6
|
+
require 'minitest/autorun'
|
7
|
+
|
8
|
+
class TestMerchantOrden < Minitest::Test
|
9
|
+
def test_method_search
|
10
|
+
sdk = Mercadopago::SDK.new('TEST-6130770563612470-121314-d27bbd7363e64c3853f058251cf8fc6e-537031659')
|
11
|
+
result = sdk.merchant_order.search(filters: { id: 123_187_219_6 })
|
12
|
+
assert_equal 200, result[:status]
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_method_post
|
16
|
+
sdk = Mercadopago::SDK.new('APP_USR-558881221729581-091712-44fdc612e60e3e638775d8b4003edd51-471763966')
|
17
|
+
data = {
|
18
|
+
items: [
|
19
|
+
{
|
20
|
+
title: 'Dummy Item',
|
21
|
+
description: 'Multicolor Item',
|
22
|
+
quantity: 1,
|
23
|
+
currency_id: '',
|
24
|
+
unit_price: 10.0
|
25
|
+
}
|
26
|
+
]
|
27
|
+
}
|
28
|
+
result_prefence = sdk.preference.create(data)
|
29
|
+
merchant_orden_object = {
|
30
|
+
preference_id: result_prefence[:response]['id'],
|
31
|
+
site_id: 'MLB',
|
32
|
+
notification_url: 'https://seller/notification',
|
33
|
+
additional_info: 'Aditional info',
|
34
|
+
external_reference: 1,
|
35
|
+
marketplace: 'NONE',
|
36
|
+
items: [{
|
37
|
+
description: 'Test Update Success',
|
38
|
+
id: '5678',
|
39
|
+
picture_url: 'http://product1.image.png',
|
40
|
+
quantity: 1,
|
41
|
+
title: 'Item 1',
|
42
|
+
currency_id: 'BRL',
|
43
|
+
unit_price: 20.5
|
44
|
+
}]
|
45
|
+
}
|
46
|
+
result_merchant_order = sdk.merchant_order.create(merchant_orden_object)
|
47
|
+
assert_equal 201, result_merchant_order[:status]
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_method_get_id
|
51
|
+
sdk = Mercadopago::SDK.new('APP_USR-558881221729581-091712-44fdc612e60e3e638775d8b4003edd51-471763966')
|
52
|
+
result = sdk.merchant_order.get('2112122225')
|
53
|
+
assert_equal 200, result[:status]
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_method_put
|
57
|
+
sdk = Mercadopago::SDK.new('APP_USR-558881221729581-091712-44fdc612e60e3e638775d8b4003edd51-471763966')
|
58
|
+
data = {
|
59
|
+
items: [
|
60
|
+
{
|
61
|
+
title: 'Dummy Item',
|
62
|
+
description: 'Multicolor Item',
|
63
|
+
quantity: 1,
|
64
|
+
currency_id: '',
|
65
|
+
unit_price: 10.0
|
66
|
+
}
|
67
|
+
]
|
68
|
+
}
|
69
|
+
result_prefence = sdk.preference.create(data)
|
70
|
+
merchant_orden_object = {
|
71
|
+
preference_id: result_prefence[:response]['id'],
|
72
|
+
site_id: 'MLB',
|
73
|
+
notification_url: 'https://seller/notification',
|
74
|
+
additional_info: 'Aditional info',
|
75
|
+
external_reference: 1,
|
76
|
+
marketplace: 'NONE',
|
77
|
+
items: [
|
78
|
+
{
|
79
|
+
description: 'Test Update Success',
|
80
|
+
id: '5678',
|
81
|
+
picture_url: 'http://product1.image.png',
|
82
|
+
quantity: 1,
|
83
|
+
title: 'Item 1',
|
84
|
+
currency_id: 'BRL',
|
85
|
+
unit_price: 20.5
|
86
|
+
}
|
87
|
+
]
|
88
|
+
}
|
89
|
+
result_merchant_order = sdk.merchant_order.create(merchant_orden_object)
|
90
|
+
merchant_order_update = { additional_info: 'Info 3' }
|
91
|
+
result = sdk.merchant_order.update(result_merchant_order[:response]['id'], merchant_order_update)
|
92
|
+
assert_equal 200, result[:status]
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative '../lib/mercadopago'
|
5
|
+
|
6
|
+
require 'minitest/autorun'
|
7
|
+
|
8
|
+
class TestPayment < Minitest::Test
|
9
|
+
def test_method_search
|
10
|
+
sdk = Mercadopago::SDK.new('TEST-6130770563612470-121314-d27bbd7363e64c3853f058251cf8fc6e-537031659')
|
11
|
+
result = sdk.payment.search(filters: { id: 1_231_872_196 })
|
12
|
+
|
13
|
+
assert_equal 200, result[:status]
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_method_get_id
|
17
|
+
sdk = Mercadopago::SDK.new('TEST-6130770563612470-121314-d27bbd7363e64c3853f058251cf8fc6e-537031659')
|
18
|
+
result = sdk.payment.get(1_231_872_196)
|
19
|
+
|
20
|
+
assert_equal 200, result[:status]
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_method_post
|
24
|
+
sdk = Mercadopago::SDK.new('APP_USR-558881221729581-091712-44fdc612e60e3e638775d8b4003edd51-471763966')
|
25
|
+
card_token_object = {
|
26
|
+
card_number: '4235647728025682',
|
27
|
+
expiration_year: 2025,
|
28
|
+
expiration_month: 11,
|
29
|
+
security_code: '123',
|
30
|
+
cardholder: {
|
31
|
+
name: 'APRO'
|
32
|
+
}
|
33
|
+
}
|
34
|
+
result_card_token = sdk.card_token.create(card_token_object)
|
35
|
+
|
36
|
+
payment_object = {
|
37
|
+
token: result_card_token[:response]['id'],
|
38
|
+
installments: 1,
|
39
|
+
transaction_amount: 58.80,
|
40
|
+
description: 'Point Mini a maquininha que dá o dinheiro de suas vendas na hora',
|
41
|
+
payment_method_id: 'visa',
|
42
|
+
payer: {
|
43
|
+
email: 'test_user_123456@testuser.com',
|
44
|
+
identification: {
|
45
|
+
number: '19119119100',
|
46
|
+
type: 'CPF'
|
47
|
+
}
|
48
|
+
},
|
49
|
+
notification_url: 'https://www.suaurl.com/notificacoes/',
|
50
|
+
binary_mode: false,
|
51
|
+
external_reference: 'MP0001',
|
52
|
+
statement_descriptor: 'MercadoPago',
|
53
|
+
additional_info: {
|
54
|
+
items: [
|
55
|
+
{
|
56
|
+
id: 'PR0001',
|
57
|
+
title: 'Point Mini',
|
58
|
+
description: 'Producto Point para cobros con tarjetas mediante bluetooth',
|
59
|
+
picture_url: 'https://http2.mlstatic.com/resources/frontend/statics/growth-sellers-landings/device-mlb-point-i_medium@2x.png',
|
60
|
+
category_id: 'electronics',
|
61
|
+
quantity: 1,
|
62
|
+
unit_price: 58.80
|
63
|
+
}
|
64
|
+
],
|
65
|
+
payer: {
|
66
|
+
first_name: 'Nome',
|
67
|
+
last_name: 'Sobrenome',
|
68
|
+
address: {
|
69
|
+
zip_code: '06233-200',
|
70
|
+
street_name: 'Av das Nacoes Unidas',
|
71
|
+
street_number: 3003
|
72
|
+
},
|
73
|
+
registration_date: '2019-01-01T12:01:01.000-03:00',
|
74
|
+
phone: {
|
75
|
+
area_code: '011',
|
76
|
+
number: '987654321'
|
77
|
+
}
|
78
|
+
},
|
79
|
+
shipments: {
|
80
|
+
receiver_address: {
|
81
|
+
street_name: 'Av das Nacoes Unidas',
|
82
|
+
street_number: 3003,
|
83
|
+
zip_code: '06233200',
|
84
|
+
city_name: 'Buzios',
|
85
|
+
state_name: 'Rio de Janeiro'
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}
|
90
|
+
result = sdk.payment.create(payment_object)
|
91
|
+
assert_equal 201, result[:status]
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_method_put
|
95
|
+
sdk = Mercadopago::SDK.new('TEST-6130770563612470-121314-d27bbd7363e64c3853f058251cf8fc6e-537031659')
|
96
|
+
data = {
|
97
|
+
status: 'approved'
|
98
|
+
}
|
99
|
+
result = sdk.payment.update(1_231_910_402, data)
|
100
|
+
assert_equal 403, result[:status]
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative '../lib/mercadopago'
|
5
|
+
|
6
|
+
require 'minitest/autorun'
|
7
|
+
|
8
|
+
class TestPaymentMethods < Minitest::Test
|
9
|
+
def test_method_get
|
10
|
+
sdk = Mercadopago::SDK.new('TEST-6130770563612470-121314-d27bbd7363e64c3853f058251cf8fc6e-537031659')
|
11
|
+
result = sdk.payment_methods.get
|
12
|
+
assert_equal 200, result[:status]
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative '../lib/mercadopago'
|
5
|
+
|
6
|
+
require 'minitest/autorun'
|
7
|
+
|
8
|
+
class TestPreference < Minitest::Test
|
9
|
+
def test_method_get_id
|
10
|
+
sdk = Mercadopago::SDK.new('TEST-6130770563612470-121314-d27bbd7363e64c3853f058251cf8fc6e-537031659')
|
11
|
+
result = sdk.preference.get('537031659-d710347b-7746-4025-b72b-e5be918b91ca')
|
12
|
+
|
13
|
+
assert_equal 200, result[:status]
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_method_post
|
17
|
+
sdk = Mercadopago::SDK.new('TEST-6130770563612470-121314-d27bbd7363e64c3853f058251cf8fc6e-537031659')
|
18
|
+
data = {
|
19
|
+
items: [
|
20
|
+
{
|
21
|
+
title: 'Dummy Item',
|
22
|
+
description: 'Multicolor Item',
|
23
|
+
quantity: 1,
|
24
|
+
currency_id: '',
|
25
|
+
unit_price: 10.0
|
26
|
+
}
|
27
|
+
]
|
28
|
+
}
|
29
|
+
result = sdk.preference.create(data)
|
30
|
+
assert_equal 201, result[:status]
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_method_put
|
34
|
+
sdk = Mercadopago::SDK.new('TEST-6130770563612470-121314-d27bbd7363e64c3853f058251cf8fc6e-537031659')
|
35
|
+
data = {
|
36
|
+
items: [
|
37
|
+
{
|
38
|
+
title: 'Camiseta Barcelona',
|
39
|
+
description: 'Camiseta Oficial Barcelona',
|
40
|
+
quantity: 1,
|
41
|
+
currency_id: '',
|
42
|
+
unit_price: 10.0
|
43
|
+
}
|
44
|
+
]
|
45
|
+
}
|
46
|
+
result = sdk.preference.update('537031659-e4a79653-8638-490c-a4e5-c39f6f8d9874', data)
|
47
|
+
assert_equal 200, result[:status]
|
48
|
+
end
|
49
|
+
end
|