six_saferpay 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/Gemfile.lock +58 -0
  4. data/lib/six_saferpay/api/six_payment_page/requests/assert.rb +34 -0
  5. data/lib/six_saferpay/api/six_payment_page/requests/initialize.rb +96 -0
  6. data/lib/six_saferpay/api/six_payment_page/responses/assert_response.rb +46 -0
  7. data/lib/six_saferpay/api/six_payment_page/responses/initalize_response.rb +44 -0
  8. data/lib/six_saferpay/api/six_payment_page.rb +10 -0
  9. data/lib/six_saferpay/api/six_transaction/requests/authorization.rb +33 -0
  10. data/lib/six_saferpay/api/six_transaction/requests/cancel.rb +33 -0
  11. data/lib/six_saferpay/api/six_transaction/requests/capture.rb +54 -0
  12. data/lib/six_saferpay/api/six_transaction/requests/initialize.rb +73 -0
  13. data/lib/six_saferpay/api/six_transaction/responses/capture_response.rb +32 -0
  14. data/lib/six_saferpay/api/six_transaction/responses/initialize_response.rb +12 -0
  15. data/lib/six_saferpay/api/six_transaction.rb +4 -0
  16. data/lib/six_saferpay/api.rb +1 -4
  17. data/lib/six_saferpay/client.rb +17 -5
  18. data/lib/six_saferpay/error.rb +11 -0
  19. data/lib/six_saferpay/model.rb +5 -0
  20. data/lib/six_saferpay/models/address.rb +73 -0
  21. data/lib/six_saferpay/models/address_form.rb +21 -0
  22. data/lib/six_saferpay/models/alias.rb +23 -0
  23. data/lib/six_saferpay/models/alipay.rb +18 -0
  24. data/lib/six_saferpay/models/amount.rb +19 -0
  25. data/lib/six_saferpay/models/bank_account.rb +35 -0
  26. data/lib/six_saferpay/models/billing_address.rb +4 -0
  27. data/lib/six_saferpay/models/billing_address_form.rb +4 -0
  28. data/lib/six_saferpay/models/billpay.rb +18 -0
  29. data/lib/six_saferpay/models/brand.rb +20 -0
  30. data/lib/six_saferpay/models/card.rb +40 -0
  31. data/lib/six_saferpay/models/card_form.rb +18 -0
  32. data/lib/six_saferpay/models/client_info.rb +20 -0
  33. data/lib/six_saferpay/models/dcc.rb +18 -0
  34. data/lib/six_saferpay/models/debit_direct.rb +20 -0
  35. data/lib/six_saferpay/models/delivery_address.rb +4 -0
  36. data/lib/six_saferpay/models/delivery_address_form.rb +4 -0
  37. data/lib/six_saferpay/models/fee.rb +4 -0
  38. data/lib/six_saferpay/models/fee_refund.rb +4 -0
  39. data/lib/six_saferpay/models/installment.rb +18 -0
  40. data/lib/six_saferpay/models/invoice.rb +22 -0
  41. data/lib/six_saferpay/models/liability.rb +36 -0
  42. data/lib/six_saferpay/models/marketplace.rb +22 -0
  43. data/lib/six_saferpay/models/notification.rb +26 -0
  44. data/lib/six_saferpay/models/options.rb +18 -0
  45. data/lib/six_saferpay/models/payee.rb +23 -0
  46. data/lib/six_saferpay/models/payer.rb +27 -7
  47. data/lib/six_saferpay/models/payer_amount.rb +22 -0
  48. data/lib/six_saferpay/models/payment.rb +33 -14
  49. data/lib/six_saferpay/models/payment_means.rb +40 -0
  50. data/lib/six_saferpay/models/payment_methods_options.rb +18 -0
  51. data/lib/six_saferpay/models/pending_notification.rb +20 -0
  52. data/lib/six_saferpay/models/recurring.rb +18 -0
  53. data/lib/six_saferpay/models/register_alias.rb +23 -0
  54. data/lib/six_saferpay/models/registration_result.rb +27 -0
  55. data/lib/six_saferpay/models/request_header.rb +12 -11
  56. data/lib/six_saferpay/models/response_header.rb +20 -0
  57. data/lib/six_saferpay/models/return_urls.rb +12 -10
  58. data/lib/six_saferpay/models/six_transaction/initialize/card.rb +44 -0
  59. data/lib/six_saferpay/models/six_transaction/initialize/payment_means.rb +32 -0
  60. data/lib/six_saferpay/models/six_transaction/initialize.rb +6 -0
  61. data/lib/six_saferpay/models/six_transaction.rb +4 -0
  62. data/lib/six_saferpay/models/styling.rb +12 -7
  63. data/lib/six_saferpay/models/terminal.rb +14 -14
  64. data/lib/six_saferpay/models/three_ds.rb +28 -0
  65. data/lib/six_saferpay/models/transaction.rb +69 -0
  66. data/lib/six_saferpay/models/transaction_reference.rb +11 -7
  67. data/lib/six_saferpay/models/twint.rb +18 -0
  68. data/lib/six_saferpay/models/verification_code.rb +4 -2
  69. data/lib/six_saferpay/models/wallet.rb +32 -0
  70. data/lib/six_saferpay/version.rb +1 -1
  71. data/lib/six_saferpay.rb +6 -15
  72. data/six_saferpay.gemspec +12 -5
  73. metadata +131 -15
  74. data/.rspec_status +0 -28
  75. data/lib/six_saferpay/api/payment_page/assert.rb +0 -30
  76. data/lib/six_saferpay/api/payment_page/initialize.rb +0 -35
  77. data/lib/six_saferpay/api/payment_page.rb +0 -20
  78. data/lib/six_saferpay/api/transaction/authorization.rb +0 -31
  79. data/lib/six_saferpay/api/transaction/cancel.rb +0 -31
  80. data/lib/six_saferpay/api/transaction/capture.rb +0 -31
  81. data/lib/six_saferpay/api/transaction/initialize.rb +0 -36
  82. data/lib/six_saferpay/api/transaction.rb +0 -22
  83. data/lib/six_saferpay/models/token.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8520c33496083c2c6f23a76657cf6ce7e1debbf05fc5761c8fbf5caf3d1a65cb
4
- data.tar.gz: 814f9bfb5e08bf71f2b2f7a28e7b633e585de745bd2acd294123e578840197a7
3
+ metadata.gz: b52f1f6d399f893e6ad6ce6a9c03252b07227d0ea8b9622b5bf7681e1b22d398
4
+ data.tar.gz: fee92aad4df6c843b6d33435b3c456225680b3afe910262895a547b3a65929f0
5
5
  SHA512:
6
- metadata.gz: fd201b0cc5967e33843eee36ea45f71d57e600eace52b34a3994322f140a828e83d803007f179376707a4cd0bc045c8c3f6ccede58e18576ead1bd17f2104722
7
- data.tar.gz: 335d9d27c32172e2f3dce215ae8c48eff207fbd83b90aa3ff5fb80b33a1b4f8ce4996bb65a329897015dc86b0be4cddbec7af6d04c8f5df369df199c60f756d2
6
+ metadata.gz: 372d49955f7b13a679097cd62e14b15ffee9098233baa1a9d5bf01de75b6e22527bafa4e6e6eb94b4ceaacf00d7320f1912183ecdf3461b710b2046a3a1cf37e
7
+ data.tar.gz: fef687dc44de1264046f7860ec12a9d636f287ecf02b3c01e403d30f7954fa54d50595b2e2397b18c2031e5c70761c3144eea2c203e5acf51d72db53c1a320ff
data/.gitignore CHANGED
@@ -161,3 +161,6 @@ tags
161
161
  [._]*.un~
162
162
 
163
163
  # End of https://www.gitignore.io/api/vim,ruby,rails,macos
164
+ #
165
+ .rspec_status
166
+ coverage
data/Gemfile.lock CHANGED
@@ -2,15 +2,38 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  six_saferpay (0.0.1)
5
+ activesupport (>= 5.0.0.0)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
10
+ activesupport (5.2.3)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 0.7, < 2)
13
+ minitest (~> 5.1)
14
+ tzinfo (~> 1.1)
15
+ addressable (2.6.0)
16
+ public_suffix (>= 2.0.2, < 4.0)
9
17
  coderay (1.1.2)
18
+ concurrent-ruby (1.1.5)
19
+ crack (0.4.3)
20
+ safe_yaml (~> 1.0.0)
10
21
  diff-lcs (1.3)
22
+ docile (1.3.1)
11
23
  dotenv (2.7.1)
24
+ equatable (0.5.0)
12
25
  ffi (1.10.0-java)
26
+ hashdiff (0.3.8)
27
+ i18n (1.6.0)
28
+ concurrent-ruby (~> 1.0)
29
+ json (2.2.0)
30
+ json (2.2.0-java)
13
31
  method_source (0.9.2)
32
+ minitest (5.11.3)
33
+ necromancer (0.4.0)
34
+ pastel (0.7.2)
35
+ equatable (~> 0.5.0)
36
+ tty-color (~> 0.4.0)
14
37
  pry (0.12.2)
15
38
  coderay (~> 1.1.0)
16
39
  method_source (~> 0.9.0)
@@ -18,6 +41,7 @@ GEM
18
41
  coderay (~> 1.1.0)
19
42
  method_source (~> 0.9.0)
20
43
  spoon (~> 0.0)
44
+ public_suffix (3.0.3)
21
45
  rake (10.5.0)
22
46
  rspec (3.8.0)
23
47
  rspec-core (~> 3.8.0)
@@ -32,8 +56,38 @@ GEM
32
56
  diff-lcs (>= 1.2.0, < 2.0)
33
57
  rspec-support (~> 3.8.0)
34
58
  rspec-support (3.8.0)
59
+ safe_yaml (1.0.5)
60
+ simplecov (0.16.1)
61
+ docile (~> 1.1)
62
+ json (>= 1.8, < 3)
63
+ simplecov-html (~> 0.10.0)
64
+ simplecov-html (0.10.2)
35
65
  spoon (0.0.6)
36
66
  ffi
67
+ thread_safe (0.3.6)
68
+ thread_safe (0.3.6-java)
69
+ timers (4.3.0)
70
+ tty-color (0.4.3)
71
+ tty-cursor (0.6.1)
72
+ tty-prompt (0.18.1)
73
+ necromancer (~> 0.4.0)
74
+ pastel (~> 0.7.0)
75
+ timers (~> 4.0)
76
+ tty-cursor (~> 0.6.0)
77
+ tty-reader (~> 0.5.0)
78
+ tty-reader (0.5.0)
79
+ tty-cursor (~> 0.6.0)
80
+ tty-screen (~> 0.6.4)
81
+ wisper (~> 2.0.0)
82
+ tty-screen (0.6.5)
83
+ tzinfo (1.2.5)
84
+ thread_safe (~> 0.1)
85
+ vcr (4.0.0)
86
+ webmock (3.5.1)
87
+ addressable (>= 2.3.6)
88
+ crack (>= 0.3.2)
89
+ hashdiff
90
+ wisper (2.0.0)
37
91
 
38
92
  PLATFORMS
39
93
  java
@@ -45,7 +99,11 @@ DEPENDENCIES
45
99
  pry (~> 0.12.0)
46
100
  rake (~> 10.0)
47
101
  rspec (~> 3.0)
102
+ simplecov (~> 0.16)
48
103
  six_saferpay!
104
+ tty-prompt (~> 0.18)
105
+ vcr (~> 4.0.0)
106
+ webmock (~> 3.5.1)
49
107
 
50
108
  BUNDLED WITH
51
109
  2.0.1
@@ -0,0 +1,34 @@
1
+ module SixSaferpay
2
+ module SixPaymentPage
3
+ class Assert
4
+
5
+ attr_accessor(:request_header, :token)
6
+
7
+ def initialize(request_header: nil, token:)
8
+ @request_header = request_header || SixSaferpay::RequestHeader.new()
9
+ @token = token
10
+ end
11
+
12
+ def to_hash
13
+ hash = Hash.new
14
+ hash.merge!(@request_header.to_h)
15
+ hash.merge!(Token: @token)
16
+ hash
17
+ end
18
+ alias_method :to_h, :to_hash
19
+
20
+ def to_json
21
+ to_hash.to_json
22
+ end
23
+
24
+ def url
25
+ '/Payment/v1/PaymentPage/Assert'
26
+ end
27
+
28
+ def response_class
29
+ SixSaferpay::SixPaymentPage::AssertResponse
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,96 @@
1
+ module SixSaferpay
2
+ module SixPaymentPage
3
+ class Initialize
4
+
5
+ attr_accessor(
6
+ :request_header,
7
+ :config_set,
8
+ :terminal_id,
9
+ :payment,
10
+ :payment_methods,
11
+ :payment_methods_options,
12
+ :wallets,
13
+ :payer,
14
+ :register_alias,
15
+ :return_urls,
16
+ :notification,
17
+ :styling,
18
+ :billing_address_form,
19
+ :delivery_address_form,
20
+ :card_form,
21
+ :condition
22
+
23
+ )
24
+
25
+ def initialize(request_header: nil,
26
+ config_set: nil,
27
+ terminal_id: nil,
28
+ payment:,
29
+ payment_methods: nil,
30
+ payment_methods_options: nil,
31
+ wallets: nil,
32
+ payer: nil,
33
+ register_alias: nil,
34
+ return_urls: nil,
35
+ notification: nil,
36
+ styling: nil,
37
+ billing_address_form: nil,
38
+ delivery_address_form: nil,
39
+ card_form: nil,
40
+ condition: nil
41
+ )
42
+ @request_header = request_header || SixSaferpay::RequestHeader.new()
43
+ @config_set = @config_set
44
+ @terminal_id = terminal_id || SixSaferpay.config.terminal_id
45
+ @payment = SixSaferpay::Payment.new(payment.to_h) if payment
46
+ @payment_methods = payment_methods
47
+ @payment_methods_options = SixSaferpay::PaymentMethodsOptions.new(payment_methods_options.to_h) if payment_methods_options
48
+ @wallets = wallets
49
+ @payer = SixSaferpay::Payer.new(payer.to_h) if payer
50
+ @register_alias = SixSaferpay::RegisterAlias.new(register_alias.to_h) if register_alias
51
+ @return_urls = return_urls || SixSaferpay::ReturnUrls.new()
52
+ @notification = SixSaferpay::Notification.new(notification.to_h) if notification
53
+ @styling = SixSaferpay::Styling.new(styling.to_h) if styling
54
+ @billing_address_form = SixSaferpay::BillingAddressForm.new(billing_address_form.to_h) if billing_address_form
55
+ @delivery_address_form = SixSaferpay::DeliveryAddressForm.new(delivery_address_form.to_h) if delivery_address_form
56
+ @card_form = SixSaferpay::CardForm.new(card_form.to_h) if card_form
57
+ @condition = condition
58
+ end
59
+
60
+ def to_hash
61
+ hash = Hash.new
62
+ hash.merge!(request_header: @request_header.to_h)
63
+ hash.merge!(config_set: @config_set) if @config_set
64
+ hash.merge!(terminal_id: @terminal_id)
65
+ hash.merge!(payment: @payment.to_h)
66
+ hash.merge!(payment_methods: @payment_methods) if @payment_methods
67
+ hash.merge!(payment_methods_options: @payment_methods_options) if @payment_methods_options
68
+ hash.merge!(wallets: @wallets) if @wallets
69
+ hash.merge!(payer: @payer.to_h) if @payer
70
+ hash.merge!(register_alias: @register_alias.to_h) if @register_alias
71
+ hash.merge!(return_urls: @return_urls.to_h)
72
+ hash.merge!(notification: @notification.to_h) if @notification
73
+ hash.merge!(styling: @styling.to_h) if @styling
74
+ hash.merge!(billing_address_form: @billing_address_form.to_h) if @billing_address_form
75
+ hash.merge!(delivery_address_form: @delivery_address_form.to_h) if @delivery_address_form
76
+ hash.merge!(card_form: @card_form.to_h) if @card_form
77
+ hash.merge!(condition: @codition) if @condition
78
+ hash
79
+ end
80
+ alias_method :to_h, :to_hash
81
+
82
+ def to_json
83
+ to_hash.to_json
84
+ end
85
+
86
+ def url
87
+ '/Payment/v1/PaymentPage/Initialize'
88
+ end
89
+
90
+ def response_class
91
+ SixSaferpay::SixPaymentPage::InitializeResponse
92
+ end
93
+
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,46 @@
1
+ module SixSaferpay
2
+ module SixPaymentPage
3
+ class AssertResponse
4
+
5
+ attr_accessor(:response_header,
6
+ :transaction,
7
+ :payment_means,
8
+ :payer,
9
+ :registration_result,
10
+ :liability,
11
+ :dcc
12
+ )
13
+
14
+ def initialize(response_header:,
15
+ transaction:,
16
+ payment_means:,
17
+ payer: nil,
18
+ registration_result: nil,
19
+ liability: nil,
20
+ dcc: nil
21
+ )
22
+ @response_header = SixSaferpay::ResponseHeader.new(response_header.to_h)
23
+ @transaction = SixSaferpay::Transaction.new(transaction.to_h)
24
+ @payment_means = SixSaferpay::PaymentMeans.new(payment_means.to_h)
25
+ @payer = SixSaferpay::Payer.new(payer.to_h) if payer
26
+ @registration_result = SixSaferpay::RegistrationResult.new(registration_result.to_h) if registration_result
27
+ @liability = SixSaferpay::Liability.new(liability.to_h) if liability
28
+ @dcc = SixSaferpay::Dcc.new(dcc.to_h) if dcc
29
+ end
30
+
31
+ def to_hash
32
+ hash = Hash.new
33
+ hash.merge!(ResponseHeader: @response_header.to_h) if @response_header
34
+ hash.merge!(Transaction: @transaction.to_h) if @transaction
35
+ hash.merge!(PaymentMeans: @payment_means.to_h) if @payment_means
36
+ hash.merge!(Payer: @payer.to_h) if @payer
37
+ hash.merge!(RegistrationResult: @registration_result.to_h) if @registration_result
38
+ hash.merge!(Liability: @liability.to_h) if @liability
39
+ hash.merge!(Dcc: @dcc.to_h) if @dcc
40
+ hash
41
+ end
42
+ alias_method :to_h, :to_hash
43
+
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,44 @@
1
+ module SixSaferpay
2
+ module SixPaymentPage
3
+ class InitializeResponse
4
+
5
+ attr_accessor(:response_header,
6
+ :token,
7
+ :expiration,
8
+ :redirect_url
9
+ )
10
+
11
+ def initialize(response_header:,
12
+ token:,
13
+ expiration:,
14
+ redirect_url: )
15
+ @response_header = SixSaferpay::ResponseHeader.new(response_header.to_h) if response_header
16
+ @token = token
17
+ @expiration = expiration
18
+ @redirect_url = redirect_url
19
+ end
20
+
21
+ def to_hash
22
+ hash = Hash.new
23
+ hash.merge!(response_header: @response_header.to_h) if @response_header
24
+ hash.merge!(token: @token) if @token
25
+ hash.merge!(expiration: @expiration) if @expiration
26
+ hash.merge!(redirect_url: @redirect_url) if @redirect_url
27
+ hash
28
+ end
29
+ alias_method :to_h, :to_hash
30
+
31
+ def token
32
+ @token
33
+ end
34
+
35
+ def expiration
36
+ @expiration
37
+ end
38
+
39
+ def redirect_url
40
+ @redirect_url
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,10 @@
1
+ require 'six_saferpay/api/six_payment_page/requests/assert'
2
+ require 'six_saferpay/api/six_payment_page/requests/initialize'
3
+
4
+ require 'six_saferpay/api/six_payment_page/responses/initalize_response'
5
+ require 'six_saferpay/api/six_payment_page/responses/assert_response'
6
+
7
+ module SixSaferpay
8
+ module SixPaymentPage
9
+ end
10
+ end
@@ -0,0 +1,33 @@
1
+ module SixSaferpay
2
+ module API
3
+ module SixTransaction
4
+ class Authorization
5
+
6
+ attr_accessor :request_header, :token, :verification_code
7
+
8
+ def initialize(token, code)
9
+ @request_header = SixSaferpay::RequestHeader.new
10
+ @token = SixSaferpay::Token.new(token)
11
+ @verification_code = SixSaferpay::VerificationCode.new(code)
12
+ end
13
+
14
+ def to_hash
15
+ hash = Hash.new
16
+ hash.merge!(@request_header.to_h)
17
+ hash.merge!(@token.to_h)
18
+ hash.merge!(@verification_code.to_h)
19
+ hash
20
+ end
21
+ alias_method :to_h, :to_hash
22
+
23
+ def to_json
24
+ to_hash.to_json
25
+ end
26
+
27
+ def url
28
+ '/Payment/v1/Transaction/Authorize'
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ module SixSaferpay
2
+ module API
3
+ module SixTransaction
4
+ class Cancel
5
+
6
+ attr_accessor :request_header, :transaction_reference
7
+
8
+ def initialize(transaction_id)
9
+ @request_header = SixSaferpay::RequestHeader.new
10
+ @transaction_reference = SixSaferpay::TransactionReference
11
+ .new(transaction_id)
12
+ end
13
+
14
+ def to_hash
15
+ hash = Hash.new
16
+ hash.merge!(@request_header.to_h)
17
+ hash.merge!(@transaction_reference.to_h)
18
+ hash
19
+ end
20
+ alias_method :to_h, :to_hash
21
+
22
+ def to_json
23
+ to_hash.to_json
24
+ end
25
+
26
+ def url
27
+ '/Payment/v1/Transaction/Cancel'
28
+ end
29
+
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,54 @@
1
+ module SixSaferpay
2
+ module SixTransaction
3
+ class Capture
4
+
5
+ attr_accessor(:request_header,
6
+ :transaction_reference,
7
+ :amount,
8
+ :billpay,
9
+ :pending_notifiction,
10
+ :marketplace
11
+ )
12
+
13
+
14
+ def initialize(request_header: nil,
15
+ transaction_reference:,
16
+ amount: nil,
17
+ billpay: nil,
18
+ pending_notifiction: nil,
19
+ marketplace: nil
20
+ )
21
+ @request_header = request_header || SixSaferpay::RequestHeader.new()
22
+ @transaction_reference = SixSaferpay::TransactionReference.new(transaction_reference.to_h) if transaction_reference
23
+ @amount = SixSaferpay::Amount.new(amount.to_h) if amount
24
+ @billpay = SixSaferpay::Billpay.new(billpay.to_h) if billpay
25
+ @pending_notifiction = SixSaferpay::PendingNotification.new(pending_notifiction.to_h) if pending_notifiction
26
+ @marketplace = SixSaferpay::Marketplace.new(marketplace.to_h) if marketplace
27
+ end
28
+
29
+ def to_hash
30
+ hash = Hash.new
31
+ hash.merge!(request_header: @request_header.to_h) if @request_header
32
+ hash.merge!(transaction_reference: @transaction_reference.to_h) if @transaction_reference
33
+ hash.merge!(billpay: @billpay.to_h) if @billpay
34
+ hash.merge!(pending_notifiction: @pending_notifiction.to_h) if @pending_notifiction
35
+ hash.merge!(marketplace: @marketplace.to_h) if @marketplace
36
+ hash
37
+ end
38
+ alias_method :to_h, :to_hash
39
+
40
+ def to_json
41
+ to_hash.to_json
42
+ end
43
+
44
+ def url
45
+ '/Payment/v1/Transaction/Capture'
46
+ end
47
+
48
+ def response_class
49
+ SixSaferpay::SixTransaction::CaptureResponse
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,73 @@
1
+ module SixSaferpay
2
+ module API
3
+ module SixTransactions
4
+ class Initialize
5
+
6
+ attr_accessor(
7
+ :request_header,
8
+ :config_set,
9
+ :terminal_id,
10
+ :payment,
11
+ :payment_means,
12
+ :payer,
13
+ :return_urls,
14
+ :styling,
15
+ :wallet,
16
+ :payment_methods,
17
+ :card_form
18
+ )
19
+
20
+
21
+ def initialize(request_header: nil,
22
+ config_set: nil,
23
+ terminal_id: nil,
24
+ payment:,
25
+ payment_means: nil,
26
+ payer: nil,
27
+ return_urls: nil,
28
+ styling: nil,
29
+ wallet: nil,
30
+ payment_methods: nil,
31
+ card_form: nil
32
+ )
33
+ @request_header = request_header || SixSaferpay::RequestHeader.new()
34
+ @config_set = config_set
35
+ @terminal_id = terminal_id || SixSaferpay.config.terminal_id
36
+ @payment = payment
37
+ @payment_means = payment_means
38
+ @return_urls = return_urls || SixSaferpay::ReturnUrls.new()
39
+ @styling = styling
40
+ @wallet = wallet
41
+ @payment_methods = payment_methods
42
+ @card_form = card_form
43
+ end
44
+
45
+ def to_hash
46
+ hash = Hash.new
47
+ hash.merge!(RequestHeader: @request_header.to_h)
48
+ hash.merge!(ConfigSet: @config_set) if @config_set
49
+ hash.merge!(TerminalID: @terminal_id)
50
+ hash.merge!(Payment: @payment.to_h)
51
+ hash.merge!(PaymentMeans: @payment_means.to_h) if @payment_means
52
+ hash.merge!(Payer: @payer.to_h) if @payer
53
+ hash.merge!(ReturnUrls: @return_urls.to_h ) if @return_urls
54
+ hash.merge!(Styling: @styling.to_h) if @styling
55
+ hash.merge!(Wallet: @wallet.to_h) if @wallet
56
+ hash.merge!(PaymentMethods: @payment_methods) if @payment_methods
57
+ hash.merge!(CardForm: @card_form.to_h) if @card_form
58
+ hash
59
+ end
60
+ alias_method :to_h, :to_hash
61
+
62
+ def to_json
63
+ to_hash.to_json
64
+ end
65
+
66
+ def url
67
+ '/Payment/v1/Transaction/Initialize'
68
+ end
69
+
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,32 @@
1
+ module SixSaferpay
2
+ module SixTransaction
3
+ class CaptureResponse
4
+
5
+ attr_accessor(:response_header,
6
+ :capture_id,
7
+ :status,
8
+ :date,
9
+ :invoice
10
+ )
11
+ def initialize(hash)
12
+ @response_header = SixSaferpay::ResponseHeader.new(response_header) if response_header
13
+ @capture_id = capture_id
14
+ @status = status
15
+ @date = date
16
+ @invoice = SixSaferpay::Invoice.new(invoice.to_h) if invoice
17
+ end
18
+
19
+ def to_hash
20
+ hash = Hash.new
21
+ hash.merge!(response_header: @response_header.to_h) if @response_header
22
+ hash.merge!(capture_id: @capture_id) if @capture_id
23
+ hash.merge!(status: @status) if @status
24
+ hash.merge!(date: @date) if @date
25
+ hash.merge!(invoice: @invoice.to_h) if @invoice
26
+ hash
27
+ end
28
+ alias_method :to_h, :to_hash
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,12 @@
1
+ module SixSaferpay
2
+ module API
3
+ module SixTransaction
4
+ class InitializeResponse
5
+
6
+ def initialize(hash)
7
+ end
8
+
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ module SixSaferpay
2
+ module SixTransaction
3
+ end
4
+ end
@@ -1,8 +1,5 @@
1
- require 'six_saferpay/api/payment_page'
2
- require 'six_saferpay/api/transaction'
3
-
4
1
  module SixSaferpay
5
2
  module API
6
- VERSION = '1.10'
3
+ VERSION = '1.11'
7
4
  end
8
5
  end
@@ -1,6 +1,6 @@
1
1
  module SixSaferpay
2
2
  class Client
3
- attr_accessor :object
3
+ attr_accessor :object, :request, :response
4
4
 
5
5
  def initialize(object)
6
6
  @object = object
@@ -13,17 +13,29 @@ module SixSaferpay
13
13
  def post
14
14
  https = Net::HTTP.new(uri.host, uri.port)
15
15
  https.use_ssl = true
16
- response = https.request(request)
17
- response
16
+ @response = https.request(request)
17
+ body = @response.body
18
+ hash = JSON.parse(body, symbolize_names: true)
19
+ hash = hash.deep_transform_keys do |key|
20
+ key = key.to_s.underscore
21
+ key.to_sym
22
+ end
23
+ @object.response_class.new(hash)
18
24
  end
19
25
 
20
26
  private
21
27
 
22
28
  def request
23
29
  request = Net::HTTP::Post.new(uri.path, {'Content-Type' => 'application/json'})
24
- request.body = @object.to_h.to_json
30
+ hash = @object.to_h
31
+ hash = hash.deep_transform_keys do |key|
32
+ key = key.to_s.camelize
33
+ key.to_sym
34
+ end
35
+ body = hash.to_json
36
+ request.body = body
25
37
  request.basic_auth(username, password)
26
- request
38
+ @request = request
27
39
  end
28
40
 
29
41
  def uri
@@ -0,0 +1,11 @@
1
+ module SixSaferpay
2
+ class Error < StandardError
3
+
4
+ attr_accessor :message
5
+
6
+ def initialize(message = nil)
7
+ @message = message
8
+ super(message)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ module SixSaferpay
2
+ class Model
3
+
4
+ end
5
+ end