mercadopago-api 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +176 -5
- data/Rakefile +2 -2
- data/lib/mercadopago/api.rb +1 -1
- data/lib/mercadopago/sdk.rb +1 -1
- data/lib/mercadopago/version.rb +1 -1
- data/mercadopago-api.gemspec +1 -2
- data/spec/spec_helper.rb +2 -2
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d82c002011ea32c8553db542e64a6d07c2b4f972
|
4
|
+
data.tar.gz: bd5e5b5c61cca31dd17cc00762f9b66d365757fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f206660a89b924531a42305a6257df866fb281a179c4927f23227fade0ee6ba3b4d1c7d2a0fefa6eae25b8c31a6e71760bcdb9f7a1344687941f51f6ba293a3
|
7
|
+
data.tar.gz: 41a3716fa1d8f9995434e1a4cfb3793ba67f914c0ebad3e8746cd1ea499bb352d4785afe28f700b32f31f09a5d504a28ba6ceafc2a13242619dd8bd309036902
|
data/README.md
CHANGED
@@ -1,24 +1,195 @@
|
|
1
1
|
# Mercadopago::Api
|
2
2
|
|
3
|
-
|
3
|
+
This is a Gem to manage mercadopago using ruby, you can use the Gem like a simple Sdk to mercadopago api or like a extension module with another options.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
|
9
|
+
gem 'mercadopago-api'
|
10
10
|
|
11
11
|
And then execute:
|
12
12
|
|
13
|
-
|
13
|
+
$ bundle install
|
14
14
|
|
15
15
|
Or install it yourself as:
|
16
16
|
|
17
|
-
|
17
|
+
$ gem install mercadopago-api
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
The gem has to ways of use it, the basic way like a normal SDK
|
22
|
+
|
23
|
+
### Usage like SDK
|
24
|
+
|
25
|
+
For normal use
|
26
|
+
|
27
|
+
mp_client = Mercadopago::Sdk.new(client_id, client_secret)
|
28
|
+
|
29
|
+
Accept a optional parameter true or false to activate sandbox mode
|
30
|
+
|
31
|
+
sandbox_client = Mercadopago::Sdk.new(client_id, client_secret, true)
|
32
|
+
|
33
|
+
#### Manage Preference
|
34
|
+
|
35
|
+
Create a checkout preference to create a link to mercadopago checkout
|
36
|
+
|
37
|
+
preference = mp_client.create_checkout_preference(data)
|
38
|
+
|
39
|
+
Data format is describe [here](http://developers.mercadopago.com/documentacion/api/preferences#glossary)
|
40
|
+
|
41
|
+
The minimal hash for data is:
|
42
|
+
|
43
|
+
data = {
|
44
|
+
:items => [
|
45
|
+
{
|
46
|
+
:title => "Title of product",
|
47
|
+
:currency_id => "VEF",
|
48
|
+
:unit_price => 2000.50,
|
49
|
+
:quantity => 2,
|
50
|
+
}
|
51
|
+
]
|
52
|
+
}
|
53
|
+
|
54
|
+
The api response wil gave this format, will be a ruby hash and the key values will be like string not like symbols
|
55
|
+
|
56
|
+
{
|
57
|
+
"code": 200,
|
58
|
+
"external_reference": "Reference_1234",
|
59
|
+
"items": [
|
60
|
+
{
|
61
|
+
"id": "Code",
|
62
|
+
"title": "Title of what youre paying for",
|
63
|
+
"description": "Description",
|
64
|
+
"quantity": 1,
|
65
|
+
"unit_price": 50.5,
|
66
|
+
"currency_id": "Currency",
|
67
|
+
"picture_url": "https://www.mercadopago.com/org-img/MP3/home/logomp3.gif"
|
68
|
+
}
|
69
|
+
], "date_created": "2011-08-16T21:28:42.606-04:00",
|
70
|
+
"id": "preference_identifier",
|
71
|
+
"collector_id": "your_ID_as_seller",
|
72
|
+
"init_point": "checkout-access-URL",
|
73
|
+
"payer": {
|
74
|
+
"email": "payer@email.com",
|
75
|
+
"name": "payer-name",
|
76
|
+
"surname": "payer-surname"
|
77
|
+
},
|
78
|
+
"back_urls": {
|
79
|
+
"success": "https://www.success.com",
|
80
|
+
"failure": "http://www.failure.com",
|
81
|
+
"pending": "http://www.pending.com"
|
82
|
+
},
|
83
|
+
"payment_methods": {
|
84
|
+
"excluded_payment_methods": [
|
85
|
+
{
|
86
|
+
"id": "amex"
|
87
|
+
}
|
88
|
+
],
|
89
|
+
"excluded_payment_types": [
|
90
|
+
{
|
91
|
+
"id": "ticket"
|
92
|
+
}
|
93
|
+
],
|
94
|
+
"installments": 12
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
If you have to search a previus create preference
|
99
|
+
|
100
|
+
preference = mp_client.get_checkout_preference(preference_id)
|
101
|
+
|
102
|
+
If you have to update a Preference
|
103
|
+
|
104
|
+
preference = mp_client.update_checkout_preference(preference_id, new_data)
|
105
|
+
|
106
|
+
Get a notification (IPN) payment info, details [here](http://developers.mercadopago.com/documentation/instant-payment-notifications)
|
107
|
+
|
108
|
+
payment = mp_client.get_payment_info(notificaion_payment_id)
|
109
|
+
|
110
|
+
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)
|
111
|
+
|
112
|
+
payment = mp_client.search_payment(payment_id)
|
113
|
+
|
114
|
+
The response for a payment search is:
|
115
|
+
|
116
|
+
{
|
117
|
+
collection: {
|
118
|
+
id: 52675155,
|
119
|
+
site_id: "Country ID",
|
120
|
+
operation_type: "regular_payment",
|
121
|
+
order_id: "4442154",
|
122
|
+
external_reference: "150671633",
|
123
|
+
status: "approved",
|
124
|
+
status_detail: "accredited",
|
125
|
+
payment_type: "ticket",
|
126
|
+
date_created: "2011-09-02T04:00:000Z",
|
127
|
+
last_modified: "2011-09-12T02:52:530Z",
|
128
|
+
date_approved: "2011-09-02T02:49:530Z",
|
129
|
+
money_release_date: "2011-09-09T02:49:530Z",
|
130
|
+
currency_id: "Currency",
|
131
|
+
transaction_amount: 50.5,
|
132
|
+
shipping_cost: 0,
|
133
|
+
finance_charge: null,
|
134
|
+
total_paid_amount: 50.5,
|
135
|
+
net_received_amount: 0,
|
136
|
+
reason: "Title of what youre paying for",
|
137
|
+
payer: {
|
138
|
+
id: 36073078,
|
139
|
+
first_name: "payer-name",
|
140
|
+
last_name: "payer-surname",
|
141
|
+
email: "payer@email.com",
|
142
|
+
nickname: "payer-MercadoLibre's-nickname"
|
143
|
+
phone: {
|
144
|
+
area_code: "011",
|
145
|
+
number: "3486 5039",
|
146
|
+
extension: null
|
147
|
+
}
|
148
|
+
},
|
149
|
+
collector: {
|
150
|
+
id: 68961616,
|
151
|
+
first_name: "collector-name",
|
152
|
+
last_name: "collector-surname",
|
153
|
+
email: "collector@email.com",
|
154
|
+
nickname: "collector-MercadoLibre's-nickname"
|
155
|
+
phone: {
|
156
|
+
area_code: "211",
|
157
|
+
number: "3486 5039",
|
158
|
+
extension: null
|
159
|
+
}
|
160
|
+
}
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
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
|
+
|
166
|
+
search_query = { :id => "13232333" }
|
167
|
+
payments = search_payments_where( search_query )
|
168
|
+
|
169
|
+
# Search by status
|
170
|
+
search_query = { :status => "approved" }
|
171
|
+
payments = search_payments_where( search_query )
|
172
|
+
|
173
|
+
the response of that will be:
|
174
|
+
|
175
|
+
{
|
176
|
+
paging: {
|
177
|
+
total: 76,
|
178
|
+
limit: 2,
|
179
|
+
offset: 10
|
180
|
+
},
|
181
|
+
results: [
|
182
|
+
collention ## one array of collection, see previus response code
|
183
|
+
]
|
184
|
+
}
|
185
|
+
|
186
|
+
TODO: refund_payment
|
187
|
+
|
188
|
+
TODO: cancel_payment
|
189
|
+
|
190
|
+
### Usage like extension
|
191
|
+
|
192
|
+
TODO: write this
|
22
193
|
|
23
194
|
## Contributing
|
24
195
|
|
data/Rakefile
CHANGED
@@ -20,8 +20,8 @@ end
|
|
20
20
|
desc 'Tags version, pushes to remote, and pushes gem'
|
21
21
|
task :release => :build do
|
22
22
|
sh "git tag v#{Mercadopago::VERSION}"
|
23
|
-
sh "git push
|
24
|
-
sh "git push
|
23
|
+
sh "git push github master"
|
24
|
+
sh "git push github v#{Mercadopago::VERSION}"
|
25
25
|
sh "gem push mercadopago-api-#{Mercadopago::VERSION}.gem"
|
26
26
|
end
|
27
27
|
|
data/lib/mercadopago/api.rb
CHANGED
data/lib/mercadopago/sdk.rb
CHANGED
data/lib/mercadopago/version.rb
CHANGED
data/mercadopago-api.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["higher.vnf@gmail.com"]
|
11
11
|
spec.description = %q{Gem to manage the mercadopago api}
|
12
12
|
spec.summary = %q{This gem manage the Mercadopago api using rest-client and mercadopago rest api}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/highercomve/mercadopago-api"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
@@ -23,5 +23,4 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency 'rspec'
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.3"
|
25
25
|
spec.add_development_dependency "rake"
|
26
|
-
spec.add_development_dependency 'test'
|
27
26
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,8 +4,8 @@ require 'rspec'
|
|
4
4
|
# setup test environment
|
5
5
|
class MercadopagoTest < Mercadopago::Mp
|
6
6
|
CREDENTIALS = {
|
7
|
-
:client_id => "
|
8
|
-
:client_secret => "
|
7
|
+
:client_id => "your-client-id-on-mercadopago",
|
8
|
+
:client_secret => "your-client-secret-on-mercadopago"
|
9
9
|
}
|
10
10
|
|
11
11
|
CONFIG = {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Marin
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: test
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - '>='
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - '>='
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
83
|
description: Gem to manage the mercadopago api
|
98
84
|
email:
|
99
85
|
- higher.vnf@gmail.com
|
@@ -115,7 +101,7 @@ files:
|
|
115
101
|
- mercadopago-api.gemspec
|
116
102
|
- spec/mercadopagoapi_spec.rb
|
117
103
|
- spec/spec_helper.rb
|
118
|
-
homepage:
|
104
|
+
homepage: https://github.com/highercomve/mercadopago-api
|
119
105
|
licenses:
|
120
106
|
- MIT
|
121
107
|
metadata: {}
|
@@ -135,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
121
|
version: '0'
|
136
122
|
requirements: []
|
137
123
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.0.
|
124
|
+
rubygems_version: 2.0.7
|
139
125
|
signing_key:
|
140
126
|
specification_version: 4
|
141
127
|
summary: This gem manage the Mercadopago api using rest-client and mercadopago rest
|