killbill-orbital 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 76aa751f41e2cbc1975e7c464347048495a9370e
4
- data.tar.gz: 0b17e7b61ebcad2e58a7dc51c214fbb3c4f91706
3
+ metadata.gz: 5ca43827edf81bbf093c563e2853aa32397481d5
4
+ data.tar.gz: b0427c2944d18a31475069f3956e15dd2d50972d
5
5
  SHA512:
6
- metadata.gz: 2cb67b537f0033408ef2457f0b8dbbb5492629dcba7e37fd407e7fb0c15ebc9ad212dac02e145dd6b430b5a1b0db4a2348867b0105d48f30fe6d123ccbb8195f
7
- data.tar.gz: 9b532c7d6224c75dfa5ec4abbc001e58786557cf73c0400cdaa18efe815f5dfb93e372e7b91c6950bffadfd0e993e5c5ca72289a6e5ae981d156b628ecc4e27c
6
+ metadata.gz: 52c0aa7c85ebe0d7a85627f18792132e0d6707959c1148427a8ad20d332958aee59d5edd7530e026b5d6911183c43a0552565beb5e51ad6a45bc9bb84016ac54
7
+ data.tar.gz: 86cbf36800c48de95f36d5c9ef51adbbe39235e8a39d95b040ca4ebab398b0580cb329d6670a7d9c5dc19a3c0fd69d048ae3ae4e7d7c93dcf6581132db4c77be
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- killbill-orbital (0.0.1)
4
+ killbill-orbital (0.0.2)
5
5
  actionpack (~> 4.1.0)
6
6
  actionview (~> 4.1.0)
7
7
  activemerchant (~> 1.55.0)
@@ -19,13 +19,13 @@ PATH
19
19
  GEM
20
20
  remote: https://rubygems.org/
21
21
  specs:
22
- actionpack (4.1.14.1)
23
- actionview (= 4.1.14.1)
24
- activesupport (= 4.1.14.1)
22
+ actionpack (4.1.16)
23
+ actionview (= 4.1.16)
24
+ activesupport (= 4.1.16)
25
25
  rack (~> 1.5.2)
26
26
  rack-test (~> 0.6.2)
27
- actionview (4.1.14.1)
28
- activesupport (= 4.1.14.1)
27
+ actionview (4.1.16)
28
+ activesupport (= 4.1.16)
29
29
  builder (~> 3.1)
30
30
  erubis (~> 2.7.0)
31
31
  active_utils (3.0.0)
@@ -36,17 +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.14.1)
40
- activesupport (= 4.1.14.1)
39
+ activemodel (4.1.16)
40
+ activesupport (= 4.1.16)
41
41
  builder (~> 3.1)
42
- activerecord (4.1.14.1)
43
- activemodel (= 4.1.14.1)
44
- activesupport (= 4.1.14.1)
42
+ activerecord (4.1.16)
43
+ activemodel (= 4.1.16)
44
+ activesupport (= 4.1.16)
45
45
  arel (~> 5.0.0)
46
- activerecord-bogacs (0.4.1)
47
- activerecord-jdbc-adapter (1.3.19)
46
+ activerecord-bogacs (0.5.0)
47
+ activerecord-jdbc-adapter (1.3.21)
48
48
  activerecord (>= 2.2)
49
- activesupport (4.1.14.1)
49
+ activesupport (4.1.16)
50
50
  i18n (~> 0.6, >= 0.6.9)
51
51
  json (~> 1.7, >= 1.7.7)
52
52
  minitest (~> 5.1)
@@ -65,9 +65,9 @@ GEM
65
65
  diff-lcs (1.1.3)
66
66
  equalizer (0.0.11)
67
67
  erubis (2.7.0)
68
- ethon (0.8.1)
68
+ ethon (0.9.1)
69
69
  ffi (>= 1.3.0)
70
- ffi (1.9.10-java)
70
+ ffi (1.9.14-java)
71
71
  i18n (0.7.0)
72
72
  ice_nine (0.11.2)
73
73
  jar-dependencies (0.3.2)
@@ -79,21 +79,21 @@ GEM
79
79
  jdbc-mariadb (1.3.4)
80
80
  jdbc-postgres (9.4.1206)
81
81
  jdbc-sqlite3 (3.8.11.2)
82
- jruby-openssl (0.9.15-java)
82
+ jruby-openssl (0.9.18-java)
83
83
  json (1.8.3-java)
84
- killbill (7.0.2)
84
+ killbill (7.0.6)
85
85
  rack (>= 1.5.2)
86
86
  sinatra (~> 1.3.4)
87
87
  typhoeus (~> 0.6.9)
88
88
  tzinfo (~> 1.2.0)
89
89
  maven-tools (1.0.13)
90
90
  virtus (~> 1.0)
91
- minitest (5.8.4)
91
+ minitest (5.9.1)
92
92
  monetize (1.1.0)
93
93
  money (~> 6.5.0)
94
94
  money (6.5.1)
95
95
  i18n (>= 0.6.4, <= 0.7.0)
96
- nokogiri (1.6.7.2-java)
96
+ nokogiri (1.6.8.1-java)
97
97
  offsite_payments (2.1.0)
98
98
  actionpack (>= 3.2.20, < 5.0.0)
99
99
  active_utils (~> 3.0.0)
data/Jarfile.lock CHANGED
@@ -14,6 +14,8 @@
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
17
+ - org.bouncycastle:bcprov-jdk15on:jar:1.55
18
+ - org.bouncycastle:bcpkix-jdk15on:jar:1.55
17
19
  - org.kill-bill.billing:killbill-util:jar:tests:0.15.10
18
20
  - org.kill-bill.billing.plugin:killbill-plugin-api-currency:jar:0.18
19
21
  - org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4:jar:1.16
@@ -22,8 +24,8 @@
22
24
  - org.skife.config:config-magic:jar:0.14
23
25
  - com.fasterxml.jackson.dataformat:jackson-dataformat-csv:jar:2.4.3
24
26
  - org.kill-bill.billing.plugin:killbill-plugin-api-control:jar:0.18
25
- - org.apache.commons:commons-email:jar:1.2
26
27
  - org.mockito:mockito-all:jar:1.10.19
28
+ - org.apache.commons:commons-email:jar:1.2
27
29
  - antlr:antlr:jar:2.7.7
28
30
  - aopalliance:aopalliance:jar:1.0
29
31
  - com.fasterxml.jackson.core:jackson-annotations:jar:2.4.3
@@ -36,12 +38,10 @@
36
38
  - org.jdbi:jdbi:jar:2.62
37
39
  - org.kill-bill.billing:killbill-platform-api:jar:0.15
38
40
  - org.kill-bill.billing:killbill-platform-osgi:jar:0.15
39
- - org.bouncycastle:bcpkix-jdk15on:jar:1.54
40
41
  - org.apache.felix:org.apache.felix.framework:jar:4.4.1
41
42
  - org.joda:joda-money:jar:0.9
42
43
  - org.kill-bill.commons:killbill-jdbi:jar:0.11
43
44
  - org.kill-bill.commons:killbill-embeddeddb-common:jar:0.11
44
- - org.bouncycastle:bcprov-jdk15on:jar:1.54
45
45
  - org.apache.shiro:shiro-core:jar:1.2.3
46
46
  - org.kill-bill.billing:killbill-platform-osgi-api:jar:0.15
47
47
  - org.kill-bill.billing.plugin:killbill-plugin-api-payment:jar:0.18
data/NEWS CHANGED
@@ -1,2 +1,5 @@
1
+ 0.1.0
2
+ Initial release for 0.18.x
3
+
1
4
  0.0.1
2
- Initial release
5
+ Initial release for 0.16.x
data/README.md CHANGED
@@ -11,6 +11,7 @@ Kill Bill compatibility
11
11
  | Plugin version | Kill Bill version |
12
12
  | -------------: | ----------------: |
13
13
  | 0.0.x | 0.16.z |
14
+ | 0.1.x | 0.18.z |
14
15
 
15
16
  Requirements
16
17
  ------------
@@ -141,6 +142,8 @@ Plugin properties
141
142
  | cc_expiration_month | Credit card expiration month |
142
143
  | cc_expiration_year | Credit card expiration year |
143
144
  | cc_verification_value | CVC/CVV/CVN |
145
+ | cvv_indicator_visa_discover | If true, set '9' as `CardSecValInd` when CVV is absent (Visa / Discover only ) |
146
+ | cvv_indicator_override_visa_discover | `CardSecValInd` value when CVV is absent (Visa / Discover only) |
144
147
  | email | Purchaser email |
145
148
  | address1 | Billing address first line |
146
149
  | address2 | Billing address second line |
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -1,10 +1,116 @@
1
1
  module ActiveMerchant
2
2
  module Billing
3
+
4
+ KB_PLUGIN_VERSION = Gem.loaded_specs['killbill-orbital'].version.version rescue nil
5
+
3
6
  class OrbitalGateway
4
7
 
5
8
  def store(creditcard, options = {})
6
- add_customer_profile(creditcard, options)
9
+ response = add_customer_profile(creditcard, options)
10
+
11
+ # Workaround: unmask the PAN if needed
12
+ # TODO We could call on-the-fly retrieve_customer_profile instead in PaymentPlugin#get_payment_source to
13
+ # avoid having to store the PAN, but this requires a specific merchant account setting
14
+ response.params['cc_account_num'] = creditcard.number if response.params['cc_account_num'].starts_with?('XXXX')
15
+
16
+ response
17
+ end
18
+
19
+ def user_agent
20
+ @@ua ||= JSON.dump({
21
+ :bindings_version => KB_PLUGIN_VERSION,
22
+ :lang => 'ruby',
23
+ :lang_version => "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})",
24
+ :platform => RUBY_PLATFORM,
25
+ :publisher => 'killbill'
26
+ })
7
27
  end
28
+
29
+ def x_request_id
30
+ # See KillbillMDCInsertingServletFilter
31
+ org::slf4j::MDC::get('req.requestId') rescue nil
32
+ end
33
+
34
+ def commit(order, message_type, trace_number=nil)
35
+ x_r_id = x_request_id
36
+
37
+ headers = POST_HEADERS.merge('Content-length' => order.size.to_s,
38
+ 'User-Agent' => user_agent,
39
+ 'Interface-Version' => 'Ruby|KillBill|Open-Source Gateway')
40
+ headers['X-Request-Id'] = x_r_id unless x_r_id.blank?
41
+ headers.merge!('Trace-number' => trace_number.to_s,
42
+ 'Merchant-Id' => @options[:merchant_id]) if @options[:retry_logic] && trace_number
43
+ request = lambda { |url| parse(ssl_post(url, order, headers)) }
44
+
45
+ # Failover URL will be attempted in the event of a connection error
46
+ response = begin
47
+ request.call(remote_url)
48
+ rescue ConnectionError
49
+ request.call(remote_url(:secondary))
50
+ end
51
+
52
+ Response.new(success?(response, message_type),
53
+ message_from(response),
54
+ response,
55
+ {
56
+ :authorization => authorization_string(response[:tx_ref_num], response[:order_id]),
57
+ :test => self.test?,
58
+ :avs_result => OrbitalGateway::AVSResult.new(response[:avs_resp_code]),
59
+ :cvv_result => OrbitalGateway::CVVResult.new(response[:cvv2_resp_code])
60
+ })
61
+ end
62
+
63
+ # A – Authorization request
64
+ def authorize(money, creditcard, options = {})
65
+ order = build_new_order_xml(AUTH_ONLY, money, options) do |xml|
66
+ add_creditcard(xml, creditcard, options)
67
+ add_address(xml, creditcard, options)
68
+ if @options[:customer_profiles]
69
+ add_customer_data(xml, creditcard, options)
70
+ add_managed_billing(xml, options)
71
+ end
72
+ end
73
+ commit(order, :authorize, options[:trace_number])
74
+ end
75
+
76
+ # AC – Authorization and Capture
77
+ def purchase(money, creditcard, options = {})
78
+ order = build_new_order_xml(AUTH_AND_CAPTURE, money, options) do |xml|
79
+ add_creditcard(xml, creditcard, options)
80
+ add_address(xml, creditcard, options)
81
+ if @options[:customer_profiles]
82
+ add_customer_data(xml, creditcard, options)
83
+ add_managed_billing(xml, options)
84
+ end
85
+ end
86
+ commit(order, :purchase, options[:trace_number])
87
+ end
88
+
89
+ def add_creditcard(xml, creditcard, options = {})
90
+ currency = options[:currency]
91
+ cvv_indicator_visa_discover = options[:cvv_indicator_visa_discover]
92
+ cvv_indicator_override_visa_discover = options[:cvv_indicator_override_visa_discover]
93
+
94
+ unless creditcard.nil?
95
+ xml.tag! :AccountNum, creditcard.number
96
+ xml.tag! :Exp, expiry_date(creditcard)
97
+ end
98
+
99
+ xml.tag! :CurrencyCode, currency_code(currency)
100
+ xml.tag! :CurrencyExponent, currency_exponents(currency)
101
+
102
+ unless creditcard.nil?
103
+ if %w( visa discover ).include?(creditcard.brand)
104
+ if cvv_indicator_visa_discover
105
+ xml.tag! :CardSecValInd, (creditcard.verification_value? ? '1' : cvv_indicator_override_visa_discover || '9')
106
+ else
107
+ xml.tag! :CardSecValInd, '1' if creditcard.verification_value?
108
+ end
109
+ end
110
+ xml.tag! :CardSecVal, creditcard.verification_value if creditcard.verification_value?
111
+ end
112
+ end
113
+
8
114
  end
9
115
  end
10
116
  end
@@ -79,6 +79,18 @@ module Killbill #:nodoc:
79
79
  :params_tx_ref_num => extract(response, 'tx_ref_num'),
80
80
  }
81
81
  end
82
+
83
+ def first_reference_id
84
+ params_tx_ref_num
85
+ end
86
+
87
+ def second_reference_id
88
+ params_order_id
89
+ end
90
+
91
+ def gateway_error_code
92
+ params_resp_code
93
+ end
82
94
  end
83
95
  end
84
96
  end
data/pom.xml CHANGED
@@ -25,7 +25,7 @@
25
25
  <groupId>org.kill-bill.billing.plugin.ruby</groupId>
26
26
  <artifactId>orbital-plugin</artifactId>
27
27
  <packaging>pom</packaging>
28
- <version>0.0.1</version>
28
+ <version>0.0.2</version>
29
29
  <name>orbital-plugin</name>
30
30
  <url>http://github.com/killbill/killbill-orbital-plugin</url>
31
31
  <description>Plugin for accessing Orbital as a payment gateway</description>
@@ -2,45 +2,20 @@ require 'spec_helper'
2
2
 
3
3
  ActiveMerchant::Billing::Base.mode = :test
4
4
 
5
- describe Killbill::Orbital::PaymentPlugin do
6
-
7
- include ::Killbill::Plugin::ActiveMerchant::RSpec
8
-
5
+ shared_examples 'common_specs' do
9
6
  before(:each) do
10
- # Start the plugin early to configure ActiveRecord
11
- @plugin = build_plugin(::Killbill::Orbital::PaymentPlugin, 'orbital')
12
- @plugin.start_plugin
13
-
14
- ::Killbill::Orbital::OrbitalPaymentMethod.delete_all
15
- ::Killbill::Orbital::OrbitalResponse.delete_all
16
- ::Killbill::Orbital::OrbitalTransaction.delete_all
17
-
18
- @call_context = build_call_context
19
-
20
- @properties = []
21
- @pm = create_payment_method(::Killbill::Orbital::OrbitalPaymentMethod, nil, @call_context.tenant_id, @properties, { :cc_number => '5454545454545454' })
22
- @amount = BigDecimal.new('100')
23
- @currency = 'USD'
24
-
25
- kb_payment_id = SecureRandom.uuid
26
- 1.upto(6) do
27
- @kb_payment = @plugin.kb_apis.proxied_services[:payment_api].add_payment(kb_payment_id)
28
- end
7
+ create_payment
29
8
  end
30
9
 
31
10
  after(:each) do
32
11
  @plugin.stop_plugin
33
12
  end
34
13
 
35
- it 'should be able to charge a Credit Card directly' do
36
- account = @plugin.kb_apis.account_user_api.get_account_by_id(nil, @call_context)
37
- properties = build_pm_properties(account, { :cc_number => '5454545454545454' })
38
-
39
- # We created the payment method, hence the rows
14
+ it 'should be able to purchase' do
40
15
  Killbill::Orbital::OrbitalResponse.all.size.should == 1
41
16
  Killbill::Orbital::OrbitalTransaction.all.size.should == 0
42
17
 
43
- 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)
18
+ 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)
44
19
  payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
45
20
  payment_response.amount.should == @amount
46
21
  payment_response.transaction_type.should == :PURCHASE
@@ -125,3 +100,201 @@ describe Killbill::Orbital::PaymentPlugin do
125
100
  payment_response.transaction_type.should == :VOID
126
101
  end
127
102
  end
103
+
104
+ shared_examples 'cvv_indicator_specs' do
105
+ after(:each) do
106
+ @plugin.stop_plugin
107
+ end
108
+
109
+ it 'should set correct indicator for visa and discover if cvv value is present regardless of cvv_indicator_visa_discover' do
110
+ validate_cvv_indicator_field 1
111
+
112
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'discover' })
113
+ validate_cvv_indicator_field 1
114
+
115
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cvv_indicator_visa_discover => true })
116
+ validate_cvv_indicator_field 1
117
+
118
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'discover', :cvv_indicator_visa_discover => true })
119
+ validate_cvv_indicator_field 1
120
+ end
121
+
122
+ it 'should set correct indicator for visa and discover if cvv value is not present and cvv_indicator_visa_discover is true' do
123
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cvv_indicator_visa_discover => true })
124
+ @properties.reject! {|property| property.key == 'ccVerificationValue' }
125
+ validate_cvv_indicator_field 9
126
+
127
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'discover', :cvv_indicator_visa_discover => true })
128
+ @properties.reject! {|property| property.key == 'ccVerificationValue' }
129
+ validate_cvv_indicator_field 9
130
+ end
131
+
132
+ it 'should set customized indicator for visa and discover if cvv value is not present and cvv_indicator_visa_discover is true and cvv_indicator_override_visa_discover is given' do
133
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cvv_indicator_visa_discover => true, :cvv_indicator_override_visa_discover => '2' })
134
+ @properties.reject! {|property| property.key == 'ccVerificationValue' }
135
+ validate_cvv_indicator_field 2
136
+
137
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'discover', :cvv_indicator_visa_discover => true, :cvv_indicator_override_visa_discover => '2' })
138
+ @properties.reject! {|property| property.key == 'ccVerificationValue' }
139
+ validate_cvv_indicator_field 2
140
+ end
141
+
142
+ it 'should set correct indicator for visa and discover if cvv value is not present and cvv_indicator_visa_discover is nil or false' do
143
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454'})
144
+ @properties.reject! {|property| property.key == 'ccVerificationValue' }
145
+ validate_cvv_indicator_field
146
+
147
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'discover'})
148
+ @properties.reject! {|property| property.key == 'ccVerificationValue' }
149
+ validate_cvv_indicator_field
150
+
151
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cvv_indicator_visa_discover => false })
152
+ @properties.reject! {|property| property.key == 'ccVerificationValue' }
153
+ validate_cvv_indicator_field
154
+
155
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'discover', :cvv_indicator_visa_discover => false })
156
+ @properties.reject! {|property| property.key == 'ccVerificationValue' }
157
+ validate_cvv_indicator_field
158
+ end
159
+
160
+ it 'should not include indicator except visa and discover for all cases' do
161
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'master' })
162
+ validate_cvv_indicator_field
163
+
164
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'american_express' })
165
+ validate_cvv_indicator_field
166
+
167
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'master', :cvv_indicator_visa_discover => false })
168
+ validate_cvv_indicator_field
169
+
170
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'american_express', :cvv_indicator_visa_discover => false })
171
+ validate_cvv_indicator_field
172
+
173
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'master', :cvv_indicator_visa_discover => true})
174
+ validate_cvv_indicator_field
175
+
176
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'american_express', :cvv_indicator_visa_discover => true })
177
+ validate_cvv_indicator_field
178
+
179
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'master' })
180
+ @properties.reject! {|property| property.key == 'ccVerificationValue' }
181
+ validate_cvv_indicator_field
182
+
183
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'american_express' })
184
+ @properties.reject! {|property| property.key == 'ccVerificationValue' }
185
+ validate_cvv_indicator_field
186
+
187
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'master', :cvv_indicator_visa_discover => false})
188
+ @properties.reject! {|property| property.key == 'ccVerificationValue' }
189
+ validate_cvv_indicator_field
190
+
191
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'american_express', :cvv_indicator_visa_discover => false })
192
+ @properties.reject! {|property| property.key == 'ccVerificationValue' }
193
+ validate_cvv_indicator_field
194
+
195
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'master', :cvv_indicator_visa_discover => true})
196
+ @properties.reject! {|property| property.key == 'ccVerificationValue' }
197
+ validate_cvv_indicator_field
198
+
199
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'american_express', :cvv_indicator_visa_discover => true })
200
+ @properties.reject! {|property| property.key == 'ccVerificationValue' }
201
+ validate_cvv_indicator_field
202
+ end
203
+ end
204
+
205
+
206
+ describe Killbill::Orbital::PaymentPlugin do
207
+
208
+ include ::Killbill::Plugin::ActiveMerchant::RSpec
209
+
210
+ before(:each) do
211
+ # Start the plugin early to configure ActiveRecord
212
+ @plugin = build_plugin(::Killbill::Orbital::PaymentPlugin, 'orbital')
213
+ @plugin.start_plugin
214
+
215
+ ::Killbill::Orbital::OrbitalPaymentMethod.delete_all
216
+ ::Killbill::Orbital::OrbitalResponse.delete_all
217
+ ::Killbill::Orbital::OrbitalTransaction.delete_all
218
+
219
+ @call_context = build_call_context
220
+ end
221
+
222
+ context 'credit card flow' do
223
+ before(:each) do
224
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454' })
225
+ @pm = create_payment_method(::Killbill::Orbital::OrbitalPaymentMethod, nil, @call_context.tenant_id, @properties, {})
226
+ @amount = BigDecimal.new('100')
227
+ @currency = 'USD'
228
+ end
229
+
230
+ include_examples 'common_specs'
231
+ end
232
+
233
+ context 'custom profile flow' do
234
+ before(:each) do
235
+ @properties = []
236
+ @pm = create_payment_method(::Killbill::Orbital::OrbitalPaymentMethod, nil, @call_context.tenant_id, @properties, { :cc_number => '5454545454545454' })
237
+ @amount = BigDecimal.new('100')
238
+ @currency = 'USD'
239
+ end
240
+
241
+ include_examples 'common_specs'
242
+ end
243
+
244
+ context 'cvv indicator spec' do
245
+ before(:each) do
246
+ @properties = build_pm_properties(nil, { :cc_number => '5454545454545454' })
247
+ @pm = create_payment_method(::Killbill::Orbital::OrbitalPaymentMethod, nil, @call_context.tenant_id, @properties, {})
248
+ @amount = BigDecimal.new('100')
249
+ @currency = 'USD'
250
+ end
251
+
252
+ include_examples 'cvv_indicator_specs'
253
+ end
254
+
255
+ def successful_authorize_response
256
+ <<-XML
257
+ <?xml version=\"1.0\" encoding=\"UTF-8\"?><Response><NewOrderResp><IndustryType></IndustryType><MessageType>A</MessageType><MerchantID>1111111</MerchantID><TerminalID>001</TerminalID><CardBrand>CC</CardBrand><AccountNum>XXXXXXXXXXXX5454</AccountNum><OrderID>5b257b31-1f84-44bc-b32</OrderID><TxRefNum>5834AA75E4466AEA59512165057C37DD810053C2</TxRefNum><TxRefIdx>0</TxRefIdx><ProcStatus>0</ProcStatus><ApprovalStatus>1</ApprovalStatus><RespCode>00</RespCode><AVSRespCode>B </AVSRespCode><CVV2RespCode> </CVV2RespCode><AuthCode>tst424</AuthCode><RecurringAdviceCd></RecurringAdviceCd><CAVVRespCode></CAVVRespCode><StatusMsg>Approved</StatusMsg><RespMsg></RespMsg><HostRespCode>100</HostRespCode><HostAVSRespCode>I3</HostAVSRespCode><HostCVV2RespCode> </HostCVV2RespCode><CustomerRefNum></CustomerRefNum><CustomerName></CustomerName><ProfileProcStatus></ProfileProcStatus><CustomerProfileMessage></CustomerProfileMessage><RespTime>152837</RespTime><PartialAuthOccurred></PartialAuthOccurred><RequestedAmount></RequestedAmount><RedeemedAmount></RedeemedAmount><RemainingBalance></RemainingBalance><CountryFraudFilterStatus></CountryFraudFilterStatus><IsoCountryCode></IsoCountryCode></NewOrderResp></Response>
258
+ XML
259
+ end
260
+
261
+ def successful_purchase_response
262
+ <<-XML
263
+ <?xml version=\"1.0\" encoding=\"UTF-8\"?><Response><NewOrderResp><IndustryType></IndustryType><MessageType>AC</MessageType><MerchantID>1111111</MerchantID><TerminalID>001</TerminalID><CardBrand>CC</CardBrand><AccountNum>XXXXXXXXXXXX5454</AccountNum><OrderID>88132d30-f4f7-4028-949</OrderID><TxRefNum>5834EAC9C7A53FEB600A479629FB6C6427A2532C</TxRefNum><TxRefIdx>1</TxRefIdx><ProcStatus>0</ProcStatus><ApprovalStatus>1</ApprovalStatus><RespCode>00</RespCode><AVSRespCode>3 </AVSRespCode><CVV2RespCode>I</CVV2RespCode><AuthCode>tst703</AuthCode><RecurringAdviceCd></RecurringAdviceCd><CAVVRespCode></CAVVRespCode><StatusMsg>Approved</StatusMsg><RespMsg></RespMsg><HostRespCode>100</HostRespCode><HostAVSRespCode> </HostAVSRespCode><HostCVV2RespCode>I</HostCVV2RespCode><CustomerRefNum></CustomerRefNum><CustomerName></CustomerName><ProfileProcStatus></ProfileProcStatus><CustomerProfileMessage></CustomerProfileMessage><RespTime>200306</RespTime><PartialAuthOccurred></PartialAuthOccurred><RequestedAmount></RequestedAmount><RedeemedAmount></RedeemedAmount><RemainingBalance></RemainingBalance><CountryFraudFilterStatus></CountryFraudFilterStatus><IsoCountryCode></IsoCountryCode></NewOrderResp></Response> XML
264
+ XML
265
+ end
266
+
267
+ def validate_cvv_indicator_field(expected_field = nil)
268
+ ::ActiveMerchant::Billing::OrbitalGateway.any_instance.stub(:ssl_post) do |host, request_body|
269
+ if expected_field.nil?
270
+ request_body.should_not match('<CardSecValInd>')
271
+ else
272
+ request_body.should match("<CardSecValInd>#{expected_field}</CardSecValInd>")
273
+ end
274
+ if request_body.include? '<MessageType>A</MessageType>'
275
+ successful_authorize_response
276
+ else
277
+ successful_purchase_response
278
+ end
279
+ end
280
+ create_payment
281
+ payment_response = @plugin.authorize_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[0].id, @pm.kb_payment_method_id, @amount, @currency, @properties, @call_context)
282
+ payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
283
+ payment_response.amount.should == @amount
284
+ payment_response.transaction_type.should == :AUTHORIZE
285
+
286
+ create_payment
287
+ 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)
288
+ payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
289
+ payment_response.amount.should == @amount
290
+ payment_response.transaction_type.should == :PURCHASE
291
+ end
292
+
293
+ def create_payment
294
+ kb_payment_id = SecureRandom.uuid
295
+ 1.upto(6) do
296
+ @kb_payment = @plugin.kb_apis.proxied_services[:payment_api].add_payment(kb_payment_id)
297
+ end
298
+ kb_payment_id
299
+ end
300
+ end
metadata CHANGED
@@ -1,295 +1,295 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill-orbital
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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: 2016-02-19 00:00:00.000000000 Z
11
+ date: 2016-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: killbill
15
- version_requirements: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '7.0'
20
14
  requirement: !ruby/object:Gem::Requirement
21
15
  requirements:
22
- - - ~>
16
+ - - "~>"
23
17
  - !ruby/object:Gem::Version
24
18
  version: '7.0'
19
+ name: killbill
25
20
  prerelease: false
26
21
  type: :runtime
27
- - !ruby/object:Gem::Dependency
28
- name: sinatra
29
22
  version_requirements: !ruby/object:Gem::Requirement
30
23
  requirements:
31
- - - ~>
24
+ - - "~>"
32
25
  - !ruby/object:Gem::Version
33
- version: 1.3.4
26
+ version: '7.0'
27
+ - !ruby/object:Gem::Dependency
34
28
  requirement: !ruby/object:Gem::Requirement
35
29
  requirements:
36
- - - ~>
30
+ - - "~>"
37
31
  - !ruby/object:Gem::Version
38
32
  version: 1.3.4
33
+ name: sinatra
39
34
  prerelease: false
40
35
  type: :runtime
41
- - !ruby/object:Gem::Dependency
42
- name: thread_safe
43
36
  version_requirements: !ruby/object:Gem::Requirement
44
37
  requirements:
45
- - - ~>
38
+ - - "~>"
46
39
  - !ruby/object:Gem::Version
47
- version: 0.3.4
40
+ version: 1.3.4
41
+ - !ruby/object:Gem::Dependency
48
42
  requirement: !ruby/object:Gem::Requirement
49
43
  requirements:
50
- - - ~>
44
+ - - "~>"
51
45
  - !ruby/object:Gem::Version
52
46
  version: 0.3.4
47
+ name: thread_safe
53
48
  prerelease: false
54
49
  type: :runtime
55
- - !ruby/object:Gem::Dependency
56
- name: activerecord
57
50
  version_requirements: !ruby/object:Gem::Requirement
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
- version: 4.1.0
54
+ version: 0.3.4
55
+ - !ruby/object:Gem::Dependency
62
56
  requirement: !ruby/object:Gem::Requirement
63
57
  requirements:
64
- - - ~>
58
+ - - "~>"
65
59
  - !ruby/object:Gem::Version
66
60
  version: 4.1.0
61
+ name: activerecord
67
62
  prerelease: false
68
63
  type: :runtime
69
- - !ruby/object:Gem::Dependency
70
- name: activerecord-bogacs
71
64
  version_requirements: !ruby/object:Gem::Requirement
72
65
  requirements:
73
- - - ~>
66
+ - - "~>"
74
67
  - !ruby/object:Gem::Version
75
- version: '0.3'
68
+ version: 4.1.0
69
+ - !ruby/object:Gem::Dependency
76
70
  requirement: !ruby/object:Gem::Requirement
77
71
  requirements:
78
- - - ~>
72
+ - - "~>"
79
73
  - !ruby/object:Gem::Version
80
74
  version: '0.3'
75
+ name: activerecord-bogacs
81
76
  prerelease: false
82
77
  type: :runtime
83
- - !ruby/object:Gem::Dependency
84
- name: activerecord-jdbc-adapter
85
78
  version_requirements: !ruby/object:Gem::Requirement
86
79
  requirements:
87
- - - ~>
88
- - !ruby/object:Gem::Version
89
- version: '1.3'
90
- - - <
80
+ - - "~>"
91
81
  - !ruby/object:Gem::Version
92
- version: '1.5'
82
+ version: '0.3'
83
+ - !ruby/object:Gem::Dependency
93
84
  requirement: !ruby/object:Gem::Requirement
94
85
  requirements:
95
- - - ~>
86
+ - - "~>"
96
87
  - !ruby/object:Gem::Version
97
88
  version: '1.3'
98
- - - <
89
+ - - "<"
99
90
  - !ruby/object:Gem::Version
100
91
  version: '1.5'
92
+ name: activerecord-jdbc-adapter
101
93
  prerelease: false
102
94
  type: :runtime
103
- - !ruby/object:Gem::Dependency
104
- name: jruby-openssl
105
95
  version_requirements: !ruby/object:Gem::Requirement
106
96
  requirements:
107
- - - ~>
97
+ - - "~>"
108
98
  - !ruby/object:Gem::Version
109
- version: 0.9.7
99
+ version: '1.3'
100
+ - - "<"
101
+ - !ruby/object:Gem::Version
102
+ version: '1.5'
103
+ - !ruby/object:Gem::Dependency
110
104
  requirement: !ruby/object:Gem::Requirement
111
105
  requirements:
112
- - - ~>
106
+ - - "~>"
113
107
  - !ruby/object:Gem::Version
114
108
  version: 0.9.7
109
+ name: jruby-openssl
115
110
  prerelease: false
116
111
  type: :runtime
117
- - !ruby/object:Gem::Dependency
118
- name: actionpack
119
112
  version_requirements: !ruby/object:Gem::Requirement
120
113
  requirements:
121
- - - ~>
114
+ - - "~>"
122
115
  - !ruby/object:Gem::Version
123
- version: 4.1.0
116
+ version: 0.9.7
117
+ - !ruby/object:Gem::Dependency
124
118
  requirement: !ruby/object:Gem::Requirement
125
119
  requirements:
126
- - - ~>
120
+ - - "~>"
127
121
  - !ruby/object:Gem::Version
128
122
  version: 4.1.0
123
+ name: actionpack
129
124
  prerelease: false
130
125
  type: :runtime
131
- - !ruby/object:Gem::Dependency
132
- name: actionview
133
126
  version_requirements: !ruby/object:Gem::Requirement
134
127
  requirements:
135
- - - ~>
128
+ - - "~>"
136
129
  - !ruby/object:Gem::Version
137
130
  version: 4.1.0
131
+ - !ruby/object:Gem::Dependency
138
132
  requirement: !ruby/object:Gem::Requirement
139
133
  requirements:
140
- - - ~>
134
+ - - "~>"
141
135
  - !ruby/object:Gem::Version
142
136
  version: 4.1.0
137
+ name: actionview
143
138
  prerelease: false
144
139
  type: :runtime
145
- - !ruby/object:Gem::Dependency
146
- name: activemerchant
147
140
  version_requirements: !ruby/object:Gem::Requirement
148
141
  requirements:
149
- - - ~>
142
+ - - "~>"
150
143
  - !ruby/object:Gem::Version
151
- version: 1.55.0
144
+ version: 4.1.0
145
+ - !ruby/object:Gem::Dependency
152
146
  requirement: !ruby/object:Gem::Requirement
153
147
  requirements:
154
- - - ~>
148
+ - - "~>"
155
149
  - !ruby/object:Gem::Version
156
150
  version: 1.55.0
151
+ name: activemerchant
157
152
  prerelease: false
158
153
  type: :runtime
159
- - !ruby/object:Gem::Dependency
160
- name: offsite_payments
161
154
  version_requirements: !ruby/object:Gem::Requirement
162
155
  requirements:
163
- - - ~>
156
+ - - "~>"
164
157
  - !ruby/object:Gem::Version
165
- version: 2.1.0
158
+ version: 1.55.0
159
+ - !ruby/object:Gem::Dependency
166
160
  requirement: !ruby/object:Gem::Requirement
167
161
  requirements:
168
- - - ~>
162
+ - - "~>"
169
163
  - !ruby/object:Gem::Version
170
164
  version: 2.1.0
165
+ name: offsite_payments
171
166
  prerelease: false
172
167
  type: :runtime
173
- - !ruby/object:Gem::Dependency
174
- name: monetize
175
168
  version_requirements: !ruby/object:Gem::Requirement
176
169
  requirements:
177
- - - ~>
170
+ - - "~>"
178
171
  - !ruby/object:Gem::Version
179
- version: 1.1.0
172
+ version: 2.1.0
173
+ - !ruby/object:Gem::Dependency
180
174
  requirement: !ruby/object:Gem::Requirement
181
175
  requirements:
182
- - - ~>
176
+ - - "~>"
183
177
  - !ruby/object:Gem::Version
184
178
  version: 1.1.0
179
+ name: monetize
185
180
  prerelease: false
186
181
  type: :runtime
187
- - !ruby/object:Gem::Dependency
188
- name: money
189
182
  version_requirements: !ruby/object:Gem::Requirement
190
183
  requirements:
191
- - - ~>
184
+ - - "~>"
192
185
  - !ruby/object:Gem::Version
193
- version: 6.5.1
186
+ version: 1.1.0
187
+ - !ruby/object:Gem::Dependency
194
188
  requirement: !ruby/object:Gem::Requirement
195
189
  requirements:
196
- - - ~>
190
+ - - "~>"
197
191
  - !ruby/object:Gem::Version
198
192
  version: 6.5.1
193
+ name: money
199
194
  prerelease: false
200
195
  type: :runtime
201
- - !ruby/object:Gem::Dependency
202
- name: jbundler
203
196
  version_requirements: !ruby/object:Gem::Requirement
204
197
  requirements:
205
- - - ~>
198
+ - - "~>"
206
199
  - !ruby/object:Gem::Version
207
- version: 0.9.2
200
+ version: 6.5.1
201
+ - !ruby/object:Gem::Dependency
208
202
  requirement: !ruby/object:Gem::Requirement
209
203
  requirements:
210
- - - ~>
204
+ - - "~>"
211
205
  - !ruby/object:Gem::Version
212
206
  version: 0.9.2
207
+ name: jbundler
213
208
  prerelease: false
214
209
  type: :development
215
- - !ruby/object:Gem::Dependency
216
- name: rake
217
210
  version_requirements: !ruby/object:Gem::Requirement
218
211
  requirements:
219
- - - '>='
212
+ - - "~>"
220
213
  - !ruby/object:Gem::Version
221
- version: 10.0.0
214
+ version: 0.9.2
215
+ - !ruby/object:Gem::Dependency
222
216
  requirement: !ruby/object:Gem::Requirement
223
217
  requirements:
224
- - - '>='
218
+ - - ">="
225
219
  - !ruby/object:Gem::Version
226
220
  version: 10.0.0
221
+ name: rake
227
222
  prerelease: false
228
223
  type: :development
229
- - !ruby/object:Gem::Dependency
230
- name: rspec
231
224
  version_requirements: !ruby/object:Gem::Requirement
232
225
  requirements:
233
- - - ~>
226
+ - - ">="
234
227
  - !ruby/object:Gem::Version
235
- version: 2.12.0
228
+ version: 10.0.0
229
+ - !ruby/object:Gem::Dependency
236
230
  requirement: !ruby/object:Gem::Requirement
237
231
  requirements:
238
- - - ~>
232
+ - - "~>"
239
233
  - !ruby/object:Gem::Version
240
234
  version: 2.12.0
235
+ name: rspec
241
236
  prerelease: false
242
237
  type: :development
243
- - !ruby/object:Gem::Dependency
244
- name: jdbc-sqlite3
245
238
  version_requirements: !ruby/object:Gem::Requirement
246
239
  requirements:
247
- - - ~>
240
+ - - "~>"
248
241
  - !ruby/object:Gem::Version
249
- version: '3.7'
242
+ version: 2.12.0
243
+ - !ruby/object:Gem::Dependency
250
244
  requirement: !ruby/object:Gem::Requirement
251
245
  requirements:
252
- - - ~>
246
+ - - "~>"
253
247
  - !ruby/object:Gem::Version
254
248
  version: '3.7'
249
+ name: jdbc-sqlite3
255
250
  prerelease: false
256
251
  type: :development
257
- - !ruby/object:Gem::Dependency
258
- name: jdbc-mariadb
259
252
  version_requirements: !ruby/object:Gem::Requirement
260
253
  requirements:
261
- - - ~>
254
+ - - "~>"
262
255
  - !ruby/object:Gem::Version
263
- version: '1.1'
256
+ version: '3.7'
257
+ - !ruby/object:Gem::Dependency
264
258
  requirement: !ruby/object:Gem::Requirement
265
259
  requirements:
266
- - - ~>
260
+ - - "~>"
267
261
  - !ruby/object:Gem::Version
268
262
  version: '1.1'
263
+ name: jdbc-mariadb
269
264
  prerelease: false
270
265
  type: :development
271
- - !ruby/object:Gem::Dependency
272
- name: jdbc-postgres
273
266
  version_requirements: !ruby/object:Gem::Requirement
274
267
  requirements:
275
- - - ~>
268
+ - - "~>"
276
269
  - !ruby/object:Gem::Version
277
- version: '9.4'
270
+ version: '1.1'
271
+ - !ruby/object:Gem::Dependency
278
272
  requirement: !ruby/object:Gem::Requirement
279
273
  requirements:
280
- - - ~>
274
+ - - "~>"
281
275
  - !ruby/object:Gem::Version
282
276
  version: '9.4'
277
+ name: jdbc-postgres
283
278
  prerelease: false
284
279
  type: :development
280
+ version_requirements: !ruby/object:Gem::Requirement
281
+ requirements:
282
+ - - "~>"
283
+ - !ruby/object:Gem::Version
284
+ version: '9.4'
285
285
  description: Kill Bill payment plugin for Orbital.
286
286
  email: killbilling-users@googlegroups.com
287
287
  executables: []
288
288
  extensions: []
289
289
  extra_rdoc_files: []
290
290
  files:
291
- - .gitignore
292
- - .travis.yml
291
+ - ".gitignore"
292
+ - ".travis.yml"
293
293
  - Gemfile
294
294
  - Gemfile.head
295
295
  - Gemfile.lock
@@ -325,23 +325,23 @@ licenses:
325
325
  metadata: {}
326
326
  post_install_message:
327
327
  rdoc_options:
328
- - --exclude
329
- - .
328
+ - "--exclude"
329
+ - "."
330
330
  require_paths:
331
331
  - lib
332
332
  required_ruby_version: !ruby/object:Gem::Requirement
333
333
  requirements:
334
- - - '>='
334
+ - - ">="
335
335
  - !ruby/object:Gem::Version
336
336
  version: 1.9.3
337
337
  required_rubygems_version: !ruby/object:Gem::Requirement
338
338
  requirements:
339
- - - '>='
339
+ - - ">="
340
340
  - !ruby/object:Gem::Version
341
341
  version: '0'
342
342
  requirements: []
343
343
  rubyforge_project:
344
- rubygems_version: 2.1.9
344
+ rubygems_version: 2.4.8
345
345
  signing_key:
346
346
  specification_version: 4
347
347
  summary: Plugin to use Orbital as a gateway.