Sha256: 90331fb0af1b157970393e61037bbde9093dfde874c5526d91652ddc76abd491

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

module Killbill::Litle
  class PrivatePaymentPlugin
    include Singleton

    def register_token!(kb_account_id, paypage_registration_id, options = {})
      litle_response = gateway.store paypage_registration_id, options
      response = save_response litle_response, :register_token

      # Create the payment method (not associated to a Killbill payment method yet)
      LitlePaymentMethod.create! :kb_account_id => kb_account_id, :kb_payment_method_id => nil, :litle_token => response.litle_token
    end

    private

    def save_response(litle_response, api_call)
      logger.warn "Unsuccessful #{api_call}: #{litle_response.message}" unless litle_response.success?

      # Save the response to our logs
      response = LitleResponse.from_response(api_call, nil, litle_response)
      response.save!
      response
    end

    def gateway
      # The gateway should have been configured when the plugin started
      Killbill::Litle::Gateway.instance
    end

    def logger
      # The logger should have been configured when the plugin started
      Killbill::Litle.logger
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
killbill-litle-1.0.6 lib/litle/private_api.rb
killbill-litle-1.0.5 lib/litle/private_api.rb
killbill-litle-1.0.3 lib/litle/private_api.rb
killbill-litle-1.0.2 lib/litle/private_api.rb
killbill-litle-1.0.1 lib/litle/private_api.rb