mercadopago-api 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +0 -1
- data/README.md +37 -6
- data/lib/mercadopago/api.rb +10 -4
- data/lib/mercadopago/version.rb +1 -1
- data/spec/{mercadopagoapi_spec.rb → mercadopago_spec.rb} +22 -2
- data/spec/spec_helper.rb +3 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 850508386709adf474e9149367fa241642339055
|
4
|
+
data.tar.gz: b35b9fc8a49cfd01fbf66a98cf8f11c038195e6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7856755132044a1d94394ad44531932881d9bc7888b26ac75741f0cd63530bdca689a6e557887952b02e1de4fbba60d75d9bbba53f03b7f85efe93a1dff8253
|
7
|
+
data.tar.gz: b0e2ad2070e22ba11ade231badead7fe6c9fc4d26e6c108f5083db4c1ff37e668b2653dbd1a70ec39f24b3aad0f607d377d68ba4b5777921f6c4d935570e7b37
|
data/.rspec
CHANGED
data/README.md
CHANGED
@@ -107,13 +107,10 @@ Get a notification (IPN) payment info, details [here](http://developers.mercadop
|
|
107
107
|
|
108
108
|
payment = mp_client.get_payment_info(notificaion_payment_id)
|
109
109
|
|
110
|
-
|
111
|
-
|
112
|
-
payment = mp_client.search_payment(payment_id)
|
113
|
-
|
114
|
-
The response for a payment search is:
|
110
|
+
This will return and object like this:
|
115
111
|
|
116
112
|
{
|
113
|
+
code: 200,
|
117
114
|
collection: {
|
118
115
|
id: 52675155,
|
119
116
|
site_id: "Country ID",
|
@@ -161,6 +158,40 @@ The response for a payment search is:
|
|
161
158
|
}
|
162
159
|
}
|
163
160
|
|
161
|
+
Search a payment by payment_id, you can get that when you set your back_urls on checkout Preference, the api will send using query string parameters to your back_url (the api will responde in this case a parameter call collection_id == payment_id)
|
162
|
+
|
163
|
+
payment = mp_client.search_payment(payment_id)
|
164
|
+
|
165
|
+
The response for a payment search is:
|
166
|
+
|
167
|
+
{
|
168
|
+
id: id-del-pago,
|
169
|
+
site_id: "Identificador de país",
|
170
|
+
date_created: "2011-12-25T12:16:45.000-04:00",
|
171
|
+
date_approved: "2011-12-25T12:16:45.000-04:00",
|
172
|
+
last_modified: "2011-12-25T12:16:55.000-04:00",
|
173
|
+
collector_id: id-del-vendedor,
|
174
|
+
payer: {
|
175
|
+
id: 36073078,
|
176
|
+
email: "payer@email.com"
|
177
|
+
}
|
178
|
+
order_id: "id-orden",
|
179
|
+
external_reference: null,
|
180
|
+
reason: "Título de lo que estás pagando",
|
181
|
+
transaction_amount: 40,
|
182
|
+
currency_id: "Tipo de moneda",
|
183
|
+
total_paid_amount: 40,
|
184
|
+
shipping_cost: 0,
|
185
|
+
net_received_amount: 38,
|
186
|
+
status: "approved",
|
187
|
+
status_detail: "accredited",
|
188
|
+
released: "yes",
|
189
|
+
payment_type: "credit_card",
|
190
|
+
installments: 1,
|
191
|
+
money_release_date: "2011-12-27T12:16:45.000-04:00",
|
192
|
+
operation_type: "regular_payment"
|
193
|
+
}
|
194
|
+
|
164
195
|
Search in all your payments given a hash, this hash will set your search parameters. For more details of what parameters you can use to search look [here](http://developers.mercadopago.com/documentation/search-received-payments#search-filters)
|
165
196
|
|
166
197
|
search_query = { :id => "13232333" }
|
@@ -179,7 +210,7 @@ the response of that will be:
|
|
179
210
|
offset: 10
|
180
211
|
},
|
181
212
|
results: [
|
182
|
-
|
213
|
+
collection ## one array of collection, see previus response code
|
183
214
|
]
|
184
215
|
}
|
185
216
|
|
data/lib/mercadopago/api.rb
CHANGED
@@ -7,20 +7,26 @@ module Mercadopago
|
|
7
7
|
|
8
8
|
def checkout_link(data)
|
9
9
|
preference = sdk.create_checkout_preference(data, config[:excluded_payment_methods])
|
10
|
-
if config[:sandbox]
|
11
|
-
preference['init_point']
|
12
|
-
else
|
10
|
+
if config[:sandbox]
|
13
11
|
preference['sandbox_init_point']
|
12
|
+
else
|
13
|
+
preference['init_point']
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
def find_payment(payment_id)
|
18
18
|
if config[:sandbox]
|
19
19
|
result = sdk.search_payments_where({:id => payment_id})['results'].first
|
20
|
-
result["collection"] unless result.nil?
|
21
20
|
else
|
22
21
|
result = sdk.search_payment(payment_id)
|
23
22
|
end
|
23
|
+
result
|
24
|
+
end
|
25
|
+
|
26
|
+
def find_payment_with_notification(payment_id)
|
27
|
+
result = sdk.get_payment_info(payment_id)
|
28
|
+
payment = result['collection']
|
29
|
+
payment[:code] = result[:code]
|
24
30
|
end
|
25
31
|
|
26
32
|
def sdk
|
data/lib/mercadopago/version.rb
CHANGED
@@ -5,11 +5,16 @@ describe 'Test Mercadopago Api Object' do
|
|
5
5
|
@credenciales = MercadopagoTest::CREDENTIALS
|
6
6
|
end
|
7
7
|
|
8
|
-
it "The object must
|
8
|
+
it "The object must be a dependecy of Mercadopago::Mp" do
|
9
9
|
api = MercadopagoTest.new(@credenciales[:client_id], @credenciales[:client_secret])
|
10
10
|
api.should be_kind_of(Mercadopago::Mp)
|
11
11
|
end
|
12
12
|
|
13
|
+
it "SDK method initialize" do
|
14
|
+
sdk = Mercadopago::Sdk.new @credenciales[:client_id], @credenciales[:client_secret]
|
15
|
+
sdk.should be_kind_of(Mercadopago::Sdk)
|
16
|
+
end
|
17
|
+
|
13
18
|
end
|
14
19
|
|
15
20
|
describe 'Mercado Pago api' do
|
@@ -20,6 +25,7 @@ describe 'Mercado Pago api' do
|
|
20
25
|
|
21
26
|
it "The object must initialize only with credentials" do
|
22
27
|
@api.should be_kind_of(Mercadopago::Mp)
|
28
|
+
@api.credentials.should == @credenciales
|
23
29
|
end
|
24
30
|
|
25
31
|
it "The sdk most have a token to work" do
|
@@ -31,4 +37,18 @@ describe 'Mercado Pago api' do
|
|
31
37
|
@api.config = config
|
32
38
|
@api.config.should == config
|
33
39
|
end
|
34
|
-
|
40
|
+
|
41
|
+
it "The preference need to be a mercadopago api preference hash, respond 200" do
|
42
|
+
true
|
43
|
+
end
|
44
|
+
|
45
|
+
it "Search a payment and return only the collection" do
|
46
|
+
payment_id = "660685397121"
|
47
|
+
payment = @api.find_payment(payment_id)
|
48
|
+
if payment
|
49
|
+
payment.should == @api.sdk.search_payment(payment_id)
|
50
|
+
else
|
51
|
+
payment[:code].should == 404
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,13 +4,13 @@ require 'rspec'
|
|
4
4
|
# setup test environment
|
5
5
|
class MercadopagoTest < Mercadopago::Mp
|
6
6
|
CREDENTIALS = {
|
7
|
-
:client_id => "your-client-id
|
8
|
-
:client_secret => "your-client-secret
|
7
|
+
:client_id => "your-client-id",
|
8
|
+
:client_secret => "your-client-secret"
|
9
9
|
}
|
10
10
|
|
11
11
|
CONFIG = {
|
12
12
|
:currency_id => "VEF",
|
13
|
-
:sandbox =>
|
13
|
+
:sandbox => false
|
14
14
|
}
|
15
15
|
end
|
16
16
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mercadopago-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Marin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -99,7 +99,7 @@ files:
|
|
99
99
|
- lib/mercadopago/version.rb
|
100
100
|
- lib/mercadopagoapi.rb
|
101
101
|
- mercadopago-api.gemspec
|
102
|
-
- spec/
|
102
|
+
- spec/mercadopago_spec.rb
|
103
103
|
- spec/spec_helper.rb
|
104
104
|
homepage: https://github.com/highercomve/mercadopago-api
|
105
105
|
licenses:
|
@@ -127,5 +127,5 @@ specification_version: 4
|
|
127
127
|
summary: This gem manage the Mercadopago api using rest-client and mercadopago rest
|
128
128
|
api
|
129
129
|
test_files:
|
130
|
-
- spec/
|
130
|
+
- spec/mercadopago_spec.rb
|
131
131
|
- spec/spec_helper.rb
|