Class: ActiveMerchant::Billing::KomojuGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/komoju.rb

Constant Summary collapse

STANDARD_ERROR_CODE_MAPPING =
{
  "bad_verification_value" => "incorrect_cvc",
  "card_expired" => "expired_card",
  "card_declined" => "card_declined",
  "invalid_number" => "invalid_number"
}

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ KomojuGateway

Returns a new instance of KomojuGateway.



22
23
24
25
# File 'lib/active_merchant/billing/gateways/komoju.rb', line 22

def initialize(options = {})
  requires!(options, :login)
  super
end

Instance Method Details

#continue(uuid, payment_details) ⇒ Object



27
28
29
30
# File 'lib/active_merchant/billing/gateways/komoju.rb', line 27

def continue(uuid, payment_details)
  details = {payment_details: payment_details}
  commit("/payments/#{uuid}", details, :patch)
end

#purchase(money, payment, options = {}) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/active_merchant/billing/gateways/komoju.rb', line 32

def purchase(money, payment, options = {})
  post = {}
  post[:amount] = amount(money)
  post[:locale] = @options[:locale] if @options[:locale]
  post[:description] = options[:description]
  add_payment_details(post, payment, options)
  post[:currency] = options[:currency] || default_currency
  post[:external_order_num] = options[:order_id] if options[:order_id]
  post[:tax] = options[:tax] if options[:tax]
  add_fraud_details(post, options)

  commit("/payments", post)
end

#refund(amount, identification, options = {}) ⇒ Object



46
47
48
49
# File 'lib/active_merchant/billing/gateways/komoju.rb', line 46

def refund(amount, identification, options = {})
  params = { :amount => amount }
  commit("/payments/#{identification}/refund", params)
end

#store(payment, options = {}) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/active_merchant/billing/gateways/komoju.rb', line 55

def store(payment, options = {})
  post = {}
  add_payment_details(post, payment, options)

  if options[:customer_profile]
    post[:email] = options[:email]
    commit("/customers", post)
  else
    commit("/tokens", post)
  end
end

#void(identification, options = {}) ⇒ Object



51
52
53
# File 'lib/active_merchant/billing/gateways/komoju.rb', line 51

def void(identification, options = {})
  commit("/payments/#{identification}/refund", {})
end