Class: MaxipagoApi::CreditCardRequest

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/maxipago_api/requests/credit_card_request.rb

Class Method Summary collapse

Class Method Details

.save(credit_card) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/maxipago_api/requests/credit_card_request.rb', line 9

def save(credit_card)
  xml = {
    'verification' => {merchantId: MaxipagoApi.store_id, merchantKey: MaxipagoApi.store_key}, 
    command: 'add-card-onfile', 
    request: credit_card.to_object
  }.to_xml(root: 'api-request', skip_types: true)
  response = post(MaxipagoApi.api_register_endpoint, body: xml, headers: {'Content-Type' => 'text/plain'})
  Hash.from_xml(response.parsed_response)
end