compropago_sdk 3.1.2.1 → 4.0.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1e438fb001c675367c2a1e7274194267f1e6448
4
- data.tar.gz: e0baa501aa4ed0dd94466bae11acbfa97cca16f6
3
+ metadata.gz: 1a3d22b5b9fb806d2946406c3576e3275e587718
4
+ data.tar.gz: 775c0b6f80e9b5afd54b0d82c7b4662cd0a4763e
5
5
  SHA512:
6
- metadata.gz: 76d2acb5b3d11f0d7a98f5c680a47f289dfeceb030988c61a8cb1fb2b3481d393b6346918e302bdfda00f97b4c8b207990085d362accb06e6c77199f53add3c1
7
- data.tar.gz: acc799aec7d970f3035770ab963e35dbadbd4b06986ec0c84e21e9776b89a7b0fbe6a2fbf2edf9d77c5a134d188e8863fbf0d209f5d2f5e1b2eb2848b5182d99
6
+ metadata.gz: a3e249629ae06777f9d92b48273f68155404bdef113fe200d8f79b252224612a51380e046ff33a0a9c63c379c74ce7fbd1ca4782f87395b57fa8ed27cdb3497b
7
+ data.tar.gz: cec639b1a97fe361ad8a318bb1648a26d7b3c85f8a09f03556acd07067b1e61b79feb37e372e4e8b85c3aca9c9b179f887edb089fffef473da2c1b9b1c9603fa
@@ -2,6 +2,7 @@ require 'openssl'
2
2
 
3
3
  require 'net/http'
4
4
  require 'json'
5
+ require 'uri'
5
6
  require 'base64'
6
7
  require 'easy_request'
7
8
 
@@ -3,7 +3,7 @@ class Client
3
3
  API_LIVE_URI = 'https://api.compropago.com/v1/'
4
4
  API_SANDBOX_URI = 'https://api.compropago.com/v1/'
5
5
 
6
- VERSION = '3.1.2.1'
6
+ VERSION = '3.0.4'
7
7
 
8
8
  attr_accessor :publickey, :privatekey, :live, :deploy_uri, :api
9
9
 
File without changes
@@ -1,9 +1,12 @@
1
1
  class CpOrderInfo
2
2
 
3
3
  attr_accessor :id
4
+ attr_accessor :short_id
4
5
  attr_accessor :type
5
6
  attr_accessor :object
6
- attr_accessor :created
7
+ attr_accessor :created_at
8
+ attr_accessor :accepted_at
9
+ attr_accessor :expires_at
7
10
  attr_accessor :paid
8
11
  attr_accessor :amount
9
12
  attr_accessor :livemode
@@ -13,12 +16,7 @@ class CpOrderInfo
13
16
  attr_accessor :fee_details
14
17
  attr_accessor :order_info
15
18
  attr_accessor :customer
16
- attr_accessor :captured
17
- attr_accessor :failure_message
18
- attr_accessor :failure_code
19
- attr_accessor :amount_refunded
20
- attr_accessor :description
21
- attr_accessor :dispute
19
+ attr_accessor :api_version
22
20
 
23
21
  def initialize
24
22
  @fee_details = FeeDetails.new
File without changes
File without changes
File without changes
@@ -1,11 +1,10 @@
1
1
  class FeeDetails
2
2
 
3
3
  attr_accessor :amount
4
- attr_accessor :tax
5
- attr_accessor :tax_percent
6
4
  attr_accessor :currency
7
5
  attr_accessor :type
8
- attr_accessor :description
6
+ attr_accessor :application
9
7
  attr_accessor :amount_refunded
10
-
8
+ attr_accessor :tax
9
+
11
10
  end
File without changes
@@ -2,19 +2,27 @@ class NewOrderInfo
2
2
 
3
3
  attr_accessor :id
4
4
  attr_accessor :short_id
5
+ attr_accessor :type
5
6
  attr_accessor :object
6
- attr_accessor :status
7
- attr_accessor :created
8
- attr_accessor :exp_date
9
- attr_accessor :live_mode
10
- attr_accessor :order_info
7
+ attr_accessor :created_at
8
+ attr_accessor :accepted_at
9
+ attr_accessor :expires_at
10
+ attr_accessor :paid
11
+ attr_accessor :amount
12
+ attr_accessor :livemode
13
+ attr_accessor :currency
14
+ attr_accessor :refunded
15
+ attr_accessor :fee
11
16
  attr_accessor :fee_details
17
+ attr_accessor :order_info
18
+ attr_accessor :customer
12
19
  attr_accessor :instructions
13
20
  attr_accessor :api_version
14
21
 
15
22
  def initialize
16
23
  @order_info = OrderInfo.new
17
24
  @fee_details = FeeDetails.new
25
+ @customer = Customer.new
18
26
  @instructions = Instructions.new
19
27
  end
20
28
 
@@ -1,9 +1,14 @@
1
1
  class OrderInfo
2
2
 
3
3
  attr_accessor :order_id
4
- attr_accessor :order_name
5
4
  attr_accessor :order_price
5
+ attr_accessor :order_name
6
+ attr_accessor :payment_method
7
+ attr_accessor :store
8
+ attr_accessor :country
6
9
  attr_accessor :image_url
10
+ attr_accessor :success_url
11
+ attr_accessor :fialed_url
7
12
  attr_accessor :exchange
8
13
 
9
14
  def initialize
@@ -5,6 +5,7 @@ class PlaceOrderInfo
5
5
  attr_accessor :order_price
6
6
  attr_accessor :customer_name
7
7
  attr_accessor :customer_email
8
+ attr_accessor :customer_phone
8
9
  attr_accessor :payment_type
9
10
  attr_accessor :currency
10
11
  attr_accessor :expiration_time
@@ -10,6 +10,5 @@ class Provider
10
10
  attr_accessor :image_large
11
11
  attr_accessor :transaction_limit
12
12
  attr_accessor :rank
13
- attr_accessor :commission
14
13
 
15
14
  end
File without changes
File without changes
File without changes
File without changes
@@ -14,39 +14,36 @@ class Serialize
14
14
  data[:currency] ? data[:currency] : 'MXN',
15
15
  data[:expiration_time] ? data[:expiration_time] : nil,
16
16
  data[:image_url] ? data[:image_url] : '',
17
- data[:app_client_name] ? data[:app_client_name] : 'sdkruby',
17
+ data[:app_client_name] ? data[:app_client_name] : 'sdk-ruby',
18
18
  data[:app_client_version] ? data[:app_client_version] : Client::VERSION,
19
19
  )
20
20
  end
21
21
  end
22
22
 
23
23
  def self.cp_order_info(data=nil)
24
+ puts JSON.pretty_generate(data)
24
25
  if data.nil?
25
26
  return CpOrderInfo.new
26
27
  else
27
28
  obj = CpOrderInfo.new
28
29
 
29
30
  obj.id = data['id']
31
+ obj.short_id = data['short_id']
30
32
  obj.type = data['type']
31
33
  obj.object = data['object']
32
- obj.created = data['created']
34
+ obj.created_at = data['created_at']
35
+ obj.accepted_at = data['accepted_at']
36
+ obj.expires_at = data['expires_at']
33
37
  obj.paid = data['paid']
34
38
  obj.amount = data['amount']
35
39
  obj.livemode = data['livemode']
36
40
  obj.currency = data['currency']
37
41
  obj.refunded = data['refunded']
38
42
  obj.fee = data['fee']
39
-
40
43
  obj.fee_details = Serialize::fee_details(data['fee_details'])
41
44
  obj.order_info = Serialize::order_info(data['order_info'])
42
45
  obj.customer = Serialize::customer(data['customer'])
43
-
44
- obj.captured = data['captured']
45
- obj.failure_message = data['failure_message']
46
- obj.failure_code = data['failure_code']
47
- obj.amount_refunded = data['amount_refunded']
48
- obj.description = data['description']
49
- obj.dispute = data['dispute']
46
+ obj.api_version = data['']
50
47
 
51
48
  return obj
52
49
  end
@@ -88,13 +85,12 @@ class Serialize
88
85
  else
89
86
  obj = FeeDetails.new
90
87
 
91
- obj.amount = data['amount'] ? data['amount'] : nil
92
- obj.tax = data['tax'] ? data['tax'] : nil
93
- obj.tax_percent = data['tax_percent'] ? data['tax_percent'] : nil
94
- obj.currency = data['currency'] ? data['currency'] : nil
95
- obj.type = data['type'] ? data['type'] : nil
96
- obj.description = data['description'] ? data['description'] : nil
97
- obj.amount_refunded = data['amount_refunded'] ? data['amount_refunded'] : nil
88
+ obj.amount = data['amount']
89
+ obj.currency = data['currency']
90
+ obj.type = data['type']
91
+ obj.application = data['application']
92
+ obj.amount_refunded = data['amount_refunded']
93
+ obj.tax = data['tax']
98
94
 
99
95
  return obj
100
96
  end
@@ -151,13 +147,20 @@ class Serialize
151
147
 
152
148
  obj.id = data['id']
153
149
  obj.short_id = data['short_id']
150
+ obj.type = data['type']
154
151
  obj.object = data['object']
155
- obj.status = data['status']
156
- obj.created = data['created']
157
- obj.exp_date = data['exp_date']
158
- obj.live_mode = data['live_mode']
159
- obj.order_info = Serialize::order_info(data['order_info'])
152
+ obj.created_at = data['created_at']
153
+ obj.accepted_at = data['accepted_at']
154
+ obj.expires_at = data['expires_at']
155
+ obj.paid = data['paid']
156
+ obj.amount = data['amount']
157
+ obj.livemode = data['livemode']
158
+ obj.currency = data['currency']
159
+ obj.refunded = data['refunded']
160
+ obj.fee = data['fee']
160
161
  obj.fee_details = Serialize::fee_details(data['fee_details'])
162
+ obj.order_info = Serialize::order_info(data['order_info'])
163
+ obj.customer = Serialize::customer(data['customer'])
161
164
  obj.instructions = Serialize::instructions(data['instructions'])
162
165
  obj.api_version = data['api_version']
163
166
 
@@ -171,10 +174,15 @@ class Serialize
171
174
  else
172
175
  obj = OrderInfo.new
173
176
 
174
- obj.order_id = data['order_id'] ? data['order_id'] : nil
175
- obj.order_name = data['order_name'] ? data['order_name'] : nil
176
- obj.order_price = data['order_price'] ? data['order_price'] : nil
177
- obj.image_url = data['image_url'] ? data['image_url'] : nil
177
+ obj.order_id = data['order_id']
178
+ obj.order_price = data['order_price']
179
+ obj.order_name = data['order_name']
180
+ obj.payment_method = data['payment_method']
181
+ obj.store = data['store']
182
+ obj.country = data['country']
183
+ obj.image_url = data['image_url']
184
+ obj.success_url = data['success_url']
185
+ obj.fialed_url = data['failed_url']
178
186
  obj.exchange = Serialize::exchange(data['exchange'])
179
187
 
180
188
  return obj
@@ -215,7 +223,6 @@ class Serialize
215
223
  obj.image_large = data['image_large']
216
224
  obj.transaction_limit = data['transaction_limit']
217
225
  obj.rank = data['rank']
218
- obj.commission = data['commission']
219
226
 
220
227
  return obj
221
228
  end
@@ -1,27 +1,18 @@
1
1
  class Service
2
- # Constructor
3
- #
4
- # @author Eduardo Aguilar <dante.aguilar41@gmail.com>
2
+ # FUNCTION: constructor
5
3
  def initialize(client)
6
4
  @client = client
7
5
  end
8
6
 
9
- # Get auth params
10
- #
7
+ # FUNCTION: get auth params
11
8
  # @return [Hash]
12
- #
13
- # @author Eduardo Aguilar <dante.aguilar41@gmail.com>
14
9
  def get_auth
15
10
  { :user => @client.get_user, :pass => @client.get_pass }
16
11
  end
17
12
 
18
- # List providers by limit and currency
19
- #
20
- # @param [float] limit limite de transaccion de los proveedores
21
- # @param [string] currency
22
- # @return [Array]
23
- #
24
- # @author Eduardo Aguilar <dante.aguilar41@gmail.com>
13
+ # FUNCTION: list providers by limit and currency
14
+ # @param limit [Float] limite de transaccion de los proveedores
15
+ # @param currency [String]
25
16
  def list_providers(limit=0, currency='MXN')
26
17
  uri = @client.deploy_uri+'providers/'
27
18
 
@@ -34,26 +25,21 @@ class Service
34
25
  end
35
26
 
36
27
  response = EasyRequest::get(uri, get_auth())
37
- Factory::get_instance_of('ListProviders', response)
28
+
29
+ Factory::get_instance_of 'ListProviders', response
38
30
  end
39
31
 
40
- # Verify order by unique_id
41
- #
42
- # @param [string] order_id
32
+ # FUNCTION: veridy order by unique_id
43
33
  # @return [CpOrderInfo]
44
- #
45
- # @author Eduardo Aguilar <dante.aguilar41@gmail.com>
46
34
  def verify_order(order_id)
47
35
  response = EasyRequest::get( @client.deploy_uri+'charges/'+order_id+'/', get_auth())
48
- Factory::get_instance_of('CpOrderInfo', response)
36
+
37
+ Factory::get_instance_of 'CpOrderInfo', response
49
38
  end
50
39
 
51
- # Place order
52
- #
53
- # @param [PlaceOrderInfo] order
40
+ # FUNCTION: place order
41
+ # @param order [PlaceOrderInfo]
54
42
  # @return [NewOrderInfo]
55
- #
56
- # @author Eduardo Aguilar <dante.aguilar41@gmail.com>
57
43
  def place_order(order)
58
44
  unless order.is_a?(PlaceOrderInfo)
59
45
  raise 'Order object is not valid'
@@ -70,69 +56,64 @@ class Service
70
56
  expiration_time: order.expiration_time,
71
57
  image_url: order.image_url,
72
58
  app_client_name: order.app_client_name,
73
- app_client_version: order.app_client_version
59
+ app_client_version: order.app_client_version,
74
60
  }
75
61
 
76
62
  response = EasyRequest::post(@client.deploy_uri+'charges/', params, get_auth())
77
- Factory::get_instance_of('NewOrderInfo', response)
63
+
64
+ Factory::get_instance_of 'NewOrderInfo', response
78
65
  end
79
66
 
80
- # Send sms of an order
81
- #
82
- # @param [string] number phone number
83
- # @param [string] order_id id de la orden generada
67
+ # FUNCTION: send sms of an order
68
+ # @param number [String] phone number
69
+ # @param order_id [String] id de la orden generada
84
70
  # @return [SmsInfo]
85
- #
86
- # @author Eduardo Aguilar <dante.aguilar41@gmail.com>
87
71
  def send_sms_instructions(number, order_id)
88
72
  params = {customer_phone: number}
73
+
89
74
  response = EasyRequest::post(@client.deploy_uri+'charges/'+order_id+'/sms/', params, get_auth())
90
- Factory::get_instance_of('SmsInfo', response)
75
+
76
+ Factory::get_instance_of 'SmsInfo', response
91
77
  end
92
78
 
93
- # Creatre webhook
94
- #
95
- # @param [string] url
79
+ # FUNCTION: creatre webhook
80
+ # @param url [String] url for the new webhook
96
81
  # @return [Webhook]
97
- #
98
- # @author Eduardo Aguilar <dante.aguilar41@gmail.com>
99
82
  def create_webhook(url)
100
83
  params = {url: url}
84
+
101
85
  response = EasyRequest::post(@client.deploy_uri+'webhooks/stores/', params, get_auth())
102
- Factory::get_instance_of('Webhook', response)
86
+
87
+ Factory::get_instance_of 'Webhook', response
103
88
  end
104
89
 
105
- # Update registered webhook
106
- #
107
- # @param [string] webhook_id registered webhook ID
108
- # @param [string] new_url new url for the webhook
109
- # @return [Webhook]
110
- #
111
- # @author Eduardo Aguilar <dante.aguilar41@gmail.com>
90
+ # FUNCTION: update registered webhook
91
+ # @param webhook_id [String] registered webhook ID
92
+ # @param new_url [String] new url for the webhook
93
+ # @return [Webhook]
112
94
  def update_webhook(webhook_id, new_url)
113
95
  params = {url: new_url}
96
+
114
97
  response = EasyRequest::put(@client.deploy_uri+'webhooks/stores/'+webhook_id+'/', params, get_auth())
115
- Factory::get_instance_of('Webhook', response)
98
+
99
+ Factory::get_instance_of 'Webhook', response
116
100
  end
117
101
 
118
- # Delete webhook
119
- #
120
- # @param [string] webhook_id registered webhook ID
102
+ # FUNCTION: delete webhook
103
+ # @param webhook_id [String] registered webhook ID
121
104
  # @param [Webhook]
122
- #
123
- # @author Eduardo Aguilar <dante.aguilar41@gmail.com>
124
105
  def delete_webhook(webhook_id)
125
106
  response = EasyRequest::delete(@client.deploy_uri+'webhooks/stores/'+webhook_id, nil, get_auth())
126
- Factory::get_instance_of('Webhook', response)
107
+
108
+ Factory::get_instance_of 'Webhook', response
127
109
  end
128
110
 
129
- # Get list registered webhooks
130
- #
131
- # @return [Array]
132
- #
133
- # @author Eduardo Aguilar <dante.aguilar41@gmail.com>
111
+ # FUNCTION: get list registered webhooks
112
+ # @return [ListWebhooks]
134
113
  def list_webhooks
135
114
  response = EasyRequest::get(@client.deploy_uri+'webhooks/stores/', get_auth())
136
- Factory::get_instance_of('ListWebhooks', response)
115
+
116
+ Factory::get_instance_of 'ListWebhooks', response
137
117
  end
118
+
138
119
  end
@@ -1,12 +1,5 @@
1
1
  class Validations
2
2
 
3
- # Obtain auth info
4
- #
5
- # @param [Client] client
6
- # @return [EvalAuthInfo]
7
- # @raise [Error]
8
- #
9
- # @author Eduardo Aguilar <dante.aguilar41@gmail.com>
10
3
  def self.eval_auth(client)
11
4
  response = EasyRequest::get(client.deploy_uri+'users/auth/', user: client.get_user, pass: client.get_pass)
12
5
  info = Factory.get_instance_of('EvalAuthInfo', response)
@@ -18,13 +11,6 @@ class Validations
18
11
  end
19
12
  end
20
13
 
21
- # Validate client instance
22
- #
23
- # @param [Client] client
24
- # @return [bool]
25
- # @raise [Error]
26
- #
27
- # @author Eduardo Aguilar <dante.aguilar41@gmail.com>
28
14
  def self.validate_gateway(client)
29
15
  unless client
30
16
  raise 'Client object is not valid'
@@ -32,7 +18,7 @@ class Validations
32
18
 
33
19
  client_mode = client.live
34
20
 
35
- auth_info = Validations::eval_auth(client)
21
+ auth_info = Validations::eval_auth client
36
22
 
37
23
  if auth_info.mode_key != auth_info.livemode
38
24
  raise 'Keys are diferent of store mode.'
@@ -45,8 +31,6 @@ class Validations
45
31
  if client_mode != auth_info.mode_key
46
32
  raise 'Client mode is diferent of keys mode'
47
33
  end
48
-
49
- return true
50
34
  end
51
35
 
52
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compropago_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2.1
4
+ version: 4.0.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo Aguilar
@@ -9,64 +9,64 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-11-16 00:00:00.000000000 Z
12
+ date: 2017-08-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '0'
20
+ version: '1.0'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ">="
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '0'
27
+ version: '1.0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '0'
34
+ version: '12.0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '0'
41
+ version: '12.0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: minitest
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '0'
48
+ version: '5.10'
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
- version: '0'
55
+ version: '5.10'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: easy_request
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: 0.0.2
62
+ version: '0'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - "~>"
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 0.0.2
69
+ version: '0'
70
70
  description: Provee los servicios de creacion de cargos verificacion etc.
71
71
  email:
72
72
  - eduardo.aguilar@compropago.com
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  requirements: []
118
118
  rubyforge_project:
119
- rubygems_version: 2.5.2
119
+ rubygems_version: 2.6.11
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: Gema para API ComproPago