Class: Gateway::KomojuWebMoney

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

Instance Method Summary collapse

Instance Method Details

#auto_capture?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'app/models/spree/gateway/komoju_web_money.rb', line 3

def auto_capture?
  true
end

#purchase(money, source, options) ⇒ Object



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
32
33
34
# File 'app/models/spree/gateway/komoju_web_money.rb', line 7

def purchase(money, source, options)
  raise SpreeKomoju::Errors::UnsupportedCurrency if options[:currency] != "JPY"

  details = {
    type: "web_money",
    email: source.email,
    prepaid_number: source.prepaid_number
  }
  options = change_options_to_dollar(options)

  if uuid = continue_uuid(options[:order_id])
    response = provider.continue(uuid, details)
  else
    response = provider.purchase(money - options[:tax], details, options)
  end

  source.update!(
    prepaid_cards: response.params["payment_details"]["prepaid_cards"],
    short_amount: response.params["payment_details"]["short_amount"]
  ) if response.success?

  if response.params["status"] == "pending"
    source.update!(payment_uuid: response.params["id"])
    response = multi_card_response(response)
  end

  response
end

#reusable_sources(*args) ⇒ Object



36
37
38
# File 'app/models/spree/gateway/komoju_web_money.rb', line 36

def reusable_sources(*args)
  []
end