Class: PayCertify::Gateway::Charge

Inherits:
Base::Resource show all
Defined in:
lib/paycertify/gateway/charge.rb

Defined Under Namespace

Classes: Validation

Constant Summary collapse

API_ENDPOINT =
'/ws/cardsafe.asmx/ProcessStoredCard'
ATTRIBUTES =
[
  :transaction_id, :app_transaction_id, :type, :amount, 
  :credit_card_id, :gateway_response
]

Instance Attribute Summary

Attributes inherited from Base::Resource

#client, #errors, #original_attributes, #response

Instance Method Summary collapse

Methods inherited from Base::Resource

#attributes, #initialize, #to_json, #validatable?, #validation

Constructor Details

This class inherits a constructor from PayCertify::Gateway::Base::Resource

Instance Method Details

#attributes_to_gateway_formatObject



30
31
32
33
34
35
36
37
38
# File 'lib/paycertify/gateway/charge.rb', line 30

def attributes_to_gateway_format
  formatted = super
  attribute_mapping = PayCertify::Gateway::AttributeMapping

  formatted.merge! attribute_mapping.type(self)
  formatted.merge!({'TokenMode' => 'DEFAULT'})

  formatted
end

#execute!Object



14
# File 'lib/paycertify/gateway/charge.rb', line 14

alias :execute! :save!

#save!Object



24
25
26
27
28
# File 'lib/paycertify/gateway/charge.rb', line 24

def save!
  super
  self.transaction_id = response['response']['transaction_result']['pn_ref']
  self
end

#success?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/paycertify/gateway/charge.rb', line 20

def success?
  response['response']['transaction_result']['result'] == '0'
end

#typeObject



16
17
18
# File 'lib/paycertify/gateway/charge.rb', line 16

def type
  'sale'
end