mercadopago 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/README.md +16 -6
- data/lib/mercadopago/client.rb +17 -3
- data/lib/mercadopago/collection.rb +9 -4
- data/lib/mercadopago/version.rb +1 -1
- metadata +15 -14
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZWMzYWNmOWU2Y2UwNjQ1ZmQ0Yjg4OTM4MzBmNDU1MTA0ZWU4ODZmOA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NzA0YTYyOTdlYjdkZTg4N2Y3MjZjYzU2Mjc2ZmM2MGM1NGQ4Nzg3MQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NzFkODEwMDBlZDc1MjMzMDc3MmYzZmQ2Y2ZlZjc1MGYxYmIzZTlmMjFkZGUw
|
10
|
+
YmFlYTRhZjVlMTA4NjE0NDk2Njg4OGRmNTllYmQyY2RhNmVlNDA3ODFlNzZk
|
11
|
+
NmZlZTA5NjZkNDcwNzcxZmY3NjJmMGIzYTJmOWY1N2QzOGQyNjI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NWQ4MTAzOGE1ZjJlNmQ3NzYyNDBjOGUzYTBkZTA0ZTNmZWMyZGFiNDY5ZGJm
|
14
|
+
Y2ViNmViZGNlZDg1NWFjYmM1MDkwMTJlYTI1MTAzMzg0MmJjMWRkM2MzNTQw
|
15
|
+
M2FlYjk5NTE4MjY1NzQyN2NhMTgzMTAxMmE4MGE1YmI2M2IxNjE=
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
MercadoPago Gem
|
2
2
|
===============
|
3
3
|
|
4
|
-
Developed and maintained by
|
4
|
+
Developed and maintained by [Kauplus](http://www.kauplus.com).
|
5
5
|
|
6
6
|
This is a Ruby client for all the services offered by [MercadoPago](http://www.mercadopago.com).
|
7
7
|
|
@@ -11,8 +11,6 @@ You can read the documentation of the MercadoPago API here:
|
|
11
11
|
* Portuguese: https://developers.mercadopago.com/integracao-checkout
|
12
12
|
* Spanish: https://developers.mercadopago.com/integracion-checkout
|
13
13
|
|
14
|
-
|
15
|
-
|
16
14
|
Installation
|
17
15
|
------------
|
18
16
|
|
@@ -85,9 +83,10 @@ Your request will need a hash to explain what the payment is for. For example:
|
|
85
83
|
If everything worked out alright, you will get a response like this:
|
86
84
|
|
87
85
|
{
|
88
|
-
"payment_methods"
|
89
|
-
"init_point"
|
90
|
-
"
|
86
|
+
"payment_methods" => {},
|
87
|
+
"init_point" => "https://www.mercadopago.com/mlb/checkout/pay?pref_id=abcdefgh-9999-9999-ab99-999999999999",
|
88
|
+
"sandbox_init_point" => "https://sandbox.mercadopago.com/mlb/checkout/pay?pref_id=abcdefgh-9999-9999-ab99-999999999999",
|
89
|
+
"collector_id" => 123456789,
|
91
90
|
"back_urls" => {
|
92
91
|
"pending"=> "https://www.site.com/pending",
|
93
92
|
"success"=> "http://www.site.com/success",
|
@@ -283,6 +282,13 @@ And the parameters thay could be used in the search hash are:
|
|
283
282
|
recurring_payment: Active subscription recurring payment.
|
284
283
|
subscription_payment: Subscription fee.
|
285
284
|
|
285
|
+
### Sandbox mode
|
286
|
+
|
287
|
+
The sandbox mode can be enabled/disabled as follows:
|
288
|
+
|
289
|
+
mp_client.sandbox(true) # Enables sandbox
|
290
|
+
mp_client.sandbox(false) # Disables sandbox
|
291
|
+
|
286
292
|
### Recurring Payment Creation
|
287
293
|
|
288
294
|
Your request will need a hash to explain what the recurring payment is for. For example:
|
@@ -413,6 +419,10 @@ This gem has tests for a few methods. To check if it is working properly, just r
|
|
413
419
|
Changelog
|
414
420
|
---------
|
415
421
|
|
422
|
+
2.2.0 (thanks gulymaestro)
|
423
|
+
|
424
|
+
Added support to the sandbox mode.
|
425
|
+
|
416
426
|
2.1.0 (thanks jamessonfaria)
|
417
427
|
|
418
428
|
Added functionality to create and get recurring payments. Also added support for recurring payments notification.
|
data/lib/mercadopago/client.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
module MercadoPago
|
2
3
|
|
3
4
|
class AccessError < Exception
|
@@ -19,10 +20,11 @@ module MercadoPago
|
|
19
20
|
# mp_client.get_preference(preference_id)
|
20
21
|
# mp_client.notification(payment_id)
|
21
22
|
# mp_client.search(data)
|
23
|
+
# mp_client.sandbox_mode(true/false)
|
22
24
|
#
|
23
25
|
class Client
|
24
26
|
|
25
|
-
attr_reader :access_token, :refresh_token
|
27
|
+
attr_reader :access_token, :refresh_token, :sandbox
|
26
28
|
|
27
29
|
#
|
28
30
|
# Creates an instance and stores the access_token to make calls to the
|
@@ -35,6 +37,18 @@ module MercadoPago
|
|
35
37
|
load_tokens MercadoPago::Authentication.access_token(client_id, client_secret)
|
36
38
|
end
|
37
39
|
|
40
|
+
#
|
41
|
+
# Enables or disables sandbox mode.
|
42
|
+
#
|
43
|
+
# - enable
|
44
|
+
#
|
45
|
+
def sandbox_mode(enable = nil)
|
46
|
+
unless enable.nil?
|
47
|
+
@sandbox = enable
|
48
|
+
end
|
49
|
+
@sandbox
|
50
|
+
end
|
51
|
+
|
38
52
|
#
|
39
53
|
# Refreshes an access token.
|
40
54
|
#
|
@@ -91,7 +105,7 @@ module MercadoPago
|
|
91
105
|
when 'merchant_order'
|
92
106
|
MercadoPago::MerchantOrder.notification(@access_token, entity_id)
|
93
107
|
else # 'payment'
|
94
|
-
MercadoPago::Collection.notification(@access_token, entity_id)
|
108
|
+
MercadoPago::Collection.notification(@access_token, entity_id, @sandbox)
|
95
109
|
end
|
96
110
|
end
|
97
111
|
|
@@ -119,7 +133,7 @@ module MercadoPago
|
|
119
133
|
# - search_hash: the search hash to find collections.
|
120
134
|
#
|
121
135
|
def search(search_hash)
|
122
|
-
MercadoPago::Collection.search(@access_token, search_hash)
|
136
|
+
MercadoPago::Collection.search(@access_token, search_hash, @sandbox)
|
123
137
|
end
|
124
138
|
|
125
139
|
#
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
module MercadoPago
|
2
3
|
|
3
4
|
module Collection
|
@@ -8,9 +9,11 @@ module MercadoPago
|
|
8
9
|
#
|
9
10
|
# - access_token: an access_token of the MercadoPago account associated with the payment to be checked.
|
10
11
|
# - payment_id: the id of the payment to be checked.
|
12
|
+
# - sandbox: whether or not the sandbox mode should be activated.
|
11
13
|
#
|
12
|
-
def self.notification(access_token, payment_id)
|
13
|
-
|
14
|
+
def self.notification(access_token, payment_id, sandbox = false)
|
15
|
+
uri_prefix = sandbox ? '/sandbox' : ''
|
16
|
+
MercadoPago::Request.wrap_get("#{uri_prefix}/collections/notifications/#{payment_id}?access_token=#{access_token}", { accept: 'application/json' })
|
14
17
|
end
|
15
18
|
|
16
19
|
#
|
@@ -34,6 +37,7 @@ module MercadoPago
|
|
34
37
|
#
|
35
38
|
# - access_token: an access_token of the MercadoPago account associated with the payment to be checked.
|
36
39
|
# - search_hash: querystring in hash format.
|
40
|
+
# - sandbox: whether or not the sandbox mode should be activated.
|
37
41
|
#
|
38
42
|
# == Search parameter valid keys:
|
39
43
|
# id::
|
@@ -97,10 +101,11 @@ module MercadoPago
|
|
97
101
|
# subscription_payment::
|
98
102
|
# Subscription fee.
|
99
103
|
#
|
100
|
-
def self.search(access_token, search_hash = {})
|
104
|
+
def self.search(access_token, search_hash = {}, sandbox = false)
|
101
105
|
query = search_hash.map { |e| e.join('=') }.join('&')
|
102
106
|
|
103
|
-
|
107
|
+
uri_prefix = sandbox ? '/sandbox' : ''
|
108
|
+
MercadoPago::Request.wrap_get("#{uri_prefix}/collections/search?access_token=#{access_token}&#{query}", { accept: 'application/json' })
|
104
109
|
end
|
105
110
|
|
106
111
|
end
|
data/lib/mercadopago/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mercadopago
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kauplus Social Commerce
|
@@ -9,62 +9,62 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ! '>='
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: 1.4.6
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ! '>='
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 1.4.6
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: faraday
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ! '>='
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: 0.9.0
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ! '>='
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: 0.9.0
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: pry
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ! '>='
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ! '>='
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: debugger
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ! '>='
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ! '>='
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
description: This gem allows developers to use the services available in the MercadoPago
|
@@ -75,7 +75,7 @@ executables: []
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
-
-
|
78
|
+
- .gitignore
|
79
79
|
- Gemfile
|
80
80
|
- README.md
|
81
81
|
- Rakefile
|
@@ -99,19 +99,20 @@ require_paths:
|
|
99
99
|
- lib
|
100
100
|
required_ruby_version: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- -
|
102
|
+
- - ! '>='
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - ! '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
111
|
rubyforge_project: mercadopago
|
112
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.4.2
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: Client for the MercadoPago API
|
116
116
|
test_files:
|
117
117
|
- test/test_mercado_pago.rb
|
118
|
+
has_rdoc:
|