killbill-paypal-express 4.1.2 → 4.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +11 -2
- data/NEWS +4 -0
- data/README.md +2 -1
- data/VERSION +1 -1
- data/killbill-paypal-express.gemspec +1 -0
- data/lib/paypal_express/api.rb +142 -103
- data/lib/paypal_express/models/response.rb +10 -0
- data/pom.xml +1 -1
- data/spec/paypal_express/remote/baid_spec.rb +52 -56
- data/spec/paypal_express/remote/baid_spec_helpers.rb +55 -0
- data/spec/paypal_express/remote/browser_helpers.rb +72 -0
- data/spec/paypal_express/remote/build_plugin_helpers.rb +33 -0
- data/spec/paypal_express/remote/hpp_spec.rb +189 -123
- data/spec/paypal_express/remote/hpp_spec_helpers.rb +364 -0
- data/spec/spec_helper.rb +14 -1
- metadata +20 -2
@@ -0,0 +1,364 @@
|
|
1
|
+
require_relative 'browser_helpers'
|
2
|
+
|
3
|
+
module Killbill
|
4
|
+
module PaypalExpress
|
5
|
+
module HppSpecHelpers
|
6
|
+
|
7
|
+
include ::Killbill::PaypalExpress::BrowserHelpers
|
8
|
+
|
9
|
+
def hpp_setup
|
10
|
+
@call_context = build_call_context
|
11
|
+
@amount = BigDecimal.new('100')
|
12
|
+
@currency = 'USD'
|
13
|
+
@form_fields = @plugin.hash_to_properties(
|
14
|
+
:order_id => '1234',
|
15
|
+
:amount => @amount,
|
16
|
+
:currency => @currency
|
17
|
+
)
|
18
|
+
kb_account_id = SecureRandom.uuid
|
19
|
+
create_kb_account(kb_account_id, @plugin.kb_apis.proxied_services[:account_user_api])
|
20
|
+
@pm = create_payment_method(::Killbill::PaypalExpress::PaypalExpressPaymentMethod, kb_account_id, @call_context.tenant_id)
|
21
|
+
verify_payment_method kb_account_id
|
22
|
+
end
|
23
|
+
|
24
|
+
def validate_form(form)
|
25
|
+
form.kb_account_id.should == @pm.kb_account_id
|
26
|
+
form.form_url.should start_with('https://www.sandbox.paypal.com/cgi-bin/webscr')
|
27
|
+
form.form_method.should == 'GET'
|
28
|
+
end
|
29
|
+
|
30
|
+
def validate_nil_form_property(form, key)
|
31
|
+
key_properties = form.properties.select { |prop| prop.key == key }
|
32
|
+
key_properties.size.should == 0
|
33
|
+
end
|
34
|
+
|
35
|
+
def validate_form_property(form, key, value=nil)
|
36
|
+
key_properties = form.properties.select { |prop| prop.key == key }
|
37
|
+
key_properties.size.should == 1
|
38
|
+
key = key_properties.first.value
|
39
|
+
value.nil? ? key.should_not(be_nil) : key.should == value
|
40
|
+
key
|
41
|
+
end
|
42
|
+
|
43
|
+
def validate_token(form)
|
44
|
+
login_and_confirm form.form_url
|
45
|
+
end
|
46
|
+
|
47
|
+
def purchase_and_refund(kb_payment_id, purchase_payment_external_key, purchase_properties)
|
48
|
+
# Trigger the purchase
|
49
|
+
payment_response = @plugin.purchase_payment(@pm.kb_account_id, kb_payment_id, purchase_payment_external_key, @pm.kb_payment_method_id, @amount, @currency, purchase_properties, @call_context)
|
50
|
+
payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
|
51
|
+
payment_response.amount.should == @amount
|
52
|
+
payment_response.transaction_type.should == :PURCHASE
|
53
|
+
|
54
|
+
# Verify GET API
|
55
|
+
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, [], @call_context)
|
56
|
+
payment_infos.size.should == 1
|
57
|
+
payment_infos[0].kb_payment_id.should == kb_payment_id
|
58
|
+
payment_infos[0].transaction_type.should == :PURCHASE
|
59
|
+
payment_infos[0].amount.should == @amount
|
60
|
+
payment_infos[0].currency.should == @currency
|
61
|
+
payment_infos[0].status.should == :PROCESSED
|
62
|
+
payment_infos[0].gateway_error.should == 'Success'
|
63
|
+
payment_infos[0].gateway_error_code.should be_nil
|
64
|
+
|
65
|
+
# Try a full refund
|
66
|
+
refund_response = @plugin.refund_payment(@pm.kb_account_id, kb_payment_id, SecureRandom.uuid, @pm.kb_payment_method_id, @amount, @currency, [], @call_context)
|
67
|
+
refund_response.status.should eq(:PROCESSED), refund_response.gateway_error
|
68
|
+
refund_response.amount.should == @amount
|
69
|
+
refund_response.transaction_type.should == :REFUND
|
70
|
+
|
71
|
+
# Verify GET API
|
72
|
+
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, [], @call_context)
|
73
|
+
payment_infos.size.should == 2
|
74
|
+
payment_infos[0].kb_payment_id.should == kb_payment_id
|
75
|
+
payment_infos[0].transaction_type.should == :PURCHASE
|
76
|
+
payment_infos[0].amount.should == @amount
|
77
|
+
payment_infos[0].currency.should == @currency
|
78
|
+
payment_infos[0].status.should == :PROCESSED
|
79
|
+
payment_infos[0].gateway_error.should == 'Success'
|
80
|
+
payment_infos[0].gateway_error_code.should be_nil
|
81
|
+
payment_infos[1].kb_payment_id.should.should == kb_payment_id
|
82
|
+
payment_infos[1].transaction_type.should == :REFUND
|
83
|
+
payment_infos[1].amount.should == @amount
|
84
|
+
payment_infos[1].currency.should == @currency
|
85
|
+
payment_infos[1].status.should == :PROCESSED
|
86
|
+
payment_infos[1].gateway_error.should == 'Success'
|
87
|
+
payment_infos[1].gateway_error_code.should be_nil
|
88
|
+
end
|
89
|
+
|
90
|
+
def authorize_capture_and_refund(kb_payment_id, payment_external_key, properties, payment_processor_account_id)
|
91
|
+
# Trigger the authorize
|
92
|
+
payment_response = @plugin.authorize_payment(@pm.kb_account_id, kb_payment_id, payment_external_key, @pm.kb_payment_method_id, @amount, @currency, properties, @call_context)
|
93
|
+
payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
|
94
|
+
payment_response.amount.should == @amount
|
95
|
+
payment_response.transaction_type.should == :AUTHORIZE
|
96
|
+
|
97
|
+
# Verify GET AUTHORIZED PAYMENT
|
98
|
+
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
|
99
|
+
payment_infos.size.should == 1
|
100
|
+
payment_infos[0].kb_payment_id.should == kb_payment_id
|
101
|
+
payment_infos[0].transaction_type.should == :AUTHORIZE
|
102
|
+
payment_infos[0].amount.should == @amount
|
103
|
+
payment_infos[0].currency.should == @currency
|
104
|
+
payment_infos[0].status.should == :PROCESSED
|
105
|
+
payment_infos[0].gateway_error.should == 'Success'
|
106
|
+
payment_infos[0].gateway_error_code.should be_nil
|
107
|
+
find_value_from_properties(payment_infos[0].properties, 'paymentInfoPaymentStatus').should == 'Pending'
|
108
|
+
find_value_from_properties(payment_infos[0].properties, 'paymentInfoPendingReason').should == 'authorization'
|
109
|
+
find_value_from_properties(payment_infos[0].properties, 'payment_processor_account_id').should == payment_processor_account_id
|
110
|
+
|
111
|
+
# Trigger the capture
|
112
|
+
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)
|
113
|
+
payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
|
114
|
+
payment_response.amount.should == @amount
|
115
|
+
payment_response.transaction_type.should == :CAPTURE
|
116
|
+
|
117
|
+
# Verify GET CAPTURED PAYMENT
|
118
|
+
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
|
119
|
+
# Two expected transactions: one auth and one capture
|
120
|
+
payment_infos.size.should == 2
|
121
|
+
payment_infos[0].kb_payment_id.should == kb_payment_id
|
122
|
+
payment_infos[0].transaction_type.should == :AUTHORIZE
|
123
|
+
payment_infos[0].amount.should == @amount
|
124
|
+
payment_infos[0].currency.should == @currency
|
125
|
+
payment_infos[0].status.should == :PROCESSED
|
126
|
+
payment_infos[0].gateway_error.should == 'Success'
|
127
|
+
payment_infos[0].gateway_error_code.should be_nil
|
128
|
+
find_value_from_properties(payment_infos[0].properties, 'payment_processor_account_id').should == payment_processor_account_id
|
129
|
+
payment_infos[1].kb_payment_id.should == kb_payment_id
|
130
|
+
payment_infos[1].transaction_type.should == :CAPTURE
|
131
|
+
payment_infos[1].amount.should == @amount
|
132
|
+
payment_infos[1].currency.should == @currency
|
133
|
+
payment_infos[1].status.should == :PROCESSED
|
134
|
+
payment_infos[1].gateway_error.should == 'Success'
|
135
|
+
payment_infos[1].gateway_error_code.should be_nil
|
136
|
+
find_value_from_properties(payment_infos[1].properties, 'paymentInfoPaymentStatus').should == 'Completed'
|
137
|
+
find_value_from_properties(payment_infos[1].properties, 'payment_processor_account_id').should == payment_processor_account_id
|
138
|
+
|
139
|
+
# Try a full refund
|
140
|
+
refund_response = @plugin.refund_payment(@pm.kb_account_id, kb_payment_id, SecureRandom.uuid, @pm.kb_payment_method_id, @amount, @currency, [], @call_context)
|
141
|
+
refund_response.status.should eq(:PROCESSED), refund_response.gateway_error
|
142
|
+
refund_response.amount.should == @amount
|
143
|
+
refund_response.transaction_type.should == :REFUND
|
144
|
+
|
145
|
+
# Verify GET API
|
146
|
+
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
|
147
|
+
payment_infos.size.should == 3
|
148
|
+
payment_infos[0].kb_payment_id.should == kb_payment_id
|
149
|
+
payment_infos[0].transaction_type.should == :AUTHORIZE
|
150
|
+
payment_infos[0].amount.should == @amount
|
151
|
+
payment_infos[0].currency.should == @currency
|
152
|
+
payment_infos[0].status.should == :PROCESSED
|
153
|
+
payment_infos[0].gateway_error.should == 'Success'
|
154
|
+
payment_infos[0].gateway_error_code.should be_nil
|
155
|
+
find_value_from_properties(payment_infos[0].properties, 'payment_processor_account_id').should == payment_processor_account_id
|
156
|
+
payment_infos[1].kb_payment_id.should == kb_payment_id
|
157
|
+
payment_infos[1].transaction_type.should == :CAPTURE
|
158
|
+
payment_infos[1].amount.should == @amount
|
159
|
+
payment_infos[1].currency.should == @currency
|
160
|
+
payment_infos[1].status.should == :PROCESSED
|
161
|
+
payment_infos[1].gateway_error.should == 'Success'
|
162
|
+
payment_infos[1].gateway_error_code.should be_nil
|
163
|
+
find_value_from_properties(payment_infos[1].properties, 'payment_processor_account_id').should == payment_processor_account_id
|
164
|
+
payment_infos[2].kb_payment_id.should.should == kb_payment_id
|
165
|
+
payment_infos[2].transaction_type.should == :REFUND
|
166
|
+
payment_infos[2].amount.should == @amount
|
167
|
+
payment_infos[2].currency.should == @currency
|
168
|
+
payment_infos[2].status.should == :PROCESSED
|
169
|
+
payment_infos[2].gateway_error.should == 'Success'
|
170
|
+
payment_infos[2].gateway_error_code.should be_nil
|
171
|
+
find_value_from_properties(payment_infos[2].properties, 'payment_processor_account_id').should == payment_processor_account_id
|
172
|
+
end
|
173
|
+
|
174
|
+
def authorize_and_double_capture(kb_payment_id, payment_external_key, properties)
|
175
|
+
# Trigger the authorize
|
176
|
+
payment_response = @plugin.authorize_payment(@pm.kb_account_id, kb_payment_id, payment_external_key, @pm.kb_payment_method_id, @amount, @currency, properties, @call_context)
|
177
|
+
payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
|
178
|
+
payment_response.amount.should == @amount
|
179
|
+
payment_response.transaction_type.should == :AUTHORIZE
|
180
|
+
|
181
|
+
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
|
182
|
+
payment_infos.size.should == 1
|
183
|
+
payment_infos[0].kb_payment_id.should == kb_payment_id
|
184
|
+
payment_infos[0].transaction_type.should == :AUTHORIZE
|
185
|
+
payment_infos[0].amount.should == @amount
|
186
|
+
payment_infos[0].currency.should == @currency
|
187
|
+
payment_infos[0].status.should == :PROCESSED
|
188
|
+
payment_infos[0].gateway_error.should == 'Success'
|
189
|
+
payment_infos[0].gateway_error_code.should be_nil
|
190
|
+
|
191
|
+
# Trigger the capture
|
192
|
+
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)
|
193
|
+
payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
|
194
|
+
payment_response.amount.should == @amount
|
195
|
+
payment_response.transaction_type.should == :CAPTURE
|
196
|
+
|
197
|
+
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
|
198
|
+
payment_infos.size.should == 2
|
199
|
+
payment_infos[0].kb_payment_id.should == kb_payment_id
|
200
|
+
payment_infos[0].transaction_type.should == :AUTHORIZE
|
201
|
+
payment_infos[0].amount.should == @amount
|
202
|
+
payment_infos[0].currency.should == @currency
|
203
|
+
payment_infos[0].status.should == :PROCESSED
|
204
|
+
payment_infos[0].gateway_error.should == 'Success'
|
205
|
+
payment_infos[0].gateway_error_code.should be_nil
|
206
|
+
payment_infos[1].kb_payment_id.should == kb_payment_id
|
207
|
+
payment_infos[1].transaction_type.should == :CAPTURE
|
208
|
+
payment_infos[1].amount.should == @amount
|
209
|
+
payment_infos[1].currency.should == @currency
|
210
|
+
payment_infos[1].status.should == :PROCESSED
|
211
|
+
payment_infos[1].gateway_error.should == 'Success'
|
212
|
+
payment_infos[1].gateway_error_code.should be_nil
|
213
|
+
|
214
|
+
# Trigger a capture again with full amount
|
215
|
+
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)
|
216
|
+
payment_response.status.should eq(:ERROR), payment_response.gateway_error
|
217
|
+
payment_response.amount.should == nil
|
218
|
+
payment_response.transaction_type.should == :CAPTURE
|
219
|
+
|
220
|
+
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
|
221
|
+
payment_infos.size.should == 3
|
222
|
+
payment_infos[0].kb_payment_id.should == kb_payment_id
|
223
|
+
payment_infos[0].transaction_type.should == :AUTHORIZE
|
224
|
+
payment_infos[0].amount.should == @amount
|
225
|
+
payment_infos[0].currency.should == @currency
|
226
|
+
payment_infos[0].status.should == :PROCESSED
|
227
|
+
payment_infos[0].gateway_error.should == 'Success'
|
228
|
+
payment_infos[0].gateway_error_code.should be_nil
|
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 == @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
|
+
payment_infos[2].kb_payment_id.should.should == kb_payment_id
|
237
|
+
payment_infos[2].transaction_type.should == :CAPTURE
|
238
|
+
payment_infos[2].amount.should be_nil
|
239
|
+
payment_infos[2].currency.should be_nil
|
240
|
+
payment_infos[2].status.should == :ERROR
|
241
|
+
payment_infos[2].gateway_error.should == 'Authorization has already been completed.'
|
242
|
+
payment_infos[2].gateway_error_code.should be_nil
|
243
|
+
end
|
244
|
+
|
245
|
+
def authorize_and_void(kb_payment_id, payment_external_key, properties, payment_processor_account_id)
|
246
|
+
# Trigger the authorize
|
247
|
+
payment_response = @plugin.authorize_payment(@pm.kb_account_id, kb_payment_id, payment_external_key, @pm.kb_payment_method_id, @amount, @currency, properties, @call_context)
|
248
|
+
payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
|
249
|
+
payment_response.amount.should == @amount
|
250
|
+
payment_response.transaction_type.should == :AUTHORIZE
|
251
|
+
|
252
|
+
# Verify get_payment_info
|
253
|
+
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
|
254
|
+
payment_infos.size.should == 1
|
255
|
+
payment_infos[0].kb_payment_id.should == kb_payment_id
|
256
|
+
payment_infos[0].transaction_type.should == :AUTHORIZE
|
257
|
+
payment_infos[0].amount.should == @amount
|
258
|
+
payment_infos[0].currency.should == @currency
|
259
|
+
payment_infos[0].status.should == :PROCESSED
|
260
|
+
payment_infos[0].gateway_error.should == 'Success'
|
261
|
+
payment_infos[0].gateway_error_code.should be_nil
|
262
|
+
find_value_from_properties(payment_infos[0].properties, 'payment_processor_account_id').should == payment_processor_account_id
|
263
|
+
|
264
|
+
# Trigger the void
|
265
|
+
payment_response = @plugin.void_payment(@pm.kb_account_id, kb_payment_id, payment_external_key, @pm.kb_payment_method_id, properties, @call_context)
|
266
|
+
payment_response.status.should eq(:PROCESSED), payment_response.gateway_error
|
267
|
+
payment_response.transaction_type.should == :VOID
|
268
|
+
|
269
|
+
# Verify get_payment_info
|
270
|
+
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, properties, @call_context)
|
271
|
+
# Two expected transactions: one auth and one capture
|
272
|
+
payment_infos.size.should == 2
|
273
|
+
payment_infos[0].kb_payment_id.should == kb_payment_id
|
274
|
+
payment_infos[0].transaction_type.should == :AUTHORIZE
|
275
|
+
payment_infos[0].amount.should == @amount
|
276
|
+
payment_infos[0].currency.should == @currency
|
277
|
+
payment_infos[0].status.should == :PROCESSED
|
278
|
+
payment_infos[0].gateway_error.should == 'Success'
|
279
|
+
payment_infos[0].gateway_error_code.should be_nil
|
280
|
+
find_value_from_properties(payment_infos[0].properties, 'payment_processor_account_id').should == payment_processor_account_id
|
281
|
+
payment_infos[1].kb_payment_id.should == kb_payment_id
|
282
|
+
payment_infos[1].transaction_type.should == :VOID
|
283
|
+
payment_infos[1].status.should == :PROCESSED
|
284
|
+
payment_infos[1].gateway_error.should == 'Success'
|
285
|
+
payment_infos[1].gateway_error_code.should be_nil
|
286
|
+
find_value_from_properties(payment_infos[1].properties, 'payment_processor_account_id').should == payment_processor_account_id
|
287
|
+
end
|
288
|
+
|
289
|
+
def purchase_with_missing_token
|
290
|
+
failed_purchase([], :CANCELED, 'Could not find the payer_id: the token is missing', 'RuntimeError')
|
291
|
+
end
|
292
|
+
|
293
|
+
def authorize_with_missing_token
|
294
|
+
failed_authorize([], :CANCELED, 'Could not find the payer_id: the token is missing', 'RuntimeError')
|
295
|
+
end
|
296
|
+
|
297
|
+
def purchase_with_invalid_token(purchase_properties)
|
298
|
+
failed_purchase(purchase_properties, :CANCELED, "Could not find the payer_id for token #{properties_to_hash(purchase_properties)[:token]}", 'RuntimeError')
|
299
|
+
end
|
300
|
+
|
301
|
+
def authorize_with_invalid_token(authorize_properties)
|
302
|
+
failed_authorize(authorize_properties, :CANCELED, "Could not find the payer_id for token #{properties_to_hash(authorize_properties)[:token]}", 'RuntimeError')
|
303
|
+
end
|
304
|
+
|
305
|
+
def subsequent_purchase(purchase_properties)
|
306
|
+
failed_purchase(purchase_properties, :ERROR, 'A successful transaction has already been completed for this token.')
|
307
|
+
end
|
308
|
+
|
309
|
+
def failed_authorize(authorize_properties, status, msg, gateway_error_code=nil)
|
310
|
+
kb_payment_id = SecureRandom.uuid
|
311
|
+
|
312
|
+
payment_response = @plugin.authorize_payment(@pm.kb_account_id, kb_payment_id, SecureRandom.uuid, @pm.kb_payment_method_id, @amount, @currency, authorize_properties, @call_context)
|
313
|
+
payment_response.status.should eq(status), payment_response.gateway_error
|
314
|
+
payment_response.amount.should be_nil
|
315
|
+
payment_response.transaction_type.should == :AUTHORIZE
|
316
|
+
|
317
|
+
# Verify GET API
|
318
|
+
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, [], @call_context)
|
319
|
+
payment_infos.size.should == 1
|
320
|
+
payment_infos[0].kb_payment_id.should == kb_payment_id
|
321
|
+
payment_infos[0].transaction_type.should == :AUTHORIZE
|
322
|
+
payment_infos[0].amount.should be_nil
|
323
|
+
payment_infos[0].currency.should be_nil
|
324
|
+
payment_infos[0].status.should == status
|
325
|
+
payment_infos[0].gateway_error.should == msg
|
326
|
+
payment_infos[0].gateway_error_code.should == gateway_error_code
|
327
|
+
end
|
328
|
+
|
329
|
+
def failed_purchase(purchase_properties, status, msg, gateway_error_code=nil)
|
330
|
+
kb_payment_id = SecureRandom.uuid
|
331
|
+
|
332
|
+
payment_response = @plugin.purchase_payment(@pm.kb_account_id, kb_payment_id, SecureRandom.uuid, @pm.kb_payment_method_id, @amount, @currency, purchase_properties, @call_context)
|
333
|
+
payment_response.status.should eq(status), payment_response.gateway_error
|
334
|
+
payment_response.amount.should be_nil
|
335
|
+
payment_response.transaction_type.should == :PURCHASE
|
336
|
+
|
337
|
+
# Verify GET API
|
338
|
+
payment_infos = @plugin.get_payment_info(@pm.kb_account_id, kb_payment_id, [], @call_context)
|
339
|
+
payment_infos.size.should == 1
|
340
|
+
payment_infos[0].kb_payment_id.should == kb_payment_id
|
341
|
+
payment_infos[0].transaction_type.should == :PURCHASE
|
342
|
+
payment_infos[0].amount.should be_nil
|
343
|
+
payment_infos[0].currency.should be_nil
|
344
|
+
payment_infos[0].status.should == status
|
345
|
+
payment_infos[0].gateway_error.should == msg
|
346
|
+
payment_infos[0].gateway_error_code.should == gateway_error_code
|
347
|
+
end
|
348
|
+
|
349
|
+
private
|
350
|
+
|
351
|
+
def verify_payment_method(kb_account_id = nil)
|
352
|
+
# Verify our table directly
|
353
|
+
kb_account_id = @pm.kb_account_id if kb_account_id.nil?
|
354
|
+
payment_methods = ::Killbill::PaypalExpress::PaypalExpressPaymentMethod.from_kb_account_id(kb_account_id, @call_context.tenant_id)
|
355
|
+
payment_methods.size.should == 1
|
356
|
+
payment_method = payment_methods.first
|
357
|
+
payment_method.should_not be_nil
|
358
|
+
payment_method.paypal_express_payer_id.should be_nil
|
359
|
+
payment_method.token.should be_nil
|
360
|
+
payment_method.kb_payment_method_id.should == @pm.kb_payment_method_id
|
361
|
+
end
|
362
|
+
end
|
363
|
+
end
|
364
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -18,7 +18,7 @@ ActiveRecord::Base.establish_connection(
|
|
18
18
|
:database => 'test.db'
|
19
19
|
)
|
20
20
|
# For debugging
|
21
|
-
#ActiveRecord::Base.logger = Logger.new(STDOUT)
|
21
|
+
# ActiveRecord::Base.logger = Logger.new(STDOUT)
|
22
22
|
# Create the schema
|
23
23
|
require File.expand_path(File.dirname(__FILE__) + '../../db/schema.rb')
|
24
24
|
|
@@ -41,4 +41,17 @@ class PaypalExpressJavaPaymentApi < ::Killbill::Plugin::ActiveMerchant::RSpec::F
|
|
41
41
|
|
42
42
|
kb_payment
|
43
43
|
end
|
44
|
+
|
45
|
+
def create_authorization(kb_account, kb_payment_method_id, kb_payment_id, amount, currency, payment_external_key, payment_transaction_external_key, properties, context)
|
46
|
+
kb_payment = add_payment(kb_payment_id || SecureRandom.uuid, SecureRandom.uuid, payment_transaction_external_key, :AUTHORIZE)
|
47
|
+
|
48
|
+
rcontext = context.to_ruby(context)
|
49
|
+
@plugin.authorize_payment(kb_account.id, kb_payment.id, kb_payment.transactions.last.id, kb_payment_method_id, amount, currency, properties, rcontext)
|
50
|
+
|
51
|
+
kb_payment
|
52
|
+
end
|
53
|
+
|
54
|
+
def delete_all_payments
|
55
|
+
@payments = []
|
56
|
+
end
|
44
57
|
end
|
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: 4.1.
|
4
|
+
version: 4.1.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: 2016-
|
11
|
+
date: 2016-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: killbill
|
@@ -240,6 +240,20 @@ dependencies:
|
|
240
240
|
version: 2.12.0
|
241
241
|
prerelease: false
|
242
242
|
type: :development
|
243
|
+
- !ruby/object:Gem::Dependency
|
244
|
+
name: selenium-webdriver
|
245
|
+
version_requirements: !ruby/object:Gem::Requirement
|
246
|
+
requirements:
|
247
|
+
- - ~>
|
248
|
+
- !ruby/object:Gem::Version
|
249
|
+
version: 2.53.0
|
250
|
+
requirement: !ruby/object:Gem::Requirement
|
251
|
+
requirements:
|
252
|
+
- - ~>
|
253
|
+
- !ruby/object:Gem::Version
|
254
|
+
version: 2.53.0
|
255
|
+
prerelease: false
|
256
|
+
type: :development
|
243
257
|
- !ruby/object:Gem::Dependency
|
244
258
|
name: jdbc-sqlite3
|
245
259
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -320,7 +334,11 @@ files:
|
|
320
334
|
- release.sh
|
321
335
|
- spec/paypal_express/base_plugin_spec.rb
|
322
336
|
- spec/paypal_express/remote/baid_spec.rb
|
337
|
+
- spec/paypal_express/remote/baid_spec_helpers.rb
|
338
|
+
- spec/paypal_express/remote/browser_helpers.rb
|
339
|
+
- spec/paypal_express/remote/build_plugin_helpers.rb
|
323
340
|
- spec/paypal_express/remote/hpp_spec.rb
|
341
|
+
- spec/paypal_express/remote/hpp_spec_helpers.rb
|
324
342
|
- spec/spec_helper.rb
|
325
343
|
homepage: http://killbill.io
|
326
344
|
licenses:
|