Class: Killbill::Stripe::PrivatePaymentPlugin
- Inherits:
-
Plugin::ActiveMerchant::PrivatePaymentPlugin
- Object
- Plugin::ActiveMerchant::PrivatePaymentPlugin
- Killbill::Stripe::PrivatePaymentPlugin
- Defined in:
- lib/stripe/private_api.rb
Instance Method Summary collapse
- #add_payment_method(params, options = {}) ⇒ Object
- #create_managed_account(kb_account_id, kb_tenant_id, account = {}, options = {}) ⇒ Object
- #get_balance(kb_account_id = nil, kb_tenant_id = nil, options = {}) ⇒ Object
-
#initialize(session = {}) ⇒ PrivatePaymentPlugin
constructor
A new instance of PrivatePaymentPlugin.
Constructor Details
#initialize(session = {}) ⇒ PrivatePaymentPlugin
Returns a new instance of PrivatePaymentPlugin.
4 5 6 7 8 9 10 |
# File 'lib/stripe/private_api.rb', line 4 def initialize(session = {}) super(:stripe, ::Killbill::Stripe::StripePaymentMethod, ::Killbill::Stripe::StripeTransaction, ::Killbill::Stripe::StripeResponse, session) end |
Instance Method Details
#add_payment_method(params, options = {}) ⇒ 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 |
# File 'lib/stripe/private_api.rb', line 12 def add_payment_method(params, = {}) # We need to log-in manually because the call comes unauthenticated from the browser # (the default credentials hardcoded: good enough since this should only be used for testing) kb_apis.security_api.login('admin', 'password') kb_account_id = params['kbAccountId'] kb_tenant_id = params['kbTenantId'] context = kb_apis.create_context(kb_tenant_id) kb_account = kb_apis.account_user_api.get_account_by_id(kb_account_id, context) payment_method_info = ::Killbill::Plugin::Model::PaymentMethodPlugin.new payment_method_info.properties = [] payment_method_info.properties << build_property('cc_first_name', params['stripeCardName']) payment_method_info.properties << build_property('address1', params['stripeCardAddressLine1']) payment_method_info.properties << build_property('address2', params['stripeCardAddressLine2']) payment_method_info.properties << build_property('city', params['stripeCardAddressCity']) payment_method_info.properties << build_property('zip', params['stripeCardAddressZip']) payment_method_info.properties << build_property('state', params['stripeCardAddressState']) payment_method_info.properties << build_property('country', params['stripeCardAddressCountry']) payment_method_info.properties << build_property('cc_expiration_month', params['stripeCardExpMonth']) payment_method_info.properties << build_property('cc_expiration_year', params['stripeCardExpYear']) payment_method_info.properties << build_property('token', params['stripeToken']) kb_apis.payment_api.add_payment_method(kb_account, params['stripeToken'], 'killbill-stripe', true, payment_method_info, [], context) end |
#create_managed_account(kb_account_id, kb_tenant_id, account = {}, options = {}) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/stripe/private_api.rb', line 50 def create_managed_account(kb_account_id, kb_tenant_id, account = {}, = {}) payment_processor_account_id = [:payment_processor_account_id] || :default gateway = gateway(payment_processor_account_id, kb_tenant_id) stripe_response = gateway.create_managed_account(account, ) save_response_and_transaction(stripe_response, :create_managed_account, kb_account_id, kb_tenant_id, payment_processor_account_id) stripe_response end |
#get_balance(kb_account_id = nil, kb_tenant_id = nil, options = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/stripe/private_api.rb', line 39 def get_balance(kb_account_id = nil, kb_tenant_id = nil, = {}) [:stripe_account] ||= ::Killbill::Stripe::StripeResponse.managed_stripe_account_id_from_kb_account_id(kb_account_id, kb_tenant_id) payment_processor_account_id = [:payment_processor_account_id] || :default gateway = gateway(payment_processor_account_id, kb_tenant_id) stripe_response = gateway.get_balance() save_response_and_transaction(stripe_response, :get_balance, kb_account_id, kb_tenant_id, payment_processor_account_id) stripe_response end |