six_saferpay 2.4.0 → 2.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +12 -2
  3. data/README.md +2 -2
  4. data/Thorfile +1 -0
  5. data/lib/generators/models.rb +100 -0
  6. data/lib/generators/templates/fabric.erb +13 -0
  7. data/lib/generators/templates/model.erb +64 -0
  8. data/lib/generators/templates/spec.erb +24 -0
  9. data/lib/six_saferpay.rb +5 -0
  10. data/lib/six_saferpay/api.rb +1 -1
  11. data/lib/six_saferpay/api/six_payment_page/requests/initialize.rb +10 -2
  12. data/lib/six_saferpay/api/six_payment_page/responses/assert_response.rb +8 -2
  13. data/lib/six_saferpay/api/six_secure_card_data/requests/insert.rb +6 -2
  14. data/lib/six_saferpay/api/six_secure_card_data/responses/insert_response.rb +9 -4
  15. data/lib/six_saferpay/api/six_secure_pay_gate_offer/requests/create_offer.rb +6 -2
  16. data/lib/six_saferpay/api/six_transaction/requests/alternative_payment.rb +11 -2
  17. data/lib/six_saferpay/api/six_transaction/requests/authorize_direct.rb +10 -2
  18. data/lib/six_saferpay/api/six_transaction/requests/initialize.rb +10 -2
  19. data/lib/six_saferpay/api/six_transaction/responses/authorize_direct_response.rb +10 -2
  20. data/lib/six_saferpay/api/six_transaction/responses/authorize_response.rb +8 -2
  21. data/lib/six_saferpay/api/six_transaction/responses/query_alternative_payment_response.rb +11 -2
  22. data/lib/six_saferpay/models/card_form.rb +11 -2
  23. data/lib/six_saferpay/models/fraud_prevention.rb +24 -0
  24. data/lib/six_saferpay/models/items.rb +84 -0
  25. data/lib/six_saferpay/models/options.rb +15 -3
  26. data/lib/six_saferpay/models/order.rb +27 -0
  27. data/lib/six_saferpay/models/payer.rb +8 -2
  28. data/lib/six_saferpay/models/payer_profile.rb +105 -0
  29. data/lib/six_saferpay/models/phone.rb +36 -0
  30. data/lib/six_saferpay/models/risk_factors.rb +39 -0
  31. data/lib/six_saferpay/version.rb +1 -1
  32. data/six_saferpay.gemspec +3 -2
  33. metadata +31 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a080926b5bdf943166bbcd992d4d7a0225312de53b76dc531bd7647ec8a42f1c
4
- data.tar.gz: dbcad29d4c52294fd934f2355176b0554c24db3696ac1e24cf64912fd6faff0b
3
+ metadata.gz: 6483acb13df18ef908da6c56f8471977ee56ce42873fa68ab6efb7a2bf316226
4
+ data.tar.gz: 3a233d74db8380ab58256e27803c4824f20fb3c00d2e13cc06dd246f23928802
5
5
  SHA512:
6
- metadata.gz: 3e2633d3ddd558c1efb063dea3490d37c100abb9d7fa48672d14ecab55e53fc20e24c280b1d68b5a01780d6e59c472b8ce62d7b548ae3f8b01a26d26154b9574
7
- data.tar.gz: b67ee84408caf95044891164d762bad9ad042401d982bda0d7265bcd9993934ee0e48b8345ac3b8f22a2e0e027521e48f39078997543c7274221d04274ab0469
6
+ metadata.gz: 487e3a0ed6d00b2aa79898249cff5e46cbd29a702f26589403d4c45c3aae190be167ce7c9c2d126ed5ea4b5d08c16a85296ee1cfd48d47808dfe2317a01cffa6
7
+ data.tar.gz: 3cbd4c3193f2f74dddc6b5bbcdd0d4dad8b4c23e200737f06592ccb5902651e4a96cbf24abe098125a38da77d78b534b986b7e188700300c33190c6b24478364
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- six_saferpay (1.16.2.4.0)
4
+ six_saferpay (2.8.0)
5
5
  activesupport (~> 6.1, >= 6.1.3)
6
6
 
7
7
  GEM
@@ -22,6 +22,7 @@ GEM
22
22
  diff-lcs (1.4.4)
23
23
  docile (1.3.5)
24
24
  dotenv (2.7.6)
25
+ ffi (1.14.2-java)
25
26
  hashdiff (1.0.1)
26
27
  i18n (1.8.9)
27
28
  concurrent-ruby (~> 1.0)
@@ -32,6 +33,10 @@ GEM
32
33
  pry (0.14.0)
33
34
  coderay (~> 1.1)
34
35
  method_source (~> 1.0)
36
+ pry (0.14.0-java)
37
+ coderay (~> 1.1)
38
+ method_source (~> 1.0)
39
+ spoon (~> 0.0)
35
40
  public_suffix (4.0.6)
36
41
  rake (13.0.3)
37
42
  rexml (3.2.4)
@@ -56,6 +61,9 @@ GEM
56
61
  simplecov_json_formatter (0.1.2)
57
62
  spinning_wheel (0.2.2)
58
63
  activesupport (>= 5.2.4.3)
64
+ spoon (0.0.6)
65
+ ffi
66
+ thor (1.1.0)
59
67
  tty-color (0.6.0)
60
68
  tty-cursor (0.7.1)
61
69
  tty-prompt (0.23.0)
@@ -77,18 +85,20 @@ GEM
77
85
  zeitwerk (2.4.2)
78
86
 
79
87
  PLATFORMS
88
+ arm64-darwin-20
80
89
  java
81
90
  ruby
82
91
 
83
92
  DEPENDENCIES
84
93
  bundler (~> 2.1)
85
94
  dotenv (~> 2.7, >= 2.7)
86
- pry (~> 0.13)
95
+ pry (~> 0.14)
87
96
  rake (~> 13.0)
88
97
  rspec (~> 3.0)
89
98
  simplecov (~> 0.19)
90
99
  six_saferpay!
91
100
  spinning_wheel (~> 0.2.2)
101
+ thor (~> 1.1.0)
92
102
  tty-prompt (~> 0.22)
93
103
  vcr (~> 4.0, >= 4.0.0)
94
104
  webmock (~> 3.10, >= 3.10)
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/six_saferpay.svg)](https://badge.fury.io/rb/six_saferpay)
2
- [![Build Status](https://travis-ci.org/fadendaten/six_saferpay.svg?branch=master)](https://travis-ci.org/fadendaten/six_saferpay)
2
+ [![Build Status](https://travis-ci.com/fadendaten/six_saferpay.svg?branch=master)](https://travis-ci.com/fadendaten/six_saferpay)
3
3
  [![Maintainability](https://api.codeclimate.com/v1/badges/76c9d1d0f261c276de96/maintainability)](https://codeclimate.com/github/fadendaten/six_saferpay/maintainability)
4
4
 
5
5
  # SixSaferpay
6
6
 
7
7
  ## Current API Version
8
8
 
9
- This gem is compatible with the SIX API version: `1.16`
9
+ This gem is compatible with the SIX API version: `1.20`
10
10
 
11
11
  ## Installation
12
12
 
data/Thorfile ADDED
@@ -0,0 +1 @@
1
+ Thor::Util.load_thorfile('lib/generators/models.rb')
@@ -0,0 +1,100 @@
1
+ require "thor"
2
+ require 'active_support/inflector'
3
+
4
+ module SixSaferpay
5
+ module Generators
6
+ class Model < Thor::Group
7
+ include Thor::Actions
8
+
9
+ attr_accessor :attributes, :file_name
10
+
11
+ argument :name
12
+ argument :method_attributes, optional: true, type: :hash
13
+ class_option :test_framework, :default => :test_unit
14
+
15
+ def self.source_root
16
+ File.dirname(__FILE__)
17
+ end
18
+
19
+ def file_name
20
+ @file_name = name.underscore
21
+ end
22
+
23
+ def create_attributes_array
24
+ @attributes = []
25
+ if method_attributes
26
+ method_attributes.each do |key, value|
27
+ split = value.split(':')
28
+
29
+ name = key.underscore
30
+ type = split.first
31
+ if split.length == 2
32
+ mandatory = split.last
33
+ else
34
+ mandatory = false
35
+ end
36
+
37
+ attribute = Attribute.new(name, type, mandatory)
38
+
39
+ @attributes << attribute
40
+ end
41
+ end
42
+ end
43
+
44
+ def create_model_file
45
+ template('templates/model.erb', "lib/six_saferpay/models/#{@file_name}.rb")
46
+ end
47
+
48
+ def create_test_file
49
+ template('templates/spec.erb', "spec/six_saferpay/models/#{@file_name}_spec.rb")
50
+ end
51
+
52
+ def create_fabric_file
53
+ template('templates/fabric.erb', "spec/fabrics/six_saferpay/models/#{@file_name.pluralize}.rb")
54
+ end
55
+
56
+ end
57
+
58
+ class Attribute
59
+ attr_accessor :name, :type, :mandatory
60
+
61
+ def initialize(name, type, mandatory = false)
62
+ @name = name
63
+ @type = type
64
+ if mandatory == "true"
65
+ @mandatory = true
66
+ elsif mandatory == "false"
67
+ @mandatory = false
68
+ else
69
+ @mandatory = mandatory
70
+ end
71
+ end
72
+
73
+ def mandatory?
74
+ @mandatory
75
+ end
76
+
77
+ def string?
78
+ @type.downcase == "string"
79
+ end
80
+
81
+ def boolean?
82
+ @type.downcase == "boolean"
83
+ end
84
+
85
+ def to_s
86
+ to_h
87
+ end
88
+
89
+ def to_h
90
+ hash = Hash.new
91
+ hash.merge!(name: name)
92
+ hash.merge!(type: type)
93
+ hash.merge!(mandatory: mandatory)
94
+ hash
95
+ end
96
+
97
+ end
98
+
99
+ end
100
+ end
@@ -0,0 +1,13 @@
1
+ SpinningWheel.define do
2
+ fabric name: '<%= file_name %>', class_name: 'SixSaferpay::<%= name %>' do
3
+ <%- attributes.each do |attr| -%>
4
+ <%- if attr.string? -%>
5
+ <%= "#{attr.name} { ' ' }" %>
6
+ <%- elsif attr.boolean? -%>
7
+ <%= "#{attr.name} { true }" %>
8
+ <%- else -%>
9
+ <%= "#{attr.name} { SpinningWheel.create('#{attr.name}') }" %>
10
+ <%- end -%>
11
+ <%- end -%>
12
+ end
13
+ end
@@ -0,0 +1,64 @@
1
+ module SixSaferpay
2
+ class <%= name %>
3
+
4
+ attr_accessor(
5
+ <%- attributes.each do |attr| -%>
6
+ :<%= attr.name %>,
7
+ <%- end -%>
8
+ )
9
+
10
+ def initialize(
11
+ <%- attributes.each_with_index do |attr, index| -%>
12
+ <%= "#{attr.name}:"-%>
13
+ <%- unless attr.mandatory? -%>
14
+ <%- -%><%= ' nil' -%>
15
+ <%- end -%>
16
+ <%- unless attr == attributes.last -%>
17
+ <%- -%><%= ',' %>
18
+ <%- end -%>
19
+ <%- end %>
20
+ )
21
+ <%- attributes.each_with_index do |attr, index| -%>
22
+ <%- if attr.string? || attr.boolean? -%>
23
+ <%= "@#{attr.name} = "-%><%= "#{attr.name}" %>
24
+ <%- else -%>
25
+ <%- %>
26
+ <%= "if #{attr.name}" %>
27
+ <%= "@#{attr.name} = "-%>
28
+ <%- -%><%= "SixSaferpay::#{attr.type}.new(#{attr.name}.to_h)" %>
29
+ <%= "end" %>
30
+ <%- end -%>
31
+ <%- end -%>
32
+ end
33
+
34
+ def to_hash
35
+ hash = Hash.new
36
+ <%- attributes.each do |attr| -%>
37
+ <%- if attr.string? -%>
38
+ <%- if attr.mandatory? -%>
39
+ <%= "hash.merge!(#{attr.name}: @#{attr.name})" %>
40
+ <%- else -%>
41
+ <%= "if @#{attr.name}" %>
42
+ <%= "hash.merge!(#{attr.name}: @#{attr.name})" %>
43
+ <%= "end" %>
44
+ <%- end -%>
45
+ <%- elsif attr.boolean? -%>
46
+ <%- if attr.mandatory? -%>
47
+ <%= "hash.merge!(#{attr.name}: @#{attr.name})" %>
48
+ <%- else -%>
49
+ <%= "if !@#{attr.name}.nil?" %>
50
+ <%= "hash.merge!(#{attr.name}: @#{attr.name})" %>
51
+ <%= "end" %>
52
+ <%- end -%>
53
+ <%- else -%>
54
+ <%= "if @#{attr.name}" %>
55
+ <%= "hash.merge!(#{attr.name}: @#{attr.name}.to_h)" %>
56
+ <%= "end" %>
57
+ <%- end -%>
58
+ <%- end -%>
59
+ hash
60
+ end
61
+ alias_method :to_h, :to_hash
62
+
63
+ end
64
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe SixSaferpay::<%= name %> do
4
+
5
+ subject { SpinningWheel.create('<%= file_name %>') }
6
+
7
+ let(:hash) {
8
+ {
9
+ <%- attributes.each do |attr| -%>
10
+ <%- if attr.string? || attr.boolean? -%>
11
+ <%= attr.name %>: subject.<%= attr.name %>,
12
+ <%- else -%>
13
+ <%= attr.name %>: subject.<%= attr.name %>.to_h,
14
+ <%- end -%>
15
+ <%- end -%>
16
+ }
17
+ }
18
+
19
+ describe 'to_hash' do
20
+ it 'returns the hash representation of the <%=name%>' do
21
+ expect(subject.to_hash).to eq(hash)
22
+ end
23
+ end
24
+ end
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.16'
3
+ VERSION = '1.20'
4
4
  end
5
5
  end
@@ -19,7 +19,9 @@ module SixSaferpay
19
19
  :billing_address_form,
20
20
  :delivery_address_form,
21
21
  :card_form,
22
- :condition
22
+ :condition,
23
+ :order,
24
+ :risk_factors
23
25
  )
24
26
 
25
27
  def initialize(request_header: nil,
@@ -38,7 +40,9 @@ module SixSaferpay
38
40
  billing_address_form: nil,
39
41
  delivery_address_form: nil,
40
42
  card_form: nil,
41
- condition: nil
43
+ condition: nil,
44
+ order: nil,
45
+ risk_factors: nil
42
46
  )
43
47
  @request_header = request_header || SixSaferpay::RequestHeader.new()
44
48
  @config_set = config_set
@@ -57,6 +61,8 @@ module SixSaferpay
57
61
  @delivery_address_form = SixSaferpay::DeliveryAddressForm.new(delivery_address_form.to_h) if delivery_address_form
58
62
  @card_form = SixSaferpay::CardForm.new(card_form.to_h) if card_form
59
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
60
66
  end
61
67
 
62
68
  def to_hash
@@ -78,6 +84,8 @@ module SixSaferpay
78
84
  hash.merge!(delivery_address_form: @delivery_address_form.to_h) if @delivery_address_form
79
85
  hash.merge!(card_form: @card_form.to_h) if @card_form
80
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
81
89
  hash
82
90
  end
83
91
  alias_method :to_h, :to_hash
@@ -9,7 +9,8 @@ module SixSaferpay
9
9
  :registration_result,
10
10
  :liability,
11
11
  :dcc,
12
- :mastercard_issuer_installments
12
+ :mastercard_issuer_installments,
13
+ :fraud_prevention,
13
14
  )
14
15
 
15
16
  def initialize(response_header:,
@@ -19,7 +20,8 @@ module SixSaferpay
19
20
  registration_result: nil,
20
21
  liability: nil,
21
22
  dcc: nil,
22
- mastercard_issuer_installments: nil
23
+ mastercard_issuer_installments: nil,
24
+ fraud_prevention: nil
23
25
  )
24
26
  @response_header = SixSaferpay::ResponseHeader.new(response_header.to_h)
25
27
  @transaction = SixSaferpay::Transaction.new(transaction.to_h)
@@ -32,6 +34,7 @@ module SixSaferpay
32
34
  @mastercard_issuer_installments = SixSaferpay::MastercardIssuerInstallments
33
35
  .new(mastercard_issuer_installments.to_h)
34
36
  end
37
+ @fraud_prevention = SixSaferpay::FraudPrevention.new(fraud_prevention.to_h) if fraud_prevention
35
38
  end
36
39
 
37
40
  def to_hash
@@ -46,6 +49,9 @@ module SixSaferpay
46
49
  if @mastercard_issuer_installments
47
50
  hash.merge!(mastercard_issuer_installments: mastercard_issuer_installments.to_h)
48
51
  end
52
+ if @fraud_prevention
53
+ hash.merge!(fraud_prevention: fraud_prevention.to_h)
54
+ end
49
55
  hash
50
56
  end
51
57
  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