killbill-paypal-express 5.0.0 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Jarfile.lock +2 -2
- data/NEWS +5 -0
- data/VERSION +1 -1
- data/db/ddl.sql +3 -1
- data/db/migrate/20161209090000_add_indexes.rb +7 -0
- data/db/schema.rb +2 -0
- data/lib/paypal_express/api.rb +25 -13
- data/lib/paypal_express/application.rb +31 -0
- data/lib/paypal_express/models/response.rb +9 -1
- data/lib/paypal_express/private_api.rb +5 -0
- data/pom.xml +1 -1
- data/spec/fixtures/DoExpressCheckoutPayment-duplicate.xml +54 -0
- data/spec/fixtures/GetExpressCheckoutDetails-success.xml +102 -0
- data/spec/paypal_express/remote/baid_spec.rb +142 -70
- data/spec/paypal_express/remote/hpp_spec.rb +5 -5
- data/spec/paypal_express/remote/hpp_spec_helpers.rb +199 -74
- data/spec/paypal_express/response_spec.rb +79 -0
- metadata +118 -114
@@ -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 ==
|
56
|
+
::Killbill::PaypalExpress::PaypalExpressTransaction.count.should == 5 * 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 ==
|
119
|
+
::Killbill::PaypalExpress::PaypalExpressTransaction.count.should == 5 * 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 ==
|
187
|
+
::Killbill::PaypalExpress::PaypalExpressTransaction.count.should == 5 * 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 authorize and
|
228
|
-
::Killbill::PaypalExpress::PaypalExpressTransaction.count.should ==
|
227
|
+
# Each loop triggers one successful details_for, authorize and void
|
228
|
+
::Killbill::PaypalExpress::PaypalExpressTransaction.count.should == 3 * n
|
229
229
|
::Killbill::PaypalExpress::PaypalExpressResponse.count.should == 9 * n / 2 + 5 * n % 2
|
230
230
|
end
|
231
231
|
|
@@ -55,15 +55,26 @@ module Killbill
|
|
55
55
|
|
56
56
|
# Verify GET API
|
57
57
|
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, [], @call_context)
|
58
|
-
payment_infos.size.should ==
|
58
|
+
payment_infos.size.should == 2
|
59
|
+
# details_for
|
59
60
|
payment_infos[0].kb_payment_id.should == kb_payment_id
|
60
61
|
payment_infos[0].transaction_type.should == :PURCHASE
|
61
|
-
payment_infos[0].amount.should
|
62
|
-
payment_infos[0].currency.should
|
62
|
+
payment_infos[0].amount.should be_nil
|
63
|
+
payment_infos[0].currency.should be_nil
|
63
64
|
payment_infos[0].status.should == :PROCESSED
|
64
65
|
payment_infos[0].gateway_error.should == 'Success'
|
65
66
|
payment_infos[0].gateway_error_code.should be_nil
|
66
67
|
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
|
67
78
|
|
68
79
|
# Try a full refund
|
69
80
|
refund_response = @plugin.refund_payment(@pm.kb_account_id, kb_payment_id, SecureRandom.uuid, @pm.kb_payment_method_id, @amount, @currency, [], @call_context)
|
@@ -73,21 +84,33 @@ module Killbill
|
|
73
84
|
|
74
85
|
# Verify GET API
|
75
86
|
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, [], @call_context)
|
76
|
-
payment_infos.size.should ==
|
87
|
+
payment_infos.size.should == 3
|
88
|
+
# details_for
|
77
89
|
payment_infos[0].kb_payment_id.should == kb_payment_id
|
78
90
|
payment_infos[0].transaction_type.should == :PURCHASE
|
79
|
-
payment_infos[0].amount.should
|
80
|
-
payment_infos[0].currency.should
|
91
|
+
payment_infos[0].amount.should be_nil
|
92
|
+
payment_infos[0].currency.should be_nil
|
81
93
|
payment_infos[0].status.should == :PROCESSED
|
82
94
|
payment_infos[0].gateway_error.should == 'Success'
|
83
95
|
payment_infos[0].gateway_error_code.should be_nil
|
84
|
-
payment_infos[
|
85
|
-
payment_infos[
|
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
|
86
101
|
payment_infos[1].amount.should == @amount
|
87
102
|
payment_infos[1].currency.should == @currency
|
88
103
|
payment_infos[1].status.should == :PROCESSED
|
89
104
|
payment_infos[1].gateway_error.should == 'Success'
|
90
105
|
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
|
91
114
|
end
|
92
115
|
|
93
116
|
def authorize_capture_and_refund(kb_payment_id, payment_external_key, properties, payment_processor_account_id)
|
@@ -101,18 +124,29 @@ module Killbill
|
|
101
124
|
|
102
125
|
# Verify GET AUTHORIZED PAYMENT
|
103
126
|
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
|
104
|
-
payment_infos.size.should ==
|
127
|
+
payment_infos.size.should == 2
|
128
|
+
# details_for
|
105
129
|
payment_infos[0].kb_payment_id.should == kb_payment_id
|
106
130
|
payment_infos[0].transaction_type.should == :AUTHORIZE
|
107
|
-
payment_infos[0].amount.should
|
108
|
-
payment_infos[0].currency.should
|
131
|
+
payment_infos[0].amount.should be_nil
|
132
|
+
payment_infos[0].currency.should be_nil
|
109
133
|
payment_infos[0].status.should == :PROCESSED
|
110
134
|
payment_infos[0].gateway_error.should == 'Success'
|
111
135
|
payment_infos[0].gateway_error_code.should be_nil
|
112
136
|
find_value_from_properties(payment_infos[0].properties, 'payerId').should == payer_id
|
113
|
-
find_value_from_properties(payment_infos[0].properties, '
|
114
|
-
|
115
|
-
|
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
|
116
150
|
|
117
151
|
# Trigger the capture
|
118
152
|
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)
|
@@ -123,24 +157,36 @@ module Killbill
|
|
123
157
|
# Verify GET CAPTURED PAYMENT
|
124
158
|
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
|
125
159
|
# Two expected transactions: one auth and one capture
|
126
|
-
payment_infos.size.should ==
|
160
|
+
payment_infos.size.should == 3
|
161
|
+
# details_for
|
127
162
|
payment_infos[0].kb_payment_id.should == kb_payment_id
|
128
163
|
payment_infos[0].transaction_type.should == :AUTHORIZE
|
129
|
-
payment_infos[0].amount.should
|
130
|
-
payment_infos[0].currency.should
|
164
|
+
payment_infos[0].amount.should be_nil
|
165
|
+
payment_infos[0].currency.should be_nil
|
131
166
|
payment_infos[0].status.should == :PROCESSED
|
132
167
|
payment_infos[0].gateway_error.should == 'Success'
|
133
168
|
payment_infos[0].gateway_error_code.should be_nil
|
134
|
-
find_value_from_properties(payment_infos[0].properties, '
|
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
|
135
172
|
payment_infos[1].kb_payment_id.should == kb_payment_id
|
136
|
-
payment_infos[1].transaction_type.should == :
|
173
|
+
payment_infos[1].transaction_type.should == :AUTHORIZE
|
137
174
|
payment_infos[1].amount.should == @amount
|
138
175
|
payment_infos[1].currency.should == @currency
|
139
176
|
payment_infos[1].status.should == :PROCESSED
|
140
177
|
payment_infos[1].gateway_error.should == 'Success'
|
141
178
|
payment_infos[1].gateway_error_code.should be_nil
|
142
|
-
find_value_from_properties(payment_infos[1].properties, 'paymentInfoPaymentStatus').should == 'Completed'
|
143
179
|
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
|
144
190
|
|
145
191
|
# Try a full refund
|
146
192
|
refund_response = @plugin.refund_payment(@pm.kb_account_id, kb_payment_id, SecureRandom.uuid, @pm.kb_payment_method_id, @amount, @currency, [], @call_context)
|
@@ -150,31 +196,44 @@ module Killbill
|
|
150
196
|
|
151
197
|
# Verify GET API
|
152
198
|
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
|
153
|
-
payment_infos.size.should ==
|
199
|
+
payment_infos.size.should == 4
|
200
|
+
# details_for
|
154
201
|
payment_infos[0].kb_payment_id.should == kb_payment_id
|
155
202
|
payment_infos[0].transaction_type.should == :AUTHORIZE
|
156
|
-
payment_infos[0].amount.should
|
157
|
-
payment_infos[0].currency.should
|
203
|
+
payment_infos[0].amount.should be_nil
|
204
|
+
payment_infos[0].currency.should be_nil
|
158
205
|
payment_infos[0].status.should == :PROCESSED
|
159
206
|
payment_infos[0].gateway_error.should == 'Success'
|
160
207
|
payment_infos[0].gateway_error_code.should be_nil
|
161
|
-
find_value_from_properties(payment_infos[0].properties, '
|
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
|
162
211
|
payment_infos[1].kb_payment_id.should == kb_payment_id
|
163
|
-
payment_infos[1].transaction_type.should == :
|
212
|
+
payment_infos[1].transaction_type.should == :AUTHORIZE
|
164
213
|
payment_infos[1].amount.should == @amount
|
165
214
|
payment_infos[1].currency.should == @currency
|
166
215
|
payment_infos[1].status.should == :PROCESSED
|
167
216
|
payment_infos[1].gateway_error.should == 'Success'
|
168
217
|
payment_infos[1].gateway_error_code.should be_nil
|
169
218
|
find_value_from_properties(payment_infos[1].properties, 'payment_processor_account_id').should == payment_processor_account_id
|
170
|
-
|
171
|
-
payment_infos[2].
|
219
|
+
# capture
|
220
|
+
payment_infos[2].kb_payment_id.should == kb_payment_id
|
221
|
+
payment_infos[2].transaction_type.should == :CAPTURE
|
172
222
|
payment_infos[2].amount.should == @amount
|
173
223
|
payment_infos[2].currency.should == @currency
|
174
224
|
payment_infos[2].status.should == :PROCESSED
|
175
225
|
payment_infos[2].gateway_error.should == 'Success'
|
176
226
|
payment_infos[2].gateway_error_code.should be_nil
|
177
227
|
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
|
178
237
|
end
|
179
238
|
|
180
239
|
def authorize_and_double_capture(kb_payment_id, payment_external_key, properties)
|
@@ -183,16 +242,29 @@ module Killbill
|
|
183
242
|
payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
|
184
243
|
payment_response.amount.should == @amount
|
185
244
|
payment_response.transaction_type.should == :AUTHORIZE
|
245
|
+
payer_id = find_value_from_properties(payment_response.properties, 'payerId')
|
246
|
+
payer_id.should_not be_nil
|
186
247
|
|
187
248
|
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
|
188
|
-
payment_infos.size.should ==
|
249
|
+
payment_infos.size.should == 2
|
250
|
+
# details_for
|
189
251
|
payment_infos[0].kb_payment_id.should == kb_payment_id
|
190
252
|
payment_infos[0].transaction_type.should == :AUTHORIZE
|
191
|
-
payment_infos[0].amount.should
|
192
|
-
payment_infos[0].currency.should
|
253
|
+
payment_infos[0].amount.should be_nil
|
254
|
+
payment_infos[0].currency.should be_nil
|
193
255
|
payment_infos[0].status.should == :PROCESSED
|
194
256
|
payment_infos[0].gateway_error.should == 'Success'
|
195
257
|
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
|
196
268
|
|
197
269
|
# Trigger the capture
|
198
270
|
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)
|
@@ -201,21 +273,33 @@ module Killbill
|
|
201
273
|
payment_response.transaction_type.should == :CAPTURE
|
202
274
|
|
203
275
|
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
|
204
|
-
payment_infos.size.should ==
|
276
|
+
payment_infos.size.should == 3
|
277
|
+
# details_for
|
205
278
|
payment_infos[0].kb_payment_id.should == kb_payment_id
|
206
279
|
payment_infos[0].transaction_type.should == :AUTHORIZE
|
207
|
-
payment_infos[0].amount.should
|
208
|
-
payment_infos[0].currency.should
|
280
|
+
payment_infos[0].amount.should be_nil
|
281
|
+
payment_infos[0].currency.should be_nil
|
209
282
|
payment_infos[0].status.should == :PROCESSED
|
210
283
|
payment_infos[0].gateway_error.should == 'Success'
|
211
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
|
212
288
|
payment_infos[1].kb_payment_id.should == kb_payment_id
|
213
|
-
payment_infos[1].transaction_type.should == :
|
289
|
+
payment_infos[1].transaction_type.should == :AUTHORIZE
|
214
290
|
payment_infos[1].amount.should == @amount
|
215
291
|
payment_infos[1].currency.should == @currency
|
216
292
|
payment_infos[1].status.should == :PROCESSED
|
217
293
|
payment_infos[1].gateway_error.should == 'Success'
|
218
294
|
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
|
219
303
|
|
220
304
|
# Trigger a capture again with full amount
|
221
305
|
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)
|
@@ -224,28 +308,41 @@ module Killbill
|
|
224
308
|
payment_response.transaction_type.should == :CAPTURE
|
225
309
|
|
226
310
|
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
|
227
|
-
payment_infos.size.should ==
|
311
|
+
payment_infos.size.should == 4
|
312
|
+
# details_for
|
228
313
|
payment_infos[0].kb_payment_id.should == kb_payment_id
|
229
314
|
payment_infos[0].transaction_type.should == :AUTHORIZE
|
230
|
-
payment_infos[0].amount.should
|
231
|
-
payment_infos[0].currency.should
|
315
|
+
payment_infos[0].amount.should be_nil
|
316
|
+
payment_infos[0].currency.should be_nil
|
232
317
|
payment_infos[0].status.should == :PROCESSED
|
233
318
|
payment_infos[0].gateway_error.should == 'Success'
|
234
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
|
235
323
|
payment_infos[1].kb_payment_id.should == kb_payment_id
|
236
|
-
payment_infos[1].transaction_type.should == :
|
324
|
+
payment_infos[1].transaction_type.should == :AUTHORIZE
|
237
325
|
payment_infos[1].amount.should == @amount
|
238
326
|
payment_infos[1].currency.should == @currency
|
239
327
|
payment_infos[1].status.should == :PROCESSED
|
240
328
|
payment_infos[1].gateway_error.should == 'Success'
|
241
329
|
payment_infos[1].gateway_error_code.should be_nil
|
242
|
-
|
330
|
+
# capture
|
331
|
+
payment_infos[2].kb_payment_id.should == kb_payment_id
|
243
332
|
payment_infos[2].transaction_type.should == :CAPTURE
|
244
|
-
payment_infos[2].amount.should
|
245
|
-
payment_infos[2].currency.should
|
246
|
-
payment_infos[2].status.should == :
|
247
|
-
payment_infos[2].gateway_error.should == '
|
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'
|
248
337
|
payment_infos[2].gateway_error_code.should be_nil
|
338
|
+
# 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"
|
249
346
|
end
|
250
347
|
|
251
348
|
def authorize_and_void(kb_payment_id, payment_external_key, properties, payment_processor_account_id)
|
@@ -254,18 +351,31 @@ module Killbill
|
|
254
351
|
payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
|
255
352
|
payment_response.amount.should == @amount
|
256
353
|
payment_response.transaction_type.should == :AUTHORIZE
|
354
|
+
payer_id = find_value_from_properties(payment_response.properties, 'payerId')
|
355
|
+
payer_id.should_not be_nil
|
257
356
|
|
258
357
|
# Verify get_payment_info
|
259
358
|
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
|
260
|
-
payment_infos.size.should ==
|
359
|
+
payment_infos.size.should == 2
|
360
|
+
# details_for
|
261
361
|
payment_infos[0].kb_payment_id.should == kb_payment_id
|
262
362
|
payment_infos[0].transaction_type.should == :AUTHORIZE
|
263
|
-
payment_infos[0].amount.should
|
264
|
-
payment_infos[0].currency.should
|
363
|
+
payment_infos[0].amount.should be_nil
|
364
|
+
payment_infos[0].currency.should be_nil
|
265
365
|
payment_infos[0].status.should == :PROCESSED
|
266
366
|
payment_infos[0].gateway_error.should == 'Success'
|
267
367
|
payment_infos[0].gateway_error_code.should be_nil
|
268
|
-
find_value_from_properties(payment_infos[0].properties, '
|
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
|
269
379
|
|
270
380
|
# Trigger the void
|
271
381
|
payment_response = @plugin.void_payment(@pm.kb_account_id, kb_payment_id, payment_external_key, @pm.kb_payment_method_id, properties, @call_context)
|
@@ -274,42 +384,54 @@ module Killbill
|
|
274
384
|
|
275
385
|
# Verify get_payment_info
|
276
386
|
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
|
277
|
-
# Two expected transactions: one auth and one capture
|
278
|
-
payment_infos.size.should ==
|
387
|
+
# Two expected transactions: one auth and one capture, plus the details call
|
388
|
+
payment_infos.size.should == 3
|
389
|
+
# details_for
|
279
390
|
payment_infos[0].kb_payment_id.should == kb_payment_id
|
280
391
|
payment_infos[0].transaction_type.should == :AUTHORIZE
|
281
|
-
payment_infos[0].amount.should
|
282
|
-
payment_infos[0].currency.should
|
392
|
+
payment_infos[0].amount.should be_nil
|
393
|
+
payment_infos[0].currency.should be_nil
|
283
394
|
payment_infos[0].status.should == :PROCESSED
|
284
395
|
payment_infos[0].gateway_error.should == 'Success'
|
285
396
|
payment_infos[0].gateway_error_code.should be_nil
|
286
|
-
find_value_from_properties(payment_infos[0].properties, '
|
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
|
287
400
|
payment_infos[1].kb_payment_id.should == kb_payment_id
|
288
|
-
payment_infos[1].transaction_type.should == :
|
401
|
+
payment_infos[1].transaction_type.should == :AUTHORIZE
|
402
|
+
payment_infos[1].amount.should == @amount
|
403
|
+
payment_infos[1].currency.should == @currency
|
289
404
|
payment_infos[1].status.should == :PROCESSED
|
290
405
|
payment_infos[1].gateway_error.should == 'Success'
|
291
406
|
payment_infos[1].gateway_error_code.should be_nil
|
292
407
|
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
|
293
415
|
end
|
294
416
|
|
295
417
|
def purchase_with_missing_token
|
296
|
-
failed_purchase([], :CANCELED, 'Could not
|
418
|
+
failed_purchase([], :CANCELED, 'Could not retrieve the payer info: the token is missing', 'RuntimeError')
|
297
419
|
end
|
298
420
|
|
299
421
|
def authorize_with_missing_token
|
300
|
-
failed_authorize([], :CANCELED, 'Could not
|
422
|
+
failed_authorize([], :CANCELED, 'Could not retrieve the payer info: the token is missing', 'RuntimeError')
|
301
423
|
end
|
302
424
|
|
303
425
|
def purchase_with_invalid_token(purchase_properties)
|
304
|
-
failed_purchase(purchase_properties, :CANCELED, "Could not
|
426
|
+
failed_purchase(purchase_properties, :CANCELED, "Could not retrieve the payer info for token #{properties_to_hash(purchase_properties)[:token]}", 'RuntimeError')
|
305
427
|
end
|
306
428
|
|
307
429
|
def authorize_with_invalid_token(authorize_properties)
|
308
|
-
failed_authorize(authorize_properties, :CANCELED, "Could not
|
430
|
+
failed_authorize(authorize_properties, :CANCELED, "Could not retrieve the payer info for token #{properties_to_hash(authorize_properties)[:token]}", 'RuntimeError')
|
309
431
|
end
|
310
432
|
|
311
433
|
def subsequent_purchase(purchase_properties)
|
312
|
-
failed_purchase(purchase_properties, :ERROR, 'A successful transaction has already been completed for this token.')
|
434
|
+
failed_purchase(purchase_properties, :ERROR, 'A successful transaction has already been completed for this token.', '11607')
|
313
435
|
end
|
314
436
|
|
315
437
|
def failed_authorize(authorize_properties, status, msg, gateway_error_code=nil)
|
@@ -322,14 +444,15 @@ module Killbill
|
|
322
444
|
|
323
445
|
# Verify GET API
|
324
446
|
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, [], @call_context)
|
325
|
-
|
326
|
-
payment_infos
|
327
|
-
payment_infos[
|
328
|
-
payment_infos[
|
329
|
-
payment_infos[
|
330
|
-
payment_infos[
|
331
|
-
payment_infos[
|
332
|
-
payment_infos[
|
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
|
333
456
|
end
|
334
457
|
|
335
458
|
def failed_purchase(purchase_properties, status, msg, gateway_error_code=nil)
|
@@ -342,14 +465,16 @@ module Killbill
|
|
342
465
|
|
343
466
|
# Verify GET API
|
344
467
|
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, [], @call_context)
|
345
|
-
|
346
|
-
|
347
|
-
payment_infos
|
348
|
-
payment_infos[
|
349
|
-
payment_infos[
|
350
|
-
payment_infos[
|
351
|
-
payment_infos[
|
352
|
-
payment_infos[
|
468
|
+
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
|
353
478
|
end
|
354
479
|
|
355
480
|
private
|