Class: Mercadopago::Card

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

Overview

This class must be used in conjunction with the Customer class. [Click here for more infos](www.mercadopago.com/developers/en/guides/online-payments/web-tokenize-checkout/customers-and-cards)

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

#create(customer_id, card_data, request_options: nil) ⇒ Object

Raises:

  • (TypeError)


17
18
19
20
21
# File 'lib/mercadopago/resources/card.rb', line 17

def create(customer_id, card_data, request_options: nil)
  raise TypeError, 'Param card_data must be a Hash' if card_data.nil? || !card_data.is_a?(Hash)

  _post(uri: "/v1/customers/#{customer_id}/cards/", data: card_data, request_options: request_options)
end

#delete(customer_id, card_id, request_options: nil) ⇒ Object



23
24
25
# File 'lib/mercadopago/resources/card.rb', line 23

def delete(customer_id, card_id, request_options: nil)
  _delete(uri: "/v1/customers/#{customer_id}/cards/#{card_id}", request_options: request_options)
end

#get(customer_id, card_id, request_options: nil) ⇒ Object



13
14
15
# File 'lib/mercadopago/resources/card.rb', line 13

def get(customer_id, card_id, request_options: nil)
  _get(uri: "/v1/customers/#{customer_id}/cards/#{card_id}", request_options: request_options)
end

#list(customer_id, request_options: nil) ⇒ Object



27
28
29
# File 'lib/mercadopago/resources/card.rb', line 27

def list(customer_id, request_options: nil)
  _get(uri: "/v1/customers/#{customer_id}/cards", request_options: request_options)
end