Class: Killbill::Plugin::ActiveMerchant::RSpec::FakeJavaPaymentApi

Inherits:
Object
  • Object
show all
Defined in:
lib/killbill/helpers/active_merchant/killbill_spec_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFakeJavaPaymentApi

Returns a new instance of FakeJavaPaymentApi.



139
140
141
# File 'lib/killbill/helpers/active_merchant/killbill_spec_helper.rb', line 139

def initialize
  @payments = []
end

Instance Attribute Details

#paymentsObject

Returns the value of attribute payments.



137
138
139
# File 'lib/killbill/helpers/active_merchant/killbill_spec_helper.rb', line 137

def payments
  @payments
end

Instance Method Details

#add_payment(kb_payment_id = SecureRandom.uuid, kb_payment_transaction_id = SecureRandom.uuid, kb_payment_transaction_external_key = SecureRandom.uuid, transaction_type = :PURCHASE) ⇒ Object

For testing



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/killbill/helpers/active_merchant/killbill_spec_helper.rb', line 144

def add_payment(kb_payment_id=SecureRandom.uuid, kb_payment_transaction_id=SecureRandom.uuid, kb_payment_transaction_external_key=SecureRandom.uuid, transaction_type=:PURCHASE)
  kb_payment = get_payment kb_payment_id
  if kb_payment.nil?
    kb_payment = ::Killbill::Plugin::Model::Payment.new
    kb_payment.id = kb_payment_id
    kb_payment.transactions = []
    @payments << kb_payment
  end

  kb_payment_transaction = ::Killbill::Plugin::Model::PaymentTransaction.new
  kb_payment_transaction.id = kb_payment_transaction_id
  kb_payment_transaction.transaction_type = transaction_type
  kb_payment_transaction.external_key = kb_payment_transaction_external_key
  kb_payment_transaction.created_date = Java::org.joda.time.DateTime.new(Java::org.joda.time.DateTimeZone::UTC)
  kb_payment.transactions << kb_payment_transaction

  kb_payment
end

#get_payment(id, with_plugin_info = false, with_attempts = false, properties = [], context = nil) ⇒ Object



163
164
165
# File 'lib/killbill/helpers/active_merchant/killbill_spec_helper.rb', line 163

def get_payment(id, with_plugin_info=false, with_attempts=false, properties=[], context=nil)
  @payments.find { |payment| payment.id == id.to_s }
end