Class: PaymentTest::PaymentPluginControl

Inherits:
Object
  • Object
show all
Defined in:
lib/payment_test/api_control.rb

Defined Under Namespace

Classes: Payment

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ PaymentPluginControl

Returns a new instance of PaymentPluginControl.


23
24
25
26
# File 'lib/payment_test/api_control.rb', line 23

def initialize(parent)
  @parent = parent
  @payments = Hash.new
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent


21
22
23
# File 'lib/payment_test/api_control.rb', line 21

def parent
  @parent
end

#paymentsObject (readonly)

Returns the value of attribute payments


21
22
23
# File 'lib/payment_test/api_control.rb', line 21

def payments
  @payments
end

Instance Method Details

#add_payment_method(kb_account_id, kb_payment_method_id, payment_method_props, set_default, properties, context) ⇒ Object


60
61
62
# File 'lib/payment_test/api_control.rb', line 60

def add_payment_method(, kb_payment_method_id, payment_method_props, set_default, properties, context)
  # Noop
end

#authorize_payment(kb_account_id, kb_payment_id, kb_transaction_id, kb_payment_method_id, amount, currency, properties, context) ⇒ Object


28
29
30
# File 'lib/payment_test/api_control.rb', line 28

def authorize_payment(, kb_payment_id, kb_transaction_id, kb_payment_method_id, amount, currency, properties, context)
  add_transaction(, kb_payment_id, kb_transaction_id, :AUTHORIZE, amount, currency, properties)
end

#build_form_descriptor(kb_account_id, customFields, properties, context) ⇒ Object

Raises:

  • (NotImplementedError)

90
91
92
# File 'lib/payment_test/api_control.rb', line 90

def build_form_descriptor(, customFields, properties, context)
  raise NotImplementedError.new("build_form_descriptor not implemented")
end

#capture_payment(kb_account_id, kb_payment_id, kb_transaction_id, kb_payment_method_id, amount, currency, properties, context) ⇒ Object


32
33
34
# File 'lib/payment_test/api_control.rb', line 32

def capture_payment(, kb_payment_id, kb_transaction_id, kb_payment_method_id, amount, currency, properties, context)
  add_transaction(, kb_payment_id, kb_transaction_id, :CAPTURE, amount, currency, properties)
end

#credit_payment(kb_account_id, kb_payment_id, kb_transaction_id, kb_payment_method_id, amount, currency, properties, context) ⇒ Object


44
45
46
# File 'lib/payment_test/api_control.rb', line 44

def credit_payment(, kb_payment_id, kb_transaction_id, kb_payment_method_id, amount, currency, properties, context)
  add_transaction(, kb_payment_id, kb_transaction_id, :CREDIT, amount, currency, properties)
end

#delete_payment_method(kb_account_id, kb_payment_method_id, properties, context) ⇒ Object


64
65
66
# File 'lib/payment_test/api_control.rb', line 64

def delete_payment_method(, kb_payment_method_id, properties, context)
  # Noop
end

#get_payment_info(kb_account_id, kb_payment_id, properties, context) ⇒ Object


52
53
54
# File 'lib/payment_test/api_control.rb', line 52

def get_payment_info(, kb_payment_id, properties, context)
  @payments[kb_payment_id] ? @payments[kb_payment_id].transactions : nil
end

#get_payment_method_detail(kb_account_id, kb_payment_method_id, properties, context) ⇒ Object


68
69
70
71
72
# File 'lib/payment_test/api_control.rb', line 68

def get_payment_method_detail(, kb_payment_method_id, properties, context)
  payment_method = ::Killbill::Plugin::Model::PaymentMethodPlugin.new
  payment_method.kb_payment_method_id = kb_payment_method_id
  payment_method
end

#get_payment_methods(kb_account_id, refresh_from_gateway, properties, context) ⇒ Object

Raises:

  • (NotImplementedError)

78
79
80
# File 'lib/payment_test/api_control.rb', line 78

def get_payment_methods(, refresh_from_gateway, properties, context)
  raise NotImplementedError.new("get_payment_methods not implemented")
end

#process_notification(notification, properties, context) ⇒ Object


94
95
96
# File 'lib/payment_test/api_control.rb', line 94

def process_notification(notification, properties, context)
  # Noop
end

#purchase_payment(kb_account_id, kb_payment_id, kb_transaction_id, kb_payment_method_id, amount, currency, properties, context) ⇒ Object


36
37
38
# File 'lib/payment_test/api_control.rb', line 36

def purchase_payment(, kb_payment_id, kb_transaction_id, kb_payment_method_id, amount, currency, properties, context)
  add_transaction(, kb_payment_id, kb_transaction_id, :PURCHASE, amount, currency, properties)
end

#refund_payment(kb_account_id, kb_payment_id, kb_transaction_id, kb_payment_method_id, amount, currency, properties, context) ⇒ Object


48
49
50
# File 'lib/payment_test/api_control.rb', line 48

def refund_payment(, kb_payment_id, kb_transaction_id, kb_payment_method_id, amount, currency, properties, context)
  add_transaction(, kb_payment_id, kb_transaction_id, :REFUND, amount, currency, properties)
end

#reset_payment_methods(kb_account_id, payment_methods, properties, context) ⇒ Object


86
87
88
# File 'lib/payment_test/api_control.rb', line 86

def reset_payment_methods(, payment_methods, properties, context)
  # Noop
end

#search_payment_methods(search_key, offset, limit, properties, context) ⇒ Object

Raises:

  • (NotImplementedError)

82
83
84
# File 'lib/payment_test/api_control.rb', line 82

def search_payment_methods(search_key, offset, limit, properties, context)
  raise NotImplementedError.new("search_payment_methods not implemented")
end

#search_payments(search_key, offset, limit, properties, context) ⇒ Object

Raises:

  • (NotImplementedError)

56
57
58
# File 'lib/payment_test/api_control.rb', line 56

def search_payments(search_key, offset, limit, properties, context)
  raise NotImplementedError.new("search_payments not implemented")
end

#set_default_payment_method(kb_account_id, kb_payment_method_id, properties, context) ⇒ Object


74
75
76
# File 'lib/payment_test/api_control.rb', line 74

def set_default_payment_method(, kb_payment_method_id, properties, context)
  # Noop
end

#should_return_nil(properties, force_nil) ⇒ Object


105
106
107
# File 'lib/payment_test/api_control.rb', line 105

def should_return_nil(properties, force_nil)
  force_nil || PluginPropertyUtils::get_property_or_nil(properties, 'RETURN_NIL')
end

#sleep_if_required(properties, force_sleep_sec) ⇒ Object


109
110
111
112
113
114
115
116
117
# File 'lib/payment_test/api_control.rb', line 109

def sleep_if_required(properties, force_sleep_sec)
  sleep_prop = PluginPropertyUtils::get_property_or_nil(properties, 'SLEEP_TIME_SEC')
  resolved_sleep_sec = force_sleep_sec || sleep_prop
  if resolved_sleep_sec
    sleep_time = resolved_sleep_sec.value.to_f
    @parent.logger.info "PaymentPluginControl sleeping #{sleep_time}"
    sleep sleep_time
  end
end

#throw_exception_if_required(properties, force_exception) ⇒ Object


98
99
100
101
102
103
# File 'lib/payment_test/api_control.rb', line 98

def throw_exception_if_required(properties, force_exception)
  exception = PluginPropertyUtils::get_property_or_nil(properties, 'THROW_EXCEPTION')
  if force_exception || exception
    raise RuntimeError.new("throwing exception}")
  end
end

#void_payment(kb_account_id, kb_payment_id, kb_transaction_id, kb_payment_method_id, properties, context) ⇒ Object


40
41
42
# File 'lib/payment_test/api_control.rb', line 40

def void_payment(, kb_payment_id, kb_transaction_id, kb_payment_method_id, properties, context)
  add_transaction(, kb_payment_id, kb_transaction_id, :VOID, nil, nil, properties)
end