wirecard-rails 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f962e2690939ed287e4d7375d4d9ff6413a2ea54
4
- data.tar.gz: a3d4f32956a4a94618fc86e5261b1bf41fcfe5c9
3
+ metadata.gz: 6eaecdea8f7e24ee14ff616063a132e4f56e9ca8
4
+ data.tar.gz: 14754e80b1c119846d0aeb521c234d809b416a48
5
5
  SHA512:
6
- metadata.gz: cd3e5f76ab5ebe0b77e9d2c6104acc3f2c5dfd6ec0ed97efb26ee59d46df01d88a83f1ae5d5af14db058ca7f2f7a4c7463f65690332fe5c388fb151ffea20091
7
- data.tar.gz: 4076ef3080d6340f44708da94d5743aef06a76dd4967ae52db66206b877e5fce93993279540fc4261139b20161a6da40ce4b19630cd948fef0de1d6c59bb1532
6
+ metadata.gz: 10cf1353af9c9ac613a63676e8b187ce37283418925146fefac806743fd23408759f4afd89dfa2e4e9b32b365dbe8aa3ce1c37c2a02fcdb4a597339a2c3a7651
7
+ data.tar.gz: c4b576f85c5f45280e3e823abfa2f5c5b39d6d882e25bab916dfb6cf10ad76a9bd68b18d2ea7ea56b97c24ec8f01e26f28da19906a548555210b15b8a96e3032
data/.gitignore CHANGED
@@ -7,3 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+
11
+ .DS_Store
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 itschn
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1 +1,37 @@
1
- require "bundler/gem_tasks"
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'WirecardRails'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ Bundler::GemHelper.install_tasks
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'lib'
31
+ t.libs << 'test'
32
+ t.pattern = 'test/**/*_test.rb'
33
+ t.verbose = false
34
+ end
35
+
36
+
37
+ task default: :test
File without changes
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,45 @@
1
+ module Wirecard
2
+ module Payify
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ helper_method :current_payment_parent, :current_payment
7
+ end
8
+
9
+ def build_current_payment
10
+ @current_payment ||= current_payment_parent.payments.new(payment_params)
11
+ end
12
+
13
+ alias_method :current_payment, :build_current_payment
14
+
15
+ def current_payment_parent
16
+ @current_payment_parent ||= if (current_payment_parent = NotificationDelivery.find_active_by_uuid(params[:casefile_id] || params[:id])).payable?
17
+ current_payment_parent
18
+ else
19
+ raise ActiveRecord::RecordNotFound
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def payment_params
26
+ (permitted_params[:payment] || {}).merge(
27
+ host: [request.protocol, request.host].join,
28
+ order_ident: current_payment_parent.unique_id,
29
+ amount: current_payment_parent.casefile_amount_cents.to_s,
30
+ consumer_ip_address: request.ip,
31
+ consumer_user_agent: request.user_agent,
32
+ currency: current_payment_parent.casefile_amount_currency,
33
+ order_description: current_payment_parent.casefile_description,
34
+ iframe_css_url: current_payment_parent.css_url,
35
+ success_url: casefile_url(id: current_payment_parent.unique_id, page: :success),
36
+ failure_url: casefile_url(id: current_payment_parent.unique_id, page: :failure),
37
+ cancel_url: casefile_url(id: current_payment_parent.unique_id, page: :cancel),
38
+ service_url: casefile_url(id: current_payment_parent.unique_id, page: :service),
39
+ confirm_url: wirecard_casefile_notifications_url(host: 'http://collecto.ngrok.com', casefile_id: current_payment_parent.unique_id),
40
+ return_url: casefile_url(current_payment_parent)
41
+ )
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,4 @@
1
+ module Wirecard
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,115 @@
1
+ module Wirecard
2
+ class NotificationsController < ApplicationController
3
+
4
+ #
5
+ # Concerns
6
+ # ---------------------------------------------------------------------------------------
7
+ #
8
+ #
9
+ #
10
+ #
11
+
12
+ #
13
+ # Settings
14
+ # ---------------------------------------------------------------------------------------
15
+ #
16
+ #
17
+ #
18
+ #
19
+
20
+ #
21
+ # Filter
22
+ # ---------------------------------------------------------------------------------------
23
+ #
24
+ #
25
+ #
26
+ #
27
+
28
+ skip_before_action :verify_authenticity_token
29
+
30
+ before_action :authenticate!
31
+
32
+ #
33
+ # Plugins
34
+ # ---------------------------------------------------------------------------------------
35
+ #
36
+ #
37
+ #
38
+ #
39
+
40
+ #
41
+ # Actions
42
+ # ---------------------------------------------------------------------------------------
43
+ #
44
+ #
45
+ #
46
+ #
47
+
48
+ def create
49
+ build_resource
50
+
51
+ if @notification.save
52
+ render json: { status: 'OK', errorCodes: 'null', 'QPAY-CONFIRMATION-RESPONSE' => { result: 'OK'} }
53
+ else
54
+ render json: { status: 'NOK', errorCodes: '1', 'QPAY-CONFIRMATION-RESPONSE' => { result: 'NOK', message: @notification.errors.full_messages.join('; ') } }
55
+ end
56
+ end
57
+
58
+ #
59
+ # Instance Methods
60
+ # ---------------------------------------------------------------------------------------
61
+ #
62
+ #
63
+ #
64
+ #
65
+
66
+ #
67
+ # Protected
68
+ # ---------------------------------------------------------------------------------------
69
+ #
70
+ #
71
+ #
72
+ #
73
+
74
+ protected
75
+
76
+ def parent
77
+ @parent ||= if (parent = NotificationDelivery.find_active_by_uuid(params[:casefile_id]))
78
+ parent
79
+ else
80
+ raise ActiveRecord::RecordNotFound
81
+ end
82
+ end
83
+
84
+ def build_resource
85
+ @notification ||= parent.payments.by_status(:pending).find_by(order_number: params[:orderNumber]).notifications.new(notification_params)
86
+ end
87
+
88
+ #
89
+ # Private
90
+ # ---------------------------------------------------------------------------------------
91
+ #
92
+ #
93
+ #
94
+ #
95
+
96
+ private
97
+
98
+ def callback
99
+ @callback ||= Wirecard::Callback.new(callback_params)
100
+ end
101
+
102
+ def authenticate!
103
+ render json: { status: 'NOK', errorCodes: '1', 'QPAY-CONFIRMATION-RESPONSE' => { result: 'NOK', message: 'INVALID_FINGERPRINT' } } unless callback.fingerprint_valid?
104
+ end
105
+
106
+ def callback_params
107
+ params.except(:action, :controller, :locale, :casefile_id)
108
+ end
109
+
110
+ def notification_params
111
+ callback.to_hash
112
+ end
113
+
114
+ end
115
+ end
@@ -0,0 +1,114 @@
1
+ module Wirecard
2
+ class PaymentsController < Application
3
+
4
+ #
5
+ # Concerns
6
+ # ---------------------------------------------------------------------------------------
7
+ #
8
+ #
9
+ #
10
+ #
11
+
12
+ include Payify
13
+
14
+ #
15
+ # Settings
16
+ # ---------------------------------------------------------------------------------------
17
+ #
18
+ #
19
+ #
20
+ #
21
+
22
+ #
23
+ # Filter
24
+ # ---------------------------------------------------------------------------------------
25
+ #
26
+ #
27
+ #
28
+ #
29
+
30
+ #
31
+ # Plugins
32
+ # ---------------------------------------------------------------------------------------
33
+ #
34
+ #
35
+ #
36
+ #
37
+
38
+ #
39
+ # Actions
40
+ # ---------------------------------------------------------------------------------------
41
+ #
42
+ #
43
+ #
44
+ #
45
+
46
+ def new
47
+ build_current_payment
48
+ end
49
+
50
+ def create
51
+ build_current_payment
52
+
53
+ case current_payment.payment_type
54
+ when 'CCARD' then persist_creditcard
55
+ else persist_payment
56
+ end
57
+ end
58
+
59
+ #
60
+ # Instance Methods
61
+ # ---------------------------------------------------------------------------------------
62
+ #
63
+ #
64
+ #
65
+ #
66
+
67
+ #
68
+ # Protected
69
+ # ---------------------------------------------------------------------------------------
70
+ #
71
+ #
72
+ #
73
+ #
74
+
75
+ protected
76
+
77
+ def persist_creditcard
78
+ respond_to do |format|
79
+ format.json do
80
+ if current_payment.save
81
+ render json: { redirect_url: current_payment.redirect_url }
82
+ else
83
+ render json: { errors: current_payment.errors.full_messages }
84
+ end
85
+ end
86
+ end
87
+ end
88
+
89
+ def persist_payment
90
+ if current_payment.save
91
+ redirect_to current_payment.redirect_url
92
+ else
93
+ flash[:alert] = t('.alert')
94
+ render action: :new
95
+ end
96
+ end
97
+
98
+ #
99
+ # Private
100
+ # ---------------------------------------------------------------------------------------
101
+ #
102
+ #
103
+ #
104
+ #
105
+
106
+ private
107
+
108
+ def permitted_params
109
+ params.permit(payment: [:payment_type, :storage_id])
110
+ end
111
+
112
+ end
113
+
114
+ end
@@ -0,0 +1,4 @@
1
+ module WirecardRails
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>WirecardRails</title>
5
+ <%= stylesheet_link_tag "wirecard_rails/application", media: "all" %>
6
+ <%= javascript_include_tag "wirecard_rails/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ Wirecard::Rails::Engine.routes.draw do
2
+ end
@@ -0,0 +1,13 @@
1
+ require 'rails/generators'
2
+
3
+ module Wirecard
4
+ module Generators
5
+ class ConfigGenerator < ::Rails::Generators::Base
6
+ source_root File.expand_path("../templates", __FILE__)
7
+
8
+ def copy_initializer_file
9
+ copy_file "initializer.rb", "config/initializers/wirecard.rb"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ require 'rails/generators'
2
+
3
+ module Wirecard
4
+ module Generators
5
+ class InstallGenerator < ::Rails::Generators::Base
6
+
7
+ def run_other_generators
8
+ generate "wirecard:config"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,43 @@
1
+ module Devise
2
+ module Generators
3
+ module OrmHelpers
4
+ def model_contents
5
+ buffer = <<-CONTENT
6
+
7
+
8
+ CONTENT
9
+ buffer += <<-CONTENT if needs_attr_accessible?
10
+
11
+
12
+ CONTENT
13
+ buffer
14
+ end
15
+
16
+ def needs_attr_accessible?
17
+ rails_3? && !strong_parameters_enabled?
18
+ end
19
+
20
+ def rails_3?
21
+ Rails::VERSION::MAJOR == 3
22
+ end
23
+
24
+ def strong_parameters_enabled?
25
+ defined?(ActionController::StrongParameters)
26
+ end
27
+
28
+ private
29
+
30
+ def model_exists?
31
+ File.exists?(File.join(destination_root, model_path))
32
+ end
33
+
34
+ def migration_path
35
+ @migration_path ||= File.join("db", "migrate")
36
+ end
37
+
38
+ def model_path
39
+ @model_path ||= File.join("app", "models", "#{file_path}.rb")
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,16 @@
1
+ Wirecard.configure do |config|
2
+ config.customer_id = 'D200001'
3
+ config.shop_id = 'qmore'
4
+ config.secret = 'B8AKTPWBRMNBV455FG6M2DANE99WU2'
5
+
6
+ # optional
7
+ # config.endpoint = 'https://checkout.wirecard.com/seamless'
8
+ # config.host = 'checkout.wirecard.com'
9
+ # config.success_url = 'http://localhost.success.url'
10
+ # config.failure_url = 'http://localhost.failure.url'
11
+ # config.cancel_url = 'http://localhost.cancel.url'
12
+ # config.service_url = 'http://localhost.service.url'
13
+ # config.confirm_url = 'http://localhost.confirm.url'
14
+ # config.return_url = 'http://localhost.return.url'
15
+ # config.language = I18n.default_locale[0..1]
16
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :wirecard_rails do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,5 @@
1
+ require 'wirecard'
2
+ require 'wirecard/rails'
3
+
4
+ require 'generators/wirecard/config_generator'
5
+ require 'generators/wirecard/install_generator'
@@ -1,7 +1,2 @@
1
- require "wirecard/rails/version"
2
-
3
- module Wirecard
4
- module Rails
5
- # Your code goes here...
6
- end
7
- end
1
+ require 'wirecard/rails/engine'
2
+ require 'wirecard/rails/version'
@@ -0,0 +1,7 @@
1
+ module Wirecard
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
7
+
@@ -0,0 +1,16 @@
1
+ module Wirecard
2
+ module Rails
3
+ def self.gem_version
4
+ Gem::Version.new VERSION::STRING
5
+ end
6
+
7
+ module VERSION
8
+ MAJOR = 0
9
+ MINOR = 1
10
+ TINY = 3
11
+ PRE = nil
12
+
13
+ STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
+ end
15
+ end
16
+ end
@@ -1,5 +1,10 @@
1
+ require_relative 'gem_version'
2
+
1
3
  module Wirecard
2
4
  module Rails
3
- VERSION = "0.1.2"
5
+ def self.version
6
+ gem_version
7
+ end
4
8
  end
5
9
  end
10
+
@@ -5,7 +5,7 @@ require "wirecard/rails/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "wirecard-rails"
8
- spec.version = Wirecard::Rails::VERSION
8
+ spec.version = Wirecard::Rails.version
9
9
  spec.authors = ["Dominic Breuker", "Michael Rüffer"]
10
10
  spec.email = ["dominic.breuker@hitfoxgroup.com", "mr@hitfoxgroup.com"]
11
11
 
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "rails", "~> 4.2"
24
24
 
25
25
  spec.add_runtime_dependency "wirecard"
26
+ spec.add_runtime_dependency "state_machines-activerecord", "~> 0.2.0"
26
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wirecard-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominic Breuker
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-28 00:00:00.000000000 Z
12
+ date: 2015-11-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -81,6 +81,20 @@ dependencies:
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: state_machines-activerecord
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: 0.2.0
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: 0.2.0
84
98
  description: This engine integrates the wirecard payment service with your rails application.
85
99
  email:
86
100
  - dominic.breuker@hitfoxgroup.com
@@ -92,12 +106,30 @@ files:
92
106
  - ".gitignore"
93
107
  - CODE_OF_CONDUCT.md
94
108
  - Gemfile
95
- - LICENSE.txt
109
+ - MIT-LICENSE
96
110
  - README.md
97
111
  - Rakefile
112
+ - app/assets/images/wirecard_rails/.keep
113
+ - app/assets/javascripts/wirecard_rails/application.js
114
+ - app/assets/stylesheets/wirecard_rails/application.css
115
+ - app/controllers/concerns/payify.rb
116
+ - app/controllers/wirecard/application_controller.rb
117
+ - app/controllers/wirecard/notifications_controller.rb
118
+ - app/controllers/wirecard/payments_controller.rb
119
+ - app/helpers/wirecard_rails/application_helper.rb
120
+ - app/views/layouts/wirecard_rails/application.html.erb
98
121
  - bin/console
99
122
  - bin/setup
123
+ - config/routes.rb
124
+ - lib/generators/wirecard/config_generator.rb
125
+ - lib/generators/wirecard/install_generator.rb
126
+ - lib/generators/wirecard/orm_helpers.rb
127
+ - lib/generators/wirecard/templates/initializer.rb
128
+ - lib/tasks/wirecard_rails_tasks.rake
129
+ - lib/wirecard-rails.rb
100
130
  - lib/wirecard/rails.rb
131
+ - lib/wirecard/rails/engine.rb
132
+ - lib/wirecard/rails/gem_version.rb
101
133
  - lib/wirecard/rails/version.rb
102
134
  - wirecard-rails.gemspec
103
135
  homepage: http://www.hitfoxgroup.com
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2015 itschn
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.