Class: PayCertify::Gateway::CreditCard

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

Defined Under Namespace

Classes: Validation

Constant Summary collapse

API_ENDPOINT =
'/ws/cardsafe.asmx/StoreCard'
SAFE_CARD_REGEX =
/\<CardSafeToken>(.*)<\/CardSafeToken>/
ATTRIBUTES =
[
  :credit_card_id, :card_number, :expiration_month, :expiration_year, 
  :customer_id, :name_on_card, :zip
]

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



25
26
27
28
29
30
31
32
33
# File 'lib/paycertify/gateway/credit_card.rb', line 25

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

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

  formatted
end

#get_credit_card_idObject



35
36
37
38
39
# File 'lib/paycertify/gateway/credit_card.rb', line 35

def get_credit_card_id
  response['response']['ext_data'].match(SAFE_CARD_REGEX)
  credit_card_id = $1
  credit_card_id.presence || response['response']['ext_data']['safe_card_token']
end

#save!Object



19
20
21
22
23
# File 'lib/paycertify/gateway/credit_card.rb', line 19

def save!
  super
  self.credit_card_id = get_credit_card_id
  self
end

#success?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/paycertify/gateway/credit_card.rb', line 15

def success?
  super && response['response']['result'] == '0'
end