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
@@ -17,17 +17,23 @@ module SixSaferpay
17
17
  hash = @response.body
18
18
  hash = JSON.parse(hash, symbolize_names: true)
19
19
  hash = transform_response_hash(hash)
20
- if @response.code == "200"
20
+ if @response.code == '200'
21
21
  @object.response_class.new(hash)
22
22
  else
23
23
  raise SixSaferpay::Error.new(hash)
24
24
  end
25
25
  end
26
26
 
27
+ protected
28
+
29
+ def header
30
+ {"Content-Type" => 'application/json'}
31
+ end
32
+
27
33
  private
28
34
 
29
35
  def request
30
- request = Net::HTTP::Post.new(uri.path, {'Content-Type' => 'application/json'})
36
+ request = Net::HTTP::Post.new(uri.path, header)
31
37
  hash = @object.to_h
32
38
  hash = transform_request_hash(hash)
33
39
  hash = hash.to_json
@@ -0,0 +1,23 @@
1
+ module SixSaferpay
2
+ module SecurePayGateApi
3
+ class Client < SixSaferpay::Client
4
+
5
+ protected
6
+
7
+ def header
8
+ super.merge!(
9
+ {
10
+ 'Saferpay-ApiVersion' => SixSaferpay::API::VERSION,
11
+ 'Saferpay-RequestId' => request_id()
12
+ }
13
+ )
14
+ end
15
+
16
+ private
17
+
18
+ def request_id
19
+ @request_id ||= SecureRandom.uuid
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,36 @@
1
+ module SixSaferpay
2
+ class Authentication
3
+
4
+ attr_accessor(
5
+ :result,
6
+ :message,
7
+ :xid,
8
+ :exemption,
9
+ :three_ds_challenge
10
+ )
11
+
12
+ def initialize(result: nil, # ATTENTION: This is in some case mandatory
13
+ message: nil, # ATTENTION: This is in some case mandatory
14
+ xid: nil,
15
+ exemption: nil,
16
+ three_ds_challenge: nil)
17
+ @result = result
18
+ @message = message
19
+ @xid = xid
20
+ @exemption = exemption
21
+ @three_ds_challenge = three_ds_challenge
22
+ end
23
+
24
+ def to_hash
25
+ hash = Hash.new
26
+ hash.merge!(result: @result) if @result
27
+ hash.merge!(message: @message) if @message
28
+ hash.merge!(xid: @xid) if @xid
29
+ hash.merge!(exemption: @exemption) if @exemption
30
+ hash.merge!(three_ds_challenge: @three_ds_challenge) if @three_ds_challenge
31
+ hash
32
+ end
33
+ alias_method :to_h, :to_hash
34
+
35
+ end
36
+ end
@@ -0,0 +1,20 @@
1
+ module SixSaferpay
2
+ class AuthenticationResult
3
+
4
+ attr_accessor :result, :message
5
+
6
+ def initialize(result:, message:)
7
+ @result = result
8
+ @message = message
9
+ end
10
+
11
+ def to_hash
12
+ hash = Hash.new
13
+ hash.merge!(result: @result)
14
+ hash.merge!(message: @message)
15
+ hash
16
+ end
17
+ alias_method :to_h, :to_hash
18
+
19
+ end
20
+ end
@@ -1,15 +1,24 @@
1
1
  module SixSaferpay
2
2
  class CardForm
3
3
 
4
- attr_accessor(:holder_name)
4
+ attr_accessor(
5
+ :holder_name,
6
+ :verification_code
7
+ )
5
8
 
6
- def initialize(holder_name: nil)
9
+ def initialize(
10
+ holder_name: nil,
11
+ verification_code: nil
12
+ )
7
13
  @holder_name = holder_name
14
+ @verification_code = verification_code
15
+
8
16
  end
9
17
 
10
18
  def to_hash
11
19
  hash = Hash.new
12
20
  hash.merge!(holder_name: @holder_name) if @holder_name
21
+ hash.merge!(verification_code: @verification_code) if @verification_code
13
22
  hash
14
23
  end
15
24
  alias_method :to_h, :to_hash
@@ -2,19 +2,23 @@ module SixSaferpay
2
2
  class CheckResult
3
3
 
4
4
  attr_accessor(:result,
5
- :message
5
+ :message,
6
+ :authentication
6
7
  )
7
8
 
8
9
  def initialize(result:,
9
- message: )
10
+ message: ,
11
+ authentication: nil)
10
12
  @result = result
11
13
  @message = message
14
+ @authentication = authentication
12
15
  end
13
16
 
14
17
  def to_hash
15
18
  hash = Hash.new
16
19
  hash.merge!(result: @result) if @result
17
20
  hash.merge!(message: @message) if @message
21
+ hash.merge!(authentication: @authentication.to_h) if @authentication
18
22
  hash
19
23
  end
20
24
  alias_method :to_h, :to_hash
@@ -0,0 +1,62 @@
1
+ module SixSaferpay
2
+ class ChosenPlan
3
+
4
+ attr_accessor(
5
+ :minimum_number_of_installments,
6
+ :maximum_number_of_installments,
7
+ :interest_rate,
8
+ :installment_fee,
9
+ :annual_percentage_rate,
10
+ :total_amount_due,
11
+ )
12
+
13
+ def initialize(
14
+ minimum_number_of_installments: ,
15
+ maximum_number_of_installments: ,
16
+ interest_rate: nil,
17
+ installment_fee: nil,
18
+ annual_percentage_rate: nil,
19
+ total_amount_due: nil
20
+ )
21
+ @minimum_number_of_installments =
22
+ minimum_number_of_installments
23
+ @maximum_number_of_installments =
24
+ maximum_number_of_installments
25
+ @interest_rate = interest_rate
26
+ if installment_fee
27
+ @installment_fee = SixSaferpay::InstallmentFee
28
+ .new(installment_fee.to_h)
29
+ end
30
+ if annual_percentage_rate
31
+ @annual_percentage_rate = annual_percentage_rate
32
+ end
33
+ if total_amount_due
34
+ @total_amount_due = SixSaferpay::TotalAmountDue
35
+ .new(total_amount_due.to_h)
36
+ end
37
+ end
38
+
39
+ def to_hash
40
+ hash = Hash.new
41
+ hash.merge!(minimum_number_of_installments:
42
+ @minimum_number_of_installments)
43
+ hash.merge!(maximum_number_of_installments:
44
+ @maximum_number_of_installments)
45
+ if @interest_rate
46
+ hash.merge!(interest_rate: @interest_rate)
47
+ end
48
+ if @installment_fee
49
+ hash.merge!(installment_fee: @installment_fee.to_h)
50
+ end
51
+ if @annual_percentage_rate
52
+ hash.merge!(annual_percentage_rate: @annual_percentage_rate)
53
+ end
54
+ if @total_amount_due
55
+ hash.merge!(total_amount_due: @total_amount_due.to_h)
56
+ end
57
+ hash
58
+ end
59
+ alias_method :to_h, :to_hash
60
+
61
+ end
62
+ end
@@ -0,0 +1,4 @@
1
+ module SixSaferpay
2
+ class CustomPlan < ChosenPlan
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module SixSaferpay
2
+ class FirstInstallmentAmount < Amount
3
+ end
4
+ end
@@ -0,0 +1,18 @@
1
+ module SixSaferpay
2
+ class Ideal
3
+
4
+ attr_accessor(:issuer_id)
5
+
6
+ def initialize(issuer_id:)
7
+ @issuer_id = issuer_id
8
+ end
9
+
10
+ def to_hash
11
+ hash = Hash.new
12
+ hash.merge!(issuer_id: @issuer_id) if @issuer_id
13
+ hash
14
+ end
15
+ alias_method :to_h, :to_hash
16
+
17
+ end
18
+ end
@@ -0,0 +1,4 @@
1
+ module SixSaferpay
2
+ class InstallmentFee < Amount
3
+ end
4
+ end
@@ -0,0 +1,73 @@
1
+ module SixSaferpay
2
+ class InstallmentPlans
3
+
4
+ attr_accessor(
5
+ :number_of_installments,
6
+ :interest_rate,
7
+ :installment_fee,
8
+ :annual_percentage_rate,
9
+ :first_installment_amount,
10
+ :subsequent_installment_amount,
11
+ :total_amount_due
12
+ )
13
+
14
+ def initialize(
15
+ number_of_installments: ,
16
+ interest_rate: nil,
17
+ installment_fee: nil,
18
+ annual_percentage_rate: nil,
19
+ first_installment_amount: nil,
20
+ subsequent_installment_amount: nil,
21
+ total_amount_due: nil
22
+ )
23
+ @number_of_installments = number_of_installments
24
+ @interest_rate = interest_rate
25
+ if installment_fee
26
+ @installment_fee = SixSaferpay::InstallmentFee
27
+ .new(installment_fee.to_h)
28
+ end
29
+ if annual_percentage_rate
30
+ @annual_percentage_rate = annual_percentage_rate
31
+ end
32
+ if first_installment_amount
33
+ @first_installment_amount = SixSaferpay::FirstInstallmentAmount
34
+ .new(first_installment_amount.to_h)
35
+ end
36
+ if subsequent_installment_amount
37
+ @subsequent_installment_amount = SixSaferpay::SubsequentInstallmentAmount
38
+ .new(subsequent_installment_amount.to_h)
39
+ end
40
+ if total_amount_due
41
+ @total_amount_due = SixSaferpay::TotalAmountDue
42
+ .new(total_amount_due.to_h)
43
+ end
44
+ end
45
+
46
+ def to_hash
47
+ hash = Hash.new
48
+ hash.merge!(number_of_installments: @number_of_installments)
49
+ if @interest_rate
50
+ hash.merge!(interest_rate: @interest_rate)
51
+ end
52
+ if @installment_fee
53
+ hash.merge!(installment_fee: @installment_fee.to_h)
54
+ end
55
+ if @annual_percentage_rate
56
+ hash.merge!(annual_percentage_rate: @annual_percentage_rate)
57
+ end
58
+ if @first_installment_amount
59
+ hash.merge!(first_installment_amount: @first_installment_amount.to_h)
60
+ end
61
+ if @subsequent_installment_amount
62
+ hash.merge!(subsequent_installment_amount: @subsequent_installment_amount.to_h)
63
+ end
64
+ if @total_amount_due
65
+ hash.merge!(total_amount_due: @total_amount_due.to_h)
66
+ end
67
+ hash
68
+ end
69
+ alias_method :to_h, :to_hash
70
+
71
+ end
72
+ end
73
+
@@ -0,0 +1,49 @@
1
+ module SixSaferpay
2
+ class MastercardIssuerInstallments
3
+
4
+ attr_accessor(
5
+ :installment_plans,
6
+ :custom_plan,
7
+ :chosen_plan,
8
+ :receipt_free_text
9
+ )
10
+
11
+ def initialize(
12
+ installment_plans: nil,
13
+ custom_plan: nil,
14
+ chosen_plan: nil,
15
+ receipt_free_text: nil
16
+ )
17
+ if installment_plans
18
+ @installment_plans = SixSaferpay::InstallmentPlans
19
+ .new(installment_plans.to_h)
20
+ end
21
+ if custom_plan
22
+ @custom_plan = SixSaferpay::CustomPlan
23
+ .new(custom_plan)
24
+ end
25
+ if chosen_plan
26
+ @chosen_plan = SixSaferpay::ChosenPlan
27
+ .new(chosen_plan.to_h)
28
+ end
29
+ @receipt_free_text = receipt_free_text
30
+ end
31
+
32
+ def to_hash
33
+ hash = Hash.new
34
+ if @installment_plans
35
+ hash.merge!(installment_plans: @installment_plans.to_h)
36
+ end
37
+ if @custom_plan
38
+ hash.merge!(custom_plan: @custom_plan.to_h)
39
+ end
40
+ if @chosen_plan
41
+ hash.merge!(chosen_plan: @chosen_plan.to_h)
42
+ end
43
+ hash.merge!(receipt_free_text: @receipt_free_text)
44
+ hash
45
+ end
46
+ alias_method :to_h, :to_hash
47
+
48
+ end
49
+ end
@@ -1,15 +1,17 @@
1
1
  module SixSaferpay
2
2
  class PaymentMethodsOptions
3
3
 
4
- attr_accessor(:alipay)
4
+ attr_accessor(:alipay, :ideal)
5
5
 
6
- def initialize(alipay: nil)
6
+ def initialize(alipay: nil, ideal: nil)
7
7
  @alipay = SixSaferpay::Alipay.new(alipay.to_h) if alipay
8
+ @ideal = SixSaferpay::Ideal.new(ideal.to_h) if ideal
8
9
  end
9
10
 
10
11
  def to_hash
11
12
  hash = Hash.new
12
13
  hash.merge!(alipay: @alipay.to_h) if @alipay
14
+ hash.merge!(ideal: @ideal.to_h) if @ideal
13
15
  hash
14
16
  end
15
17
  alias_method :to_h, :to_hash
@@ -3,17 +3,23 @@ module SixSaferpay
3
3
 
4
4
  attr_accessor(:success,
5
5
  :fd_alias,
6
- :error
6
+ :error,
7
+ :authentication_result
7
8
  )
8
9
 
9
10
 
10
11
  def initialize(success:,
11
12
  fd_alias: nil,
12
- error: nil)
13
+ error: nil,
14
+ authentication_result: nil)
13
15
 
14
16
  @success = success
15
17
  @fd_alias = SixSaferpay::RegistrationAlias.new(fd_alias.to_h) if fd_alias
16
18
  @error = SixSaferpay::RegistrationError.new(error.to_h) if error
19
+ if authentication_result
20
+ @authentication_result = SixSaferpay::AuthenticationResult
21
+ .new(authentication_result.to_h)
22
+ end
17
23
  end
18
24
 
19
25
  def to_hash
@@ -21,6 +27,9 @@ module SixSaferpay
21
27
  hash.merge!(success: @success) if !@success.nil?
22
28
  hash.merge!(fd_alias: @fd_alias.to_h) if @fd_alias
23
29
  hash.merge!(error: @error.to_h) if @error
30
+ if authentication_result
31
+ hash.merge!(authentication_result: @authentication_result.to_h)
32
+ end
24
33
  hash
25
34
  end
26
35
  alias_method :to_h, :to_hash