Class: Mercadopago::Card
- Defined in:
- lib/mercadopago/resources/card.rb
Overview
Manages saved cards linked to a Customer.
Stored cards enable one-click purchases by allowing customers to re-use previously tokenised card data. A card is always associated with a customer ID.
Instance Method Summary collapse
-
#create(customer_id, card_data, request_options: nil) ⇒ Hash{Symbol => Object}
Saves a new card for a customer using a previously generated card token.
-
#delete(customer_id, card_id, request_options: nil) ⇒ Hash{Symbol => Object}
Deletes a saved card from a customer.
-
#get(customer_id, card_id, request_options: nil) ⇒ Hash{Symbol => Object}
Retrieves a specific card saved for a customer.
-
#list(customer_id, request_options: nil) ⇒ Hash{Symbol => Object}
Lists all saved cards for a customer.
-
#update(customer_id, card_id, card_data, request_options: nil) ⇒ Hash{Symbol => Object}
Updates a saved card for a customer.
Methods inherited from MPBase
#_check_headers, #_check_request_options, #_delete, #_get, #_path_param, #_post, #_put, #initialize
Constructor Details
This class inherits a constructor from Mercadopago::MPBase
Instance Method Details
#create(customer_id, card_data, request_options: nil) ⇒ Hash{Symbol => Object}
Saves a new card for a customer using a previously generated card token.
32 33 34 35 36 |
# File 'lib/mercadopago/resources/card.rb', line 32 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/#{_path_param(customer_id)}/cards/", data: card_data, request_options: ) end |
#delete(customer_id, card_id, request_options: nil) ⇒ Hash{Symbol => Object}
Deletes a saved card from a customer.
61 62 63 |
# File 'lib/mercadopago/resources/card.rb', line 61 def delete(customer_id, card_id, request_options: nil) _delete(uri: "/v1/customers/#{_path_param(customer_id)}/cards/#{_path_param(card_id)}", request_options: ) end |
#get(customer_id, card_id, request_options: nil) ⇒ Hash{Symbol => Object}
Retrieves a specific card saved for a customer.
20 21 22 |
# File 'lib/mercadopago/resources/card.rb', line 20 def get(customer_id, card_id, request_options: nil) _get(uri: "/v1/customers/#{_path_param(customer_id)}/cards/#{_path_param(card_id)}", request_options: ) end |
#list(customer_id, request_options: nil) ⇒ Hash{Symbol => Object}
Lists all saved cards for a customer.
71 72 73 |
# File 'lib/mercadopago/resources/card.rb', line 71 def list(customer_id, request_options: nil) _get(uri: "/v1/customers/#{_path_param(customer_id)}/cards", request_options: ) end |
#update(customer_id, card_id, card_data, request_options: nil) ⇒ Hash{Symbol => Object}
Updates a saved card for a customer.
46 47 48 49 50 51 52 |
# File 'lib/mercadopago/resources/card.rb', line 46 def update(customer_id, card_id, card_data, request_options: nil) _put( uri: "/v1/customers/#{_path_param(customer_id)}/cards/#{_path_param(card_id)}", data: card_data, request_options: ) end |