killbill-paypal-express 5.0.15 → 5.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/paypal_express/api.rb +128 -33
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9eed5bc0972cf50c5d1fc6e78c0fb1f6adaa9f19
|
4
|
+
data.tar.gz: 3d282224dcc0dbf454fd40705d6860a2498dca89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee1c6cb5b204b9ffbf3a4f4d9dad8a5785bed9365db77664c118a8bfd5cad7eab440c8366aa37cdb4f4b267bb371ad3c7340dc6f5f5b8d0af1e0bfd20ca42119
|
7
|
+
data.tar.gz: f1e4184e291e8e8bb74c9a2dff8e961e260b2768b78518c530305062fb718fb27189b936fe802184735f2107d8059509f38e41c3a17742a8fb5bc57d1338463e
|
data/lib/paypal_express/api.rb
CHANGED
@@ -301,6 +301,28 @@ module Killbill #:nodoc:
|
|
301
301
|
response
|
302
302
|
end
|
303
303
|
|
304
|
+
def create_billing_aggrement(token,
|
305
|
+
kb_account_id,
|
306
|
+
kb_tenant_id,
|
307
|
+
payment_processor_account_id,
|
308
|
+
kb_payment_id = nil,
|
309
|
+
kb_payment_transaction_id = nil,
|
310
|
+
transaction_type = nil)
|
311
|
+
raise 'Could create billing aggrement: the token is missing' if token.blank?
|
312
|
+
|
313
|
+
# Go to Paypal to create the billing aggrement
|
314
|
+
payment_processor_account_id = payment_processor_account_id || :default
|
315
|
+
gateway = lookup_gateway(payment_processor_account_id, kb_tenant_id)
|
316
|
+
gw_response = gateway.store(token)
|
317
|
+
|
318
|
+
response = @response_model.create_response(:store, kb_account_id, kb_payment_id, kb_payment_transaction_id, transaction_type, payment_processor_account_id, kb_tenant_id, gw_response)
|
319
|
+
|
320
|
+
raise response.message unless response.success?
|
321
|
+
raise "Could not create billing aggrement for token #{token}" if response.billing_agreement_id.blank?
|
322
|
+
|
323
|
+
response
|
324
|
+
end
|
325
|
+
|
304
326
|
def add_default_options(kb_payment_transaction_id, options)
|
305
327
|
options[:payment_type] ||= 'Any'
|
306
328
|
options[:invoice_id] ||= kb_payment_transaction_id
|
@@ -328,6 +350,7 @@ module Killbill #:nodoc:
|
|
328
350
|
|
329
351
|
with_baid = ::Killbill::Plugin::ActiveMerchant::Utils.normalized(properties_hash, :with_baid)
|
330
352
|
if with_baid
|
353
|
+
options[:payment_processor_account_id] = ::Killbill::Plugin::ActiveMerchant::Utils.normalized(properties_hash, :payment_master_processor_account_id)
|
331
354
|
[:billing_agreement_type, :billing_agreement_description].each { |sym| options[sym] = ::Killbill::Plugin::ActiveMerchant::Utils.normalized(properties_hash, sym) }
|
332
355
|
end
|
333
356
|
|
@@ -349,7 +372,15 @@ module Killbill #:nodoc:
|
|
349
372
|
|
350
373
|
def authorize_or_purchase_payment(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context, is_authorize = false)
|
351
374
|
properties_hash = properties_to_hash properties
|
375
|
+
with_baid = ::Killbill::Plugin::ActiveMerchant::Utils.normalized(properties_hash, :with_baid)
|
376
|
+
logger.info("withBaidFlag=#{with_baid}")
|
377
|
+
|
352
378
|
payment_processor_account_id = ::Killbill::Plugin::ActiveMerchant::Utils.normalized(properties_hash, :payment_processor_account_id)
|
379
|
+
logger.info("paymentProcessorAccountId=#{payment_processor_account_id}")
|
380
|
+
|
381
|
+
payment_master_processor_account_id = ::Killbill::Plugin::ActiveMerchant::Utils.normalized(properties_hash, :payment_master_processor_account_id)
|
382
|
+
logger.info("paymentMasterProcessorAccountId=#{payment_master_processor_account_id}")
|
383
|
+
|
353
384
|
transaction_type = is_authorize ? :AUTHORIZE : :PURCHASE
|
354
385
|
api_call_type = is_authorize ? :authorize : :purchase
|
355
386
|
|
@@ -384,40 +415,71 @@ module Killbill #:nodoc:
|
|
384
415
|
options[:payment_processor_account_id] = payment_processor_account_id
|
385
416
|
options[:payer_id] = ::Killbill::Plugin::ActiveMerchant::Utils.normalized(properties_hash, :payer_id)
|
386
417
|
|
387
|
-
if
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
kb_account_id,
|
392
|
-
context.tenant_id,
|
393
|
-
payment_processor_account_id,
|
394
|
-
kb_payment_id,
|
395
|
-
kb_payment_transaction_id,
|
396
|
-
transaction_type)
|
397
|
-
rescue => e
|
398
|
-
# Maybe invalid token?
|
399
|
-
response = @response_model.create(:api_call => api_call_type,
|
400
|
-
:kb_account_id => kb_account_id,
|
401
|
-
:kb_payment_id => kb_payment_id,
|
402
|
-
:kb_payment_transaction_id => kb_payment_transaction_id,
|
403
|
-
:transaction_type => transaction_type,
|
404
|
-
:authorization => nil,
|
405
|
-
:payment_processor_account_id => payment_processor_account_id,
|
406
|
-
:kb_tenant_id => context.tenant_id,
|
407
|
-
:success => false,
|
408
|
-
:created_at => Time.now.utc,
|
409
|
-
:updated_at => Time.now.utc,
|
410
|
-
:message => { :payment_plugin_status => :CANCELED, :exception_class => e.class.to_s, :exception_message => e.message }.to_json)
|
411
|
-
return response.to_transaction_info_plugin(nil)
|
412
|
-
end
|
413
|
-
if options[:payer_id].nil?
|
414
|
-
options[:payer_id] = payer_info.payer_id
|
415
|
-
end
|
416
|
-
options[:payer_email] = payer_info.payer_email
|
418
|
+
if with_baid
|
419
|
+
baid_payment_processor_account_id = payment_master_processor_account_id
|
420
|
+
else
|
421
|
+
baid_payment_processor_account_id_ = payment_processor_account_id
|
417
422
|
end
|
418
423
|
|
419
|
-
|
420
|
-
|
424
|
+
if with_baid
|
425
|
+
if options.has_key?(:token) && options[:reference_id].nil?
|
426
|
+
# Retrieve payer_id and payer_email
|
427
|
+
begin
|
428
|
+
|
429
|
+
payer_info = get_payer_info(options[:token],
|
430
|
+
kb_account_id,
|
431
|
+
context.tenant_id,
|
432
|
+
baid_payment_processor_account_id,
|
433
|
+
kb_payment_id,
|
434
|
+
kb_payment_transaction_id,
|
435
|
+
transaction_type)
|
436
|
+
rescue => e
|
437
|
+
# Maybe invalid token?
|
438
|
+
response = @response_model.create(:api_call => api_call_type,
|
439
|
+
:kb_account_id => kb_account_id,
|
440
|
+
:kb_payment_id => kb_payment_id,
|
441
|
+
:kb_payment_transaction_id => kb_payment_transaction_id,
|
442
|
+
:transaction_type => transaction_type,
|
443
|
+
:authorization => nil,
|
444
|
+
:payment_processor_account_id => baid_payment_processor_account_id,
|
445
|
+
:kb_tenant_id => context.tenant_id,
|
446
|
+
:success => false,
|
447
|
+
:created_at => Time.now.utc,
|
448
|
+
:updated_at => Time.now.utc,
|
449
|
+
:message => { :payment_plugin_status => :CANCELED, :exception_class => e.class.to_s, :exception_message => e.message }.to_json)
|
450
|
+
return response.to_transaction_info_plugin(nil)
|
451
|
+
end
|
452
|
+
if options[:payer_id].nil?
|
453
|
+
options[:payer_id] = payer_info.payer_id
|
454
|
+
end
|
455
|
+
options[:payer_email] = payer_info.payer_email
|
456
|
+
|
457
|
+
begin
|
458
|
+
options[:reference_id] = create_billing_aggrement(options[:token],
|
459
|
+
kb_account_id,
|
460
|
+
context.tenant_id,
|
461
|
+
baid_payment_processor_account_id,
|
462
|
+
kb_payment_id,
|
463
|
+
kb_payment_transaction_id,
|
464
|
+
transaction_type).billing_agreement_id
|
465
|
+
rescue => e
|
466
|
+
# Maybe invalid token?
|
467
|
+
response = @response_model.create(:api_call => api_call_type,
|
468
|
+
:kb_account_id => kb_account_id,
|
469
|
+
:kb_payment_id => kb_payment_id,
|
470
|
+
:kb_payment_transaction_id => kb_payment_transaction_id,
|
471
|
+
:transaction_type => transaction_type,
|
472
|
+
:authorization => nil,
|
473
|
+
:payment_processor_account_id => baid_payment_processor_account_id,
|
474
|
+
:kb_tenant_id => context.tenant_id,
|
475
|
+
:success => false,
|
476
|
+
:created_at => Time.now.utc,
|
477
|
+
:updated_at => Time.now.utc,
|
478
|
+
:message => { :payment_plugin_status => :CANCELED, :exception_class => e.class.to_s, :exception_message => e.message }.to_json)
|
479
|
+
return response.to_transaction_info_plugin(nil)
|
480
|
+
end
|
481
|
+
end
|
482
|
+
|
421
483
|
if is_authorize
|
422
484
|
gateway_call_proc = Proc.new do |gateway, linked_transaction, payment_source, amount_in_cents, options|
|
423
485
|
# Can't use default implementation: the purchase signature is for one-off payments only
|
@@ -430,7 +492,40 @@ module Killbill #:nodoc:
|
|
430
492
|
end
|
431
493
|
end
|
432
494
|
else
|
433
|
-
|
495
|
+
|
496
|
+
if options.has_key?(:token)
|
497
|
+
# Retrieve payer_id and payer_email
|
498
|
+
begin
|
499
|
+
|
500
|
+
payer_info = get_payer_info(options[:token],
|
501
|
+
kb_account_id,
|
502
|
+
context.tenant_id,
|
503
|
+
baid_payment_processor_account_id,
|
504
|
+
kb_payment_id,
|
505
|
+
kb_payment_transaction_id,
|
506
|
+
transaction_type)
|
507
|
+
rescue => e
|
508
|
+
# Maybe invalid token?
|
509
|
+
response = @response_model.create(:api_call => api_call_type,
|
510
|
+
:kb_account_id => kb_account_id,
|
511
|
+
:kb_payment_id => kb_payment_id,
|
512
|
+
:kb_payment_transaction_id => kb_payment_transaction_id,
|
513
|
+
:transaction_type => transaction_type,
|
514
|
+
:authorization => nil,
|
515
|
+
:payment_processor_account_id => baid_payment_processor_account_id,
|
516
|
+
:kb_tenant_id => context.tenant_id,
|
517
|
+
:success => false,
|
518
|
+
:created_at => Time.now.utc,
|
519
|
+
:updated_at => Time.now.utc,
|
520
|
+
:message => { :payment_plugin_status => :CANCELED, :exception_class => e.class.to_s, :exception_message => e.message }.to_json)
|
521
|
+
return response.to_transaction_info_plugin(nil)
|
522
|
+
end
|
523
|
+
if options[:payer_id].nil?
|
524
|
+
options[:payer_id] = payer_info.payer_id
|
525
|
+
end
|
526
|
+
options[:payer_email] = payer_info.payer_email
|
527
|
+
end
|
528
|
+
|
434
529
|
if is_authorize
|
435
530
|
gateway_call_proc = Proc.new do |gateway, linked_transaction, payment_source, amount_in_cents, options|
|
436
531
|
gateway.authorize(amount_in_cents, options)
|
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.
|
4
|
+
version: 5.0.16
|
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:
|
11
|
+
date: 2020-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|