sofort 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 44dd736e69ff1d78d775a47027128af7f67512d4
4
+ data.tar.gz: 7c56369147b69d7ea4922bf098e5f1b525a0bced
5
+ SHA512:
6
+ metadata.gz: 7b6f13c85581b584a5590b148c51e16e9a15c9e166d87c4ba9faa5b02d9c862b395df0a8d4603eb003193d61114aef3a28b5abf385d4886e8f8ddec470cd85a7
7
+ data.tar.gz: 9def96b09045250868486bf34c98cd18a502f07bea11012240063119ed474078c599260c1ac0f625d60ea50b13c67db27e9a0d35594704c9d3bc8044cd7949de
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sofort-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 skopu
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ Not ready!
2
+
3
+ # Sofort::Rails
4
+
5
+ TODO: Write a gem description
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'sofort-rails'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install sofort-rails
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/sofort-rails/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,19 @@
1
+ require 'rails/generators/base'
2
+
3
+ module Sofort
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("../../templates", __FILE__)
7
+
8
+ desc "Creates a Sofort initializer to your application."
9
+
10
+ def copy_initializer
11
+ template "sofort.rb", "config/initializers/sofort.rb"
12
+ end
13
+
14
+ def show_readme
15
+ readme "README" if behavior == :invoke
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ Sofort.setup do |config|
2
+
3
+ config.base_url = "https://api.sofort.com/api/xml"
4
+ config.user_id = 'sofort_user_id'
5
+ config.api_key = 'api_key'
6
+ config.abort_url = 'abort_url'
7
+ config.success_url = 'success_url'
8
+
9
+ config.email_customer = 'email_customer'
10
+ config.notification_email = 'notification_email'
11
+ config.project_id = 'project_id'
12
+ config.country_code = "DE"
13
+ config.currency_code = "EUR"
14
+ config.reson = "Reason"
15
+
16
+ end
@@ -0,0 +1,78 @@
1
+ require 'xmlsimple'
2
+ require 'httparty'
3
+
4
+ module Sofort
5
+ class Client
6
+ include ::HTTParty
7
+ format :xml
8
+ headers 'Accept' => 'application/xml; charset=UTF-8'
9
+ headers 'Content-Type' => 'application/xml; charset=UTF-8'
10
+
11
+ def initialize
12
+ @options = {}
13
+ @options[:basic_auth] = {
14
+ username: Sofort.user_id,
15
+ password: Sofort.api_key
16
+ }
17
+ @options[:headers] = {
18
+ 'Accept' => 'application/xml',
19
+ 'Content-Type' => 'application/xml'
20
+ }
21
+ end
22
+
23
+ def pay(amount, name, *args)
24
+ opts = args.extract_options!.symbolize_keys!
25
+ xml = pay_xml(amount, name, opts)
26
+ results = self.class.post(Sofort.base_url, @options.merge(body: xml))
27
+ results['new_transaction'].present? ? results['new_transaction'] : results
28
+ end
29
+
30
+ def details(token)
31
+ xml = details_xml(token)
32
+ results = self.class.post(Sofort.base_url, @options.merge(body: xml))
33
+ transactions = results['transactions']
34
+ if transactions && transactions['transaction_details']
35
+ transactions['transaction_details']
36
+ else
37
+ results
38
+ end
39
+ end
40
+
41
+ def details_xml(token)
42
+ <<-eos
43
+ <transaction_request version="2">
44
+ <transaction>#{token}</transaction>
45
+ </transaction_request>
46
+ eos
47
+ end
48
+
49
+ def pay_xml(amount, name, opts)
50
+ reason = opts['reason'] || Sofort.reason
51
+ currency_code = opts['currency_code'] || Sofort.currency_code
52
+ country_code = opts['country_code'] || Sofort.country_code
53
+ success_url = opts['success_url'] || Sofort.success_url
54
+ abort_url = opts['abort_url'] || Sofort.abort_url
55
+
56
+ {
57
+ amount: amount,
58
+ currency_code: currency_code,
59
+ reasons: {
60
+ reason: reason
61
+ },
62
+ sender: {
63
+ holder: name,
64
+ country_code: country_code
65
+ },
66
+ email_customer: Sofort.email_customer,
67
+ notification_emails: {
68
+ notification_email: Sofort.notification_email
69
+ },
70
+ success_url: success_url,
71
+ abort_url: abort_url,
72
+ su: '',
73
+ project_id: Sofort.project_id
74
+ }.to_xml(root: 'multipay', skip_types: true, dasherize: false)
75
+
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,3 @@
1
+ module Sofort
2
+ VERSION = "0.0.4"
3
+ end
data/lib/sofort.rb ADDED
@@ -0,0 +1,32 @@
1
+ require 'sofort/version'
2
+ require 'sofort/client'
3
+
4
+ module Sofort
5
+
6
+ mattr_accessor :user_id
7
+ mattr_accessor :api_key
8
+ mattr_accessor :base_url
9
+ mattr_accessor :abort_url
10
+ mattr_accessor :success_url
11
+ mattr_accessor :email_customer
12
+ mattr_accessor :notification_email
13
+ mattr_accessor :project_id
14
+ mattr_accessor :country_code
15
+ mattr_accessor :currency_code
16
+ mattr_accessor :reason
17
+
18
+ @@user_id = 'sofort_user_id'
19
+ @@api_key = 'api_key'
20
+
21
+ @@base_url = "https://api.sofort.com/api/xml"
22
+ @@abort_url = 'abort_url'
23
+ @@success_url = 'success_url'
24
+
25
+ @@email_customer = 'email_customer'
26
+ @@notification_email = 'notification_email'
27
+ @@project_id = 'project_id'
28
+ @@country_code = "DE"
29
+ @@currency_code = "EUR"
30
+ @@reson = "Reason"
31
+
32
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sofort/version'
5
+ require "active_support/all"
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sofort"
8
+ spec.version = Sofort::VERSION
9
+ spec.authors = ["skopu"]
10
+ spec.email = ["sebastian.skopp@gmail.com"]
11
+ spec.summary = %q{Ruby Client for Sofort Api}
12
+ spec.description = %q{The newest sofort Api}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "httparty"
25
+ spec.add_development_dependency "webmock"
26
+ spec.add_development_dependency "xml-simple"
27
+ spec.add_dependency 'rails'
28
+ end
metadata ADDED
@@ -0,0 +1,153 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sofort
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - skopu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-16 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: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: httparty
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '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'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: xml-simple
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: The newest sofort Api
112
+ email:
113
+ - sebastian.skopp@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - Gemfile
120
+ - LICENSE.txt
121
+ - README.md
122
+ - Rakefile
123
+ - lib/generators/sofort/install_generator.rb
124
+ - lib/generators/templates/sofort.rb
125
+ - lib/sofort.rb
126
+ - lib/sofort/client.rb
127
+ - lib/sofort/version.rb
128
+ - sofort-rails.gemspec
129
+ homepage: ''
130
+ licenses:
131
+ - MIT
132
+ metadata: {}
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubyforge_project:
149
+ rubygems_version: 2.2.2
150
+ signing_key:
151
+ specification_version: 4
152
+ summary: Ruby Client for Sofort Api
153
+ test_files: []