Class: Mercadopago::AdvancedPayment

Inherits:
MPBase
  • Object
show all
Defined in:
lib/mercadopago/resources/advanced_payment.rb

Overview

Access to Advanced Payments

Instance Method Summary collapse

Methods inherited from MPBase

#_check_headers, #_check_request_options, #_delete, #_get, #_post, #_put, #initialize

Constructor Details

This class inherits a constructor from Mercadopago::MPBase

Instance Method Details

#cancel(advanced_payment_id, request_options: nil) ⇒ Object



37
38
39
40
# File 'lib/mercadopago/resources/advanced_payment.rb', line 37

def cancel(advanced_payment_id, request_options: nil)
  cancel_data = { status: 'cancelled' }
  _put(uri: "/v1/advanced_payments/#{advanced_payment_id}", data: cancel_data, request_options: request_options)
end

#capture(advanced_payment_id, request_options: nil) ⇒ Object



25
26
27
28
# File 'lib/mercadopago/resources/advanced_payment.rb', line 25

def capture(advanced_payment_id, request_options: nil)
  capture_data = { capture: true }
  _put(uri: "/v1/advanced_payments/#{advanced_payment_id}", data: capture_data, request_options: request_options)
end

#create(advanced_payment_data, request_options: nil) ⇒ Object

Raises:

  • (TypeError)


19
20
21
22
23
# File 'lib/mercadopago/resources/advanced_payment.rb', line 19

def create(advanced_payment_data, request_options: nil)
  raise TypeError, 'Param advanced_payment_data must be a Hash' unless advanced_payment_data.is_a?(Hash)

  _post(uri: '/v1/advanced_payments', data: advanced_payment_data, request_options: request_options)
end

#get(advanced_payment_id, request_options: nil) ⇒ Object



15
16
17
# File 'lib/mercadopago/resources/advanced_payment.rb', line 15

def get(advanced_payment_id, request_options: nil)
  _get(uri: "/v1/advanced_payments/#{advanced_payment_id}", request_options: request_options)
end

#search(filters: nil, request_options: nil) ⇒ Object

Raises:

  • (TypeError)


9
10
11
12
13
# File 'lib/mercadopago/resources/advanced_payment.rb', line 9

def search(filters: nil, request_options: nil)
  raise TypeError, 'Param filters must be a Hash' unless filters.nil? || filters.is_a?(Hash)

  _get(uri: '/v1/advanced_payments/search', filters: filters, request_options: request_options)
end

#update(advanced_payment_id, advanced_payment_data, request_options: nil) ⇒ Object

Raises:

  • (TypeError)


30
31
32
33
34
35
# File 'lib/mercadopago/resources/advanced_payment.rb', line 30

def update(advanced_payment_id, advanced_payment_data, request_options: nil)
  raise TypeError, 'Param advanced_payment_data must be a Hash' unless advanced_payment_data.is_a?(Hash)

  _put(uri: "/v1/advanced_payments/#{advanced_payment_id}", data: advanced_payment_data,
       request_options: request_options)
end

#update_release_date(advanced_payment_id, release_date, request_options: nil) ⇒ Object



42
43
44
45
46
# File 'lib/mercadopago/resources/advanced_payment.rb', line 42

def update_release_date(advanced_payment_id, release_date, request_options: nil)
  disbursement_data = { money_release_date: release_date.strftime('%Y-%m-%d %H:%M:%S.%f') }
  _post(uri: "/v1/advanced_payments/#{advanced_payment_id}/disburses", data: disbursement_data,
        request_options: request_options)
end