Class: WebPay::Mock::FakeEntity::Charge

Inherits:
Base
  • Object
show all
Defined in:
lib/webpay/mock/fake_entity/charge.rb

Instance Attribute Summary

Attributes inherited from Base

#builder

Instance Method Summary collapse

Methods inherited from Base

#build, #initialize, #override, #set_params

Methods included from WebPay::Mock::FakeEntity

#card_from, #charge_from, #customer_from, #fake_account, #fake_card, #fake_event, #fake_fingerprint, #fake_list, #token_from

Methods included from Util

#stringify_keys

Constructor Details

This class inherits a constructor from WebPay::Mock::FakeEntity::Base

Instance Method Details

#basic_attributesObject



7
8
9
# File 'lib/webpay/mock/fake_entity/charge.rb', line 7

def basic_attributes
  { amount: 1000, currency: 'jpy', amount_refunded: 0, paid: true, refunded: false, failure_message: nil, captured: true, expire_time: nil, card: fake_card }
end

#conversion(key, value) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/webpay/mock/fake_entity/charge.rb', line 15

def conversion(key, value)
  case key
  when 'card'
    { card: value.is_a?(Hash) ? card_from(value) : fake_card }
  when 'customer'
    { card: fake_card, customer: value }
  when 'capture'
    if value == false
      {
        captured:  false,
        paid: false,
        expire_time: Time.now.to_i + 60 * 60 * 24 * 7
      }
    end
  end
end

#copy_attributesObject



11
12
13
# File 'lib/webpay/mock/fake_entity/charge.rb', line 11

def copy_attributes
  [:amount, :currency, :description]
end

#object_nameObject



3
4
5
# File 'lib/webpay/mock/fake_entity/charge.rb', line 3

def object_name
  'charge'
end