killbill-paypal-express 5.0.2 → 5.0.3

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: 913eedcc9a3244894dd570f66b759d51108ba7c6
4
- data.tar.gz: dd6bfb8b20f9d073d4e001588bd7c0d10a0646f2
3
+ metadata.gz: 588915d1b5f301d56b925a8c75f5f643c2725562
4
+ data.tar.gz: c0025ed6f693a9f726645ca22f368d396457ef07
5
5
  SHA512:
6
- metadata.gz: d90e70548f11dc0881ed4005f8e254a1c1f72a0eea876d20e6fe635cbfd15519d91891f94b2bb0abd1f505356eb9e025275281750d235160995c39c950b8813d
7
- data.tar.gz: 93a62549de619d9d5bae207e1afaeb93080d5c6547436d21a964256cf936b28d514039e2b4f183eab4b328b8f6b6475ffc860471afd030aa21d9d701e87f7f13
6
+ metadata.gz: 9717c0e506aa81b724132330923b2c4778335482ecce4a7f3c1f3f05387598401ba8ad63a196408a1a393fa7e5a2cf8e6861f0090bdc7f4dfc6255f621871fd3
7
+ data.tar.gz: 2428403edb96d25c5e373f762e2dd013eb464bd0f6765df1e89b2952984bed239ce3c5062888636fc19fc1a3f6ec6d4e2653964d8d4ac0d9d2045952fb46ee4e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- killbill-paypal-express (5.0.2)
4
+ killbill-paypal-express (5.0.3)
5
5
  actionpack (~> 4.1.0)
6
6
  actionview (~> 4.1.0)
7
7
  activemerchant (~> 1.53.0)
data/NEWS CHANGED
@@ -1,3 +1,6 @@
1
+ 5.0.3
2
+ Fix for https://github.com/killbill/killbill-paypal-express-plugin/issues/26
3
+
1
4
  5.0.2
2
5
  Make text on checkout button configurable (through review plugin property)
3
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.0.2
1
+ 5.0.3
@@ -84,7 +84,14 @@ module Killbill #:nodoc:
84
84
  end
85
85
 
86
86
  def get_payment_info(kb_account_id, kb_payment_id, properties, context)
87
- t_info_plugins = super(kb_account_id, kb_payment_id, properties, context)
87
+ ignored_api_calls = [:details_for]
88
+ responses = @response_model.from_kb_payment_id(@transaction_model, kb_payment_id, context.tenant_id)
89
+ responses = responses.reject do |response|
90
+ ignored_api_calls.include?(response.api_call.to_sym)
91
+ end
92
+ t_info_plugins = responses.collect do |response|
93
+ response.to_transaction_info_plugin(response.send("#{@identifier}_transaction"))
94
+ end
88
95
  # Should never happen...
89
96
  return [] if t_info_plugins.nil?
90
97
 
@@ -288,7 +295,8 @@ module Killbill #:nodoc:
288
295
  payment_processor_account_id = payment_processor_account_id || :default
289
296
  gateway = lookup_gateway(payment_processor_account_id, kb_tenant_id)
290
297
  gw_response = gateway.details_for(token)
291
- response, transaction = save_response_and_transaction(gw_response, :details_for, kb_account_id, kb_tenant_id, payment_processor_account_id, kb_payment_id, kb_payment_transaction_id, transaction_type)
298
+
299
+ response = @response_model.create_response(:details_for, kb_account_id, kb_payment_id, kb_payment_transaction_id, transaction_type, payment_processor_account_id, kb_tenant_id, gw_response)
292
300
 
293
301
  raise response.message unless response.success?
294
302
  raise "Could not retrieve the payer info for token #{token}" if response.payer_id.blank?
@@ -63,6 +63,13 @@ module Killbill #:nodoc:
63
63
  model)
64
64
  end
65
65
 
66
+ def self.create_response(api_call, kb_account_id, kb_payment_id, kb_payment_transaction_id, transaction_type, payment_processor_account_id, kb_tenant_id, gw_response, extra_params = {}, model = ::Killbill::PaypalExpress::PaypalExpressResponse)
67
+ response = model.from_response(api_call, kb_account_id, kb_payment_id, kb_payment_transaction_id, transaction_type, payment_processor_account_id, kb_tenant_id, gw_response, extra_params, model)
68
+ response.save!(shared_activerecord_options)
69
+ response
70
+ end
71
+
72
+
66
73
  def self.last_token(kb_account_id, kb_tenant_id)
67
74
  response = where(:api_call => 'initiate_express_checkout',
68
75
  :success => true,
data/pom.xml CHANGED
@@ -26,7 +26,7 @@
26
26
  <groupId>org.kill-bill.billing.plugin.ruby</groupId>
27
27
  <artifactId>paypal-express-plugin</artifactId>
28
28
  <packaging>pom</packaging>
29
- <version>5.0.2</version>
29
+ <version>5.0.3</version>
30
30
  <name>paypal-express-plugin</name>
31
31
  <url>http://github.com/killbill/killbill-paypal-express-plugin</url>
32
32
  <description>Plugin for accessing Paypal Express Checkout as a payment gateway</description>
@@ -21,27 +21,18 @@ shared_examples 'baid_spec_common' do
21
21
  payer_id = find_value_from_properties(payment_response.properties, 'payerId')
22
22
  payer_id.should_not be_nil
23
23
 
24
+ validate_details_for(@kb_payment.id, :PURCHASE, payer_id)
24
25
  # Verify GET API
25
26
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
26
- payment_infos.size.should == 2
27
- # details_for
27
+ payment_infos.size.should == 1
28
+ # purchase
28
29
  payment_infos[0].kb_payment_id.should == @kb_payment.id
29
30
  payment_infos[0].transaction_type.should == :PURCHASE
30
- payment_infos[0].amount.should be_nil
31
- payment_infos[0].currency.should be_nil
31
+ payment_infos[0].amount.should == @amount
32
+ payment_infos[0].currency.should == @currency
32
33
  payment_infos[0].status.should == :PROCESSED
33
34
  payment_infos[0].gateway_error.should == 'Success'
34
35
  payment_infos[0].gateway_error_code.should be_nil
35
- find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
36
- find_value_from_properties(payment_infos[0].properties, 'payerName').should_not be_nil
37
- # purchase
38
- payment_infos[1].kb_payment_id.should == @kb_payment.id
39
- payment_infos[1].transaction_type.should == :PURCHASE
40
- payment_infos[1].amount.should == @amount
41
- payment_infos[1].currency.should == @currency
42
- payment_infos[1].status.should == :PROCESSED
43
- payment_infos[1].gateway_error.should == 'Success'
44
- payment_infos[1].gateway_error_code.should be_nil
45
36
  find_value_from_properties(payment_infos[0].properties, 'payment_processor_account_id').should == @payment_processor_account_id
46
37
  find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
47
38
 
@@ -53,34 +44,24 @@ shared_examples 'baid_spec_common' do
53
44
 
54
45
  # Verify GET API
55
46
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
56
- payment_infos.size.should == 3
57
- # details_for
47
+ payment_infos.size.should == 2
48
+ # purchase
58
49
  payment_infos[0].kb_payment_id.should == @kb_payment.id
59
50
  payment_infos[0].transaction_type.should == :PURCHASE
60
- payment_infos[0].amount.should be_nil
61
- payment_infos[0].currency.should be_nil
51
+ payment_infos[0].amount.should == @amount
52
+ payment_infos[0].currency.should == @currency
62
53
  payment_infos[0].status.should == :PROCESSED
63
54
  payment_infos[0].gateway_error.should == 'Success'
64
55
  payment_infos[0].gateway_error_code.should be_nil
65
- find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
66
- find_value_from_properties(payment_infos[0].properties, 'payerName').should_not be_nil
67
- # purchase
56
+ find_value_from_properties(payment_infos[0].properties, 'payment_processor_account_id').should == @payment_processor_account_id
57
+ # refund
68
58
  payment_infos[1].kb_payment_id.should == @kb_payment.id
69
- payment_infos[1].transaction_type.should == :PURCHASE
59
+ payment_infos[1].transaction_type.should == :REFUND
70
60
  payment_infos[1].amount.should == @amount
71
61
  payment_infos[1].currency.should == @currency
72
62
  payment_infos[1].status.should == :PROCESSED
73
63
  payment_infos[1].gateway_error.should == 'Success'
74
64
  payment_infos[1].gateway_error_code.should be_nil
75
- find_value_from_properties(payment_infos[0].properties, 'payment_processor_account_id').should == @payment_processor_account_id
76
- # refund
77
- payment_infos[2].kb_payment_id.should == @kb_payment.id
78
- payment_infos[2].transaction_type.should == :REFUND
79
- payment_infos[2].amount.should == @amount
80
- payment_infos[2].currency.should == @currency
81
- payment_infos[2].status.should == :PROCESSED
82
- payment_infos[2].gateway_error.should == 'Success'
83
- payment_infos[2].gateway_error_code.should be_nil
84
65
  find_value_from_properties(payment_infos[1].properties, 'payment_processor_account_id').should == @payment_processor_account_id
85
66
  end
86
67
 
@@ -92,27 +73,18 @@ shared_examples 'baid_spec_common' do
92
73
  payer_id = find_value_from_properties(payment_response.properties, 'payerId')
93
74
  payer_id.should_not be_nil
94
75
 
76
+ validate_details_for(@kb_payment.id, :AUTHORIZE, payer_id)
95
77
  # Verify GET API
96
78
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
97
- payment_infos.size.should == 2
98
- # details_for
79
+ payment_infos.size.should == 1
80
+ # purchase
99
81
  payment_infos[0].kb_payment_id.should == @kb_payment.id
100
82
  payment_infos[0].transaction_type.should == :AUTHORIZE
101
- payment_infos[0].amount.should be_nil
102
- payment_infos[0].currency.should be_nil
83
+ payment_infos[0].amount.should == @amount
84
+ payment_infos[0].currency.should == @currency
103
85
  payment_infos[0].status.should == :PROCESSED
104
86
  payment_infos[0].gateway_error.should == 'Success'
105
87
  payment_infos[0].gateway_error_code.should be_nil
106
- find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
107
- find_value_from_properties(payment_infos[0].properties, 'payerName').should_not be_nil
108
- # purchase
109
- payment_infos[1].kb_payment_id.should == @kb_payment.id
110
- payment_infos[1].transaction_type.should == :AUTHORIZE
111
- payment_infos[1].amount.should == @amount
112
- payment_infos[1].currency.should == @currency
113
- payment_infos[1].status.should == :PROCESSED
114
- payment_infos[1].gateway_error.should == 'Success'
115
- payment_infos[1].gateway_error_code.should be_nil
116
88
  find_value_from_properties(payment_infos[0].properties, 'payment_processor_account_id').should == @payment_processor_account_id
117
89
  find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
118
90
 
@@ -126,15 +98,15 @@ shared_examples 'baid_spec_common' do
126
98
 
127
99
  # Verify GET API
128
100
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
129
- payment_infos.size.should == 2 + i
130
- payment_infos[i + 1].kb_payment_id.should == @kb_payment.id
131
- payment_infos[i + 1].transaction_type.should == :CAPTURE
132
- payment_infos[i + 1].amount.should == partial_capture_amount
133
- payment_infos[i + 1].currency.should == @currency
134
- payment_infos[i + 1].status.should == :PROCESSED
135
- payment_infos[i + 1].gateway_error.should == 'Success'
136
- payment_infos[i + 1].gateway_error_code.should be_nil
137
- find_value_from_properties(payment_infos[i + 1].properties, 'payment_processor_account_id').should == @payment_processor_account_id
101
+ payment_infos.size.should == i + 1
102
+ payment_infos[i].kb_payment_id.should == @kb_payment.id
103
+ payment_infos[i].transaction_type.should == :CAPTURE
104
+ payment_infos[i].amount.should == partial_capture_amount
105
+ payment_infos[i].currency.should == @currency
106
+ payment_infos[i].status.should == :PROCESSED
107
+ payment_infos[i].gateway_error.should == 'Success'
108
+ payment_infos[i].gateway_error_code.should be_nil
109
+ find_value_from_properties(payment_infos[i].properties, 'payment_processor_account_id').should == @payment_processor_account_id
138
110
  end
139
111
 
140
112
  # Try a partial refund
@@ -145,15 +117,15 @@ shared_examples 'baid_spec_common' do
145
117
 
146
118
  # Verify GET API
147
119
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
148
- payment_infos.size.should == 6
149
- payment_infos[5].kb_payment_id.should == @kb_payment.id
150
- payment_infos[5].transaction_type.should == :REFUND
151
- payment_infos[5].amount.should == partial_capture_amount
152
- payment_infos[5].currency.should == @currency
153
- payment_infos[5].status.should == :PROCESSED
154
- payment_infos[5].gateway_error.should == 'Success'
155
- payment_infos[5].gateway_error_code.should be_nil
156
- find_value_from_properties(payment_infos[5].properties, 'payment_processor_account_id').should == @payment_processor_account_id
120
+ payment_infos.size.should == 5
121
+ payment_infos[4].kb_payment_id.should == @kb_payment.id
122
+ payment_infos[4].transaction_type.should == :REFUND
123
+ payment_infos[4].amount.should == partial_capture_amount
124
+ payment_infos[4].currency.should == @currency
125
+ payment_infos[4].status.should == :PROCESSED
126
+ payment_infos[4].gateway_error.should == 'Success'
127
+ payment_infos[4].gateway_error_code.should be_nil
128
+ find_value_from_properties(payment_infos[4].properties, 'payment_processor_account_id').should == @payment_processor_account_id
157
129
 
158
130
  # Try to capture again
159
131
  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)
@@ -163,15 +135,15 @@ shared_examples 'baid_spec_common' do
163
135
 
164
136
  # Verify GET API
165
137
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
166
- payment_infos.size.should == 7
167
- payment_infos[6].kb_payment_id.should == @kb_payment.id
168
- payment_infos[6].transaction_type.should == :CAPTURE
169
- payment_infos[6].amount.should == partial_capture_amount
170
- payment_infos[6].currency.should == @currency
171
- payment_infos[6].status.should == :PROCESSED
172
- payment_infos[6].gateway_error.should == 'Success'
173
- payment_infos[6].gateway_error_code.should be_nil
174
- find_value_from_properties(payment_infos[6].properties, 'payment_processor_account_id').should == @payment_processor_account_id
138
+ payment_infos.size.should == 6
139
+ payment_infos[5].kb_payment_id.should == @kb_payment.id
140
+ payment_infos[5].transaction_type.should == :CAPTURE
141
+ payment_infos[5].amount.should == partial_capture_amount
142
+ payment_infos[5].currency.should == @currency
143
+ payment_infos[5].status.should == :PROCESSED
144
+ payment_infos[5].gateway_error.should == 'Success'
145
+ payment_infos[5].gateway_error_code.should be_nil
146
+ find_value_from_properties(payment_infos[5].properties, 'payment_processor_account_id').should == @payment_processor_account_id
175
147
  end
176
148
 
177
149
  it 'should be able to auth and void' do
@@ -182,28 +154,19 @@ shared_examples 'baid_spec_common' do
182
154
  payer_id = find_value_from_properties(payment_response.properties, 'payerId')
183
155
  payer_id.should_not be_nil
184
156
 
157
+ validate_details_for(@kb_payment.id, :AUTHORIZE, payer_id)
185
158
  # Verify GET API
186
159
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
187
- payment_infos.size.should == 2
188
- # details_for
160
+ payment_infos.size.should == 1
161
+ # authorize
189
162
  payment_infos[0].kb_payment_id.should == @kb_payment.id
190
163
  payment_infos[0].transaction_type.should == :AUTHORIZE
191
- payment_infos[0].amount.should be_nil
192
- payment_infos[0].currency.should be_nil
164
+ payment_infos[0].amount.should == @amount
165
+ payment_infos[0].currency.should == @currency
193
166
  payment_infos[0].status.should == :PROCESSED
194
167
  payment_infos[0].gateway_error.should == 'Success'
195
168
  payment_infos[0].gateway_error_code.should be_nil
196
- find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
197
- find_value_from_properties(payment_infos[0].properties, 'payerName').should_not be_nil
198
- # authorize
199
- payment_infos[1].kb_payment_id.should == @kb_payment.id
200
- payment_infos[1].transaction_type.should == :AUTHORIZE
201
- payment_infos[1].amount.should == @amount
202
- payment_infos[1].currency.should == @currency
203
- payment_infos[1].status.should == :PROCESSED
204
- payment_infos[1].gateway_error.should == 'Success'
205
- payment_infos[1].gateway_error_code.should be_nil
206
- find_value_from_properties(payment_infos[1].properties, 'payment_processor_account_id').should == @payment_processor_account_id
169
+ find_value_from_properties(payment_infos[0].properties, 'payment_processor_account_id').should == @payment_processor_account_id
207
170
 
208
171
  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)
209
172
  payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
@@ -211,35 +174,25 @@ shared_examples 'baid_spec_common' do
211
174
 
212
175
  # Verify GET API
213
176
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
214
- payment_infos.size.should == 3
215
- # details_for
177
+ payment_infos.size.should == 2
178
+ # authorize
216
179
  payment_infos[0].kb_payment_id.should == @kb_payment.id
217
180
  payment_infos[0].transaction_type.should == :AUTHORIZE
218
- payment_infos[0].amount.should be_nil
219
- payment_infos[0].currency.should be_nil
181
+ payment_infos[0].amount.should == @amount
182
+ payment_infos[0].currency.should == @currency
220
183
  payment_infos[0].status.should == :PROCESSED
221
184
  payment_infos[0].gateway_error.should == 'Success'
222
185
  payment_infos[0].gateway_error_code.should be_nil
223
- find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
224
- find_value_from_properties(payment_infos[0].properties, 'payerName').should_not be_nil
225
- # authorize
186
+ find_value_from_properties(payment_infos[0].properties, 'payment_processor_account_id').should == @payment_processor_account_id
187
+ # void
226
188
  payment_infos[1].kb_payment_id.should == @kb_payment.id
227
- payment_infos[1].transaction_type.should == :AUTHORIZE
228
- payment_infos[1].amount.should == @amount
229
- payment_infos[1].currency.should == @currency
189
+ payment_infos[1].transaction_type.should == :VOID
190
+ payment_infos[1].amount.should be_nil
191
+ payment_infos[1].currency.should be_nil
230
192
  payment_infos[1].status.should == :PROCESSED
231
193
  payment_infos[1].gateway_error.should == 'Success'
232
194
  payment_infos[1].gateway_error_code.should be_nil
233
195
  find_value_from_properties(payment_infos[1].properties, 'payment_processor_account_id').should == @payment_processor_account_id
234
- # void
235
- payment_infos[2].kb_payment_id.should == @kb_payment.id
236
- payment_infos[2].transaction_type.should == :VOID
237
- payment_infos[2].amount.should be_nil
238
- payment_infos[2].currency.should be_nil
239
- payment_infos[2].status.should == :PROCESSED
240
- payment_infos[2].gateway_error.should == 'Success'
241
- payment_infos[2].gateway_error_code.should be_nil
242
- find_value_from_properties(payment_infos[2].properties, 'payment_processor_account_id').should == @payment_processor_account_id
243
196
  end
244
197
 
245
198
  it 'should be able to auth, partial capture and void' do
@@ -250,27 +203,18 @@ shared_examples 'baid_spec_common' do
250
203
  payer_id = find_value_from_properties(payment_response.properties, 'payerId')
251
204
  payer_id.should_not be_nil
252
205
 
206
+ validate_details_for(@kb_payment.id, :AUTHORIZE, payer_id)
253
207
  # Verify GET API
254
208
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
255
- payment_infos.size.should == 2
256
- # details_for
209
+ payment_infos.size.should == 1
210
+ # authorize
257
211
  payment_infos[0].kb_payment_id.should == @kb_payment.id
258
212
  payment_infos[0].transaction_type.should == :AUTHORIZE
259
- payment_infos[0].amount.should be_nil
260
- payment_infos[0].currency.should be_nil
213
+ payment_infos[0].amount.should == @amount
214
+ payment_infos[0].currency.should == @currency
261
215
  payment_infos[0].status.should == :PROCESSED
262
216
  payment_infos[0].gateway_error.should == 'Success'
263
217
  payment_infos[0].gateway_error_code.should be_nil
264
- find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
265
- find_value_from_properties(payment_infos[0].properties, 'payerName').should_not be_nil
266
- # authorize
267
- payment_infos[1].kb_payment_id.should == @kb_payment.id
268
- payment_infos[1].transaction_type.should == :AUTHORIZE
269
- payment_infos[1].amount.should == @amount
270
- payment_infos[1].currency.should == @currency
271
- payment_infos[1].status.should == :PROCESSED
272
- payment_infos[1].gateway_error.should == 'Success'
273
- payment_infos[1].gateway_error_code.should be_nil
274
218
  find_value_from_properties(payment_infos[0].properties, 'payment_processor_account_id').should == @payment_processor_account_id
275
219
 
276
220
  partial_capture_amount = BigDecimal.new('10')
@@ -281,15 +225,15 @@ shared_examples 'baid_spec_common' do
281
225
 
282
226
  # Verify GET API
283
227
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
284
- payment_infos.size.should == 3
285
- payment_infos[2].kb_payment_id.should == @kb_payment.id
286
- payment_infos[2].transaction_type.should == :CAPTURE
287
- payment_infos[2].amount.should == partial_capture_amount
288
- payment_infos[2].currency.should == @currency
289
- payment_infos[2].status.should == :PROCESSED
290
- payment_infos[2].gateway_error.should == 'Success'
291
- payment_infos[2].gateway_error_code.should be_nil
292
- find_value_from_properties(payment_infos[2].properties, 'payment_processor_account_id').should == @payment_processor_account_id
228
+ payment_infos.size.should == 2
229
+ payment_infos[1].kb_payment_id.should == @kb_payment.id
230
+ payment_infos[1].transaction_type.should == :CAPTURE
231
+ payment_infos[1].amount.should == partial_capture_amount
232
+ payment_infos[1].currency.should == @currency
233
+ payment_infos[1].status.should == :PROCESSED
234
+ payment_infos[1].gateway_error.should == 'Success'
235
+ payment_infos[1].gateway_error_code.should be_nil
236
+ find_value_from_properties(payment_infos[1].properties, 'payment_processor_account_id').should == @payment_processor_account_id
293
237
 
294
238
  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)
295
239
  payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
@@ -297,15 +241,15 @@ shared_examples 'baid_spec_common' do
297
241
 
298
242
  # Verify GET API
299
243
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, @kb_payment.id, [], @call_context)
300
- payment_infos.size.should == 4
301
- payment_infos[3].kb_payment_id.should == @kb_payment.id
302
- payment_infos[3].transaction_type.should == :VOID
303
- payment_infos[3].amount.should be_nil
304
- payment_infos[3].currency.should be_nil
305
- payment_infos[3].status.should == :PROCESSED
306
- payment_infos[3].gateway_error.should == 'Success'
307
- payment_infos[3].gateway_error_code.should be_nil
308
- find_value_from_properties(payment_infos[3].properties, 'payment_processor_account_id').should == @payment_processor_account_id
244
+ payment_infos.size.should == 3
245
+ payment_infos[2].kb_payment_id.should == @kb_payment.id
246
+ payment_infos[2].transaction_type.should == :VOID
247
+ payment_infos[2].amount.should be_nil
248
+ payment_infos[2].currency.should be_nil
249
+ payment_infos[2].status.should == :PROCESSED
250
+ payment_infos[2].gateway_error.should == 'Success'
251
+ payment_infos[2].gateway_error_code.should be_nil
252
+ find_value_from_properties(payment_infos[2].properties, 'payment_processor_account_id').should == @payment_processor_account_id
309
253
  end
310
254
 
311
255
  it 'should generate forms correctly' do
@@ -53,7 +53,7 @@ shared_examples 'hpp_spec_common' do
53
53
  end
54
54
 
55
55
  # Each loop triggers one successful purchase and one successful refund
56
- ::Killbill::PaypalExpress::PaypalExpressTransaction.count.should == 5 * n
56
+ ::Killbill::PaypalExpress::PaypalExpressTransaction.count.should == 2 * n
57
57
  ::Killbill::PaypalExpress::PaypalExpressResponse.count.should == 1 + 8 * n
58
58
  end
59
59
 
@@ -116,7 +116,7 @@ shared_examples 'hpp_spec_common' do
116
116
  end
117
117
 
118
118
  # Each loop triggers one successful purchase and one successful refund
119
- ::Killbill::PaypalExpress::PaypalExpressTransaction.count.should == 5 * n
119
+ ::Killbill::PaypalExpress::PaypalExpressTransaction.count.should == 2 * n
120
120
  ::Killbill::PaypalExpress::PaypalExpressResponse.count.should == 1 + 9 * n
121
121
  end
122
122
 
@@ -184,7 +184,7 @@ shared_examples 'hpp_spec_common' do
184
184
  end
185
185
 
186
186
  # Each loop triggers one successful auth, one successful capture and one successful refund
187
- ::Killbill::PaypalExpress::PaypalExpressTransaction.count.should == 5 * n
187
+ ::Killbill::PaypalExpress::PaypalExpressTransaction.count.should == 3 * n
188
188
  ::Killbill::PaypalExpress::PaypalExpressResponse.count.should == 1 + 15 * n / 2 + 7 * n % 2
189
189
  end
190
190
 
@@ -224,8 +224,8 @@ shared_examples 'hpp_spec_common' do
224
224
  @plugin.kb_apis.proxied_services[:payment_api].payments.size.should == i / 2
225
225
  end
226
226
 
227
- # Each loop triggers one successful details_for, authorize and void
228
- ::Killbill::PaypalExpress::PaypalExpressTransaction.count.should == 3 * n
227
+ # Each loop triggers one successful authorize and void
228
+ ::Killbill::PaypalExpress::PaypalExpressTransaction.count.should == 2 * n
229
229
  ::Killbill::PaypalExpress::PaypalExpressResponse.count.should == 9 * n / 2 + 5 * n % 2
230
230
  end
231
231
 
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require_relative 'browser_helpers'
2
3
 
3
4
  module Killbill
@@ -53,28 +54,19 @@ module Killbill
53
54
  payer_id = find_value_from_properties(payment_response.properties, 'payerId')
54
55
  payer_id.should_not be_nil
55
56
 
57
+ validate_details_for(kb_payment_id, :PURCHASE, payer_id)
56
58
  # Verify GET API
57
59
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, [], @call_context)
58
- payment_infos.size.should == 2
59
- # details_for
60
+ payment_infos.size.should == 1
61
+ # purchase
60
62
  payment_infos[0].kb_payment_id.should == kb_payment_id
61
63
  payment_infos[0].transaction_type.should == :PURCHASE
62
- payment_infos[0].amount.should be_nil
63
- payment_infos[0].currency.should be_nil
64
+ payment_infos[0].amount.should == @amount
65
+ payment_infos[0].currency.should == @currency
64
66
  payment_infos[0].status.should == :PROCESSED
65
67
  payment_infos[0].gateway_error.should == 'Success'
66
68
  payment_infos[0].gateway_error_code.should be_nil
67
69
  find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
68
- find_value_from_properties(payment_infos[0].properties, 'payerName').should_not be_nil
69
- # purchase
70
- payment_infos[1].kb_payment_id.should == kb_payment_id
71
- payment_infos[1].transaction_type.should == :PURCHASE
72
- payment_infos[1].amount.should == @amount
73
- payment_infos[1].currency.should == @currency
74
- payment_infos[1].status.should == :PROCESSED
75
- payment_infos[1].gateway_error.should == 'Success'
76
- payment_infos[1].gateway_error_code.should be_nil
77
- find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
78
70
 
79
71
  # Try a full refund
80
72
  refund_response = @plugin.refund_payment(@pm.kb_account_id, kb_payment_id, SecureRandom.uuid, @pm.kb_payment_method_id, @amount, @currency, [], @call_context)
@@ -84,33 +76,15 @@ module Killbill
84
76
 
85
77
  # Verify GET API
86
78
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, [], @call_context)
87
- payment_infos.size.should == 3
88
- # details_for
89
- payment_infos[0].kb_payment_id.should == kb_payment_id
90
- payment_infos[0].transaction_type.should == :PURCHASE
91
- payment_infos[0].amount.should be_nil
92
- payment_infos[0].currency.should be_nil
93
- payment_infos[0].status.should == :PROCESSED
94
- payment_infos[0].gateway_error.should == 'Success'
95
- payment_infos[0].gateway_error_code.should be_nil
96
- find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
97
- find_value_from_properties(payment_infos[0].properties, 'payerName').should_not be_nil
98
- # purchase
99
- payment_infos[1].kb_payment_id.should == kb_payment_id
100
- payment_infos[1].transaction_type.should == :PURCHASE
79
+ payment_infos.size.should == 2
80
+ # refund
81
+ payment_infos[1].kb_payment_id.should.should == kb_payment_id
82
+ payment_infos[1].transaction_type.should == :REFUND
101
83
  payment_infos[1].amount.should == @amount
102
84
  payment_infos[1].currency.should == @currency
103
85
  payment_infos[1].status.should == :PROCESSED
104
86
  payment_infos[1].gateway_error.should == 'Success'
105
87
  payment_infos[1].gateway_error_code.should be_nil
106
- # refund
107
- payment_infos[2].kb_payment_id.should.should == kb_payment_id
108
- payment_infos[2].transaction_type.should == :REFUND
109
- payment_infos[2].amount.should == @amount
110
- payment_infos[2].currency.should == @currency
111
- payment_infos[2].status.should == :PROCESSED
112
- payment_infos[2].gateway_error.should == 'Success'
113
- payment_infos[2].gateway_error_code.should be_nil
114
88
  end
115
89
 
116
90
  def authorize_capture_and_refund(kb_payment_id, payment_external_key, properties, payment_processor_account_id)
@@ -122,31 +96,22 @@ module Killbill
122
96
  payer_id = find_value_from_properties(payment_response.properties, 'payerId')
123
97
  payer_id.should_not be_nil
124
98
 
99
+ validate_details_for(kb_payment_id, :AUTHORIZE, payer_id)
125
100
  # Verify GET AUTHORIZED PAYMENT
126
101
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
127
- payment_infos.size.should == 2
128
- # details_for
102
+ payment_infos.size.should == 1
103
+ # authorize
129
104
  payment_infos[0].kb_payment_id.should == kb_payment_id
130
105
  payment_infos[0].transaction_type.should == :AUTHORIZE
131
- payment_infos[0].amount.should be_nil
132
- payment_infos[0].currency.should be_nil
106
+ payment_infos[0].amount.should == @amount
107
+ payment_infos[0].currency.should == @currency
133
108
  payment_infos[0].status.should == :PROCESSED
134
109
  payment_infos[0].gateway_error.should == 'Success'
135
110
  payment_infos[0].gateway_error_code.should be_nil
136
111
  find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
137
- find_value_from_properties(payment_infos[0].properties, 'payerName').should_not be_nil
138
- # authorize
139
- payment_infos[1].kb_payment_id.should == kb_payment_id
140
- payment_infos[1].transaction_type.should == :AUTHORIZE
141
- payment_infos[1].amount.should == @amount
142
- payment_infos[1].currency.should == @currency
143
- payment_infos[1].status.should == :PROCESSED
144
- payment_infos[1].gateway_error.should == 'Success'
145
- payment_infos[1].gateway_error_code.should be_nil
146
- find_value_from_properties(payment_infos[1].properties, 'payerId').should == payer_id
147
- find_value_from_properties(payment_infos[1].properties, 'paymentInfoPaymentStatus').should == 'Pending'
148
- find_value_from_properties(payment_infos[1].properties, 'paymentInfoPendingReason').should == 'authorization'
149
- find_value_from_properties(payment_infos[1].properties, 'payment_processor_account_id').should == payment_processor_account_id
112
+ find_value_from_properties(payment_infos[0].properties, 'paymentInfoPaymentStatus').should == 'Pending'
113
+ find_value_from_properties(payment_infos[0].properties, 'paymentInfoPendingReason').should == 'authorization'
114
+ find_value_from_properties(payment_infos[0].properties, 'payment_processor_account_id').should == payment_processor_account_id
150
115
 
151
116
  # Trigger the capture
152
117
  payment_response = @plugin.capture_payment(@pm.kb_account_id, kb_payment_id, payment_external_key, @pm.kb_payment_method_id, @amount, @currency, properties, @call_context)
@@ -157,36 +122,17 @@ module Killbill
157
122
  # Verify GET CAPTURED PAYMENT
158
123
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
159
124
  # Two expected transactions: one auth and one capture
160
- payment_infos.size.should == 3
161
- # details_for
162
- payment_infos[0].kb_payment_id.should == kb_payment_id
163
- payment_infos[0].transaction_type.should == :AUTHORIZE
164
- payment_infos[0].amount.should be_nil
165
- payment_infos[0].currency.should be_nil
166
- payment_infos[0].status.should == :PROCESSED
167
- payment_infos[0].gateway_error.should == 'Success'
168
- payment_infos[0].gateway_error_code.should be_nil
169
- find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
170
- find_value_from_properties(payment_infos[0].properties, 'payerName').should_not be_nil
171
- # authorize
125
+ payment_infos.size.should == 2
126
+ # capture
172
127
  payment_infos[1].kb_payment_id.should == kb_payment_id
173
- payment_infos[1].transaction_type.should == :AUTHORIZE
128
+ payment_infos[1].transaction_type.should == :CAPTURE
174
129
  payment_infos[1].amount.should == @amount
175
130
  payment_infos[1].currency.should == @currency
176
131
  payment_infos[1].status.should == :PROCESSED
177
132
  payment_infos[1].gateway_error.should == 'Success'
178
133
  payment_infos[1].gateway_error_code.should be_nil
134
+ find_value_from_properties(payment_infos[1].properties, 'paymentInfoPaymentStatus').should == 'Completed'
179
135
  find_value_from_properties(payment_infos[1].properties, 'payment_processor_account_id').should == payment_processor_account_id
180
- #capture
181
- payment_infos[2].kb_payment_id.should == kb_payment_id
182
- payment_infos[2].transaction_type.should == :CAPTURE
183
- payment_infos[2].amount.should == @amount
184
- payment_infos[2].currency.should == @currency
185
- payment_infos[2].status.should == :PROCESSED
186
- payment_infos[2].gateway_error.should == 'Success'
187
- payment_infos[2].gateway_error_code.should be_nil
188
- find_value_from_properties(payment_infos[2].properties, 'paymentInfoPaymentStatus').should == 'Completed'
189
- find_value_from_properties(payment_infos[2].properties, 'payment_processor_account_id').should == payment_processor_account_id
190
136
 
191
137
  # Try a full refund
192
138
  refund_response = @plugin.refund_payment(@pm.kb_account_id, kb_payment_id, SecureRandom.uuid, @pm.kb_payment_method_id, @amount, @currency, [], @call_context)
@@ -196,44 +142,16 @@ module Killbill
196
142
 
197
143
  # Verify GET API
198
144
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
199
- payment_infos.size.should == 4
200
- # details_for
201
- payment_infos[0].kb_payment_id.should == kb_payment_id
202
- payment_infos[0].transaction_type.should == :AUTHORIZE
203
- payment_infos[0].amount.should be_nil
204
- payment_infos[0].currency.should be_nil
205
- payment_infos[0].status.should == :PROCESSED
206
- payment_infos[0].gateway_error.should == 'Success'
207
- payment_infos[0].gateway_error_code.should be_nil
208
- find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
209
- find_value_from_properties(payment_infos[0].properties, 'payerName').should_not be_nil
210
- # authorize
211
- payment_infos[1].kb_payment_id.should == kb_payment_id
212
- payment_infos[1].transaction_type.should == :AUTHORIZE
213
- payment_infos[1].amount.should == @amount
214
- payment_infos[1].currency.should == @currency
215
- payment_infos[1].status.should == :PROCESSED
216
- payment_infos[1].gateway_error.should == 'Success'
217
- payment_infos[1].gateway_error_code.should be_nil
218
- find_value_from_properties(payment_infos[1].properties, 'payment_processor_account_id').should == payment_processor_account_id
219
- # capture
220
- payment_infos[2].kb_payment_id.should == kb_payment_id
221
- payment_infos[2].transaction_type.should == :CAPTURE
145
+ payment_infos.size.should == 3
146
+ # refund
147
+ payment_infos[2].kb_payment_id.should.should == kb_payment_id
148
+ payment_infos[2].transaction_type.should == :REFUND
222
149
  payment_infos[2].amount.should == @amount
223
150
  payment_infos[2].currency.should == @currency
224
151
  payment_infos[2].status.should == :PROCESSED
225
152
  payment_infos[2].gateway_error.should == 'Success'
226
153
  payment_infos[2].gateway_error_code.should be_nil
227
154
  find_value_from_properties(payment_infos[2].properties, 'payment_processor_account_id').should == payment_processor_account_id
228
- # refund
229
- payment_infos[3].kb_payment_id.should.should == kb_payment_id
230
- payment_infos[3].transaction_type.should == :REFUND
231
- payment_infos[3].amount.should == @amount
232
- payment_infos[3].currency.should == @currency
233
- payment_infos[3].status.should == :PROCESSED
234
- payment_infos[3].gateway_error.should == 'Success'
235
- payment_infos[3].gateway_error_code.should be_nil
236
- find_value_from_properties(payment_infos[3].properties, 'payment_processor_account_id').should == payment_processor_account_id
237
155
  end
238
156
 
239
157
  def authorize_and_double_capture(kb_payment_id, payment_external_key, properties)
@@ -245,26 +163,17 @@ module Killbill
245
163
  payer_id = find_value_from_properties(payment_response.properties, 'payerId')
246
164
  payer_id.should_not be_nil
247
165
 
166
+ validate_details_for(kb_payment_id, :AUTHORIZE, payer_id)
248
167
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
249
- payment_infos.size.should == 2
250
- # details_for
168
+ payment_infos.size.should == 1
169
+ # autorize
251
170
  payment_infos[0].kb_payment_id.should == kb_payment_id
252
171
  payment_infos[0].transaction_type.should == :AUTHORIZE
253
- payment_infos[0].amount.should be_nil
254
- payment_infos[0].currency.should be_nil
172
+ payment_infos[0].amount.should == @amount
173
+ payment_infos[0].currency.should == @currency
255
174
  payment_infos[0].status.should == :PROCESSED
256
175
  payment_infos[0].gateway_error.should == 'Success'
257
176
  payment_infos[0].gateway_error_code.should be_nil
258
- find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
259
- find_value_from_properties(payment_infos[0].properties, 'payerName').should_not be_nil
260
- # autorize
261
- payment_infos[1].kb_payment_id.should == kb_payment_id
262
- payment_infos[1].transaction_type.should == :AUTHORIZE
263
- payment_infos[1].amount.should == @amount
264
- payment_infos[1].currency.should == @currency
265
- payment_infos[1].status.should == :PROCESSED
266
- payment_infos[1].gateway_error.should == 'Success'
267
- payment_infos[1].gateway_error_code.should be_nil
268
177
 
269
178
  # Trigger the capture
270
179
  payment_response = @plugin.capture_payment(@pm.kb_account_id, kb_payment_id, payment_external_key, @pm.kb_payment_method_id, @amount, @currency, properties, @call_context)
@@ -273,33 +182,15 @@ module Killbill
273
182
  payment_response.transaction_type.should == :CAPTURE
274
183
 
275
184
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
276
- payment_infos.size.should == 3
277
- # details_for
278
- payment_infos[0].kb_payment_id.should == kb_payment_id
279
- payment_infos[0].transaction_type.should == :AUTHORIZE
280
- payment_infos[0].amount.should be_nil
281
- payment_infos[0].currency.should be_nil
282
- payment_infos[0].status.should == :PROCESSED
283
- payment_infos[0].gateway_error.should == 'Success'
284
- payment_infos[0].gateway_error_code.should be_nil
285
- find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
286
- find_value_from_properties(payment_infos[0].properties, 'payerName').should_not be_nil
287
- # autorize
185
+ payment_infos.size.should == 2
186
+ # capture
288
187
  payment_infos[1].kb_payment_id.should == kb_payment_id
289
- payment_infos[1].transaction_type.should == :AUTHORIZE
188
+ payment_infos[1].transaction_type.should == :CAPTURE
290
189
  payment_infos[1].amount.should == @amount
291
190
  payment_infos[1].currency.should == @currency
292
191
  payment_infos[1].status.should == :PROCESSED
293
192
  payment_infos[1].gateway_error.should == 'Success'
294
193
  payment_infos[1].gateway_error_code.should be_nil
295
- # capture
296
- payment_infos[2].kb_payment_id.should == kb_payment_id
297
- payment_infos[2].transaction_type.should == :CAPTURE
298
- payment_infos[2].amount.should == @amount
299
- payment_infos[2].currency.should == @currency
300
- payment_infos[2].status.should == :PROCESSED
301
- payment_infos[2].gateway_error.should == 'Success'
302
- payment_infos[2].gateway_error_code.should be_nil
303
194
 
304
195
  # Trigger a capture again with full amount
305
196
  payment_response = @plugin.capture_payment(@pm.kb_account_id, kb_payment_id, payment_external_key, @pm.kb_payment_method_id, @amount, @currency, properties, @call_context)
@@ -308,41 +199,15 @@ module Killbill
308
199
  payment_response.transaction_type.should == :CAPTURE
309
200
 
310
201
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
311
- payment_infos.size.should == 4
312
- # details_for
313
- payment_infos[0].kb_payment_id.should == kb_payment_id
314
- payment_infos[0].transaction_type.should == :AUTHORIZE
315
- payment_infos[0].amount.should be_nil
316
- payment_infos[0].currency.should be_nil
317
- payment_infos[0].status.should == :PROCESSED
318
- payment_infos[0].gateway_error.should == 'Success'
319
- payment_infos[0].gateway_error_code.should be_nil
320
- find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
321
- find_value_from_properties(payment_infos[0].properties, 'payerName').should_not be_nil
322
- # authorize
323
- payment_infos[1].kb_payment_id.should == kb_payment_id
324
- payment_infos[1].transaction_type.should == :AUTHORIZE
325
- payment_infos[1].amount.should == @amount
326
- payment_infos[1].currency.should == @currency
327
- payment_infos[1].status.should == :PROCESSED
328
- payment_infos[1].gateway_error.should == 'Success'
329
- payment_infos[1].gateway_error_code.should be_nil
330
- # capture
331
- payment_infos[2].kb_payment_id.should == kb_payment_id
332
- payment_infos[2].transaction_type.should == :CAPTURE
333
- payment_infos[2].amount.should == @amount
334
- payment_infos[2].currency.should == @currency
335
- payment_infos[2].status.should == :PROCESSED
336
- payment_infos[2].gateway_error.should == 'Success'
337
- payment_infos[2].gateway_error_code.should be_nil
202
+ payment_infos.size.should == 3
338
203
  # capture again
339
- payment_infos[3].kb_payment_id.should.should == kb_payment_id
340
- payment_infos[3].transaction_type.should == :CAPTURE
341
- payment_infos[3].amount.should be_nil
342
- payment_infos[3].currency.should be_nil
343
- payment_infos[3].status.should == :ERROR
344
- payment_infos[3].gateway_error.should == 'Authorization has already been completed.'
345
- payment_infos[3].gateway_error_code.should == "10602"
204
+ payment_infos[2].kb_payment_id.should.should == kb_payment_id
205
+ payment_infos[2].transaction_type.should == :CAPTURE
206
+ payment_infos[2].amount.should be_nil
207
+ payment_infos[2].currency.should be_nil
208
+ payment_infos[2].status.should == :ERROR
209
+ payment_infos[2].gateway_error.should == 'Authorization has already been completed.'
210
+ payment_infos[2].gateway_error_code.should == "10602"
346
211
  end
347
212
 
348
213
  def authorize_and_void(kb_payment_id, payment_external_key, properties, payment_processor_account_id)
@@ -354,28 +219,19 @@ module Killbill
354
219
  payer_id = find_value_from_properties(payment_response.properties, 'payerId')
355
220
  payer_id.should_not be_nil
356
221
 
222
+ validate_details_for(kb_payment_id, :AUTHORIZE, payer_id)
357
223
  # Verify get_payment_info
358
224
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
359
- payment_infos.size.should == 2
360
- # details_for
225
+ payment_infos.size.should == 1
226
+ # authorize
361
227
  payment_infos[0].kb_payment_id.should == kb_payment_id
362
228
  payment_infos[0].transaction_type.should == :AUTHORIZE
363
- payment_infos[0].amount.should be_nil
364
- payment_infos[0].currency.should be_nil
229
+ payment_infos[0].amount.should == @amount
230
+ payment_infos[0].currency.should == @currency
365
231
  payment_infos[0].status.should == :PROCESSED
366
232
  payment_infos[0].gateway_error.should == 'Success'
367
233
  payment_infos[0].gateway_error_code.should be_nil
368
- find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
369
- find_value_from_properties(payment_infos[0].properties, 'payerName').should_not be_nil
370
- # authorize
371
- payment_infos[1].kb_payment_id.should == kb_payment_id
372
- payment_infos[1].transaction_type.should == :AUTHORIZE
373
- payment_infos[1].amount.should == @amount
374
- payment_infos[1].currency.should == @currency
375
- payment_infos[1].status.should == :PROCESSED
376
- payment_infos[1].gateway_error.should == 'Success'
377
- payment_infos[1].gateway_error_code.should be_nil
378
- find_value_from_properties(payment_infos[1].properties, 'payment_processor_account_id').should == payment_processor_account_id
234
+ find_value_from_properties(payment_infos[0].properties, 'payment_processor_account_id').should == payment_processor_account_id
379
235
 
380
236
  # Trigger the void
381
237
  payment_response = @plugin.void_payment(@pm.kb_account_id, kb_payment_id, payment_external_key, @pm.kb_payment_method_id, properties, @call_context)
@@ -385,33 +241,14 @@ module Killbill
385
241
  # Verify get_payment_info
386
242
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
387
243
  # Two expected transactions: one auth and one capture, plus the details call
388
- payment_infos.size.should == 3
389
- # details_for
390
- payment_infos[0].kb_payment_id.should == kb_payment_id
391
- payment_infos[0].transaction_type.should == :AUTHORIZE
392
- payment_infos[0].amount.should be_nil
393
- payment_infos[0].currency.should be_nil
394
- payment_infos[0].status.should == :PROCESSED
395
- payment_infos[0].gateway_error.should == 'Success'
396
- payment_infos[0].gateway_error_code.should be_nil
397
- find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
398
- find_value_from_properties(payment_infos[0].properties, 'payerName').should_not be_nil
399
- # authorize
244
+ payment_infos.size.should == 2
245
+ # void
400
246
  payment_infos[1].kb_payment_id.should == kb_payment_id
401
- payment_infos[1].transaction_type.should == :AUTHORIZE
402
- payment_infos[1].amount.should == @amount
403
- payment_infos[1].currency.should == @currency
247
+ payment_infos[1].transaction_type.should == :VOID
404
248
  payment_infos[1].status.should == :PROCESSED
405
249
  payment_infos[1].gateway_error.should == 'Success'
406
250
  payment_infos[1].gateway_error_code.should be_nil
407
251
  find_value_from_properties(payment_infos[1].properties, 'payment_processor_account_id').should == payment_processor_account_id
408
- # void
409
- payment_infos[2].kb_payment_id.should == kb_payment_id
410
- payment_infos[2].transaction_type.should == :VOID
411
- payment_infos[2].status.should == :PROCESSED
412
- payment_infos[2].gateway_error.should == 'Success'
413
- payment_infos[2].gateway_error_code.should be_nil
414
- find_value_from_properties(payment_infos[2].properties, 'payment_processor_account_id').should == payment_processor_account_id
415
252
  end
416
253
 
417
254
  def purchase_with_missing_token
@@ -444,15 +281,14 @@ module Killbill
444
281
 
445
282
  # Verify GET API
446
283
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, [], @call_context)
447
- # we might have an extra details_for call
448
- payment_infos.size.should be_in([1, 2])
449
- payment_infos[-1].kb_payment_id.should == kb_payment_id
450
- payment_infos[-1].transaction_type.should == :AUTHORIZE
451
- payment_infos[-1].amount.should be_nil
452
- payment_infos[-1].currency.should be_nil
453
- payment_infos[-1].status.should == status
454
- payment_infos[-1].gateway_error.should == msg
455
- payment_infos[-1].gateway_error_code.should == gateway_error_code
284
+ payment_infos.size.should == 1
285
+ payment_infos[0].kb_payment_id.should == kb_payment_id
286
+ payment_infos[0].transaction_type.should == :AUTHORIZE
287
+ payment_infos[0].amount.should be_nil
288
+ payment_infos[0].currency.should be_nil
289
+ payment_infos[0].status.should == status
290
+ payment_infos[0].gateway_error.should == msg
291
+ payment_infos[0].gateway_error_code.should == gateway_error_code
456
292
  end
457
293
 
458
294
  def failed_purchase(purchase_properties, status, msg, gateway_error_code=nil)
@@ -466,15 +302,14 @@ module Killbill
466
302
  # Verify GET API
467
303
  payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, [], @call_context)
468
304
  token = find_value_from_properties(purchase_properties, 'token')
469
- # we might have an extra details_for call
470
- payment_infos.size.should be_in([1, 2])
471
- payment_infos[-1].kb_payment_id.should == kb_payment_id
472
- payment_infos[-1].transaction_type.should == :PURCHASE
473
- payment_infos[-1].amount.should be_nil
474
- payment_infos[-1].currency.should be_nil
475
- payment_infos[-1].status.should == status
476
- payment_infos[-1].gateway_error.should == msg
477
- payment_infos[-1].gateway_error_code.should == gateway_error_code
305
+ payment_infos.size.should == 1
306
+ payment_infos[0].kb_payment_id.should == kb_payment_id
307
+ payment_infos[0].transaction_type.should == :PURCHASE
308
+ payment_infos[0].amount.should be_nil
309
+ payment_infos[0].currency.should be_nil
310
+ payment_infos[0].status.should == status
311
+ payment_infos[0].gateway_error.should == msg
312
+ payment_infos[0].gateway_error_code.should == gateway_error_code
478
313
  end
479
314
 
480
315
  private
data/spec/spec_helper.rb CHANGED
@@ -22,6 +22,16 @@ ActiveRecord::Base.establish_connection(
22
22
  # Create the schema
23
23
  require File.expand_path(File.dirname(__FILE__) + '../../db/schema.rb')
24
24
 
25
+
26
+ def validate_details_for(kb_payment_id, transaction_type, payer_id)
27
+ details_for = ::Killbill::PaypalExpress::PaypalExpressResponse.where(:kb_payment_id => kb_payment_id).where(:api_call => :details_for).last
28
+ details_for.message.should == "Success"
29
+ details_for.transaction_type.to_sym.should == transaction_type.to_sym
30
+ details_for.payer_id.should == payer_id
31
+ details_for.payer_name.should_not be_nil
32
+ end
33
+
34
+
25
35
  class PaypalExpressJavaPaymentApi < ::Killbill::Plugin::ActiveMerchant::RSpec::FakeJavaPaymentApi
26
36
 
27
37
  def initialize(plugin)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill-paypal-express
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.2
4
+ version: 5.0.3
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: 2017-03-16 00:00:00.000000000 Z
11
+ date: 2017-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement