Module: MercadoPago::Checkout

Defined in:
lib/mercadopago/checkout.rb

Class Method Summary collapse

Class Method Details

.create_preapproval_payment(access_token, data) ⇒ Object

  • access_token: the MercadoPago account associated with this access_token will

    receive the money from the payment of preapproval payment.
    
  • data: a hash of preferences that will be trasmitted to checkout API.



45
46
47
48
49
50
# File 'lib/mercadopago/checkout.rb', line 45

def self.create_preapproval_payment(access_token, data)
  payload = JSON.generate(data)
  headers = { content_type: 'application/json', accept: 'application/json' }

  MercadoPago::Request.wrap_post("/preapproval?access_token=#{access_token}", payload, headers)
end

.create_preference(access_token, data) ⇒ Object

Allows you to configure the checkout process. Receives an access_token and a prefereces hash and creates a new checkout preference. Once you have created the checkout preference, you can use the init_point URL to start the payment flow.

  • access_token: the MercadoPago account associated with this access_token will

    receive the money from the payment of this checkout preference.
    
  • data: a hash of preferences that will be trasmitted to checkout API.



15
16
17
18
19
20
# File 'lib/mercadopago/checkout.rb', line 15

def self.create_preference(access_token, data)
  payload = JSON.generate(data)
  headers = { content_type: 'application/json', accept: 'application/json' }

  MercadoPago::Request.wrap_post("/checkout/preferences?access_token=#{access_token}", payload, headers)
end

.get_preapproval_payment(access_token, preapproval_id) ⇒ Object

Returns the hash with the details of certain preapproval payment.

  • access_token: the MercadoPago account access token

  • preapproval_id: the preapproval payment ID



58
59
60
61
# File 'lib/mercadopago/checkout.rb', line 58

def self.get_preapproval_payment(access_token, preapproval_id)
  headers = { accept: 'application/json' }
  MercadoPago::Request.wrap_get("/preapproval/#{preapproval_id}?access_token=#{access_token}")
end

.get_preference(access_token, preference_id) ⇒ Object

Returns the hash with the details of certain payment preference.

  • access_token: the MercadoPago account access token

  • preference_id: the payment preference ID



35
36
37
38
# File 'lib/mercadopago/checkout.rb', line 35

def self.get_preference(access_token, preference_id)
  headers = { accept: 'application/json' }
  MercadoPago::Request.wrap_get("/checkout/preferences/#{preference_id}?access_token=#{access_token}")
end

.update_preferenceObject

TODO



25
26
27
# File 'lib/mercadopago/checkout.rb', line 25

def self.update_preference
  # TODO
end