Class: Killbill::Litle::PrivatePaymentPlugin

Inherits:
Plugin::ActiveMerchant::PrivatePaymentPlugin
  • Object
show all
Defined in:
lib/litle/private_api.rb

Instance Method Summary collapse

Constructor Details

#initialize(session = {}) ⇒ PrivatePaymentPlugin

Returns a new instance of PrivatePaymentPlugin.



4
5
6
7
8
9
10
# File 'lib/litle/private_api.rb', line 4

def initialize(session = {})
  super(:litle,
        ::Killbill::Litle::LitlePaymentMethod,
        ::Killbill::Litle::LitleTransaction,
        ::Killbill::Litle::LitleResponse,
        session)
end

Instance Method Details

#add_payment_method(params) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/litle/private_api.rb', line 12

def add_payment_method(params)
   = params[:payment_processor_account_id] || :default

  exp_month, exp_year = (params[:exp_date] || '').split('/')

  # TODO Save response row (to keep the response_litle_txn_id)

  # Create the payment method (not associated with a Kill Bill payment method yet)
  Killbill::Litle::LitlePaymentMethod.create!(:kb_account_id        => params[:kb_account_id],
                                              :kb_payment_method_id => nil,
                                              :kb_tenant_id         => params[:kb_tenant_id],
                                              :token                => params[:response_paypage_registration_id],
                                              :cc_first_name        => params[:first_name],
                                              :cc_last_name         => params[:last_name],
                                              :cc_type              => nil,
                                              :cc_exp_month         => exp_month,
                                              :cc_exp_year          => exp_year,
                                              :cc_last_4            => params[:cc_num],
                                              :address1             => nil,
                                              :address2             => nil,
                                              :city                 => nil,
                                              :state                => nil,
                                              :zip                  => nil,
                                              :country              => nil,
                                              :created_at           => Time.now.utc,
                                              :updated_at           => Time.now.utc)
end

#get_currency(kb_account_id) ⇒ Object



40
41
42
43
44
45
# File 'lib/litle/private_api.rb', line 40

def get_currency()
   = kb_apis.()
  .currency
rescue => e
  'USD'
end