conekta 0.4.4 → 0.4.5
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 +8 -8
- data/CHANGELOG +4 -0
- data/README.md +18 -8
- data/lib/conekta/card.rb +1 -3
- data/lib/conekta/charge.rb +2 -6
- data/lib/conekta/operations/create.rb +1 -2
- data/lib/conekta/operations/create_member.rb +4 -4
- data/lib/conekta/operations/custom_action.rb +3 -7
- data/lib/conekta/operations/find.rb +3 -11
- data/lib/conekta/operations/update.rb +1 -3
- data/lib/conekta/operations/where.rb +3 -10
- data/lib/conekta/payout_method.rb +1 -3
- data/lib/conekta/resource.rb +3 -4
- data/lib/conekta/subscription.rb +2 -3
- data/lib/conekta/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDBkYWQ2NWE4ODYzZDA5MTExOTU0YzJiOGVmZTU1ZjU1NDU2ZjA0ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjBmNDgyYmYyYzJmNDFkMWQ0ZDZiNTU3ZTFlN2ZmMjgyNzQ1Nzk5MQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2IyNmRkMjI1YWU3MDEyYTFjMWY3MDJiNDUyNjVlYzQwZTMzNGQyZjFmN2E0
|
10
|
+
ZWYzNDgxY2M5NjcyOTMwNzkxODU1YjgxM2QwMDQyNDQ5ZmJlYTQyMzc0NzIy
|
11
|
+
MjY5MTI4NTZjNjE3ZmYzMjFjZmEzYjBiYzUzYjAwNzk0ZmNjNWY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDJkMzNhNjkzMTEwMDk2NDg4YmVhODQ2NWEwYjAxZjUzNGZmZWI0MGU4MzA0
|
14
|
+
ZTZhMGVhNWJkOGIyMDY2ZGNjNDY5NDdlMjA1ZTJjNzMxYTZlYzBmMzAyMDc2
|
15
|
+
NmY2YWI5MDcxMzE1Mjc4NzE0YmQ5M2E1ZDNhNWU0YzdlZjZiOTk=
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -21,17 +21,27 @@ Or install it yourself as:
|
|
21
21
|
Conekta.locale = :es
|
22
22
|
|
23
23
|
Conekta.api_key = '1tv5yJp3xnVZ7eK67m4h'
|
24
|
-
|
24
|
+
|
25
25
|
begin
|
26
|
-
|
27
|
-
|
26
|
+
charge = Conekta::Charge.create({
|
27
|
+
amount: 51000,
|
28
|
+
currency: "MXN",
|
29
|
+
description: "Pizza Delivery",
|
30
|
+
reference_id: "orden_de_id_interno",
|
31
|
+
card: params[:conektaTokenId]
|
32
|
+
#"tok_a4Ff0dD2xYZZq82d9"
|
33
|
+
})
|
34
|
+
rescue Conekta::ParameterValidationError => e
|
35
|
+
puts e.message
|
36
|
+
#alguno de los parámetros fueron inválidos
|
37
|
+
rescue Conekta::ProcessingError => e
|
38
|
+
puts e.message
|
39
|
+
#la tarjeta no pudo ser procesada
|
28
40
|
rescue Conekta::Error
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
# Error message translated
|
33
|
-
e.message_to_purchaser
|
41
|
+
puts e.message
|
42
|
+
#un error ocurrió que no sucede en el flujo normal de cobros como por ejemplo un auth_key incorrecto
|
34
43
|
end
|
44
|
+
|
35
45
|
|
36
46
|
{
|
37
47
|
"id": "5286828b8ee31e64b7001739",
|
data/lib/conekta/card.rb
CHANGED
@@ -4,9 +4,7 @@ module Conekta
|
|
4
4
|
include Conekta::Operations::Update
|
5
5
|
include Conekta::Operations::CustomAction
|
6
6
|
def url
|
7
|
-
|
8
|
-
raise Error.new('Could not get the id of ' + self.class.class_name + ' instance.')
|
9
|
-
end
|
7
|
+
raise Error.new('Could not get the id of ' + self.class.class_name + ' instance.') if (id.nil? || id.empty?)
|
10
8
|
self.customer.url + self.class.url + "/" + id
|
11
9
|
end
|
12
10
|
def delete
|
data/lib/conekta/charge.rb
CHANGED
@@ -5,14 +5,10 @@ module Conekta
|
|
5
5
|
include Conekta::Operations::Create
|
6
6
|
include Conekta::Operations::CustomAction
|
7
7
|
def capture
|
8
|
-
custom_action(:post, 'capture'
|
8
|
+
custom_action(:post, 'capture')
|
9
9
|
end
|
10
10
|
def refund(params=nil)
|
11
|
-
|
12
|
-
params = {"amount" => self.amount}
|
13
|
-
else
|
14
|
-
params = {"amount" => params}
|
15
|
-
end
|
11
|
+
params = { 'amount' => (params || self.amount) }
|
16
12
|
custom_action(:post, 'refund', params)
|
17
13
|
end
|
18
14
|
end
|
@@ -3,9 +3,8 @@ module Conekta
|
|
3
3
|
module Create
|
4
4
|
module ClassMethods
|
5
5
|
def create(params)
|
6
|
-
requestor = Requestor.new
|
7
6
|
url = Util.types[self.class_name.downcase].url
|
8
|
-
response =
|
7
|
+
response = Requestor.new.request(:post, url, params)
|
9
8
|
instance = self.new
|
10
9
|
instance.load_from(response)
|
11
10
|
instance
|
@@ -2,13 +2,13 @@ module Conekta
|
|
2
2
|
module Operations
|
3
3
|
module CreateMember
|
4
4
|
def create_member(member, params)
|
5
|
-
url = self.url
|
5
|
+
url = [self.url, member].join('/')
|
6
6
|
member = member.to_sym
|
7
|
-
|
8
|
-
|
7
|
+
response = Requestor.new.request(:post, url, params)
|
8
|
+
|
9
9
|
if self.method(member).call and self.method(member).call.class.class_name == "ConektaObject"
|
10
10
|
arr = []
|
11
|
-
self.method(member).call.values.each do |
|
11
|
+
self.method(member).call.values.each do |_,v|
|
12
12
|
arr << v.to_hash
|
13
13
|
end
|
14
14
|
arr << response
|
@@ -2,13 +2,9 @@ module Conekta
|
|
2
2
|
module Operations
|
3
3
|
module CustomAction
|
4
4
|
def custom_action(method, action=nil, params=nil)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
else
|
9
|
-
url = self.url
|
10
|
-
end
|
11
|
-
response = requestor.request(method, url, params)
|
5
|
+
url = action ? [self.url, action].join('/') : self.url
|
6
|
+
response = Requestor.new.request(method, url, params)
|
7
|
+
|
12
8
|
self.load_from(response)
|
13
9
|
self
|
14
10
|
end
|
@@ -4,21 +4,13 @@ module Conekta
|
|
4
4
|
module ClassMethods
|
5
5
|
def find(id)
|
6
6
|
instance = self.new(id)
|
7
|
-
|
8
|
-
requestor = Requestor.new
|
9
|
-
response = requestor.request(:get, url)
|
7
|
+
response = Requestor.new.request(:get, instance.url)
|
10
8
|
instance.load_from(response)
|
11
9
|
instance
|
12
10
|
end
|
11
|
+
|
13
12
|
# <b>DEPRECATED:</b> Please use <tt>find</tt> instead.
|
14
|
-
|
15
|
-
instance = self.new(id)
|
16
|
-
url = instance.url
|
17
|
-
requestor = Requestor.new
|
18
|
-
response = requestor.request(:get, url)
|
19
|
-
instance.load_from(response)
|
20
|
-
instance
|
21
|
-
end
|
13
|
+
alias_method :retrieve, :find
|
22
14
|
end
|
23
15
|
def self.included(base)
|
24
16
|
base.extend(ClassMethods)
|
@@ -2,9 +2,7 @@ module Conekta
|
|
2
2
|
module Operations
|
3
3
|
module Update
|
4
4
|
def update(params)
|
5
|
-
|
6
|
-
url = self.url
|
7
|
-
response = requestor.request(:put, url, params)
|
5
|
+
response = Requestor.new.request(:put, self.url, params)
|
8
6
|
self.load_from(response)
|
9
7
|
self
|
10
8
|
end
|
@@ -5,20 +5,13 @@ module Conekta
|
|
5
5
|
def where(params=nil)
|
6
6
|
instance = ConektaObject.new
|
7
7
|
url = Util.types[self.class_name.downcase].url
|
8
|
-
|
9
|
-
response = requestor.request(:get, url,params)
|
8
|
+
response = Requestor.new.request(:get, url,params)
|
10
9
|
instance.load_from(response)
|
11
10
|
instance
|
12
11
|
end
|
12
|
+
|
13
13
|
# <b>DEPRECATED:</b> Please use <tt>where</tt> instead.
|
14
|
-
|
15
|
-
instance = ConektaObject.new
|
16
|
-
url = Util.types[self.class_name.downcase].url
|
17
|
-
requestor = Requestor.new
|
18
|
-
response = requestor.request(:get, url)
|
19
|
-
instance.load_from(response)
|
20
|
-
instance
|
21
|
-
end
|
14
|
+
alias_method :all, :where
|
22
15
|
end
|
23
16
|
def self.included(base)
|
24
17
|
base.extend(ClassMethods)
|
@@ -4,9 +4,7 @@ module Conekta
|
|
4
4
|
include Conekta::Operations::Update
|
5
5
|
include Conekta::Operations::CustomAction
|
6
6
|
def url
|
7
|
-
|
8
|
-
raise Error.new('Could not get the id of ' + self.class.class_name + ' instance.')
|
9
|
-
end
|
7
|
+
raise Error.new('Could not get the id of ' + self.class.class_name + ' instance.') if (id.nil? || id.empty?)
|
10
8
|
self.payee.url + self.class.url + "/" + id
|
11
9
|
end
|
12
10
|
def delete
|
data/lib/conekta/resource.rb
CHANGED
@@ -4,10 +4,9 @@ module Conekta
|
|
4
4
|
"/#{CGI.escape(self.class_name.downcase)}s"
|
5
5
|
end
|
6
6
|
def url
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
self.class.url + "/" + id
|
7
|
+
raise Error.new(I18n.t('error.resource.id', {resource: self.class.class_name, locale: :en}), I18n.t('error.resource.id', {resource: self.class.class_name, locale: Conekta.locale.to_sym})) if (id.nil? || id.empty?)
|
8
|
+
|
9
|
+
return [self.class.url, id].join('/')
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|
data/lib/conekta/subscription.rb
CHANGED
@@ -3,9 +3,8 @@ module Conekta
|
|
3
3
|
include Conekta::Operations::Update
|
4
4
|
include Conekta::Operations::CustomAction
|
5
5
|
def url
|
6
|
-
|
7
|
-
|
8
|
-
end
|
6
|
+
raise Error.new('Could not get the id of ' + self.class.class_name + ' instance.') if (id.nil? || id.empty?)
|
7
|
+
|
9
8
|
self.customer.url + "/subscription"
|
10
9
|
end
|
11
10
|
def pause
|
data/lib/conekta/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conekta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MauricioMurga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|