Class: Gateway::KomojuBankTransfer

Inherits:
KomojuGateway
  • Object
show all
Defined in:
app/models/spree/gateway/komoju_bank_transfer.rb

Instance Method Summary collapse

Instance Method Details

#authorize(money, source, options) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/spree/gateway/komoju_bank_transfer.rb', line 3

def authorize(money, source, options)
  details = {
    type:             "bank_transfer",
    email:            source.email,
    phone:            source.phone,
    given_name:       source.given_name,
    family_name:      source.family_name,
    given_name_kana:  source.given_name_kana,
    family_name_kana: source.family_name_kana
  }
  options = change_options_to_dollar(options) if options[:currency] == "JPY"

  response = provider.purchase(money - options[:tax], details, options)

  source.update!(
    expires_at:  response.params["payment_deadline"].to_time,
    order_id:    response.params["payment_details"]["order_id"],
    bank_number: response.params["payment_details"]["bank_number"],
    instructions_url: response.params["payment_details"]["instructions_url"]
  ) if response.success?
  response
end

#reusable_sources(*args) ⇒ Object



26
27
28
# File 'app/models/spree/gateway/komoju_bank_transfer.rb', line 26

def reusable_sources(*args)
  []
end