Class: PayjpMock::Response::Resource::Charge
- Defined in:
- lib/payjp_mock/response/resource/charge.rb
Constant Summary collapse
- PREFIX =
'ch'.freeze
- OBJECT =
'charge'.freeze
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
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
#canonicalize(key, value) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/payjp_mock/response/resource/charge.rb', line 36 def canonicalize(key, value) case key when :card { card: Card.new(value.is_a?(Hash)? value : {}).to_h } when :capture { captured: value, captured_at: value ? Time.now.to_i : nil } when :expiry_days expired_at = if value == 60 expired_date = Time.now + 59.days Time.local(expired_date.year, expired_date.month, expired_date.day, 23, 59, 59) else Time.now + value.days end { expired_at: expired_at.to_i } else super end end |
#default_attributes ⇒ Object
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 |
# File 'lib/payjp_mock/response/resource/charge.rb', line 9 def default_attributes now = Time.now.to_i { amount: 3500, amount_refunded: 0, captured: true, captured_at: now, card: Card.new.to_h, created: now, currency: 'jpy', customer: nil, description: nil, expired_at: nil, failure_code: nil, failure_message: nil, id: generate_resource_id(PREFIX), livemode: false, metadata: nil, object: OBJECT, paid: true, refund_reason: nil, refunded: false, subscription: nil } end |