killbill-payment-test 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a664c1965053965e7f01b9d7976c1e7493b17d51
4
- data.tar.gz: 93113c6b15ebf46346d4dd269dbbdb368cdff21e
3
+ metadata.gz: 7372b10969f7c4de8f1d65a4f43e0b47ff43b715
4
+ data.tar.gz: 3f4c20f14d7f01fa72beb56bb9f129f8e1938b0d
5
5
  SHA512:
6
- metadata.gz: 7773e5935ac7985b3441ca8831e691879d53cc124ba7b98fcba76a02fd4499cd4119a34bb02eed627074fd5062f34e7b05428a41be08e43404702dfa4e58ebbc
7
- data.tar.gz: 016b3d90189fd4ff93deb6d9f81fa61e4b86529024ac23055a5d725ddf2e7b7af7386a023145dab4fc80e28618e8762ebbf4a228568860aca590030f57ccc27e
6
+ metadata.gz: 7f0779f9964563294be903d42627de18f7a506cdfd8a0b448d894870be4ca99643367b9195217dbfe11efc731276ad7e6ecde37fc4ca708f1c4c25380d0be179
7
+ data.tar.gz: 78f9fb8821ca938a0d0f0e07474cb47342110b421688104ef211824f46cc4f8d142d08836fe8aacf9faa3641cf171311cefed5a5fc7e9905a25a93522e6d8b5d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- killbill-payment-test (3.2.0)
4
+ killbill-payment-test (3.3.0)
5
5
  actionpack (~> 4.1.0)
6
6
  actionview (~> 4.1.0)
7
7
  activemerchant (~> 1.53.0)
data/Jarfile.lock CHANGED
@@ -8,9 +8,9 @@
8
8
  - org.kill-bill.billing.plugin:killbill-plugin-api-notification:jar:0.18
9
9
  - commons-beanutils:commons-beanutils:jar:1.8.3
10
10
  - org.kill-bill.billing:killbill-internal-api:jar:0.15.10
11
+ - com.google.inject:guice:jar:3.0
11
12
  - org.kill-bill.commons:killbill-xmlloader:jar:0.11
12
13
  - org.kill-bill.billing.plugin:killbill-plugin-api-entitlement:jar:0.18
13
- - com.google.inject:guice:jar:3.0
14
14
  - org.osgi:org.osgi.core:jar:5.0.0
15
15
  - org.slf4j:slf4j-api:jar:1.7.12
16
16
  - com.samskivert:jmustache:jar:1.5
@@ -50,14 +50,14 @@
50
50
  - org.kill-bill.commons:killbill-locker:jar:0.11
51
51
  - org.osgi:org.osgi.compendium:jar:5.0.0
52
52
  - org.kill-bill.commons:killbill-queue:jar:0.11
53
- - org.kill-bill.commons:killbill-concurrent:jar:0.11
54
53
  - javax.servlet:javax.servlet-api:jar:3.1.0
54
+ - org.kill-bill.commons:killbill-concurrent:jar:0.11
55
55
  - org.apache.shiro:shiro-ehcache:jar:1.2.3
56
56
  - javax.inject:javax.inject:jar:1
57
57
  - com.fasterxml.jackson.datatype:jackson-datatype-joda:jar:2.4.3
58
58
  - com.google.inject.extensions:guice-multibindings:jar:3.0
59
59
  - net.sf.ehcache:ehcache:jar:2.9.1
60
- - org.kill-bill.billing.plugin:killbill-plugin-api-invoice:jar:0.18
61
60
  - org.kill-bill.billing:killbill-api:jar:0.32
61
+ - org.kill-bill.billing.plugin:killbill-plugin-api-invoice:jar:0.18
62
62
  - org.apache.shiro:shiro-guice:jar:1.2.3
63
63
  - com.google.code.findbugs:annotations:jar:3.0.0
data/README.md CHANGED
@@ -17,6 +17,7 @@ When using payment api, one can provide payment plugin properties to enable fail
17
17
 
18
18
  In that mode, the property `TEST_MODE` must be set to something different than `BEATRIX` (any other string would work. In addition the following properties are allowed:
19
19
 
20
+ * `ACTION_RETURN_PLUGIN_STATUS_ERROR`=true : This will make the plugin return a `PaymentPluginStatus.ERROR` on each payment call (e.g to simulate Insuficient Fund type of errors).
20
21
  * `THROW_EXCEPTION`=true : This will make the plugin throw RuntimeException exception on each call
21
22
  * `RETURN_NIL`=true : This will make the plugin return a nil value on each call
22
23
  * `SLEEP_TIME_SEC`=sleep_time_sec : This will make the plugin sleep `sleep_time_sec` on each call
@@ -35,7 +36,7 @@ The json body for the call supports the following:
35
36
 
36
37
  Examples:
37
38
 
38
- This will confgure the plugin th throw exception on each `purchase_payment` call:
39
+ This will confgure the plugin to return an payment error on each `purchase_payment` call (note that the name of the methods come from the definition of the [payment plugin api](https://github.com/killbill/killbill-plugin-api/blob/master/payment/src/main/java/org/killbill/billing/payment/plugin/api/PaymentPluginApi.java):
39
40
 
40
41
  ```
41
42
  curl -v \
@@ -45,7 +46,7 @@ curl -v \
45
46
  -H "Content-Type: application/json" \
46
47
  -H 'X-Killbill-CreatedBy: stephane' \
47
48
  -X POST \
48
- --data-binary '{"CONFIGURE_ACTION":"ACTION_THROW_EXCEPTION", "METHODS":"purchase_payment"}' \
49
+ --data-binary '{"CONFIGURE_ACTION":"ACTION_RETURN_PLUGIN_STATUS_ERROR", "METHODS":"purchase_payment"}' \
49
50
  -v 'http://127.0.0.1:8080/plugins/killbill-payment-test/configure'
50
51
  ```
51
52
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.2.0
1
+ 3.3.0
@@ -43,6 +43,7 @@ module PaymentTest
43
43
 
44
44
  def method_missing(method, *args, &block)
45
45
  # properties is always the second last argument right before context
46
+ args[args.length - 2] = [] if args[args.length - 2].nil?
46
47
  properties = args[args.length - 2]
47
48
 
48
49
  # Let's be cautious..
@@ -62,6 +63,10 @@ module PaymentTest
62
63
  # Check if we need to sleep
63
64
  @api_control.sleep_if_required(properties, @state.sleep_time_sec(method))
64
65
 
66
+ if @state.always_return_plugin_status_error(method)
67
+ PluginPropertyUtils.add_property_if_not_exist(properties, 'TRANSACTION_STATUS', 'ERROR')
68
+ end
69
+
65
70
  # Finally make the call
66
71
  @api_control.send method, *args
67
72
  end
@@ -26,11 +26,13 @@ post '/plugins/killbill-payment-test/configure', :provides => 'json' do
26
26
 
27
27
  action = data['CONFIGURE_ACTION']
28
28
  if action.nil?
29
- halt 400, {'Content-Type' => 'text/plain'}, "Invalid json, need to specify one CONFIGURE_ACTION={ACTION_THROW_EXCEPTION|ACTION_RETURN_NIL|ACTION_SLEEP|ACTION_RESET}"
29
+ 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}"
30
30
  end
31
31
 
32
32
 
33
- if action == 'ACTION_THROW_EXCEPTION'
33
+ if action == 'ACTION_RETURN_PLUGIN_STATUS_ERROR'
34
+ state.configure_always_return_plugin_status_error(data['METHODS'])
35
+ elsif action == 'ACTION_THROW_EXCEPTION'
34
36
  state.configure_always_throw(data['METHODS'])
35
37
  elsif action == 'ACTION_RETURN_NIL'
36
38
  state.configure_return_nil(data['METHODS'])
@@ -10,6 +10,15 @@ module PaymentTest
10
10
  test_props.size == 1 ? test_props[0] : nil
11
11
  end
12
12
 
13
+ def self.add_property_if_not_exist(properties, key_name, key_value)
14
+ if get_property_or_nil(properties, key_name).nil?
15
+ prop = Killbill::Plugin::Model::PluginProperty.new
16
+ prop.key = key_name
17
+ prop.value = key_value
18
+ properties << prop
19
+ end
20
+ end
21
+
13
22
  def self.validate_properties(properties)
14
23
  if properties.nil?
15
24
  return
@@ -9,25 +9,37 @@ module PaymentTest
9
9
  reset_configuration
10
10
  end
11
11
 
12
+ def configure_always_return_plugin_status_error(methods=nil)
13
+ reset_configuration
14
+ configure_methods(methods)
15
+ @always_return_plugin_status_error = true
16
+ log_current_state
17
+ end
18
+
19
+
12
20
  def configure_always_throw(methods=nil)
21
+ reset_configuration
13
22
  configure_methods(methods)
14
23
  @always_throw = true
15
24
  log_current_state
16
25
  end
17
26
 
18
27
  def configure_return_nil(methods=nil)
28
+ reset_configuration
19
29
  configure_methods(methods)
20
30
  @always_return_nil = true
21
31
  log_current_state
22
32
  end
23
33
 
24
34
  def configure_sleep_time(sleep_time_sec, methods=nil)
35
+ reset_configuration
25
36
  configure_methods(methods)
26
37
  @sleep_time_sec = sleep_time_sec
27
38
  log_current_state
28
39
  end
29
40
 
30
41
  def reset_configuration
42
+ @always_return_plugin_status_error = false
31
43
  @always_throw = false
32
44
  @always_return_nil = false
33
45
  @sleep_time_sec = nil
@@ -35,6 +47,10 @@ module PaymentTest
35
47
  log_current_state
36
48
  end
37
49
 
50
+ def always_return_plugin_status_error(method)
51
+ @always_return_plugin_status_error && is_for_method(method)
52
+ end
53
+
38
54
  def always_throw(method)
39
55
  @always_throw && is_for_method(method)
40
56
  end
@@ -49,11 +65,11 @@ module PaymentTest
49
65
  end
50
66
 
51
67
  def is_clear
52
- return !@always_throw && !@always_return_nil && @sleep_time_sec.nil?
68
+ return !@always_return_plugin_status_error && !@always_throw && !@always_return_nil && @sleep_time_sec.nil?
53
69
  end
54
70
 
55
71
  def log_current_state
56
- puts "PaymentTest:State : @always_throw = #{@always_throw}, @always_return_nil = #{@always_return_nil}, @sleep_time_sec = #{@sleep_time_sec}, @methods=#{@methods}"
72
+ puts "PaymentTest:State : @always_return_plugin_status_error = #{@always_return_plugin_status_error}, @always_throw = #{@always_throw}, @always_return_nil = #{@always_return_nil}, @sleep_time_sec = #{@sleep_time_sec}, @methods=#{@methods}"
57
73
  end
58
74
 
59
75
  private
data/pom.xml CHANGED
@@ -27,7 +27,7 @@
27
27
  <groupId>org.kill-bill.billing.plugin.ruby</groupId>
28
28
  <artifactId>payment-test-plugin</artifactId>
29
29
  <packaging>pom</packaging>
30
- <version>3.1.0</version>
30
+ <version>3.3.0</version>
31
31
  <name>payment-test-plugin</name>
32
32
  <description></description>
33
33
  <scm>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill-payment-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kill Bill core team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-29 00:00:00.000000000 Z
11
+ date: 2015-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: killbill