six_saferpay 2.1.1 → 2.5.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/.test.env +1 -1
  4. data/.travis.yml +4 -2
  5. data/Gemfile.lock +77 -82
  6. data/README.md +19 -1
  7. data/Thorfile +1 -0
  8. data/lib/generators/models.rb +96 -0
  9. data/lib/generators/templates/fabric.erb +15 -0
  10. data/lib/generators/templates/model.erb +56 -0
  11. data/lib/generators/templates/spec.erb +24 -0
  12. data/lib/six_saferpay.rb +5 -0
  13. data/lib/six_saferpay/api.rb +1 -1
  14. data/lib/six_saferpay/api/six_payment_page/requests/initialize.rb +4 -0
  15. data/lib/six_saferpay/api/six_payment_page/responses/assert_response.rb +11 -2
  16. data/lib/six_saferpay/api/six_secure_card_data/requests/insert.rb +6 -2
  17. data/lib/six_saferpay/api/six_secure_card_data/responses/insert_response.rb +9 -4
  18. data/lib/six_saferpay/api/six_secure_pay_gate_offer/requests/create_offer.rb +61 -0
  19. data/lib/six_saferpay/api/six_secure_pay_gate_offer/responses/create_offer_response.rb +26 -0
  20. data/lib/six_saferpay/api/six_transaction/requests/authorize_direct.rb +4 -0
  21. data/lib/six_saferpay/api/six_transaction/requests/authorize_referenced.rb +4 -0
  22. data/lib/six_saferpay/api/six_transaction/requests/capture.rb +11 -2
  23. data/lib/six_saferpay/api/six_transaction/requests/initialize.rb +4 -0
  24. data/lib/six_saferpay/api/six_transaction/responses/authorize_direct_response.rb +11 -2
  25. data/lib/six_saferpay/api/six_transaction/responses/authorize_response.rb +11 -3
  26. data/lib/six_saferpay/client.rb +8 -2
  27. data/lib/six_saferpay/clients/secure_pay_gate_api/client.rb +23 -0
  28. data/lib/six_saferpay/models/authentication.rb +36 -0
  29. data/lib/six_saferpay/models/authentication_result.rb +20 -0
  30. data/lib/six_saferpay/models/card_form.rb +11 -2
  31. data/lib/six_saferpay/models/check_result.rb +6 -2
  32. data/lib/six_saferpay/models/chosen_plan.rb +62 -0
  33. data/lib/six_saferpay/models/custom_plan.rb +4 -0
  34. data/lib/six_saferpay/models/first_installment_amount.rb +4 -0
  35. data/lib/six_saferpay/models/ideal.rb +18 -0
  36. data/lib/six_saferpay/models/installment_fee.rb +4 -0
  37. data/lib/six_saferpay/models/installment_plans.rb +73 -0
  38. data/lib/six_saferpay/models/mastercard_issuer_installments.rb +49 -0
  39. data/lib/six_saferpay/models/payment_methods_options.rb +4 -2
  40. data/lib/six_saferpay/models/registration_result.rb +11 -2
  41. data/lib/six_saferpay/models/request_payment_means.rb +6 -2
  42. data/lib/six_saferpay/models/saferpay_fields.rb +18 -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 +57 -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.13'
3
+ VERSION = '1.17'
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,
@@ -27,6 +28,7 @@ module SixSaferpay
27
28
  payment:,
28
29
  payment_methods: nil,
29
30
  payment_methods_options: nil,
31
+ authentication: nil,
30
32
  wallets: nil,
31
33
  payer: nil,
32
34
  register_alias: nil,
@@ -44,6 +46,7 @@ module SixSaferpay
44
46
  @payment = SixSaferpay::Payment.new(payment.to_h) if payment
45
47
  @payment_methods = payment_methods
46
48
  @payment_methods_options = SixSaferpay::PaymentMethodsOptions.new(payment_methods_options.to_h) if payment_methods_options
49
+ @authentication = SixSaferpay::Authentication.new(authentication.to_h) if authentication
47
50
  @wallets = wallets
48
51
  @payer = SixSaferpay::Payer.new(payer.to_h) if payer
49
52
  @register_alias = SixSaferpay::RegisterAlias.new(register_alias.to_h) if register_alias
@@ -64,6 +67,7 @@ module SixSaferpay
64
67
  hash.merge!(payment: @payment.to_h)
65
68
  hash.merge!(payment_methods: @payment_methods) if @payment_methods
66
69
  hash.merge!(payment_methods_options: @payment_methods_options.to_h) if @payment_methods_options
70
+ hash.merge!(authentication: @authentication.to_h) if @authentication
67
71
  hash.merge!(wallets: @wallets) if @wallets
68
72
  hash.merge!(payer: @payer.to_h) if @payer
69
73
  hash.merge!(register_alias: @register_alias.to_h) if @register_alias
@@ -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
@@ -0,0 +1,61 @@
1
+ module SixSaferpay
2
+ module SixSecurePayGateOffer
3
+ class CreateOffer
4
+
5
+ attr_accessor(:payment,
6
+ :expiration_date,
7
+ :config_set,
8
+ :payer,
9
+ :billing_address_form
10
+ )
11
+
12
+ def initialize(payment: ,
13
+ expiration_date: ,
14
+ config_set: nil,
15
+ payer: ,
16
+ billing_address_form: nil
17
+ )
18
+
19
+ @payment = SixSaferpay::Payment.new(payment.to_h) if payment
20
+ @expiration_date = expiration_date
21
+ @config_set = config_set
22
+ @payer = SixSaferpay::Payer.new(payer.to_h) if payer
23
+ @billing_address_form =
24
+ SixSaferpay::BillingAddressForm.new(billing_address_form) if billing_address_form
25
+ end
26
+
27
+ def to_hash
28
+ hash = Hash.new
29
+ hash.merge!(payment: @payment.to_h) if @payment
30
+ hash.merge!(expiration_date: @expiration_date) if @expiration_date
31
+ hash.merge!(config_set: @config_set) if @config_set
32
+ hash.merge!(payer: @payer.to_h) if @payer
33
+ hash.merge!(billing_address_form: @billing_address_form.to_h) if @billing_address_form
34
+ hash
35
+ end
36
+ alias_method :to_h, :to_hash
37
+
38
+ def to_json
39
+ to_hash.to_json
40
+ end
41
+
42
+ def url
43
+ "/rest/customers/#{customer_id}/terminals/#{terminal_id}/spg-offers"
44
+ end
45
+
46
+ def response_class
47
+ SixSaferpay::SixSecurePayGateOffer::CreateOfferResponse
48
+ end
49
+
50
+ private
51
+
52
+ def customer_id
53
+ SixSaferpay.config.customer_id
54
+ end
55
+
56
+ def terminal_id
57
+ SixSaferpay.config.terminal_id
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,26 @@
1
+ module SixSaferpay
2
+ module SixSecurePayGateOffer
3
+ class CreateOfferResponse
4
+
5
+ attr_accessor(:offer_id,
6
+ :payment_link
7
+ )
8
+
9
+ def initialize(offer_id:,
10
+ payment_link: )
11
+
12
+ @offer_id = offer_id if offer_id
13
+ @payment_link = payment_link if payment_link
14
+ end
15
+
16
+ def to_hash
17
+ hash = Hash.new
18
+ hash.merge!(offer_id: @offer_id) if @offer_id
19
+ hash.merge!(payment_link: @payment_link) if @payment_link
20
+ hash
21
+ end
22
+ alias_method :to_h, :to_hash
23
+
24
+ end
25
+ end
26
+ end
@@ -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,6 +8,7 @@ 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,
@@ -22,6 +23,7 @@ module SixSaferpay
22
23
  terminal_id: nil,
23
24
  payment:,
24
25
  payment_means: nil,
26
+ authentication: nil,
25
27
  payer: nil,
26
28
  return_urls: nil,
27
29
  styling: nil,
@@ -34,6 +36,7 @@ module SixSaferpay
34
36
  @terminal_id = terminal_id || SixSaferpay.config.terminal_id
35
37
  @payment = SixSaferpay::Payment.new(payment.to_h) if payment
36
38
  @payment_means = SixSaferpay::RequestPaymentMeans.new(payment_means.to_h) if payment_means
39
+ @authentication = SixSaferpay::Authentication.new(authentication.to_h) if authentication
37
40
  @payer = SixSaferpay::Payer.new(payer.to_h) if payer
38
41
  @return_urls = return_urls || SixSaferpay::ReturnUrls.new()
39
42
  @styling = SixSaferpay::Styling.new(styling.to_h) if styling
@@ -49,6 +52,7 @@ module SixSaferpay
49
52
  hash.merge!(terminal_id: @terminal_id) if @terminal_id
50
53
  hash.merge!(payment: @payment.to_h) if @payment
51
54
  hash.merge!(payment_means: @payment_means.to_h) if @payment_means
55
+ hash.merge!(authentication: @authentication.to_h) if @authentication
52
56
  hash.merge!(payer: @payer.to_h) if @payer
53
57
  hash.merge!(return_urls: @return_urls.to_h ) if @return_urls
54
58
  hash.merge!(styling: @styling.to_h) if @styling
@@ -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
@@ -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
 
@@ -18,8 +19,8 @@ module SixSaferpay
18
19
  payer: nil,
19
20
  registration_result: nil,
20
21
  liability: nil,
21
- dcc: nil
22
-
22
+ dcc: nil,
23
+ mastercard_issuer_installments: nil
23
24
  )
24
25
  @response_header = SixSaferpay::ResponseHeader.new(response_header.to_h) if response_header
25
26
  @transaction = SixSaferpay::Transaction.new(transaction.to_h) if transaction
@@ -28,6 +29,10 @@ module SixSaferpay
28
29
  @registration_result = SixSaferpay::RegistrationResult.new(registration_result.to_h) if registration_result
29
30
  @liability = SixSaferpay::Liability.new(liability.to_h) if liability
30
31
  @dcc = SixSaferpay::Dcc.new(dcc.to_h) if dcc
32
+ if mastercard_issuer_installments
33
+ @mastercard_issuer_installments = SixSaferpay::MastercardIssuerInstallments
34
+ .new(mastercard_issuer_installments.to_h)
35
+ end
31
36
  end
32
37
 
33
38
  def to_hash
@@ -39,6 +44,9 @@ module SixSaferpay
39
44
  hash.merge!(registration_result: @registration_result.to_h) if @registration_result
40
45
  hash.merge!(liability: @liability.to_h) if @liability
41
46
  hash.merge!(dcc: @dcc.to_h) if @dcc
47
+ if @mastercard_issuer_installments
48
+ hash.merge!(mastercard_issuer_installments: mastercard_issuer_installments.to_h)
49
+ end
42
50
  hash
43
51
  end
44
52
  alias_method :to_h, :to_hash