Class: Mercadopago::Client
- Inherits:
-
Object
- Object
- Mercadopago::Client
- Includes:
- Api, Authentication, Preferences
- Defined in:
- app/models/mercadopago/client.rb,
app/models/mercadopago/client/api.rb,
app/models/mercadopago/client/preferences.rb,
app/models/mercadopago/client/authentication.rb
Defined Under Namespace
Modules: Api, Authentication, Preferences
Instance Attribute Summary collapse
-
#auth_response ⇒ Object
readonly
Returns the value of attribute auth_response.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#preferences_response ⇒ Object
readonly
Returns the value of attribute preferences_response.
Instance Method Summary collapse
- #get_operation_info(operation_id) ⇒ Object
-
#get_payment_status(external_reference) ⇒ Object
def get_external_reference(operation_id) response = send_notification_request(operation_id) if response response[‘external_reference’] end end.
-
#initialize(payment_method, options = {}) ⇒ Client
constructor
A new instance of Client.
Methods included from Api
Methods included from Preferences
Methods included from Authentication
Constructor Details
#initialize(payment_method, options = {}) ⇒ Client
Returns a new instance of Client.
20 21 22 23 24 |
# File 'app/models/mercadopago/client.rb', line 20 def initialize(payment_method, = {}) @payment_method = payment_method @api_options = .clone @errors = [] end |
Instance Attribute Details
#auth_response ⇒ Object (readonly)
Returns the value of attribute auth_response.
17 18 19 |
# File 'app/models/mercadopago/client.rb', line 17 def auth_response @auth_response end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
16 17 18 |
# File 'app/models/mercadopago/client.rb', line 16 def errors @errors end |
#preferences_response ⇒ Object (readonly)
Returns the value of attribute preferences_response.
18 19 20 |
# File 'app/models/mercadopago/client.rb', line 18 def preferences_response @preferences_response end |
Instance Method Details
#get_operation_info(operation_id) ⇒ Object
26 27 28 29 30 |
# File 'app/models/mercadopago/client.rb', line 26 def get_operation_info(operation_id) url = create_url(notifications_url(operation_id), access_token: access_token) = { content_type: 'application/x-www-form-urlencoded', accept: 'application/json' } get(url, , quiet: true) end |
#get_payment_status(external_reference) ⇒ Object
def get_external_reference(operation_id)
response = send_notification_request(operation_id)
if response
response['collection']['external_reference']
end
end
39 40 41 42 43 44 45 46 47 |
# File 'app/models/mercadopago/client.rb', line 39 def get_payment_status(external_reference) response = send_search_request(external_reference: external_reference, access_token: access_token) if response['results'].empty? 'pending' else response['results'][0]['collection']['status'] end end |