Sha256: 730672c9343f454ef7b787ad185a43ad3dc55b2f076477627016749bc075487f

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

# -- encoding : utf-8 --

#include Killbill::Plugin::ActiveMerchant::Sinatra

require 'sinatra'

configure do
end

helpers do
  def state
    PaymentTest::State.instance
  end
end



post '/plugins/killbill-payment-test/configure', :provides => 'json' do


  begin
    data = JSON.parse request.body.read
  rescue JSON::ParserError => e
    halt 400, {'Content-Type' => 'text/plain'}, "Invalid payload: #{e}"
  end

  action = data['CONFIGURE_ACTION']
  if action.nil?
    halt 400, {'Content-Type' => 'text/plain'}, "Invalid json, need to specify one CONFIGURE_ACTION={ACTION_RETURN_PLUGIN_STATUS_ERROR|ACTION_THROW_EXCEPTION|ACTION_RETURN_NIL|ACTION_SLEEP|ACTION_RESET}"
  end


  if action == 'ACTION_RETURN_PLUGIN_STATUS_ERROR'
    state.configure_always_return_plugin_status_error(data['METHODS'])
  elsif action == 'ACTION_THROW_EXCEPTION'
    state.configure_always_throw(data['METHODS'])
  elsif action == 'ACTION_RETURN_NIL'
    state.configure_return_nil(data['METHODS'])
  elsif action == 'ACTION_SLEEP'
    state.configure_sleep_time(data['SLEEP_TIME_SEC'], data['METHODS'])
  else
    state.reset_configuration
  end
  status 200
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
killbill-payment-test-4.0.1 lib/payment_test/application.rb
killbill-payment-test-4.0.0 lib/payment_test/application.rb
killbill-payment-test-3.3.0 lib/payment_test/application.rb