killbill-orbital 0.1.3 → 0.1.4

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.
@@ -1,54 +0,0 @@
1
- require 'spec_helper'
2
-
3
- include ::Killbill::Plugin::ActiveMerchant::RSpec
4
-
5
- ActiveMerchant::Billing::Base.mode = :test
6
-
7
- shared_examples "avs_response_code_specs" do |raw_code, expected_code|
8
- it 'should translate to correct AVS codes from Orbital AVS codes' do
9
- ::ActiveMerchant::Billing::OrbitalGateway.any_instance.stub(:ssl_post) do
10
- mock_authorize_response(raw_code)
11
- end
12
- validate_avs_response expected_code
13
- end
14
-
15
- def mock_authorize_response(code)
16
- <<-XML
17
- <?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>#{code}</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>
18
- XML
19
- end
20
-
21
- def validate_avs_response(expected_code)
22
- kb_payment_id, kb_transaction_id = create_payment
23
- payment_response = @plugin.authorize_payment(SecureRandom.uuid, kb_payment_id, kb_transaction_id, SecureRandom.uuid, @amount, @currency, @properties, @call_context)
24
- find_value_from_properties(payment_response.properties, 'avsResultCode').should == expected_code
25
- end
26
- end
27
-
28
- describe 'Should present correct AVS codes' do
29
-
30
- before(:each) do
31
- # Start the plugin early to configure ActiveRecord
32
- @plugin = build_plugin(::Killbill::Orbital::PaymentPlugin, 'orbital')
33
- @plugin.start_plugin
34
- ::Killbill::Orbital::OrbitalPaymentMethod.delete_all
35
- ::Killbill::Orbital::OrbitalResponse.delete_all
36
- ::Killbill::Orbital::OrbitalTransaction.delete_all
37
- @call_context = build_call_context
38
- @properties = build_pm_properties(nil,
39
- {
40
- :cc_number => 4111111111111111,
41
- :cc_type => 'visa'
42
- })
43
- @amount = BigDecimal.new('100')
44
- @currency = 'USD'
45
- end
46
-
47
- after(:each) do
48
- @plugin.stop_plugin
49
- end
50
-
51
- ::ActiveMerchant::Billing::OrbitalGateway::AVSResult::CONVERT_MAP.each do |raw_code, expected_code|
52
- include_examples "avs_response_code_specs", raw_code, expected_code
53
- end
54
- end
@@ -1,30 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Killbill::Orbital::PaymentPlugin do
4
-
5
- include ::Killbill::Plugin::ActiveMerchant::RSpec
6
-
7
- before(:each) do
8
- Dir.mktmpdir do |dir|
9
- file = File.new(File.join(dir, 'orbital.yml'), 'w+')
10
- file.write(<<-eos)
11
- :orbital:
12
- :test: true
13
- # As defined by spec_helper.rb
14
- :database:
15
- :adapter: 'sqlite3'
16
- :database: 'test.db'
17
- eos
18
- file.close
19
-
20
- @plugin = build_plugin(::Killbill::Orbital::PaymentPlugin, 'orbital', File.dirname(file))
21
-
22
- # Start the plugin here - since the config file will be deleted
23
- @plugin.start_plugin
24
- end
25
- end
26
-
27
- it 'should start and stop correctly' do
28
- @plugin.stop_plugin
29
- end
30
- end
@@ -1,171 +0,0 @@
1
- require 'spec_helper'
2
-
3
- ActiveMerchant::Billing::Base.mode = :test
4
-
5
- describe Killbill::Orbital::PaymentPlugin do
6
-
7
- include ::Killbill::Plugin::ActiveMerchant::RSpec
8
-
9
- before(:each) do
10
- @plugin = build_plugin(::Killbill::Orbital::PaymentPlugin, 'orbital')
11
- @plugin.start_plugin
12
- @call_context = build_call_context
13
-
14
- ::Killbill::Orbital::OrbitalPaymentMethod.delete_all
15
- ::Killbill::Orbital::OrbitalResponse.delete_all
16
- ::Killbill::Orbital::OrbitalTransaction.delete_all
17
- end
18
-
19
- after(:each) do
20
- @plugin.stop_plugin
21
- end
22
-
23
- context 'cvv indicator spec' do
24
- before(:each) do
25
- @amount = BigDecimal.new('100')
26
- @currency = 'USD'
27
- end
28
-
29
- it 'should set correct indicator for visa and discover if cvv value is present regardless of cvv_indicator_visa_discover' do
30
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454' })
31
- validate_cvv_indicator_field 1
32
-
33
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'discover' })
34
- validate_cvv_indicator_field 1
35
-
36
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cvv_indicator_visa_discover => true })
37
- validate_cvv_indicator_field 1
38
-
39
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'discover', :cvv_indicator_visa_discover => true })
40
- validate_cvv_indicator_field 1
41
- end
42
-
43
- it 'should set correct indicator for visa and discover if cvv value is not present and cvv_indicator_visa_discover is true' do
44
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cvv_indicator_visa_discover => true })
45
- @properties.reject! {|property| property.key == 'ccVerificationValue' }
46
- validate_cvv_indicator_field 9
47
-
48
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'discover', :cvv_indicator_visa_discover => true })
49
- @properties.reject! {|property| property.key == 'ccVerificationValue' }
50
- validate_cvv_indicator_field 9
51
- end
52
-
53
- 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
54
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cvv_indicator_visa_discover => true, :cvv_indicator_override_visa_discover => '2' })
55
- @properties.reject! {|property| property.key == 'ccVerificationValue' }
56
- validate_cvv_indicator_field 2
57
-
58
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'discover', :cvv_indicator_visa_discover => true, :cvv_indicator_override_visa_discover => '2' })
59
- @properties.reject! {|property| property.key == 'ccVerificationValue' }
60
- validate_cvv_indicator_field 2
61
- end
62
-
63
- 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
64
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454'})
65
- @properties.reject! {|property| property.key == 'ccVerificationValue' }
66
- validate_cvv_indicator_field
67
-
68
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'discover'})
69
- @properties.reject! {|property| property.key == 'ccVerificationValue' }
70
- validate_cvv_indicator_field
71
-
72
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cvv_indicator_visa_discover => false })
73
- @properties.reject! {|property| property.key == 'ccVerificationValue' }
74
- validate_cvv_indicator_field
75
-
76
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'discover', :cvv_indicator_visa_discover => false })
77
- @properties.reject! {|property| property.key == 'ccVerificationValue' }
78
- validate_cvv_indicator_field
79
- end
80
-
81
- it 'should not include indicator except visa and discover for all cases' do
82
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'master' })
83
- validate_cvv_indicator_field
84
-
85
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'american_express' })
86
- validate_cvv_indicator_field
87
-
88
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'master', :cvv_indicator_visa_discover => false })
89
- validate_cvv_indicator_field
90
-
91
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'american_express', :cvv_indicator_visa_discover => false })
92
- validate_cvv_indicator_field
93
-
94
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'master', :cvv_indicator_visa_discover => true})
95
- validate_cvv_indicator_field
96
-
97
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'american_express', :cvv_indicator_visa_discover => true })
98
- validate_cvv_indicator_field
99
-
100
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'master' })
101
- @properties.reject! {|property| property.key == 'ccVerificationValue' }
102
- validate_cvv_indicator_field
103
-
104
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'american_express' })
105
- @properties.reject! {|property| property.key == 'ccVerificationValue' }
106
- validate_cvv_indicator_field
107
-
108
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'master', :cvv_indicator_visa_discover => false})
109
- @properties.reject! {|property| property.key == 'ccVerificationValue' }
110
- validate_cvv_indicator_field
111
-
112
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'american_express', :cvv_indicator_visa_discover => false })
113
- @properties.reject! {|property| property.key == 'ccVerificationValue' }
114
- validate_cvv_indicator_field
115
-
116
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'master', :cvv_indicator_visa_discover => true})
117
- @properties.reject! {|property| property.key == 'ccVerificationValue' }
118
- validate_cvv_indicator_field
119
-
120
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454', :cc_type => 'american_express', :cvv_indicator_visa_discover => true })
121
- @properties.reject! {|property| property.key == 'ccVerificationValue' }
122
- validate_cvv_indicator_field
123
- end
124
- end
125
-
126
- def successful_authorize_response
127
- <<-XML
128
- <?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>
129
- XML
130
- end
131
-
132
- def successful_purchase_response
133
- <<-XML
134
- <?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
135
- XML
136
- end
137
-
138
- def validate_cvv_indicator_field(expected_field = nil)
139
- ::ActiveMerchant::Billing::OrbitalGateway.any_instance.stub(:ssl_post) do |host, request_body|
140
- if expected_field.nil?
141
- request_body.should_not match('<CardSecValInd>')
142
- else
143
- request_body.should match("<CardSecValInd>#{expected_field}</CardSecValInd>")
144
- end
145
- if request_body.include? '<MessageType>A</MessageType>'
146
- successful_authorize_response
147
- else
148
- successful_purchase_response
149
- end
150
- end
151
-
152
- authorize
153
- purchase
154
- end
155
-
156
- def authorize
157
- kb_payment_id, kb_transaction_id = create_payment
158
- payment_response = @plugin.authorize_payment(SecureRandom.uuid, kb_payment_id, kb_transaction_id, SecureRandom.uuid, @amount, @currency, @properties, @call_context)
159
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
160
- payment_response.amount.should == @amount
161
- payment_response.transaction_type.should == :AUTHORIZE
162
- end
163
-
164
- def purchase
165
- kb_payment_id, kb_transaction_id = create_payment
166
- payment_response = @plugin.purchase_payment(SecureRandom.uuid, kb_payment_id, kb_transaction_id, SecureRandom.uuid, @amount, @currency, @properties, @call_context)
167
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
168
- payment_response.amount.should == @amount
169
- payment_response.transaction_type.should == :PURCHASE
170
- end
171
- end
@@ -1,111 +0,0 @@
1
- require 'spec_helper'
2
- require_relative 'shared_examples_for_payment_flow'
3
-
4
- ActiveMerchant::Billing::Base.mode = :test
5
-
6
- describe Killbill::Orbital::PaymentPlugin do
7
-
8
- include ::Killbill::Plugin::ActiveMerchant::RSpec
9
-
10
- before(:each) do
11
- # Start the plugin early to configure ActiveRecord
12
- @plugin = build_plugin(::Killbill::Orbital::PaymentPlugin, 'orbital')
13
- @plugin.start_plugin
14
-
15
- ::Killbill::Orbital::OrbitalPaymentMethod.delete_all
16
- ::Killbill::Orbital::OrbitalResponse.delete_all
17
- ::Killbill::Orbital::OrbitalTransaction.delete_all
18
-
19
- @call_context = build_call_context
20
- end
21
-
22
- context 'credit card flow' do
23
- before(:each) do
24
- @properties = build_pm_properties(nil, { :cc_number => '5454545454545454' })
25
- @pm = create_payment_method(::Killbill::Orbital::OrbitalPaymentMethod, nil, @call_context.tenant_id, @properties, {})
26
- @amount = BigDecimal.new('100')
27
- @currency = 'USD'
28
- end
29
-
30
- include_examples 'payment_flow_spec'
31
- end
32
-
33
- context 'custom profile flow' do
34
- before(:each) do
35
- @properties = []
36
- @pm = create_payment_method(::Killbill::Orbital::OrbitalPaymentMethod, nil, @call_context.tenant_id, @properties, { :cc_number => '5454545454545454' })
37
- @amount = BigDecimal.new('100')
38
- @currency = 'USD'
39
- end
40
-
41
- include_examples 'payment_flow_spec'
42
- end
43
-
44
- context 'tokenized credit card flow amex' do
45
- before(:each) do
46
- cryptogram = 'EHuWW9PiBkWvqE5juRwDzAUFBAk='
47
- @properties = build_pm_properties(nil,
48
- {
49
- :cc_number => 378282246310005,
50
- :cc_type => 'american_express',
51
- :payment_cryptogram => cryptogram
52
- })
53
- @pm = create_payment_method(::Killbill::Orbital::OrbitalPaymentMethod, nil, @call_context.tenant_id, @properties, {})
54
- @amount = BigDecimal.new('100')
55
- @currency = 'USD'
56
- end
57
-
58
- include_examples 'payment_flow_spec'
59
- end
60
-
61
- context 'tokenized credit card flow master' do
62
- before(:each) do
63
- cryptogram = 'EHuWW9PiBkWvqE5juRwDzAUFBAk='
64
- @properties = build_pm_properties(nil,
65
- {
66
- :cc_number => 5555555555554444,
67
- :cc_type => 'master',
68
- :payment_cryptogram => cryptogram
69
- })
70
- @pm = create_payment_method(::Killbill::Orbital::OrbitalPaymentMethod, nil, @call_context.tenant_id, @properties, {})
71
- @amount = BigDecimal.new('100')
72
- @currency = 'USD'
73
- end
74
-
75
- include_examples 'payment_flow_spec'
76
- end
77
-
78
- context 'tokenized credit card flow discover' do
79
- before(:each) do
80
- cryptogram = 'EHuWW9PiBkWvqE5juRwDzAUFBAk='
81
- @properties = build_pm_properties(nil,
82
- {
83
- :cc_number => 6011111111111117,
84
- :cc_type => 'discover',
85
- :payment_cryptogram => cryptogram
86
- })
87
- @pm = create_payment_method(::Killbill::Orbital::OrbitalPaymentMethod, nil, @call_context.tenant_id, @properties, {})
88
- @amount = BigDecimal.new('100')
89
- @currency = 'USD'
90
- end
91
-
92
- include_examples 'payment_flow_spec'
93
- end
94
-
95
- context 'tokenized credit card flow visa' do
96
- before(:each) do
97
- cryptogram = 'EHuWW9PiBkWvqE5juRwDzAUFBAk='
98
- @properties = build_pm_properties(nil,
99
- {
100
- :cc_number => 4112344112344113,
101
- :cc_type => 'visa',
102
- :payment_cryptogram => cryptogram
103
- })
104
- @pm = create_payment_method(::Killbill::Orbital::OrbitalPaymentMethod, nil, @call_context.tenant_id, @properties, {})
105
- @amount = BigDecimal.new('100')
106
- @currency = 'USD'
107
- end
108
-
109
- include_examples 'payment_flow_spec'
110
- end
111
- end
@@ -1,120 +0,0 @@
1
- shared_examples 'payment_flow_spec' do
2
-
3
- before(:each) do
4
- create_payment
5
- end
6
-
7
- after(:each) do
8
- @plugin.stop_plugin
9
- end
10
-
11
- it 'should be able to purchase' do
12
- Killbill::Orbital::OrbitalResponse.all.size.should == 1
13
- Killbill::Orbital::OrbitalTransaction.all.size.should == 0
14
-
15
- 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)
16
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
17
- payment_response.amount.should == @amount
18
- payment_response.transaction_type.should == :PURCHASE
19
- find_value_from_properties(payment_response.properties, 'processorResponse').should == '100'
20
-
21
- responses = Killbill::Orbital::OrbitalResponse.all
22
- responses.size.should == 2
23
- responses[0].api_call.should == 'add_payment_method'
24
- responses[0].message.should == 'Profile Request Processed'
25
- responses[1].api_call.should == 'purchase'
26
- responses[1].message.should == 'Approved'
27
- transactions = Killbill::Orbital::OrbitalTransaction.all
28
- transactions.size.should == 1
29
- transactions[0].api_call.should == 'purchase'
30
- end
31
-
32
- it 'should be able to charge and refund' do
33
- 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)
34
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
35
- payment_response.amount.should == @amount
36
- payment_response.transaction_type.should == :PURCHASE
37
- find_value_from_properties(payment_response.properties, 'processorResponse').should == '100'
38
-
39
- # Try a full refund
40
- refund_response = @plugin.refund_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[1].id, @pm.kb_payment_method_id, @amount, @currency, @properties, @call_context)
41
- refund_response.status.should eq(:PROCESSED), refund_response.gateway_error
42
- refund_response.amount.should == @amount
43
- refund_response.transaction_type.should == :REFUND
44
- end
45
-
46
- it 'should be able to auth, capture and refund' do
47
- 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)
48
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
49
- payment_response.amount.should == @amount
50
- payment_response.transaction_type.should == :AUTHORIZE
51
- find_value_from_properties(payment_response.properties, 'processorResponse').should == '100'
52
-
53
- # Try multiple partial captures
54
- partial_capture_amount = BigDecimal.new('10')
55
- 1.upto(3) do |i|
56
- payment_response = @plugin.capture_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[i].id, @pm.kb_payment_method_id, partial_capture_amount, @currency, @properties, @call_context)
57
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
58
- payment_response.amount.should == partial_capture_amount
59
- payment_response.transaction_type.should == :CAPTURE
60
- end
61
-
62
- # Try a partial refund
63
- refund_response = @plugin.refund_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[4].id, @pm.kb_payment_method_id, partial_capture_amount, @currency, @properties, @call_context)
64
- refund_response.status.should eq(:PROCESSED), refund_response.gateway_error
65
- refund_response.amount.should == partial_capture_amount
66
- refund_response.transaction_type.should == :REFUND
67
-
68
- # Try to capture again
69
- payment_response = @plugin.capture_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[5].id, @pm.kb_payment_method_id, partial_capture_amount, @currency, @properties, @call_context)
70
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
71
- payment_response.amount.should == partial_capture_amount
72
- payment_response.transaction_type.should == :CAPTURE
73
- end
74
-
75
- it 'should be able to auth and void' do
76
- 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)
77
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
78
- payment_response.amount.should == @amount
79
- payment_response.transaction_type.should == :AUTHORIZE
80
- find_value_from_properties(payment_response.properties, 'processorResponse').should == '100'
81
-
82
- payment_response = @plugin.void_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[1].id, @pm.kb_payment_method_id, @properties, @call_context)
83
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
84
- payment_response.transaction_type.should == :VOID
85
- end
86
-
87
- it 'should be able to auth, partial capture and void' do
88
- 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)
89
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
90
- payment_response.amount.should == @amount
91
- payment_response.transaction_type.should == :AUTHORIZE
92
- find_value_from_properties(payment_response.properties, 'processorResponse').should == '100'
93
-
94
- partial_capture_amount = BigDecimal.new('10')
95
- payment_response = @plugin.capture_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[1].id, @pm.kb_payment_method_id, partial_capture_amount, @currency, @properties, @call_context)
96
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
97
- payment_response.amount.should == partial_capture_amount
98
- payment_response.transaction_type.should == :CAPTURE
99
-
100
- payment_response = @plugin.void_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[2].id, @pm.kb_payment_method_id, @properties, @call_context)
101
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
102
- payment_response.transaction_type.should == :VOID
103
- end
104
-
105
- it 'should be able to credit' do
106
- payment_response = @plugin.credit_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[0].id, @pm.kb_payment_method_id, @amount, @currency, @properties, @call_context)
107
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
108
- payment_response.amount.should == @amount
109
- payment_response.transaction_type.should == :CREDIT
110
- end
111
-
112
- it 'should include host response code' do
113
- # Sending a specific amount of 530 will trigger the Do Not Honor error.
114
- payment_response = @plugin.authorize_payment(@pm.kb_account_id, @kb_payment.id, @kb_payment.transactions[0].id, @pm.kb_payment_method_id, BigDecimal.new('530'), @currency, @properties, @call_context)
115
- payment_response.status.should eq(:ERROR), payment_response.gateway_error
116
- payment_response.transaction_type.should == :AUTHORIZE
117
- payment_response.amount.should be_nil
118
- find_value_from_properties(payment_response.properties, 'processorResponse').should == '530'
119
- end
120
- end
@@ -1,134 +0,0 @@
1
- require 'spec_helper'
2
-
3
- ActiveMerchant::Billing::Base.mode = :test
4
-
5
- describe 'Payment request for network tokenized card' do
6
-
7
- include ::Killbill::Plugin::ActiveMerchant::RSpec
8
-
9
- 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
- end
20
-
21
- after(:each) do
22
- @plugin.stop_plugin
23
- end
24
-
25
- it 'should send correct payload for visa network tokenized card' do
26
-
27
- cryptogram = 'EHuWW9PiBkWvqE5juRwDzAUFBAk='
28
- @properties = build_pm_properties(nil,
29
- {
30
- :cc_number => 4111111111111111,
31
- :cc_type => 'visa',
32
- :payment_cryptogram => cryptogram
33
- })
34
- @amount = BigDecimal.new('100')
35
- @currency = 'USD'
36
-
37
- ::ActiveMerchant::Billing::OrbitalGateway.any_instance.stub(:ssl_post) do |host, request_body|
38
- request_body.should match("<CAVV>#{cryptogram}</CAVV>")
39
- request_body.should match('<DPANInd>Y</DPANInd>')
40
- request_body.should match("<DigitalTokenCryptogram>#{cryptogram}</DigitalTokenCryptogram>")
41
-
42
- successful_authorize_response
43
- end
44
-
45
- validate_payment
46
- end
47
-
48
- it 'should send correct payload for amex network tokenized card' do
49
-
50
- cryptogram = 'EHuWW9PiBkWvqE5juRwDzAUFBAk='
51
- @properties = build_pm_properties(nil,
52
- {
53
- :cc_number => 378282246310005,
54
- :cc_type => 'american_express',
55
- :payment_cryptogram => cryptogram,
56
- :eci => '7',
57
- })
58
- @amount = BigDecimal.new('100')
59
- @currency = 'USD'
60
-
61
- ::ActiveMerchant::Billing::OrbitalGateway.any_instance.stub(:ssl_post) do |host, request_body|
62
- request_body.should match("<AEVV>#{cryptogram}</AEVV>")
63
- request_body.should match('<DPANInd>Y</DPANInd>')
64
- request_body.should match("<DigitalTokenCryptogram>#{cryptogram}</DigitalTokenCryptogram>")
65
- request_body.should match('<AuthenticationECIInd>7</AuthenticationECIInd>')
66
-
67
- successful_authorize_response
68
- end
69
-
70
- validate_payment
71
- end
72
-
73
- it 'should send correct payload for master network tokenized card' do
74
-
75
- cryptogram = 'EHuWW9PiBkWvqE5juRwDzAUFBAk='
76
- @properties = build_pm_properties(nil,
77
- {
78
- :cc_number => 5555555555554444,
79
- :cc_type => 'master',
80
- :payment_cryptogram => cryptogram,
81
- })
82
- @amount = BigDecimal.new('100')
83
- @currency = 'USD'
84
-
85
- ::ActiveMerchant::Billing::OrbitalGateway.any_instance.stub(:ssl_post) do |host, request_body|
86
- request_body.should match("<AAV>#{cryptogram}</AAV>")
87
- request_body.should match('<DPANInd>Y</DPANInd>')
88
- request_body.should match("<DigitalTokenCryptogram>#{cryptogram}</DigitalTokenCryptogram>")
89
-
90
- successful_authorize_response
91
- end
92
-
93
- validate_payment
94
- end
95
-
96
- it 'should send correct payload for discover network tokenized card' do
97
-
98
- cryptogram = 'EHuWW9PiBkWvqE5juRwDzAUFBAk='
99
- @properties = build_pm_properties(nil,
100
- {
101
- :cc_number => 6011111111111117,
102
- :cc_type => 'discover',
103
- :payment_cryptogram => cryptogram
104
- })
105
- @amount = BigDecimal.new('100')
106
- @currency = 'USD'
107
-
108
- ::ActiveMerchant::Billing::OrbitalGateway.any_instance.stub(:ssl_post) do |host, request_body|
109
- request_body.should match('<DPANInd>Y</DPANInd>')
110
- request_body.should match("<DigitalTokenCryptogram>#{cryptogram}</DigitalTokenCryptogram>")
111
-
112
- successful_authorize_response
113
- end
114
-
115
- validate_payment
116
- end
117
-
118
- private
119
-
120
- def successful_authorize_response
121
- <<-XML
122
- <?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>
123
- XML
124
- end
125
-
126
- def validate_payment
127
- kb_payment_id, kb_transaction_id = create_payment
128
- payment_response = @plugin.authorize_payment(SecureRandom.uuid, kb_payment_id, kb_transaction_id, SecureRandom.uuid, @amount, @currency, @properties, @call_context)
129
- payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
130
- payment_response.amount.should == @amount
131
- payment_response.transaction_type.should == :AUTHORIZE
132
- end
133
-
134
- end
data/spec/spec_helper.rb DELETED
@@ -1,32 +0,0 @@
1
- require 'bundler'
2
- require 'orbital'
3
- require 'killbill/helpers/active_merchant/killbill_spec_helper'
4
-
5
- require 'logger'
6
-
7
- require 'rspec'
8
-
9
- RSpec.configure do |config|
10
- config.color_enabled = true
11
- config.tty = true
12
- config.formatter = 'documentation'
13
- end
14
-
15
- require 'active_record'
16
- ActiveRecord::Base.establish_connection(
17
- :adapter => 'sqlite3',
18
- :database => 'test.db'
19
- )
20
- # For debugging
21
- #ActiveRecord::Base.logger = Logger.new(STDOUT)
22
- # Create the schema
23
- require File.expand_path(File.dirname(__FILE__) + '../../db/schema.rb')
24
-
25
- def create_payment
26
- kb_payment_id = SecureRandom.uuid
27
- 1.upto(6) do
28
- @kb_payment = @plugin.kb_apis.proxied_services[:payment_api].add_payment(kb_payment_id)
29
- end
30
- [kb_payment_id, @kb_payment.transactions[0].id]
31
- end
32
-