six_saferpay 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8520c33496083c2c6f23a76657cf6ce7e1debbf05fc5761c8fbf5caf3d1a65cb
4
+ data.tar.gz: 814f9bfb5e08bf71f2b2f7a28e7b633e585de745bd2acd294123e578840197a7
5
+ SHA512:
6
+ metadata.gz: fd201b0cc5967e33843eee36ea45f71d57e600eace52b34a3994322f140a828e83d803007f179376707a4cd0bc045c8c3f6ccede58e18576ead1bd17f2104722
7
+ data.tar.gz: 335d9d27c32172e2f3dce215ae8c48eff207fbd83b90aa3ff5fb80b33a1b4f8ce4996bb65a329897015dc86b0be4cddbec7af6d04c8f5df369df199c60f756d2
data/.gitignore ADDED
@@ -0,0 +1,163 @@
1
+ # Created by https://www.gitignore.io/api/vim,ruby,rails,macos
2
+ # Edit at https://www.gitignore.io/?templates=vim,ruby,rails,macos
3
+
4
+ ### macOS ###
5
+ # General
6
+ .DS_Store
7
+ .AppleDouble
8
+ .LSOverride
9
+
10
+ # Icon must end with two \r
11
+ Icon
12
+
13
+ # Thumbnails
14
+ ._*
15
+
16
+ # Files that might appear in the root of a volume
17
+ .DocumentRevisions-V100
18
+ .fseventsd
19
+ .Spotlight-V100
20
+ .TemporaryItems
21
+ .Trashes
22
+ .VolumeIcon.icns
23
+ .com.apple.timemachine.donotpresent
24
+
25
+ # Directories potentially created on remote AFP share
26
+ .AppleDB
27
+ .AppleDesktop
28
+ Network Trash Folder
29
+ Temporary Items
30
+ .apdisk
31
+
32
+ ### Rails ###
33
+ *.rbc
34
+ capybara-*.html
35
+ .rspec
36
+ /log
37
+ /tmp
38
+ /db/*.sqlite3
39
+ /db/*.sqlite3-journal
40
+ /public/system
41
+ /coverage/
42
+ /spec/tmp
43
+ *.orig
44
+ rerun.txt
45
+ pickle-email-*.html
46
+
47
+ # TODO Comment out this rule if you are OK with secrets being uploaded to the repo
48
+ config/initializers/secret_token.rb
49
+ config/master.key
50
+
51
+ # Only include if you have production secrets in this file, which is no longer a Rails default
52
+ # config/secrets.yml
53
+
54
+ # dotenv
55
+ # TODO Comment out this rule if environment variables can be committed
56
+ .env
57
+
58
+ ## Environment normalization:
59
+ /.bundle
60
+ /vendor/bundle
61
+
62
+ # these should all be checked in to normalize the environment:
63
+ # Gemfile.lock, .ruby-version, .ruby-gemset
64
+
65
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
66
+ .rvmrc
67
+
68
+ # if using bower-rails ignore default bower_components path bower.json files
69
+ /vendor/assets/bower_components
70
+ *.bowerrc
71
+ bower.json
72
+
73
+ # Ignore pow environment settings
74
+ .powenv
75
+
76
+ # Ignore Byebug command history file.
77
+ .byebug_history
78
+
79
+ # Ignore node_modules
80
+ node_modules/
81
+
82
+ # Ignore precompiled javascript packs
83
+ /public/packs
84
+ /public/packs-test
85
+ /public/assets
86
+
87
+ # Ignore yarn files
88
+ /yarn-error.log
89
+ yarn-debug.log*
90
+ .yarn-integrity
91
+
92
+ # Ignore uploaded files in development
93
+ /storage/*
94
+ !/storage/.keep
95
+
96
+ ### Ruby ###
97
+ *.gem
98
+ /.config
99
+ /InstalledFiles
100
+ /pkg/
101
+ /spec/reports/
102
+ /spec/examples.txt
103
+ /test/tmp/
104
+ /test/version_tmp/
105
+ /tmp/
106
+
107
+ # Used by dotenv library to load environment variables.
108
+ # .env
109
+
110
+ # Ignore Byebug command history file.
111
+
112
+ ## Specific to RubyMotion:
113
+ .dat*
114
+ .repl_history
115
+ build/
116
+ *.bridgesupport
117
+ build-iPhoneOS/
118
+ build-iPhoneSimulator/
119
+
120
+ ## Specific to RubyMotion (use of CocoaPods):
121
+ #
122
+ # We recommend against adding the Pods directory to your .gitignore. However
123
+ # you should judge for yourself, the pros and cons are mentioned at:
124
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
125
+ # vendor/Pods/
126
+
127
+ ## Documentation cache and generated files:
128
+ /.yardoc/
129
+ /_yardoc/
130
+ /doc/
131
+ /rdoc/
132
+
133
+ /.bundle/
134
+ /lib/bundler/man/
135
+
136
+ # for a library or gem, you might want to ignore these files since the code is
137
+ # intended to run in multiple environments; otherwise, check them in:
138
+ # Gemfile.lock
139
+ # .ruby-version
140
+ # .ruby-gemset
141
+
142
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
143
+
144
+ ### Vim ###
145
+ # Swap
146
+ [._]*.s[a-v][a-z]
147
+ [._]*.sw[a-p]
148
+ [._]s[a-rt-v][a-z]
149
+ [._]ss[a-gi-z]
150
+ [._]sw[a-p]
151
+
152
+ # Session
153
+ Session.vim
154
+
155
+ # Temporary
156
+ .netrwhist
157
+ *~
158
+ # Auto-generated tag files
159
+ tags
160
+ # Persistent undo
161
+ [._]*.un~
162
+
163
+ # End of https://www.gitignore.io/api/vim,ruby,rails,macos
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rspec_status ADDED
@@ -0,0 +1,28 @@
1
+ example_id | status | run_time |
2
+ --------------------------------------------------------------- | ------ | --------------- |
3
+ ./spec/six_saferpay/api/payment_page/assert_spec.rb[1:1:1] | passed | 0.00097 seconds |
4
+ ./spec/six_saferpay/api/payment_page/assert_spec.rb[1:2:1] | passed | 0.00019 seconds |
5
+ ./spec/six_saferpay/api/payment_page/assert_spec.rb[1:3:1] | passed | 0.00008 seconds |
6
+ ./spec/six_saferpay/api/payment_page/initialize_spec.rb[1:1:1] | passed | 0.00021 seconds |
7
+ ./spec/six_saferpay/api/payment_page/initialize_spec.rb[1:2:1] | passed | 0.0002 seconds |
8
+ ./spec/six_saferpay/api/payment_page/initialize_spec.rb[1:3:1] | passed | 0.00014 seconds |
9
+ ./spec/six_saferpay/api/transaction/cancel_spec.rb[1:1:1] | passed | 0.00021 seconds |
10
+ ./spec/six_saferpay/api/transaction/cancel_spec.rb[1:2:1] | passed | 0.00015 seconds |
11
+ ./spec/six_saferpay/api/transaction/cancel_spec.rb[1:3:1] | passed | 0.00012 seconds |
12
+ ./spec/six_saferpay/api/transaction/capture_spec.rb[1:1:1] | passed | 0.00019 seconds |
13
+ ./spec/six_saferpay/api/transaction/capture_spec.rb[1:2:1] | passed | 0.00014 seconds |
14
+ ./spec/six_saferpay/api/transaction/capture_spec.rb[1:3:1] | passed | 0.00013 seconds |
15
+ ./spec/six_saferpay/client_spec.rb[1:1:1] | passed | 0.00923 seconds |
16
+ ./spec/six_saferpay/client_spec.rb[1:2:1] | passed | 0.00295 seconds |
17
+ ./spec/six_saferpay/models/payer_spec.rb[1:1:1] | passed | 0.00023 seconds |
18
+ ./spec/six_saferpay/models/payment_spec.rb[1:1:1] | passed | 0.00087 seconds |
19
+ ./spec/six_saferpay/models/request_header_spec.rb[1:1:1] | passed | 0.00026 seconds |
20
+ ./spec/six_saferpay/models/return_urls_spec.rb[1:1:1] | passed | 0.00067 seconds |
21
+ ./spec/six_saferpay/models/styling_spec.rb[1:1:1] | passed | 0.00014 seconds |
22
+ ./spec/six_saferpay/models/terminal_spec.rb[1:1:1] | passed | 0.00076 seconds |
23
+ ./spec/six_saferpay/models/token_spec.rb[1:1:1] | passed | 0.00013 seconds |
24
+ ./spec/six_saferpay/models/transaction_reference_spec.rb[1:1:1] | passed | 0.00094 seconds |
25
+ ./spec/six_saferpay/models/verification_code_spec.rb[1:1:1] | passed | 0.00016 seconds |
26
+ ./spec/six_saferpay_spec.rb[1:1] | passed | 0.00413 seconds |
27
+ ./spec/six_saferpay_spec.rb[1:2:1] | passed | 0.0024 seconds |
28
+ ./spec/six_saferpay_spec.rb[1:2:2] | passed | 0.00563 seconds |
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5.1
data/.test.env ADDED
@@ -0,0 +1,8 @@
1
+ SIX_SAFERPAY_CUSTOMER_ID='245294'
2
+ SIX_SAFERPAY_TERMINAL_ID='17925560'
3
+ SIX_SAFERPAY_USERNAME='API_245294_08700063'
4
+ SIX_SAFERPAY_PASSWORD='mei4Xoozle4doi0A'
5
+ SIX_SAFERPAY_FAIL_URL='http://localhost:3004'
6
+ SIX_SAFERPAY_SUCCESS_URL='http://localhost:3004'
7
+ SIX_SAFERPAY_BASE_URL='https://test.saferpay.com/api/'
8
+ SIX_SAFERPAY_CSS_URL='http://localhost:3004/six_payment.css'
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.0
7
+ before_install: gem install bundler -v 2.0.1
8
+
9
+ notifications:
10
+ slack: fadendaten:tWoet2mtObvbwSZSyUAY93jl
11
+ email: false
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in six_saferpay.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ six_saferpay (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.2)
10
+ diff-lcs (1.3)
11
+ dotenv (2.7.1)
12
+ ffi (1.10.0-java)
13
+ method_source (0.9.2)
14
+ pry (0.12.2)
15
+ coderay (~> 1.1.0)
16
+ method_source (~> 0.9.0)
17
+ pry (0.12.2-java)
18
+ coderay (~> 1.1.0)
19
+ method_source (~> 0.9.0)
20
+ spoon (~> 0.0)
21
+ rake (10.5.0)
22
+ rspec (3.8.0)
23
+ rspec-core (~> 3.8.0)
24
+ rspec-expectations (~> 3.8.0)
25
+ rspec-mocks (~> 3.8.0)
26
+ rspec-core (3.8.0)
27
+ rspec-support (~> 3.8.0)
28
+ rspec-expectations (3.8.2)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.8.0)
31
+ rspec-mocks (3.8.0)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.8.0)
34
+ rspec-support (3.8.0)
35
+ spoon (0.0.6)
36
+ ffi
37
+
38
+ PLATFORMS
39
+ java
40
+ ruby
41
+
42
+ DEPENDENCIES
43
+ bundler (~> 2.0)
44
+ dotenv (~> 2.7.0)
45
+ pry (~> 0.12.0)
46
+ rake (~> 10.0)
47
+ rspec (~> 3.0)
48
+ six_saferpay!
49
+
50
+ BUNDLED WITH
51
+ 2.0.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Felix Langenegger
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ [![Build Status](https://travis-ci.org/fadendaten/six_saferpay.svg?branch=master)](https://travis-ci.org/fadendaten/six_saferpay)
2
+ [![Maintainability](https://api.codeclimate.com/v1/badges/76c9d1d0f261c276de96/maintainability)](https://codeclimate.com/github/fadendaten/six_saferpay/maintainability)
3
+
4
+ # SixSaferpay
5
+
6
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/six_saferpay`. To experiment with that code, run `bin/console` for an interactive prompt.
7
+
8
+ TODO: Delete this and the text above, and describe your gem
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'six_saferpay'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install six_saferpay
25
+
26
+ ## Usage
27
+
28
+ TODO: Write usage instructions here
29
+
30
+ ## Development
31
+
32
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
33
+
34
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
35
+
36
+ ## Contributing
37
+
38
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/six_saferpay.
39
+
40
+ ## License
41
+
42
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "six_saferpay"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,30 @@
1
+ module SixSaferpay
2
+ module PaymentPage
3
+ class Assert
4
+
5
+ attr_accessor :request_header, :token
6
+
7
+ def initialize(token)
8
+ @request_header = SixSaferpay::RequestHeader.new
9
+ @token = SixSaferpay::Token.new(token)
10
+ end
11
+
12
+ def to_hash
13
+ hash = Hash.new
14
+ hash.merge!(@request_header.to_h)
15
+ hash.merge!(@token.to_h)
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
+ end
29
+ end
30
+ end
@@ -0,0 +1,35 @@
1
+ module SixSaferpay
2
+ module PaymentPage
3
+ class Initialize
4
+
5
+ attr_accessor :request_header, :terminal_id, :payment, :return_urls
6
+
7
+ def initialize(value, currency, order_id, description)
8
+ @request_header = SixSaferpay::RequestHeader.new
9
+ @terminal_id = SixSaferpay::Terminal.new
10
+ @payment = SixSaferpay::Payment
11
+ .new(value, currency, order_id, description)
12
+ @return_urls = SixSaferpay::ReturnUrls.new
13
+ end
14
+
15
+ def to_hash
16
+ hash = Hash.new
17
+ hash.merge!(@request_header.to_h)
18
+ hash.merge!(@terminal_id.to_h)
19
+ hash.merge!(@payment.to_h)
20
+ hash.merge!(@return_urls.to_h)
21
+ hash
22
+ end
23
+ alias_method :to_h, :to_hash
24
+
25
+ def to_json
26
+ to_hash.to_json
27
+ end
28
+
29
+ def url
30
+ '/Payment/v1/PaymentPage/Initialize'
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,20 @@
1
+ require 'six_saferpay/api/payment_page/assert'
2
+ require 'six_saferpay/api/payment_page/initialize'
3
+
4
+ module SixSaferpay
5
+ module PaymentPage
6
+
7
+ def to_hash
8
+ end
9
+
10
+ def to_h
11
+ end
12
+
13
+ def to_json
14
+ end
15
+
16
+ def url
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,31 @@
1
+ module SixSaferpay
2
+ module Transaction
3
+ class Authorization
4
+
5
+ attr_accessor :request_header, :token, :verification_code
6
+
7
+ def initialize(token, code)
8
+ @request_header = SixSaferpay::RequestHeader.new
9
+ @token = SixSaferpay::Token.new(token)
10
+ @verification_code = SixSaferpay::VerificationCode.new(code)
11
+ end
12
+
13
+ def to_hash
14
+ hash = Hash.new
15
+ hash.merge!(@request_header.to_h)
16
+ hash.merge!(@token.to_h)
17
+ hash.merge!(@verification_code.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/Authorize'
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ module SixSaferpay
2
+ module Transaction
3
+ class Cancel
4
+
5
+ attr_accessor :request_header, :transaction_reference
6
+
7
+ def initialize(transaction_id)
8
+ @request_header = SixSaferpay::RequestHeader.new
9
+ @transaction_reference = SixSaferpay::TransactionReference
10
+ .new(transaction_id)
11
+ end
12
+
13
+ def to_hash
14
+ hash = Hash.new
15
+ hash.merge!(@request_header.to_h)
16
+ hash.merge!(@transaction_reference.to_h)
17
+ hash
18
+ end
19
+ alias_method :to_h, :to_hash
20
+
21
+ def to_json
22
+ to_hash.to_json
23
+ end
24
+
25
+ def url
26
+ '/Payment/v1/Transaction/Cancel'
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ module SixSaferpay
2
+ module Transaction
3
+ class Capture
4
+
5
+ attr_accessor :request_header, :transaction_reference
6
+
7
+ def initialize(transaction_id)
8
+ @request_header = SixSaferpay::RequestHeader.new
9
+ @transaction_reference = SixSaferpay::TransactionReference
10
+ .new(transaction_id)
11
+ end
12
+
13
+ def to_hash
14
+ hash = Hash.new
15
+ hash.merge!(@request_header.to_h)
16
+ hash.merge!(@transaction_reference.to_h)
17
+ hash
18
+ end
19
+ alias_method :to_h, :to_hash
20
+
21
+ def to_json
22
+ to_hash.to_json
23
+ end
24
+
25
+ def url
26
+ '/Payment/v1/Transaction/Capture'
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,36 @@
1
+ module SixSaferpay
2
+ module Transaction
3
+ class Initialize
4
+
5
+ def initialize(value, currency, order_id, description, language)
6
+ @request_header = SixSaferpay::RequestHeader.new
7
+ @terminal_id = SixSaferpay::Terminal.new
8
+ @payment = SixSaferpay::Payment
9
+ .new(value, currency, order_id, description)
10
+ @payer = SixSaferpay::Payer.new(language)
11
+ @return_urls = SixSaferpay::ReturnUrls.new
12
+ @styling = SixSaferpay::Styling.new
13
+ end
14
+
15
+ def to_hash
16
+ hash = Hash.new
17
+ hash.merge!(@request_header.to_h)
18
+ hash.merge!(@terminal_id.to_h)
19
+ hash.merge!(@payment.to_h)
20
+ hash.merge!(@payer.to_h)
21
+ hash.merge!(@styling.to_h)
22
+ hash.merge!(@return_urls.to_h)
23
+ hash
24
+ end
25
+ alias_method :to_h, :to_hash
26
+
27
+ def to_json
28
+ to_hash.to_json
29
+ end
30
+
31
+ def url
32
+ '/Payment/v1/Transaction/Initialize'
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,22 @@
1
+ require 'six_saferpay/api/transaction/authorization'
2
+ require 'six_saferpay/api/transaction/cancel'
3
+ require 'six_saferpay/api/transaction/capture'
4
+ require 'six_saferpay/api/transaction/initialize'
5
+
6
+ module SixSaferpay
7
+ module Transaction
8
+
9
+ def to_hash
10
+ end
11
+
12
+ def to_h
13
+ end
14
+
15
+ def to_json
16
+ end
17
+
18
+ def url
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,8 @@
1
+ require 'six_saferpay/api/payment_page'
2
+ require 'six_saferpay/api/transaction'
3
+
4
+ module SixSaferpay
5
+ module API
6
+ VERSION = '1.10'
7
+ end
8
+ end
@@ -0,0 +1,46 @@
1
+ module SixSaferpay
2
+ class Client
3
+ attr_accessor :object
4
+
5
+ def initialize(object)
6
+ @object = object
7
+ end
8
+
9
+ def self.post(object)
10
+ new(object).post
11
+ end
12
+
13
+ def post
14
+ https = Net::HTTP.new(uri.host, uri.port)
15
+ https.use_ssl = true
16
+ response = https.request(request)
17
+ response
18
+ end
19
+
20
+ private
21
+
22
+ def request
23
+ request = Net::HTTP::Post.new(uri.path, {'Content-Type' => 'application/json'})
24
+ request.body = @object.to_h.to_json
25
+ request.basic_auth(username, password)
26
+ request
27
+ end
28
+
29
+ def uri
30
+ URI.parse(base_url + @object.url)
31
+ end
32
+
33
+ def base_url
34
+ SixSaferpay.config.base_url
35
+ end
36
+
37
+ def username
38
+ SixSaferpay.config.username
39
+ end
40
+
41
+ def password
42
+ SixSaferpay.config.password
43
+ end
44
+
45
+ end
46
+ end
@@ -0,0 +1,17 @@
1
+ module SixSaferpay
2
+ class Payer
3
+
4
+ def initialize(language)
5
+ @language = language
6
+ end
7
+
8
+ def to_hash
9
+ {
10
+ 'Payer': {
11
+ 'LanguageCode': @language
12
+ }
13
+ }
14
+ end
15
+ alias_method :to_h, :to_hash
16
+ end
17
+ end
@@ -0,0 +1,27 @@
1
+ module SixSaferpay
2
+ class Payment
3
+ attr_accessor :value, :currency, :order_id, :description
4
+
5
+ def initialize(value, currency, order_id, description)
6
+ @value = value
7
+ @currency = currency
8
+ @order_id = order_id
9
+ @description = description
10
+ end
11
+
12
+ def to_hash
13
+ {
14
+ 'Payment': {
15
+ 'Amount': {
16
+ 'Value': @value,
17
+ 'CurrencyCode': @currency
18
+ },
19
+ 'OrderId': @order_id,
20
+ 'Description': @description
21
+ }
22
+ }
23
+ end
24
+ alias_method :to_h, :to_hash
25
+ end
26
+
27
+ end
@@ -0,0 +1,29 @@
1
+ module SixSaferpay
2
+ class RequestHeader
3
+
4
+ attr_accessor :spec_version,
5
+ :customer_id,
6
+ :request_id,
7
+ :retry_indicator
8
+
9
+ def initialize
10
+ @spec_version = SixSaferpay::API::VERSION
11
+ @customer_id = SixSaferpay.config.customer_id
12
+ @request_id = SecureRandom.uuid
13
+ @retry_indicator = 0
14
+ end
15
+
16
+ def to_hash
17
+ {
18
+ 'RequestHeader': {
19
+ 'SpecVersion': @spec_version,
20
+ 'CustomerId': @customer_id,
21
+ 'RequestId': @request_id,
22
+ 'RetryIndicator': @retry_indicator
23
+ }
24
+ }
25
+ end
26
+ alias_method :to_h, :to_hash
27
+
28
+ end
29
+ end
@@ -0,0 +1,20 @@
1
+ module SixSaferpay
2
+ class ReturnUrls
3
+ attr_accessor :success_url, :fail_url
4
+
5
+ def initialize
6
+ @success_url = SixSaferpay.config.success_url
7
+ @fail_url = SixSaferpay.config.fail_url
8
+ end
9
+
10
+ def to_hash
11
+ {
12
+ 'ReturnUrls': {
13
+ 'Success': @success_url,
14
+ 'Fail': @fail_url
15
+ }
16
+ }
17
+ end
18
+ alias_method :to_h, :to_hash
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ module SixSaferpay
2
+ class Styling
3
+
4
+ def initialize
5
+ @css_url = SixSaferpay.config.css_url || ''
6
+ end
7
+
8
+ def to_hash
9
+ {
10
+ 'Styling': {
11
+ 'CssUrl': @css_url
12
+ }
13
+ }
14
+ end
15
+ alias_method :to_h, :to_hash
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ module SixSaferpay
2
+ class Terminal
3
+ attr_accessor :terminal_id
4
+
5
+ def initialize
6
+ @terminal_id = SixSaferpay.config.terminal_id
7
+ end
8
+
9
+ def to_hash
10
+ {
11
+ "TerminalId": @terminal_id
12
+ }
13
+ end
14
+ alias_method :to_h, :to_hash
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ module SixSaferpay
2
+ class Token
3
+
4
+ attr_accessor :token
5
+
6
+ def initialize(token)
7
+ @token = token
8
+ end
9
+
10
+ def to_hash
11
+ {
12
+ 'Token': @token
13
+ }
14
+ end
15
+ alias_method :to_h, :to_hash
16
+
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module SixSaferpay
2
+ class TransactionReference
3
+ attr_accessor :transaction_id
4
+
5
+ def initialize(transaction_id)
6
+ @transaction_id = transaction_id
7
+ end
8
+
9
+ def to_hash
10
+ {
11
+ 'TransactionReference': {
12
+ 'TransactionId': @transaction_id
13
+ }
14
+ }
15
+ end
16
+ alias_method :to_h, :to_hash
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ module SixSaferpay
2
+ class VerificationCode
3
+
4
+ attr_accessor :code
5
+
6
+ def initialize(code)
7
+ @code = code
8
+ end
9
+
10
+ def to_hash
11
+ {
12
+ "VerificationCode": @code
13
+ }
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module SixSaferpay
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,42 @@
1
+ require 'six_saferpay/api'
2
+ require 'six_saferpay/client'
3
+ require 'six_saferpay/version'
4
+
5
+ require 'six_saferpay/models/payer'
6
+ require 'six_saferpay/models/payment'
7
+ require 'six_saferpay/models/request_header'
8
+ require 'six_saferpay/models/return_urls'
9
+ require 'six_saferpay/models/styling'
10
+ require 'six_saferpay/models/terminal'
11
+ require 'six_saferpay/models/token'
12
+ require 'six_saferpay/models/transaction_reference'
13
+ require 'six_saferpay/models/verification_code'
14
+
15
+ require 'securerandom'
16
+ require 'json'
17
+ require 'net/http'
18
+
19
+ module SixSaferpay
20
+ class Error < StandardError; end
21
+
22
+ class Config
23
+ attr_accessor :customer_id, # ID of the Customer by SIX Saferpay
24
+ :terminal_id, # ID of the Terminal by SIX Saferpay
25
+ :username,
26
+ :password,
27
+ :success_url,
28
+ :fail_url,
29
+ :base_url,
30
+ :css_url
31
+ end
32
+
33
+ # Initialize the config class
34
+ def self.config
35
+ @@config ||= Config.new
36
+ end
37
+
38
+ # Set the configs
39
+ def self.configure
40
+ yield self.config
41
+ end
42
+ end
@@ -0,0 +1,32 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "six_saferpay/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "six_saferpay"
8
+ spec.version = SixSaferpay::VERSION
9
+ spec.authors = ["Felix Langenegger"]
10
+ spec.email = ["felix.langenegger@fadendaten.ch"]
11
+
12
+ spec.summary = %q{Write a short summary, because RubyGems requires one.}
13
+ spec.description = %q{Write a longer description or delete this line.}
14
+ spec.homepage = "http://fadendaten.ch"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+
27
+ spec.add_development_dependency "bundler", "~> 2.0"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "rspec", "~> 3.0"
30
+ spec.add_development_dependency "pry", "~> 0.12.0"
31
+ spec.add_development_dependency "dotenv", "~> 2.7.0"
32
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: six_saferpay
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Felix Langenegger
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-02-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.12.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.12.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: dotenv
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.7.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.7.0
83
+ description: Write a longer description or delete this line.
84
+ email:
85
+ - felix.langenegger@fadendaten.ch
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".rspec_status"
93
+ - ".ruby-version"
94
+ - ".test.env"
95
+ - ".travis.yml"
96
+ - Gemfile
97
+ - Gemfile.lock
98
+ - LICENSE.txt
99
+ - README.md
100
+ - Rakefile
101
+ - bin/console
102
+ - bin/setup
103
+ - lib/six_saferpay.rb
104
+ - lib/six_saferpay/api.rb
105
+ - lib/six_saferpay/api/payment_page.rb
106
+ - lib/six_saferpay/api/payment_page/assert.rb
107
+ - lib/six_saferpay/api/payment_page/initialize.rb
108
+ - lib/six_saferpay/api/transaction.rb
109
+ - lib/six_saferpay/api/transaction/authorization.rb
110
+ - lib/six_saferpay/api/transaction/cancel.rb
111
+ - lib/six_saferpay/api/transaction/capture.rb
112
+ - lib/six_saferpay/api/transaction/initialize.rb
113
+ - lib/six_saferpay/client.rb
114
+ - lib/six_saferpay/models/payer.rb
115
+ - lib/six_saferpay/models/payment.rb
116
+ - lib/six_saferpay/models/request_header.rb
117
+ - lib/six_saferpay/models/return_urls.rb
118
+ - lib/six_saferpay/models/styling.rb
119
+ - lib/six_saferpay/models/terminal.rb
120
+ - lib/six_saferpay/models/token.rb
121
+ - lib/six_saferpay/models/transaction_reference.rb
122
+ - lib/six_saferpay/models/verification_code.rb
123
+ - lib/six_saferpay/version.rb
124
+ - six_saferpay.gemspec
125
+ homepage: http://fadendaten.ch
126
+ licenses:
127
+ - MIT
128
+ metadata: {}
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubyforge_project:
145
+ rubygems_version: 2.7.6
146
+ signing_key:
147
+ specification_version: 4
148
+ summary: Write a short summary, because RubyGems requires one.
149
+ test_files: []