killbill-cybersource 3.0.0 → 3.1.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: a43a923c2c9b198447cd1479a2ca3478685f706b
4
- data.tar.gz: cb7b47881a91c1ca479153f97960e649fd21531d
3
+ metadata.gz: 94ede73472f0efc7fcb99f2096e257964eb0a013
4
+ data.tar.gz: 7fc15969cdb1d4fd53086a035fe1ae4a30b5d78f
5
5
  SHA512:
6
- metadata.gz: 8643323ee817645537cb091d16d08c4853bcf4f875e7bc37904dda13731c124c22018e9cd5ad5052a68acc7a5f5eee6793760054f4f612ce57865ce5da9328c7
7
- data.tar.gz: beeae965c890f3ada234a6db810ca535569399f52da5d3c744f23d0cb791941f9923dcb20fd8c3160dc780b68762f150b30dca1333697fbee9c03c0ad4165866
6
+ metadata.gz: db42929422720141856c0d853dc85fc26413c30e087c5f1a2c7d0a4eb0cf36fb4b1de5d333fe29afcb19562932a9e48fabf5b159f5998b3320e874bdcb459456
7
+ data.tar.gz: c52284173c58b08b29003dc19e81ebc0610e831339f8389cabe375d4f435a1515faf2ed2b5107f5dd6edfe91fb133ca5b3ec14d4b09cb3c9632638e6c2444d00
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- killbill-cybersource (3.0.0)
4
+ killbill-cybersource (3.1.0)
5
5
  actionpack (~> 4.1.0)
6
6
  actionview (~> 4.1.0)
7
7
  activemerchant (~> 1.48.0)
@@ -9,7 +9,7 @@ PATH
9
9
  activerecord-bogacs (~> 0.3)
10
10
  activerecord-jdbc-adapter (~> 1.3)
11
11
  jruby-openssl (~> 0.9.6)
12
- killbill (~> 5.1.0)
12
+ killbill (~> 6.1.0)
13
13
  monetize (~> 1.1.0)
14
14
  money (~> 6.5.1)
15
15
  offsite_payments (~> 2.1.0)
@@ -19,13 +19,13 @@ PATH
19
19
  GEM
20
20
  remote: https://rubygems.org/
21
21
  specs:
22
- actionpack (4.1.12)
23
- actionview (= 4.1.12)
24
- activesupport (= 4.1.12)
22
+ actionpack (4.1.14)
23
+ actionview (= 4.1.14)
24
+ activesupport (= 4.1.14)
25
25
  rack (~> 1.5.2)
26
26
  rack-test (~> 0.6.2)
27
- actionview (4.1.12)
28
- activesupport (= 4.1.12)
27
+ actionview (4.1.14)
28
+ activesupport (= 4.1.14)
29
29
  builder (~> 3.1)
30
30
  erubis (~> 2.7.0)
31
31
  active_utils (3.0.0)
@@ -36,18 +36,17 @@ GEM
36
36
  builder (>= 2.1.2, < 4.0.0)
37
37
  i18n (>= 0.6.9)
38
38
  nokogiri (~> 1.4)
39
- activemodel (4.1.12)
40
- activesupport (= 4.1.12)
39
+ activemodel (4.1.14)
40
+ activesupport (= 4.1.14)
41
41
  builder (~> 3.1)
42
- activerecord (4.1.12)
43
- activemodel (= 4.1.12)
44
- activesupport (= 4.1.12)
42
+ activerecord (4.1.14)
43
+ activemodel (= 4.1.14)
44
+ activesupport (= 4.1.14)
45
45
  arel (~> 5.0.0)
46
- activerecord-bogacs (0.3.0)
47
- thread_safe (~> 0.3)
48
- activerecord-jdbc-adapter (1.3.17)
46
+ activerecord-bogacs (0.4.1)
47
+ activerecord-jdbc-adapter (1.3.19)
49
48
  activerecord (>= 2.2)
50
- activesupport (4.1.12)
49
+ activesupport (4.1.14)
51
50
  i18n (~> 0.6, >= 0.6.9)
52
51
  json (~> 1.7, >= 1.7.7)
53
52
  minitest (~> 5.1)
@@ -57,7 +56,7 @@ GEM
57
56
  builder (3.2.2)
58
57
  diff-lcs (1.1.3)
59
58
  erubis (2.7.0)
60
- ethon (0.7.4)
59
+ ethon (0.8.0)
61
60
  ffi (>= 1.3.0)
62
61
  ffi (1.9.10-java)
63
62
  i18n (0.7.0)
@@ -66,20 +65,20 @@ GEM
66
65
  ruby-maven (~> 3.0.4)
67
66
  jdbc-mariadb (1.1.8)
68
67
  jdbc-sqlite3 (3.8.10.1)
69
- jruby-openssl (0.9.7-java)
68
+ jruby-openssl (0.9.12-java)
70
69
  json (1.8.3-java)
71
- killbill (5.1.0)
70
+ killbill (6.1.0)
72
71
  rack (>= 1.5.2)
73
72
  sinatra (~> 1.3.4)
74
73
  typhoeus (~> 0.6.9)
75
74
  tzinfo (~> 1.2.0)
76
75
  maven-tools (0.32.5)
77
- minitest (5.7.0)
76
+ minitest (5.8.3)
78
77
  monetize (1.1.0)
79
78
  money (~> 6.5.0)
80
79
  money (6.5.1)
81
80
  i18n (>= 0.6.4, <= 0.7.0)
82
- nokogiri (1.6.6.2-java)
81
+ nokogiri (1.6.7-java)
83
82
  offsite_payments (2.1.0)
84
83
  actionpack (>= 3.2.20, < 5.0.0)
85
84
  active_utils (~> 3.0.0)
data/Jarfile CHANGED
@@ -1,11 +1,11 @@
1
- jar 'org.kill-bill.billing:killbill-api', '0.20'
2
- jar 'org.kill-bill.billing.plugin:killbill-plugin-api-currency', '0.15'
3
- jar 'org.kill-bill.billing.plugin:killbill-plugin-api-invoice', '0.15'
4
- jar 'org.kill-bill.billing.plugin:killbill-plugin-api-notification', '0.15'
5
- jar 'org.kill-bill.billing.plugin:killbill-plugin-api-payment', '0.15'
6
- jar 'org.kill-bill.billing.plugin:killbill-plugin-api-control', '0.15'
7
- jar 'org.kill-bill.billing.plugin:killbill-plugin-api-catalog', '0.15'
8
- jar 'org.kill-bill.billing.plugin:killbill-plugin-api-entitlement', '0.15'
9
- jar 'org.kill-bill.billing:killbill-util:tests', '0.15.3'
1
+ jar 'org.kill-bill.billing:killbill-api', '0.30'
2
+ jar 'org.kill-bill.billing.plugin:killbill-plugin-api-currency', '0.18'
3
+ jar 'org.kill-bill.billing.plugin:killbill-plugin-api-invoice', '0.18'
4
+ jar 'org.kill-bill.billing.plugin:killbill-plugin-api-notification', '0.18'
5
+ jar 'org.kill-bill.billing.plugin:killbill-plugin-api-payment', '0.18'
6
+ jar 'org.kill-bill.billing.plugin:killbill-plugin-api-control', '0.18'
7
+ jar 'org.kill-bill.billing.plugin:killbill-plugin-api-catalog', '0.18'
8
+ jar 'org.kill-bill.billing.plugin:killbill-plugin-api-entitlement', '0.18'
9
+ jar 'org.kill-bill.billing:killbill-util:tests', '0.15.9'
10
10
  jar 'org.mockito:mockito-all', '1.10.19'
11
11
  jar 'javax.servlet:javax.servlet-api', '3.1.0'
data/Jarfile.lock CHANGED
@@ -1,14 +1,14 @@
1
- org.kill-bill.billing:killbill-api:jar:0.20
1
+ org.kill-bill.billing:killbill-api:jar:0.30
2
2
  com.fasterxml.jackson.core:jackson-annotations:jar:2.4.3
3
3
  joda-time:joda-time:jar:2.3
4
- org.kill-bill.billing.plugin:killbill-plugin-api-currency:jar:0.15
5
- org.kill-bill.billing.plugin:killbill-plugin-api-invoice:jar:0.15
6
- org.kill-bill.billing.plugin:killbill-plugin-api-notification:jar:0.15
7
- org.kill-bill.billing.plugin:killbill-plugin-api-payment:jar:0.15
8
- org.kill-bill.billing.plugin:killbill-plugin-api-control:jar:0.15
9
- org.kill-bill.billing.plugin:killbill-plugin-api-catalog:jar:0.15
10
- org.kill-bill.billing.plugin:killbill-plugin-api-entitlement:jar:0.15
11
- org.kill-bill.billing:killbill-util:jar:tests:0.15.3
4
+ org.kill-bill.billing.plugin:killbill-plugin-api-currency:jar:0.18
5
+ org.kill-bill.billing.plugin:killbill-plugin-api-invoice:jar:0.18
6
+ org.kill-bill.billing.plugin:killbill-plugin-api-notification:jar:0.18
7
+ org.kill-bill.billing.plugin:killbill-plugin-api-payment:jar:0.18
8
+ org.kill-bill.billing.plugin:killbill-plugin-api-control:jar:0.18
9
+ org.kill-bill.billing.plugin:killbill-plugin-api-catalog:jar:0.18
10
+ org.kill-bill.billing.plugin:killbill-plugin-api-entitlement:jar:0.18
11
+ org.kill-bill.billing:killbill-util:jar:tests:0.15.9
12
12
  com.fasterxml.jackson.core:jackson-databind:jar:2.4.3
13
13
  com.fasterxml.jackson.core:jackson-core:jar:2.4.3
14
14
  com.fasterxml.jackson.dataformat:jackson-dataformat-csv:jar:2.4.3
@@ -32,22 +32,22 @@ aopalliance:aopalliance:jar:1.0
32
32
  com.google.inject.extensions:guice-multibindings:jar:3.0
33
33
  org.jdbi:jdbi:jar:2.62
34
34
  org.joda:joda-money:jar:0.9
35
- org.kill-bill.billing:killbill-internal-api:jar:0.15.3
36
- org.kill-bill.billing:killbill-platform-api:jar:0.8
37
- org.kill-bill.billing:killbill-platform-base:jar:0.8
35
+ org.kill-bill.billing:killbill-internal-api:jar:0.15.9
36
+ org.kill-bill.billing:killbill-platform-api:jar:0.13
37
+ org.kill-bill.billing:killbill-platform-base:jar:0.13
38
38
  com.google.code.findbugs:annotations:jar:3.0.0
39
39
  org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4:jar:1.16
40
- org.kill-bill.billing:killbill-platform-osgi-api:jar:0.8
40
+ org.kill-bill.billing:killbill-platform-osgi-api:jar:0.13
41
41
  org.osgi:org.osgi.core:jar:5.0.0
42
- org.kill-bill.commons:killbill-clock:jar:0.6
43
- org.kill-bill.commons:killbill-concurrent:jar:0.6
44
- org.kill-bill.commons:killbill-embeddeddb-common:jar:0.6
45
- org.kill-bill.commons:killbill-jdbi:jar:0.6
42
+ org.kill-bill.commons:killbill-clock:jar:0.10
43
+ org.kill-bill.commons:killbill-concurrent:jar:0.10
44
+ org.kill-bill.commons:killbill-embeddeddb-common:jar:0.10
45
+ org.kill-bill.commons:killbill-jdbi:jar:0.10
46
46
  com.h2database:h2:jar:1.4.186
47
47
  javax.inject:javax.inject:jar:1
48
- org.kill-bill.commons:killbill-locker:jar:0.6
49
- org.kill-bill.commons:killbill-queue:jar:0.6
50
- org.kill-bill.commons:killbill-xmlloader:jar:0.6
48
+ org.kill-bill.commons:killbill-locker:jar:0.10
49
+ org.kill-bill.commons:killbill-queue:jar:0.10
50
+ org.kill-bill.commons:killbill-xmlloader:jar:0.10
51
51
  org.skife.config:config-magic:jar:0.14
52
52
  org.slf4j:jcl-over-slf4j:jar:1.7.12
53
53
  org.slf4j:slf4j-api:jar:1.7.12
data/README.md CHANGED
@@ -11,6 +11,7 @@ Kill Bill compatibility
11
11
  | Plugin version | Kill Bill version |
12
12
  | -------------: | ----------------: |
13
13
  | 1.x.y | 0.14.z |
14
+ | 3.x.y | 0.15.z |
14
15
 
15
16
  Requirements
16
17
  ------------
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.0
1
+ 3.1.0
data/cybersource.yml CHANGED
@@ -3,10 +3,10 @@
3
3
  :test: true
4
4
  :login: <%= ENV['LOGIN'] %>
5
5
  :password: <%= ENV['PASSWORD'] %>
6
- - :account_id: on_demand
7
- :merchantID: <%= ENV['MERCHANT_ID'] %>
8
- :username: <%= ENV['OD_USERNAME'] %>
9
- :password: <%= ENV['OD_PASSWORD'] %>
6
+ # - :account_id: on_demand
7
+ # :merchantID: <%= ENV['MERCHANT_ID'] %>
8
+ # :username: <%= ENV['OD_USERNAME'] %>
9
+ # :password: <%= ENV['OD_PASSWORD'] %>
10
10
 
11
11
  :database:
12
12
  # SQLite (development)
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.rdoc_options << '--exclude' << '.'
24
24
 
25
- s.add_dependency 'killbill', '~> 5.1.0'
25
+ s.add_dependency 'killbill', '~> 6.1.0'
26
26
 
27
27
  s.add_dependency 'sinatra', '~> 1.3.4'
28
28
  s.add_dependency 'thread_safe', '~> 0.3.4'
@@ -2,6 +2,8 @@ module Killbill #:nodoc:
2
2
  module Cybersource #:nodoc:
3
3
  class PaymentPlugin < ::Killbill::Plugin::ActiveMerchant::PaymentPlugin
4
4
 
5
+ SIXTY_DAYS_AGO = (60 * 86400)
6
+
5
7
  def initialize
6
8
  gateway_builder = Proc.new do |config|
7
9
  ::ActiveMerchant::Billing::CyberSourceGateway.new :login => config[:login], :password => config[:password]
@@ -73,6 +75,11 @@ module Killbill #:nodoc:
73
75
  end
74
76
 
75
77
  def refund_payment(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context)
78
+ if should_credit?(kb_payment_id, context, properties_to_hash(properties))
79
+ # Note: from the plugin perspective, this transaction is a CREDIT but Kill Bill doesn't care about PaymentTransactionInfoPlugin#TransactionType
80
+ return credit_payment(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context)
81
+ end
82
+
76
83
  # Pass extra parameters for the gateway here
77
84
  options = {}
78
85
 
@@ -231,6 +238,18 @@ module Killbill #:nodoc:
231
238
  end
232
239
  end
233
240
 
241
+ def should_credit?(kb_payment_id, context, options = {})
242
+ # Transform refunds on old payments into credits automatically unless the disable_auto_credit property is passed
243
+ return false if Killbill::Plugin::ActiveMerchant::Utils.normalized(options, :disable_auto_credit)
244
+
245
+ transaction = @transaction_model.find_candidate_transaction_for_refund(kb_payment_id, context.tenant_id)
246
+ return false if transaction.nil?
247
+
248
+ threshold = (Killbill::Plugin::ActiveMerchant::Utils.normalized(options, :auto_credit_threshold) || SIXTY_DAYS_AGO).to_i
249
+ # Note: we cannot use Kill Bill clock yet (see https://github.com/killbill/killbill-platform/issues/4)
250
+ (Time.now - transaction.created_at) >= threshold
251
+ end
252
+
234
253
  # Make calls idempotent
235
254
  def before_gateway(gateway, kb_transaction, last_transaction, payment_source, amount_in_cents, currency, options, context)
236
255
  super
data/pom.xml CHANGED
@@ -25,7 +25,7 @@
25
25
  <groupId>org.kill-bill.billing.plugin.ruby</groupId>
26
26
  <artifactId>cybersource-plugin</artifactId>
27
27
  <packaging>pom</packaging>
28
- <version>3.0.0</version>
28
+ <version>3.1.0</version>
29
29
  <name>cybersource-plugin</name>
30
30
  <url>http://github.com/killbill/killbill-cybersource-plugin</url>
31
31
  <description>Plugin for accessing Cybersource as a payment gateway</description>
@@ -27,4 +27,41 @@ describe Killbill::Cybersource::PaymentPlugin do
27
27
  it 'should start and stop correctly' do
28
28
  @plugin.stop_plugin
29
29
  end
30
+
31
+ it 'should detect when to credit refunds' do
32
+ context = build_call_context
33
+ kb_payment_id = SecureRandom.uuid
34
+
35
+ @plugin.should_credit?(SecureRandom.uuid, context).should be_false
36
+
37
+ with_transaction(kb_payment_id, :AUTHORIZE, 60.days.ago, build_call_context(SecureRandom.uuid)) { @plugin.should_credit?(kb_payment_id, context).should be_false }
38
+ with_transaction(kb_payment_id, :AUTHORIZE, 59.days.ago, context) { @plugin.should_credit?(kb_payment_id, context).should be_false }
39
+ with_transaction(kb_payment_id, :VOID, 60.days.ago, context) { @plugin.should_credit?(kb_payment_id, context).should be_false }
40
+ with_transaction(SecureRandom.uuid, :AUTHORIZE, 60.days.ago, context) { @plugin.should_credit?(kb_payment_id, context).should be_false }
41
+
42
+ with_transaction(kb_payment_id, :AUTHORIZE, 60.days.ago, context) do
43
+ @plugin.should_credit?(kb_payment_id, context, {:disable_auto_credit => true}).should be_false
44
+ @plugin.should_credit?(kb_payment_id, context, {:auto_credit_threshold => 61 * 86400}).should be_false
45
+ @plugin.should_credit?(kb_payment_id, context).should be_true
46
+ end
47
+ end
48
+
49
+ private
50
+
51
+ def with_transaction(kb_payment_id, transaction_type, created_at, context)
52
+ t = ::Killbill::Cybersource::CybersourceTransaction.create(:kb_payment_id => kb_payment_id,
53
+ :transaction_type => transaction_type,
54
+ :kb_tenant_id => context.tenant_id,
55
+ :created_at => created_at,
56
+ # The data below doesn't matter
57
+ :updated_at => created_at,
58
+ :kb_account_id => SecureRandom.uuid,
59
+ :kb_payment_transaction_id => SecureRandom.uuid,
60
+ :api_call => :refund,
61
+ :cybersource_response_id => 1)
62
+ t.should_not be_nil
63
+ yield t if block_given?
64
+ ensure
65
+ t.destroy! unless t.nil?
66
+ end
30
67
  end
@@ -31,6 +31,10 @@ describe Killbill::Cybersource::PaymentPlugin do
31
31
  @plugin.stop_plugin
32
32
  end
33
33
 
34
+ let(:with_report_api) do
35
+ @plugin.get_report_api(@call_context.tenant_id).present?
36
+ end
37
+
34
38
  it 'should be able to charge a Credit Card directly and calls should be idempotent' do
35
39
  properties = build_pm_properties
36
40
 
@@ -56,6 +60,9 @@ describe Killbill::Cybersource::PaymentPlugin do
56
60
  transactions.size.should == 1
57
61
  transactions[0].api_call.should == 'purchase'
58
62
 
63
+ # Skip the rest of the test if the report API isn't configured
64
+ break unless with_report_api
65
+
59
66
  payment_response = @plugin.purchase_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[0].id, @pm.kb_payment_method_id, @amount, @currency, @properties, @call_context)
60
67
  payment_response.amount.should == @amount
61
68
  payment_response.status.should == :PROCESSED
@@ -101,15 +108,18 @@ describe Killbill::Cybersource::PaymentPlugin do
101
108
  transaction_info_plugins.size.should == 1
102
109
  transaction_info_plugins.first.status.should eq(:UNDEFINED)
103
110
 
104
- # Fix it
105
- transaction_info_plugins = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, @properties, @call_context)
106
- transaction_info_plugins.size.should == 1
107
- transaction_info_plugins.first.status.should eq(:PROCESSED)
108
-
109
- # Set skip_gw=true, to check the local state
110
- transaction_info_plugins = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, properties_with_skip_gw, @call_context)
111
- transaction_info_plugins.size.should == 1
112
- transaction_info_plugins.first.status.should eq(:PROCESSED)
111
+ # Skip if the report API isn't configured
112
+ if with_report_api
113
+ # Fix it
114
+ transaction_info_plugins = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, @properties, @call_context)
115
+ transaction_info_plugins.size.should == 1
116
+ transaction_info_plugins.first.status.should eq(:PROCESSED)
117
+
118
+ # Set skip_gw=true, to check the local state
119
+ transaction_info_plugins = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, properties_with_skip_gw, @call_context)
120
+ transaction_info_plugins.size.should == 1
121
+ transaction_info_plugins.first.status.should eq(:PROCESSED)
122
+ end
113
123
 
114
124
  # Compare the state of the old and new response
115
125
  new_response = Killbill::Cybersource::CybersourceResponse.last
@@ -134,7 +144,7 @@ describe Killbill::Cybersource::PaymentPlugin do
134
144
  new_response.params_avs_code_raw.should == response.params_avs_code_raw
135
145
  new_response.params_reconciliation_id.should == response.params_reconciliation_id
136
146
  new_response.success.should be_true
137
- new_response.message.should == 'Request was processed successfully.'
147
+ new_response.message.should == (with_report_api ? 'Request was processed successfully.' : '{"payment_plugin_status":"UNDEFINED"}')
138
148
  end
139
149
 
140
150
  it 'should be able to charge and refund' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill-cybersource
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.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-08-22 00:00:00.000000000 Z
11
+ date: 2015-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: killbill
@@ -16,12 +16,12 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 5.1.0
19
+ version: 6.1.0
20
20
  requirement: !ruby/object:Gem::Requirement
21
21
  requirements:
22
22
  - - ~>
23
23
  - !ruby/object:Gem::Version
24
- version: 5.1.0
24
+ version: 6.1.0
25
25
  prerelease: false
26
26
  type: :runtime
27
27
  - !ruby/object:Gem::Dependency
@@ -324,7 +324,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
324
324
  version: '0'
325
325
  requirements: []
326
326
  rubyforge_project:
327
- rubygems_version: 2.4.8
327
+ rubygems_version: 2.4.6
328
328
  signing_key:
329
329
  specification_version: 4
330
330
  summary: Plugin to use Cybersource as a gateway.