Module: MercadoPago::Checkout

Defined in:
lib/mercadopago/checkout.rb

Class Method Summary collapse

Class Method Details

.cancel_preapproval_payment(access_token, preapproval_id) ⇒ Object

  • access_token: the MercadoPago account associated with this access_token will

    receive the money from the payment of preapproval payment.
    
  • preapproval_id: the preapproval payment ID



69
70
71
72
73
74
75
76
77
# File 'lib/mercadopago/checkout.rb', line 69

def self.cancel_preapproval_payment(access_token, preapproval_id)
  payload = JSON.generate(status: :cancelled)
  headers = { content_type: 'application/json', accept: 'application/json' }

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

.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
51
# File 'lib/mercadopago/checkout.rb', line 45

def self.create_preapproval_payment(access_token, data)
  payload = JSON.generate(data)

  MercadoPago::Request
    .wrap_post("/preapproval?access_token=#{access_token}",
               payload)
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
21
# File 'lib/mercadopago/checkout.rb', line 15

def self.create_preference(access_token, data)
  payload = JSON.generate(data)

  MercadoPago::Request
    .wrap_post("/checkout/preferences?access_token=#{access_token}",
               payload)
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



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

def self.get_preapproval_payment(access_token, preapproval_id)
  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



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

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

.update_preferenceObject

TODO



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

def self.update_preference
  # TODO
end