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, #recursion_from, #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
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/webpay/mock/fake_entity/charge.rb', line 7

def basic_attributes
  {
    amount: 1000,
    card: fake_card,
    currency: 'jpy',
    paid: true,
    captured: true,
    refunded: false,
    amount_refunded: 0,
    customer: nil,
    shop: nil,
    recursion: nil,
    description: nil,
    failure_message: nil,
    expire_time: nil,
    fees: [{
        object: 'fee',
        transaction_type: 'payment',
        transaction_fee: 0,
        rate: 3.25,
        amount: 33,
        created: Time.now.to_i
      }]
  }
end

#conversion(key, value) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/webpay/mock/fake_entity/charge.rb', line 37

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: true,
        expire_time: Time.now.to_i + 60 * 60 * 24 * 7
      }
    end
  end
end

#copy_attributesObject



33
34
35
# File 'lib/webpay/mock/fake_entity/charge.rb', line 33

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