Class: SolidusOpenPay::Builders::Charge

Inherits:
Object
  • Object
show all
Defined in:
app/models/solidus_open_pay/builders/charge.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source:, amount:, options: {}) ⇒ Charge

Returns a new instance of Charge.



8
9
10
11
12
# File 'app/models/solidus_open_pay/builders/charge.rb', line 8

def initialize(source:, amount:, options: {})
  @source = source
  @amount = amount
  @options = options
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



6
7
8
# File 'app/models/solidus_open_pay/builders/charge.rb', line 6

def amount
  @amount
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'app/models/solidus_open_pay/builders/charge.rb', line 6

def options
  @options
end

#sourceObject (readonly)

Returns the value of attribute source.



6
7
8
# File 'app/models/solidus_open_pay/builders/charge.rb', line 6

def source
  @source
end

Instance Method Details

#payloadObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/models/solidus_open_pay/builders/charge.rb', line 14

def payload
  {
    'source_id' => token_id,
    'method' => 'card',
    'amount' => amount / 100,
    'currency' => 'MXN',
    'capture' => capture,
    'description' => 'Cargo inicial',
    'order_id' => order_id,
    'device_session_id' => device_session_id,
    'customer' => {
      'name' => first_name,
      'last_name' => last_name,
      'phone_number' => phone_number,
      'email' => email
    }
  }
end