Class: PayjpMock::Response::Resource::Transfer

Inherits:
Base
  • Object
show all
Defined in:
lib/payjp_mock/response/resource/transfer.rb

Constant Summary collapse

PREFIX =
'tr'.freeze
OBJECT =
'transfer'.freeze

Instance Attribute Summary

Attributes inherited from Base

#attributes

Instance Method Summary collapse

Methods inherited from Base

#canonicalize, #initialize, #set, #status

Methods included from Util

#generate_fingerprint, #generate_resource_id

Methods inherited from Base

#body, #exception, #status, #to_h

Constructor Details

This class inherits a constructor from PayjpMock::Response::Resource::Base

Instance Method Details

#default_attributesObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/payjp_mock/response/resource/transfer.rb', line 9

def default_attributes
  id  = generate_resource_id(PREFIX)
  now = Time.now

  charged_at = (now + 30.days).to_i
  charges = Response::List.new("/transfers/#{id}/charges", count: 1) do
    Charge.new(
      amount:      1000,
      captured_at: charged_at,
      card:        Card.new(created: charged_at).to_h,
      created:     charged_at
    )
  end

  {
    amount:          1000,
    carried_balance: nil,
    charges:         charges.to_h,
    created:         now.to_i,
    currency:        'jpy',
    description:     nil,
    id:              id,
    livemode:        false,
    object:          OBJECT,
    scheduled_date:  (now + 45.days).strftime('%Y-%m-%d'),
    status:          'pending',
    summary:         {
      charge_count:  1,
      charge_fee:    0,
      charge_gross:  1000,
      net:           1000,
      refund_amount: 0,
      refund_count:  0
    },
    term_end:        (now + 15.days).to_i,
    term_start:      now.to_i,
    transfer_amount: nil,
    transfer_date:   nil
  }
end