module Mercadopago::Api
Attributes
credentials[W]
preference[W]
sdk[R]
Public Instance Methods
checkout_link(data)
click to toggle source
# File lib/mercadopago/api.rb, line 8 def checkout_link(data) preference = sdk.create_checkout_preference(data, config[:excluded_payment_methods]) if config[:sandbox] preference['sandbox_init_point'] else preference['init_point'] end end
config()
click to toggle source
# File lib/mercadopago/api.rb, line 56 def config @config || {} end
config=(config)
click to toggle source
# File lib/mercadopago/api.rb, line 60 def config=(config) @config = config end
credentials()
click to toggle source
# File lib/mercadopago/api.rb, line 40 def credentials if @credentials.empty? raise "Please set yours Credentials, using set_credentials" else @credentials end end
find_payment(payment_id)
click to toggle source
# File lib/mercadopago/api.rb, line 17 def find_payment(payment_id) if config[:sandbox] result = sdk.search_payments_where({:id => payment_id})['results'].first else result = sdk.search_payment(payment_id) end if result["collection"].nil? result else result["collection"] end end
find_payment_with_notification(payment_id)
click to toggle source
# File lib/mercadopago/api.rb, line 30 def find_payment_with_notification(payment_id) result = sdk.get_payment_info(payment_id) payment = result['collection'] payment[:code] = result[:code] end
preference()
click to toggle source
# File lib/mercadopago/api.rb, line 48 def preference if @preference.nil? raise "You have to create or get a preference first" else @preference end end
set_credentials(client_id, client_secret)
click to toggle source
# File lib/mercadopago/api.rb, line 64 def set_credentials(client_id, client_secret) @credentials = { :client_id => client_id, :client_secret => client_secret } end