six_saferpay 2.2.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +4 -2
  4. data/Gemfile.lock +77 -82
  5. data/README.md +3 -2
  6. data/Thorfile +1 -0
  7. data/lib/generators/models.rb +100 -0
  8. data/lib/generators/templates/fabric.erb +13 -0
  9. data/lib/generators/templates/model.erb +64 -0
  10. data/lib/generators/templates/spec.erb +24 -0
  11. data/lib/six_saferpay.rb +5 -0
  12. data/lib/six_saferpay/api.rb +1 -1
  13. data/lib/six_saferpay/api/six_payment_page/requests/initialize.rb +14 -2
  14. data/lib/six_saferpay/api/six_payment_page/responses/assert_response.rb +11 -2
  15. data/lib/six_saferpay/api/six_secure_card_data/requests/insert.rb +6 -2
  16. data/lib/six_saferpay/api/six_secure_card_data/responses/insert_response.rb +9 -4
  17. data/lib/six_saferpay/api/six_secure_pay_gate_offer/requests/create_offer.rb +6 -2
  18. data/lib/six_saferpay/api/six_transaction/requests/authorize_direct.rb +4 -0
  19. data/lib/six_saferpay/api/six_transaction/requests/authorize_referenced.rb +4 -0
  20. data/lib/six_saferpay/api/six_transaction/requests/capture.rb +11 -2
  21. data/lib/six_saferpay/api/six_transaction/requests/initialize.rb +14 -2
  22. data/lib/six_saferpay/api/six_transaction/responses/authorize_direct_response.rb +11 -2
  23. data/lib/six_saferpay/api/six_transaction/responses/authorize_response.rb +11 -3
  24. data/lib/six_saferpay/models/authentication.rb +36 -0
  25. data/lib/six_saferpay/models/authentication_result.rb +20 -0
  26. data/lib/six_saferpay/models/card_form.rb +11 -2
  27. data/lib/six_saferpay/models/check_result.rb +6 -2
  28. data/lib/six_saferpay/models/chosen_plan.rb +62 -0
  29. data/lib/six_saferpay/models/custom_plan.rb +4 -0
  30. data/lib/six_saferpay/models/first_installment_amount.rb +4 -0
  31. data/lib/six_saferpay/models/ideal.rb +18 -0
  32. data/lib/six_saferpay/models/installment_fee.rb +4 -0
  33. data/lib/six_saferpay/models/installment_plans.rb +73 -0
  34. data/lib/six_saferpay/models/items.rb +84 -0
  35. data/lib/six_saferpay/models/mastercard_issuer_installments.rb +49 -0
  36. data/lib/six_saferpay/models/order.rb +27 -0
  37. data/lib/six_saferpay/models/payer.rb +8 -2
  38. data/lib/six_saferpay/models/payer_profile.rb +105 -0
  39. data/lib/six_saferpay/models/payment_methods_options.rb +4 -2
  40. data/lib/six_saferpay/models/phone.rb +36 -0
  41. data/lib/six_saferpay/models/registration_result.rb +11 -2
  42. data/lib/six_saferpay/models/risk_factors.rb +39 -0
  43. data/lib/six_saferpay/models/subsequent_installment_amount.rb +4 -0
  44. data/lib/six_saferpay/models/total_amont_due.rb +4 -0
  45. data/lib/six_saferpay/version.rb +1 -1
  46. data/six_saferpay.gemspec +9 -8
  47. metadata +58 -24
data/lib/six_saferpay.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'active_support/core_ext/hash'
2
2
  require 'active_support/core_ext/string'
3
+ require 'active_support/inflector'
3
4
  require 'securerandom'
4
5
  require 'json'
5
6
  require 'net/http'
@@ -12,6 +13,10 @@ Dir[File.join(gem_root, "lib", "six_saferpay", "**/*.rb")].sort.each do |file|
12
13
  require file
13
14
  end
14
15
 
16
+ Dir[File.join(gem_root, "lib", "generators", "**/*.thor")].sort.each do |file|
17
+ require file
18
+ end
19
+
15
20
  module SixSaferpay
16
21
 
17
22
  class Config
@@ -1,5 +1,5 @@
1
1
  module SixSaferpay
2
2
  module API
3
- VERSION = '1.14'
3
+ VERSION = '1.18'
4
4
  end
5
5
  end
@@ -9,6 +9,7 @@ module SixSaferpay
9
9
  :payment,
10
10
  :payment_methods,
11
11
  :payment_methods_options,
12
+ :authentication,
12
13
  :wallets,
13
14
  :payer,
14
15
  :register_alias,
@@ -18,7 +19,9 @@ module SixSaferpay
18
19
  :billing_address_form,
19
20
  :delivery_address_form,
20
21
  :card_form,
21
- :condition
22
+ :condition,
23
+ :order,
24
+ :risk_factors
22
25
  )
23
26
 
24
27
  def initialize(request_header: nil,
@@ -27,6 +30,7 @@ module SixSaferpay
27
30
  payment:,
28
31
  payment_methods: nil,
29
32
  payment_methods_options: nil,
33
+ authentication: nil,
30
34
  wallets: nil,
31
35
  payer: nil,
32
36
  register_alias: nil,
@@ -36,7 +40,9 @@ module SixSaferpay
36
40
  billing_address_form: nil,
37
41
  delivery_address_form: nil,
38
42
  card_form: nil,
39
- condition: nil
43
+ condition: nil,
44
+ order: nil,
45
+ risk_factors: nil
40
46
  )
41
47
  @request_header = request_header || SixSaferpay::RequestHeader.new()
42
48
  @config_set = config_set
@@ -44,6 +50,7 @@ module SixSaferpay
44
50
  @payment = SixSaferpay::Payment.new(payment.to_h) if payment
45
51
  @payment_methods = payment_methods
46
52
  @payment_methods_options = SixSaferpay::PaymentMethodsOptions.new(payment_methods_options.to_h) if payment_methods_options
53
+ @authentication = SixSaferpay::Authentication.new(authentication.to_h) if authentication
47
54
  @wallets = wallets
48
55
  @payer = SixSaferpay::Payer.new(payer.to_h) if payer
49
56
  @register_alias = SixSaferpay::RegisterAlias.new(register_alias.to_h) if register_alias
@@ -54,6 +61,8 @@ module SixSaferpay
54
61
  @delivery_address_form = SixSaferpay::DeliveryAddressForm.new(delivery_address_form.to_h) if delivery_address_form
55
62
  @card_form = SixSaferpay::CardForm.new(card_form.to_h) if card_form
56
63
  @condition = condition
64
+ @order = SixSaferpay::Order.new(order.to_h) if order
65
+ @risk_factors = SixSaferpay::RiskFactors.new(risk_factors.to_h) if risk_factors
57
66
  end
58
67
 
59
68
  def to_hash
@@ -64,6 +73,7 @@ module SixSaferpay
64
73
  hash.merge!(payment: @payment.to_h)
65
74
  hash.merge!(payment_methods: @payment_methods) if @payment_methods
66
75
  hash.merge!(payment_methods_options: @payment_methods_options.to_h) if @payment_methods_options
76
+ hash.merge!(authentication: @authentication.to_h) if @authentication
67
77
  hash.merge!(wallets: @wallets) if @wallets
68
78
  hash.merge!(payer: @payer.to_h) if @payer
69
79
  hash.merge!(register_alias: @register_alias.to_h) if @register_alias
@@ -74,6 +84,8 @@ module SixSaferpay
74
84
  hash.merge!(delivery_address_form: @delivery_address_form.to_h) if @delivery_address_form
75
85
  hash.merge!(card_form: @card_form.to_h) if @card_form
76
86
  hash.merge!(condition: @condition) if @condition
87
+ hash.merge!(order: @order.to_h) if @order
88
+ hash.merge!(risk_factors: @risk_factors.to_h) if @risk_factors
77
89
  hash
78
90
  end
79
91
  alias_method :to_h, :to_hash
@@ -8,7 +8,8 @@ module SixSaferpay
8
8
  :payer,
9
9
  :registration_result,
10
10
  :liability,
11
- :dcc
11
+ :dcc,
12
+ :mastercard_issuer_installments
12
13
  )
13
14
 
14
15
  def initialize(response_header:,
@@ -17,7 +18,8 @@ module SixSaferpay
17
18
  payer: nil,
18
19
  registration_result: nil,
19
20
  liability: nil,
20
- dcc: nil
21
+ dcc: nil,
22
+ mastercard_issuer_installments: nil
21
23
  )
22
24
  @response_header = SixSaferpay::ResponseHeader.new(response_header.to_h)
23
25
  @transaction = SixSaferpay::Transaction.new(transaction.to_h)
@@ -26,6 +28,10 @@ module SixSaferpay
26
28
  @registration_result = SixSaferpay::RegistrationResult.new(registration_result.to_h) if registration_result
27
29
  @liability = SixSaferpay::Liability.new(liability.to_h) if liability
28
30
  @dcc = SixSaferpay::Dcc.new(dcc.to_h) if dcc
31
+ if mastercard_issuer_installments
32
+ @mastercard_issuer_installments = SixSaferpay::MastercardIssuerInstallments
33
+ .new(mastercard_issuer_installments.to_h)
34
+ end
29
35
  end
30
36
 
31
37
  def to_hash
@@ -37,6 +43,9 @@ module SixSaferpay
37
43
  hash.merge!(registration_result: @registration_result.to_h) if @registration_result
38
44
  hash.merge!(liability: @liability.to_h) if @liability
39
45
  hash.merge!(dcc: @dcc.to_h) if @dcc
46
+ if @mastercard_issuer_installments
47
+ hash.merge!(mastercard_issuer_installments: mastercard_issuer_installments.to_h)
48
+ end
40
49
  hash
41
50
  end
42
51
  alias_method :to_h, :to_hash
@@ -10,7 +10,8 @@ module SixSaferpay
10
10
  :language_code,
11
11
  :check,
12
12
  :payment_methods,
13
- :card_form
13
+ :card_form,
14
+ :payment_means
14
15
  )
15
16
 
16
17
  def initialize(request_header: nil,
@@ -21,7 +22,8 @@ module SixSaferpay
21
22
  language_code: nil,
22
23
  check: nil,
23
24
  payment_methods: nil,
24
- card_form: nil
25
+ card_form: nil,
26
+ payment_means: nil
25
27
  )
26
28
  @request_header = request_header || SixSaferpay::RequestHeader.new()
27
29
  @register_alias = SixSaferpay::RegisterAlias.new(register_alias.to_h) if register_alias
@@ -32,6 +34,7 @@ module SixSaferpay
32
34
  @check = SixSaferpay::Check.new(check.to_h) if check
33
35
  @payment_methods = payment_methods
34
36
  @card_form = SixSaferpay::CardForm.new(card_form.to_h) if card_form
37
+ @payment_means = SixSaferpay::RequestPaymentMeans.new(payment_means.to_h) if payment_means
35
38
  end
36
39
 
37
40
  def to_hash
@@ -45,6 +48,7 @@ module SixSaferpay
45
48
  hash.merge!(check: @check.to_h) if @check
46
49
  hash.merge!(payment_methods: @payment_methods) if @payment_methods
47
50
  hash.merge!(card_form: @card_form.to_h) if @card_form
51
+ hash.merge!(payment_means: @payment_means.to_h) if @payment_means
48
52
  hash
49
53
  end
50
54
  alias_method :to_h, :to_hash
@@ -5,17 +5,21 @@ module SixSaferpay
5
5
  attr_accessor(:response_header,
6
6
  :token,
7
7
  :expiration,
8
- :redirect_url
8
+ :redirect_required,
9
+ :redirect
9
10
  )
10
11
 
11
12
  def initialize(response_header:,
12
13
  token:,
13
14
  expiration:,
14
- redirect_url: )
15
+ redirect_required:,
16
+ redirect:
17
+ )
15
18
  @response_header = SixSaferpay::ResponseHeader.new(response_header.to_h) if response_header
16
19
  @token = token
17
20
  @expiration = expiration
18
- @redirect_url = redirect_url
21
+ @redirect_required = redirect_required
22
+ @redirect = SixSaferpay::Redirect.new(redirect.to_h) if redirect
19
23
  end
20
24
 
21
25
  def to_hash
@@ -23,7 +27,8 @@ module SixSaferpay
23
27
  hash.merge!(response_header: @response_header.to_h) if @response_header
24
28
  hash.merge!(token: @token) if @token
25
29
  hash.merge!(expiration: @expiration) if @expiration
26
- hash.merge!(redirect_url: @redirect_url) if @redirect_url
30
+ hash.merge!(redirect_required: @redirect_required) if !@redirect_required.nil?
31
+ hash.merge!(redirect: @redirect.to_h) if @redirect
27
32
  hash
28
33
  end
29
34
  alias_method :to_h, :to_hash
@@ -6,14 +6,16 @@ module SixSaferpay
6
6
  :expiration_date,
7
7
  :config_set,
8
8
  :payer,
9
- :billing_address_form
9
+ :billing_address_form,
10
+ :register_alias,
10
11
  )
11
12
 
12
13
  def initialize(payment: ,
13
14
  expiration_date: ,
14
15
  config_set: nil,
15
16
  payer: ,
16
- billing_address_form: nil
17
+ billing_address_form: nil,
18
+ register_alias: nil
17
19
  )
18
20
 
19
21
  @payment = SixSaferpay::Payment.new(payment.to_h) if payment
@@ -22,6 +24,7 @@ module SixSaferpay
22
24
  @payer = SixSaferpay::Payer.new(payer.to_h) if payer
23
25
  @billing_address_form =
24
26
  SixSaferpay::BillingAddressForm.new(billing_address_form) if billing_address_form
27
+ @register_alias = SixSaferpay::RegisterAlias.new(register_alias.to_h) if register_alias
25
28
  end
26
29
 
27
30
  def to_hash
@@ -31,6 +34,7 @@ module SixSaferpay
31
34
  hash.merge!(config_set: @config_set) if @config_set
32
35
  hash.merge!(payer: @payer.to_h) if @payer
33
36
  hash.merge!(billing_address_form: @billing_address_form.to_h) if @billing_address_form
37
+ hash.merge!(register_alias: @register_alias.to_h) if @register_alias
34
38
  hash
35
39
  end
36
40
  alias_method :to_h, :to_hash
@@ -6,6 +6,7 @@ module SixSaferpay
6
6
  :terminal_id,
7
7
  :payment,
8
8
  :payment_means,
9
+ :authentication,
9
10
  :register_alias,
10
11
  :payer
11
12
  )
@@ -15,6 +16,7 @@ module SixSaferpay
15
16
  terminal_id: nil,
16
17
  payment:,
17
18
  payment_means:,
19
+ authentication: nil,
18
20
  register_alias: nil,
19
21
  payer: nil
20
22
  )
@@ -22,6 +24,7 @@ module SixSaferpay
22
24
  @terminal_id = SixSaferpay.config.terminal_id || terminal_id
23
25
  @payment = SixSaferpay::Payment.new(payment.to_h) if payment
24
26
  @payment_means = SixSaferpay::RequestPaymentMeans.new(payment_means.to_h) if payment_means
27
+ @authentication = SixSaferpay::Authentication.new(authentication.to_h) if authentication
25
28
  @register_alias = SixSaferpay::RegisterAlias.new(register_alias.to_h) if register_alias
26
29
  @payer = SixSaferpay::Payer.new(payer.to_h) if payer
27
30
  end
@@ -32,6 +35,7 @@ module SixSaferpay
32
35
  hash.merge!(terminal_id: @terminal_id) if @terminal_id
33
36
  hash.merge!(payment: @payment.to_h) if @payment
34
37
  hash.merge!(payment_means: @payment_means.to_h) if @payment_means
38
+ hash.merge!(authentication: @authentication.to_h) if @authentication
35
39
  hash.merge!(register_alias: @register_alias.to_h) if @register_alias
36
40
  hash.merge!(payer: @payer.to_h) if @payer
37
41
  hash
@@ -6,6 +6,7 @@ module SixSaferpay
6
6
  :terminal_id,
7
7
  :payment,
8
8
  :transaction_reference,
9
+ :authentication,
9
10
  :suppress_dcc
10
11
  )
11
12
 
@@ -14,12 +15,14 @@ module SixSaferpay
14
15
  terminal_id: nil,
15
16
  payment:,
16
17
  transaction_reference:,
18
+ authentication: nil,
17
19
  suppress_dcc:
18
20
  )
19
21
  @request_header = request_header || SixSaferpay::RequestHeader.new()
20
22
  @terminal_id = terminal_id || SixSaferpay.config.terminal_id
21
23
  @payment = SixSaferpay::Payment.new(payment.to_h) if payment
22
24
  @transaction_reference = SixSaferpay::TransactionReference.new(transaction_reference.to_h) if transaction_reference
25
+ @authentication = SixSaferpay::Authentication.new(authentication.to_h) if authentication
23
26
  @suppress_dcc = suppress_dcc
24
27
  end
25
28
 
@@ -29,6 +32,7 @@ module SixSaferpay
29
32
  hash.merge!(terminal_id: @terminal_id) if @terminal_id
30
33
  hash.merge!(payment: @payment.to_h) if @payment
31
34
  hash.merge!(transaction_reference: @transaction_reference.to_h) if @transaction_reference
35
+ hash.merge!(authentication: @authentication.to_h) if @authentication
32
36
  hash.merge!(suppress_dcc: @suppress_dcc) if !@suppress_dcc.nil?
33
37
  hash
34
38
  end
@@ -7,7 +7,8 @@ module SixSaferpay
7
7
  :amount,
8
8
  :billpay,
9
9
  :pending_notification,
10
- :marketplace
10
+ :marketplace,
11
+ :mastercard_issuer_installments
11
12
  )
12
13
 
13
14
 
@@ -16,7 +17,8 @@ module SixSaferpay
16
17
  amount: nil,
17
18
  billpay: nil,
18
19
  pending_notification: nil,
19
- marketplace: nil
20
+ marketplace: nil,
21
+ mastercard_issuer_installments: nil
20
22
  )
21
23
  @request_header = request_header || SixSaferpay::RequestHeader.new()
22
24
  @transaction_reference = SixSaferpay::TransactionReference.new(transaction_reference.to_h) if transaction_reference
@@ -24,6 +26,10 @@ module SixSaferpay
24
26
  @billpay = SixSaferpay::Billpay.new(billpay.to_h) if billpay
25
27
  @pending_notification = SixSaferpay::PendingNotification.new(pending_notification.to_h) if pending_notification
26
28
  @marketplace = SixSaferpay::Marketplace.new(marketplace.to_h) if marketplace
29
+ if mastercard_issuer_installments
30
+ @mastercard_issuer_installments = SixSaferpay::MastercardIssuerInstallments
31
+ .new(mastercard_issuer_installments.to_h)
32
+ end
27
33
  end
28
34
 
29
35
  def to_hash
@@ -34,6 +40,9 @@ module SixSaferpay
34
40
  hash.merge!(billpay: @billpay.to_h) if @billpay
35
41
  hash.merge!(pending_notification: @pending_notification.to_h) if @pending_notification
36
42
  hash.merge!(marketplace: @marketplace.to_h) if @marketplace
43
+ if @mastercard_issuer_installments
44
+ hash.merge!(mastercard_issuer_installments: mastercard_issuer_installments.to_h)
45
+ end
37
46
  hash
38
47
  end
39
48
  alias_method :to_h, :to_hash
@@ -8,12 +8,15 @@ module SixSaferpay
8
8
  :terminal_id,
9
9
  :payment,
10
10
  :payment_means,
11
+ :authentication,
11
12
  :payer,
12
13
  :return_urls,
13
14
  :styling,
14
15
  :wallet,
15
16
  :payment_methods,
16
- :card_form
17
+ :card_form,
18
+ :order,
19
+ :risk_factors
17
20
  )
18
21
 
19
22
 
@@ -22,24 +25,30 @@ module SixSaferpay
22
25
  terminal_id: nil,
23
26
  payment:,
24
27
  payment_means: nil,
28
+ authentication: nil,
25
29
  payer: nil,
26
30
  return_urls: nil,
27
31
  styling: nil,
28
32
  wallet: nil,
29
33
  payment_methods: nil,
30
- card_form: nil
34
+ card_form: nil,
35
+ order: nil,
36
+ risk_factors: nil
31
37
  )
32
38
  @request_header = request_header || SixSaferpay::RequestHeader.new()
33
39
  @config_set = config_set
34
40
  @terminal_id = terminal_id || SixSaferpay.config.terminal_id
35
41
  @payment = SixSaferpay::Payment.new(payment.to_h) if payment
36
42
  @payment_means = SixSaferpay::RequestPaymentMeans.new(payment_means.to_h) if payment_means
43
+ @authentication = SixSaferpay::Authentication.new(authentication.to_h) if authentication
37
44
  @payer = SixSaferpay::Payer.new(payer.to_h) if payer
38
45
  @return_urls = return_urls || SixSaferpay::ReturnUrls.new()
39
46
  @styling = SixSaferpay::Styling.new(styling.to_h) if styling
40
47
  @wallet = SixSaferpay::Wallet.new(wallet.to_h) if wallet
41
48
  @payment_methods = payment_methods
42
49
  @card_form = SixSaferpay::CardForm.new(card_form.to_h) if card_form
50
+ @order = SixSaferpay::Order.new(order.to_h) if order
51
+ @risk_factors = SixSaferpay::RiskFactors.new(risk_factors.to_h) if risk_factors
43
52
  end
44
53
 
45
54
  def to_hash
@@ -49,12 +58,15 @@ module SixSaferpay
49
58
  hash.merge!(terminal_id: @terminal_id) if @terminal_id
50
59
  hash.merge!(payment: @payment.to_h) if @payment
51
60
  hash.merge!(payment_means: @payment_means.to_h) if @payment_means
61
+ hash.merge!(authentication: @authentication.to_h) if @authentication
52
62
  hash.merge!(payer: @payer.to_h) if @payer
53
63
  hash.merge!(return_urls: @return_urls.to_h ) if @return_urls
54
64
  hash.merge!(styling: @styling.to_h) if @styling
55
65
  hash.merge!(wallet: @wallet.to_h) if @wallet
56
66
  hash.merge!(payment_methods: @payment_methods) if @payment_methods
57
67
  hash.merge!(card_form: @card_form.to_h) if @card_form
68
+ hash.merge!(order: @order.to_h) if @order
69
+ hash.merge!(risk_factors: @risk_factors.to_h) if @risk_factors
58
70
  hash
59
71
  end
60
72
  alias_method :to_h, :to_hash
@@ -6,7 +6,8 @@ module SixSaferpay
6
6
  :transaction,
7
7
  :payment_means,
8
8
  :payer,
9
- :registration_result
9
+ :registration_result,
10
+ :mastercard_issuer_installments
10
11
  )
11
12
 
12
13
 
@@ -14,13 +15,18 @@ module SixSaferpay
14
15
  transaction:,
15
16
  payment_means:,
16
17
  payer: nil,
17
- registration_result: nil
18
+ registration_result: nil,
19
+ mastercard_issuer_installments: nil
18
20
  )
19
21
  @response_header = SixSaferpay::ResponseHeader.new(response_header.to_h) if response_header
20
22
  @transaction = SixSaferpay::Transaction.new(transaction.to_h) if transaction
21
23
  @payment_means = SixSaferpay::ResponsePaymentMeans.new(payment_means.to_h) if payment_means
22
24
  @payer = SixSaferpay::Payer.new(payer.to_h) if payer
23
25
  @registration_result = SixSaferpay::RegistrationResult.new(registration_result.to_h) if registration_result
26
+ if mastercard_issuer_installments
27
+ @mastercard_issuer_installments = SixSaferpay::MastercardIssuerInstallments
28
+ .new(mastercard_issuer_installments.to_h)
29
+ end
24
30
  end
25
31
 
26
32
  def to_hash
@@ -30,6 +36,9 @@ module SixSaferpay
30
36
  hash.merge!(payment_means: @payment_means.to_h) if @payment_means
31
37
  hash.merge!(payer: @payer.to_h) if @payer
32
38
  hash.merge!(registration_result: @registration_result.to_h) if @registration_result
39
+ if @mastercard_issuer_installments
40
+ hash.merge!(mastercard_issuer_installments: mastercard_issuer_installments.to_h)
41
+ end
33
42
  hash
34
43
  end
35
44
  alias_method :to_h, :to_hash