Class: Killbill::Plugin::ActiveMerchant::PrivatePaymentPlugin
- Inherits:
-
Payment
- Object
- PluginBase
- Notification
- Payment
- Killbill::Plugin::ActiveMerchant::PrivatePaymentPlugin
- Includes:
- ActionController::RequestForgeryProtection, ActionView::Context, ActionView::Helpers::FormTagHelper, ActiveSupport::Configurable, OffsitePayments::ActionViewHelper
- Defined in:
- lib/killbill/helpers/active_merchant/private_payment_plugin.rb
Instance Attribute Summary collapse
-
#session ⇒ Object
readonly
For RequestForgeryProtection.
Attributes inherited from PluginBase
#active, #clock, #conf_dir, #plugin_name, #root
Instance Method Summary collapse
- #gateway(payment_processor_account_id = :default, kb_tenant_id = nil) ⇒ Object
-
#initialize(identifier, payment_method_model, transaction_model, response_model, session = {}) ⇒ PrivatePaymentPlugin
constructor
A new instance of PrivatePaymentPlugin.
- #kb_apis ⇒ Object
- #logger ⇒ Object
-
#payment_form_for(order_id, account_id, service, options = {}, &proc) ⇒ Object
Valid options: :amount, :currency, :test, :credential2, :credential3, :credential4, :country, :account_name, :transaction_type, :authcode, :notify_url, :return_url, :redirect_param, :forward_url.
-
#payment_link_for(name, order_id, account_id, service, options = {}) ⇒ Object
Valid options: :amount, :currency, :test, :credential2, :credential3, :credential4, :country, :account_name, :transaction_type, :authcode, :notify_url, :return_url, :redirect_param, :forward_url.
- #save_response_and_transaction(gw_response, api_call, kb_account_id, kb_tenant_id, payment_processor_account_id, kb_payment_id = nil, kb_payment_transaction_id = nil, transaction_type = nil, amount_in_cents = 0, currency = nil) ⇒ Object
Methods inherited from Payment
#add_payment_method, #authorize_payment, #build_form_descriptor, #capture_payment, #credit_payment, #delete_payment_method, #get_payment_info, #get_payment_method_detail, #get_payment_methods, #process_notification, #purchase_payment, #refund_payment, #reset_payment_methods, #search_payment_methods, #search_payments, #set_default_payment_method, #void_payment
Methods inherited from Notification
Methods inherited from PluginBase
#after_request, #start_plugin, #stop_plugin
Constructor Details
#initialize(identifier, payment_method_model, transaction_model, response_model, session = {}) ⇒ PrivatePaymentPlugin
Returns a new instance of PrivatePaymentPlugin.
23 24 25 26 27 28 29 30 31 |
# File 'lib/killbill/helpers/active_merchant/private_payment_plugin.rb', line 23 def initialize(identifier, payment_method_model, transaction_model, response_model, session = {}) @identifier = identifier @payment_method_model = payment_method_model @transaction_model = transaction_model @response_model = response_model @session = session reset_output_buffer end |
Instance Attribute Details
#session ⇒ Object (readonly)
For RequestForgeryProtection
21 22 23 |
# File 'lib/killbill/helpers/active_merchant/private_payment_plugin.rb', line 21 def session @session end |
Instance Method Details
#gateway(payment_processor_account_id = :default, kb_tenant_id = nil) ⇒ Object
88 89 90 91 92 |
# File 'lib/killbill/helpers/active_merchant/private_payment_plugin.rb', line 88 def gateway(payment_processor_account_id=:default, kb_tenant_id=nil) gateway = ::Killbill::Plugin::ActiveMerchant.gateways(kb_tenant_id)[payment_processor_account_id.to_sym] raise "Unable to lookup gateway for payment_processor_account_id #{payment_processor_account_id}, kb_tenant_id = #{kb_tenant_id}, gateways: #{::Killbill::Plugin::ActiveMerchant.gateways(kb_tenant_id)}" if gateway.nil? gateway end |
#kb_apis ⇒ Object
84 85 86 |
# File 'lib/killbill/helpers/active_merchant/private_payment_plugin.rb', line 84 def kb_apis ::Killbill::Plugin::ActiveMerchant.kb_apis end |
#logger ⇒ Object
94 95 96 |
# File 'lib/killbill/helpers/active_merchant/private_payment_plugin.rb', line 94 def logger ::Killbill::Plugin::ActiveMerchant.logger end |
#payment_form_for(order_id, account_id, service, options = {}, &proc) ⇒ Object
Valid options: :amount, :currency, :test, :credential2, :credential3, :credential4, :country, :account_name,
:transaction_type, :authcode, :notify_url, :return_url, :redirect_param, :forward_url
Additionally, you can have a :html key which will be passed through to the form_tag helper
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/killbill/helpers/active_merchant/private_payment_plugin.rb', line 61 def payment_form_for(order_id, account_id, service, = {}, &proc) # For ActiveMerchant routing [:service] = service [:html] ||= {} [:html][:disable_authenticity_token] ||= true [:html][:enforce_utf8] ||= false payment_service_for(order_id, account_id, , &proc) output_buffer end |
#payment_link_for(name, order_id, account_id, service, options = {}) ⇒ Object
Valid options: :amount, :currency, :test, :credential2, :credential3, :credential4, :country, :account_name,
:transaction_type, :authcode, :notify_url, :return_url, :redirect_param, :forward_url
Additionally, you can have a :html key which will be passed through to the link_to helper
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/killbill/helpers/active_merchant/private_payment_plugin.rb', line 37 def payment_link_for(name, order_id, account_id, service, = {}) integration_module = ::OffsitePayments.integration(service.to_s.camelize) service_class = integration_module.const_get('Helper') = .delete(:html) || {} service = service_class.new(order_id, account_id, ) service_url = service.respond_to?(:credential_based_url) ? service.credential_based_url : integration_module.service_url # Hack for QIWI which requires 'id' to be the first query parameter... params = service.form_fields order_key = service.mappings[:order] url = service_url + '?' + "#{CGI.escape(order_key.to_param)}=#{CGI.escape(params[order_key].to_s)}" params.delete order_key url += '&' + params.to_query # service.form_fields are query parameters link_to name, url, .merge(service.form_fields) end |
#save_response_and_transaction(gw_response, api_call, kb_account_id, kb_tenant_id, payment_processor_account_id, kb_payment_id = nil, kb_payment_transaction_id = nil, transaction_type = nil, amount_in_cents = 0, currency = nil) ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/killbill/helpers/active_merchant/private_payment_plugin.rb', line 74 def save_response_and_transaction(gw_response, api_call, kb_account_id, kb_tenant_id, payment_processor_account_id, kb_payment_id=nil, kb_payment_transaction_id=nil, transaction_type=nil, amount_in_cents=0, currency=nil) logger.warn "Unsuccessful #{api_call}: #{gw_response.}" unless gw_response.success? response, transaction = @response_model.create_response_and_transaction(@identifier, @transaction_model, api_call, kb_account_id, kb_payment_id, kb_payment_transaction_id, transaction_type, payment_processor_account_id, kb_tenant_id, gw_response, amount_in_cents, currency, {}, @response_model) logger.debug { "Recorded transaction: #{transaction.inspect}" } unless transaction.nil? return response, transaction end |