Class: Mercadopago::Preapproval
- Defined in:
- lib/mercadopago/resources/preapproval.rb
Overview
Manages recurring subscriptions (preapprovals).
A preapproval authorises MercadoPago to charge the buyer periodically according to the terms defined by a PreapprovalPlan. Use this resource to create, update, pause, or cancel individual subscriptions.
Instance Method Summary collapse
-
#create(preapproval_data, request_options: nil) ⇒ Hash{Symbol => Object}
Creates a new subscription.
-
#get(preapproval_id, request_options: nil) ⇒ Hash{Symbol => Object}
Retrieves a single subscription by ID.
-
#search(filters: nil, request_options: nil) ⇒ Hash{Symbol => Object}
Searches subscriptions matching the given filters.
-
#update(preapproval_id, preapproval_data, request_options: nil) ⇒ Hash{Symbol => Object}
Updates an existing subscription (e.g. pause, resume, or cancel).
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(preapproval_data, request_options: nil) ⇒ Hash{Symbol => Object}
Creates a new subscription.
44 45 46 47 48 |
# File 'lib/mercadopago/resources/preapproval.rb', line 44 def create(preapproval_data, request_options: nil) raise TypeError, 'Param preapproval_data must be a Hash' unless preapproval_data.is_a?(Hash) _post(uri: '/preapproval/', data: preapproval_data, request_options: ) end |
#get(preapproval_id, request_options: nil) ⇒ Hash{Symbol => Object}
Retrieves a single subscription by ID.
33 34 35 |
# File 'lib/mercadopago/resources/preapproval.rb', line 33 def get(preapproval_id, request_options: nil) _get(uri: "/preapproval/#{preapproval_id}", request_options: ) end |
#search(filters: nil, request_options: nil) ⇒ Hash{Symbol => Object}
Searches subscriptions matching the given filters.
21 22 23 24 25 |
# File 'lib/mercadopago/resources/preapproval.rb', line 21 def search(filters: nil, request_options: nil) raise TypeError, 'Param filters must be a Hash' unless filters.nil? || filters.is_a?(Hash) _get(uri: '/preapproval/search', filters: filters, request_options: ) end |
#update(preapproval_id, preapproval_data, request_options: nil) ⇒ Hash{Symbol => Object}
Updates an existing subscription (e.g. pause, resume, or cancel).
58 59 60 61 62 |
# File 'lib/mercadopago/resources/preapproval.rb', line 58 def update(preapproval_id, preapproval_data, request_options: nil) raise TypeError, 'Param preapproval_data must be a Hash' unless preapproval_data.is_a?(Hash) _put(uri: "/preapproval/#{preapproval_id}", data: preapproval_data, request_options: ) end |