class Killbill::PaymentTest::PaymentTestClient

Constants

KILLBILL_PAYMENT_TEST_PREFIX

Public Class Methods

reset(methods, options = {}) click to toggle source
# File lib/payment_test/client.rb, line 41
def reset(methods, options = {})
  configure('ACTION_RESET', nil, methods, options)
end
set_sleep_time(sleep_time_sec, methods, options = {}) click to toggle source
# File lib/payment_test/client.rb, line 29
def set_sleep_time(sleep_time_sec, methods, options = {})
  configure('ACTION_SLEEP', sleep_time_sec, methods, options)
end
set_status_canceled(methods, options = {}) click to toggle source
# File lib/payment_test/client.rb, line 25
def set_status_canceled(methods, options = {})
  configure('ACTION_RETURN_PLUGIN_STATUS_CANCELED', nil, methods, options)
end
set_status_error(methods, options = {}) click to toggle source
# File lib/payment_test/client.rb, line 21
def set_status_error(methods, options = {})
  configure('ACTION_RETURN_PLUGIN_STATUS_ERROR', nil, methods, options)
end
set_status_null(methods, options = {}) click to toggle source
# File lib/payment_test/client.rb, line 37
def set_status_null(methods, options = {})
  configure('ACTION_RETURN_NIL', nil, methods, options)
end
set_status_pending(methods, options = {}) click to toggle source
# File lib/payment_test/client.rb, line 17
def set_status_pending(methods, options = {})
  configure('ACTION_RETURN_PLUGIN_STATUS_PENDING', nil, methods, options)
end
set_status_throw(methods, options = {}) click to toggle source
# File lib/payment_test/client.rb, line 33
def set_status_throw(methods, options = {})
  configure('ACTION_THROW_EXCEPTION', nil, methods, options)
end
status(options = {}) click to toggle source
# File lib/payment_test/client.rb, line 10
def status(options = {})
  response = KillBillClient::API.get "#{KILLBILL_PAYMENT_TEST_PREFIX}/status",
                                     {},
                                     options
  JSON.parse(response.body)
end

Private Class Methods

configure(action, arg, methods, options = {}) click to toggle source
# File lib/payment_test/client.rb, line 47
def configure(action, arg, methods, options = {})
  body = {
    'CONFIGURE_ACTION' => action
  }

  body['SLEEP_TIME_SEC'] = arg if action == 'ACTION_RESET'

  body['METHODS'] = methods.nil? ? nil : methods.join(',')

  KillBillClient::API.post "#{KILLBILL_PAYMENT_TEST_PREFIX}/configure",
                           body.to_json,
                           {},
                           {
                             user: 'anonymous',
                             reason: 'TEST',
                             comment: 'TEST'
                           }.merge(options)
end