Sha256: a959868725daec885b80f1f3ef924244144261ebbf134919c4d1ea106af9e2f6

Contents?: true

Size: 1.96 KB

Versions: 2

Compression:

Stored size: 1.96 KB

Contents

require 'date'

require 'killbill/payment'

module PaymentTest
  class PaymentPlugin < Killbill::Plugin::Payment


    def start_plugin
      super
    end

    def initialize(*args)
      @raise_exception = false
      super(*args)
    end

    def get_name
    end

    def process_payment(kb_account_id, kb_payment_id, kb_payment_method_id, amount_in_cents, currency, options = {})
      res = Killbill::Plugin::PaymentResponse.new(amount_in_cents, DateTime.now, DateTime.now, Killbill::Plugin::PaymentStatus::SUCCESS, "gateway_error", "gateway_error_code")
    end

    def get_payment_info(kb_account_id, kb_payment_id, options = {})
        Killbill::Plugin::PaymentResponse.new(0, DateTime.now, DateTime.now, Killbill::Plugin::PaymentStatus::SUCCESS, "gateway_error", "gateway_error_code")
    end

    def process_refund(kb_account_id, kb_payment_id, amount_in_cents, currency, options = {})
        Killbill::Plugin::RefundResponse.new(amount_in_cents, DateTime.now, DateTime.now, Killbill::Plugin::PaymentStatus::SUCCESS, "gateway_error", "gateway_error_code")
    end

    def add_payment_method(kb_account_id, kb_payment_method_id, payment_method_props, set_default, options = {})
      nil
    end

    def delete_payment_method(kb_account_id, kb_payment_method_id, options = {})
    end

    def get_payment_method_detail(kb_account_id, kb_payment_method_id, options = {})
        Killbill::Plugin::PaymentMethodResponse.new("foo", true, [])
    end

    def set_default_payment_method(kb_account_id, kb_payment_method_id, options = {})
    end

    def get_payment_methods(kb_account_id, refresh_from_gateway, options = {})
        [Killbill::Plugin::PaymentMethodResponseInternal.new(kb_account_id, kb_account_id, true, "external_payment_method_id")]
    end

    def reset_payment_methods(kb_account_id, payment_methods)
    end

    def raise_exception_on_next_calls
      @raise_exception = true
    end

    def clear_exception_on_next_calls
      @raise_exception = false
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
killbill-payment-test-1.0.5 lib/payment_test/api.rb
killbill-payment-test-1.0.4 lib/payment_test/api.rb