ecconnect_rails 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +155 -0
  3. data/app/controllers/ecconnect_rails/base_controller.rb +4 -164
  4. data/lib/ecconnect_rails.rb +3 -3
  5. data/{app/models/ecconnect_rails/ecconnect_payment.rb → lib/ecconnect_rails/base_model.rb} +21 -69
  6. data/lib/ecconnect_rails/controller_actions.rb +169 -0
  7. data/lib/ecconnect_rails/controller_defaults.rb +14 -0
  8. data/lib/ecconnect_rails/version.rb +1 -1
  9. data/spec/controllers/ecconnect_payments_controller_spec.rb +38 -41
  10. data/spec/dummy/Gemfile.lock +1 -3
  11. data/spec/dummy/app/controllers/ecconnect_payments_controller.rb +3 -2
  12. data/spec/dummy/app/models/ecconnect_payment.rb +35 -0
  13. data/spec/dummy/app/models/user.rb +5 -0
  14. data/{app/views/ecconnect_rails → spec/dummy/app/views}/ecconnect_payments/failure.html.erb +0 -0
  15. data/{app/views/ecconnect_rails → spec/dummy/app/views}/ecconnect_payments/new.html.erb +0 -0
  16. data/{app/views/ecconnect_rails → spec/dummy/app/views}/ecconnect_payments/notify.html.erb +0 -0
  17. data/{app/views/ecconnect_rails → spec/dummy/app/views}/ecconnect_payments/show.html.erb +0 -0
  18. data/{app/views/ecconnect_rails → spec/dummy/app/views}/ecconnect_payments/success.html.erb +0 -0
  19. data/spec/dummy/config/routes.rb +8 -1
  20. data/spec/dummy/log/test.log +46 -0
  21. data/spec/factories/econnect_payment.rb +3 -1
  22. data/spec/features/ecconnect_payments_spec.rb +4 -4
  23. data/spec/models/ecconnect_rails/ecconnect_payment_spec.rb +2 -2
  24. data/spec/routing/ecconnect_rails/ecconnect_payments_routing_spec.rb +8 -8
  25. metadata +24 -41
  26. data/README.rdoc +0 -5
  27. data/app/controllers/ecconnect_rails/application_controller.rb +0 -4
  28. data/app/controllers/ecconnect_rails/ecconnect_payments_controller.rb +0 -4
  29. data/config/routes.rb +0 -9
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2Q5ZTRlYmVkNjZhZmIxMGFjN2Q1Mjk0ZTgyMmMxODAyODIzNzVhOQ==
4
+ OTlkMmVlZjQ1MzEzZjgyNDM1ZWUzMTYzNGEyODdmMWNhZTZjNjM0NA==
5
5
  data.tar.gz: !binary |-
6
- YTNlNzMwNzE4NWNjNDQ4MzBlNzgxNDAwYTBiNzdiZmI0M2E0MGQzMg==
6
+ OGY3ZjI5ZGU1NWQyM2QyNDkwNzUxNDBhNTg3MzNjZWJlMTE2MTQzYQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NTA1YjUxYTM4OTVmZTZmNjcwNTA0ZTA5MTM3ZjYwM2JlNjdjNTE2ODM0YWM2
10
- NGU2ZDkzNWJhODViZTE1NTYzMWI1OWFhYWU3Y2Q1YWQ3MzdjZDZiZjIyYTU5
11
- NjYyY2E2M2QyODE2ODhlYjE5Y2I2MDNiYWI0MzNhN2M1ZGE3MjQ=
9
+ YmFmNGY5YjkwODg1MDlmNzAwMWZjNTdhMGU0OWQyNjU5NGRmMzdkNWFhZjM4
10
+ YTcxMmVkM2JiNTU5NjczMGU4NDg2MGFiZDMwZGNjMTZiN2QzMGZiNDBkZWE3
11
+ NmQ2Njg2MDYwNmYyNjc3MDdhODdjMzcwZjg1Mjc3YjU3OTNlYWE=
12
12
  data.tar.gz: !binary |-
13
- YTk1NjVlODMxZjYzZjlkNDdlZTVlN2VhMTdjZWNiMmM3MjcxYjQwZjM0YWRi
14
- N2YyNzlhODRjNTRkZjcyOTgxNmFkZDE3OWM0M2VjY2ZjNjMwNzU2NmY0Yzhm
15
- MGRkMTg1MTMxYjdkZjIxMGQ1N2FhYTY2ODhlMzEyY2FmZGRmMzQ=
13
+ NzU0NDdhY2Y5MzVmZTNhODRkYjZkZTk1ZDIwYzQ4NWIxY2NjYTNhNDg3OTEw
14
+ NDhjYTBjMmVkYTA3NGI0ZjIyODk5OWIxNzU0M2YxMWM4ZTFhMzZhNzY4MGQ3
15
+ NjhiOTgxYTUxMjg1ZWQzYTI5ZTM1MjBlOTlhNDdjMTVkMGE0NjE=
@@ -0,0 +1,155 @@
1
+ #Ecconnect Rails
2
+
3
+ Rails engine for integration with eCommerceConnect
4
+
5
+ ##Installation
6
+
7
+ You can let bundler install Ecconnect Rails by adding this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ecconnect_rails'
11
+ ```
12
+ And then execute:
13
+ ```sh
14
+ $ bundle install
15
+ ```
16
+ Or install it yourself with:
17
+ ```sh
18
+ $ gem install ecconnect_rails
19
+ ```
20
+
21
+ ##Basic Usage
22
+
23
+ ### Add initiliazer
24
+
25
+
26
+ config/initiliazers/ecconnect_rails.rb
27
+
28
+ ```ruby
29
+ EcconnectRails.default_options = { merchant_id: "merchant_id",
30
+ terminal_id: "terminal_id",
31
+ request_url: "url",
32
+ cert_path: Rails.root.join(paht_to_cert)
33
+ pem_path: Rails.root.join(paht_to_pem)
34
+ currency_id: currency_number }
35
+ ```
36
+
37
+ Example
38
+ ```ruby
39
+ EcconnectRails.default_options = { merchant_id: "12345",
40
+ terminal_id: "E1234",
41
+ request_url: "https://secure.upc.ua/ecgtest/enter",
42
+ cert_path: Rails.root.join('certs/test-server.cert')
43
+ pem_path: Rails.root.join('certs/12345.pem')
44
+ currency_id: 980 }
45
+ ```
46
+
47
+ ### Create model
48
+
49
+ #### Mongoid
50
+
51
+ ```ruby
52
+ require 'autoinc'
53
+
54
+ class EcconnectPayment
55
+ include EcconnectRails::BaseModel
56
+ include Mongoid::Document
57
+ include Mongoid::Timestamps
58
+ include Mongoid::Autoinc
59
+
60
+ field :delay, type: Boolean
61
+ field :merchant_id, type: Integer
62
+ field :terminal_id, type: String
63
+ field :tran_code, type: String
64
+ field :approval_code, type: Integer
65
+ field :locale, type: String
66
+ field :proxy_pan, type: String
67
+ field :currency_id, type: Integer
68
+ field :alt_currency_id, type: Integer
69
+ field :amount, type: Float
70
+ field :alt_amount, type: Integer
71
+ field :order_id, type: Integer
72
+ field :income_signature, type: String
73
+ field :purchase_desc, type: String
74
+ field :email, type: String
75
+ field :sd, type: String
76
+ field :xid, type: String
77
+ field :rrn, type: String
78
+
79
+ increments :order_id, seed: 1
80
+
81
+ ecconnect_payment
82
+ end
83
+ ```
84
+ #### ActiveRecord
85
+
86
+ ### Create controller
87
+
88
+ ```ruby
89
+ class EcconnectPaymentsController < EcconnectRails::BaseController
90
+
91
+ private
92
+ def success_right_signature ecconnect_payment
93
+ #Job after recieved success request with right signature
94
+ end
95
+ end
96
+ ```
97
+
98
+ You can override other private methods
99
+ ```ruby
100
+ private
101
+ def success_wrong_signature ecconnect_payment
102
+ #Job after recieved success request with wrong signature
103
+ end
104
+
105
+ def failure_right_signature ecconnect_payment
106
+ #Job after recieved failure request with right signature
107
+ end
108
+
109
+ def failure_wrong_signature ecconnect_payment
110
+ #Job after recieved failure request with wrong signature
111
+ end
112
+
113
+ def notify_right_signature ecconnect_payment
114
+ #Job after recieved notify request with right signature and wrong code
115
+ end
116
+
117
+ def notify_right_signature_and_code ecconnect_payment
118
+ #Job after recieved notify request with right signature and code
119
+ end
120
+
121
+ def notify_wrong_signature ecconnect_payment
122
+ #Job after recieved notify request with wrong signature
123
+ end
124
+
125
+ def forward_url_success
126
+ #Return success url for notify
127
+ end
128
+
129
+ def forward_url_failure
130
+ #Return failure url for notify
131
+ end
132
+ ```
133
+ ### Add routes
134
+
135
+ ```ruby
136
+ resources :ecconnect_payments, only: [:new, :create, :show] do
137
+ collection do
138
+ post 'success'
139
+ post 'failure'
140
+ post 'notify'
141
+ end
142
+ end
143
+ ```
144
+
145
+ ##TO DO
146
+
147
+ - Add generators for ActiveRecord
148
+ - Add specs for ActiveRecord ecconnect model
149
+ - Add generators for Views
150
+ - Add Inherited Resources to BasicController
151
+
152
+ ##License
153
+
154
+
155
+ MIT
@@ -1,170 +1,10 @@
1
1
  module EcconnectRails
2
2
  class BaseController < ActionController::Base
3
- respond_to :json, :html
4
- def new
5
- @ecconnect_payment = EcconnectRails::EcconnectPayment.new
6
- respond_to do |format|
7
- format.html do
8
- render 'new'
9
- end
10
- format.json{ render json: @ecconnect_payment.ecconnect_json }
11
- end
12
- end
13
-
14
- def create
15
- @ecconnect_payment = EcconnectRails::EcconnectPayment.new params[:ecconnect_payment]
16
- if @ecconnect_payment.save
17
- respond_to do |format|
18
- format.html{ redirect_to ecconnect_payment_path(@ecconnect_payment.to_param) }
19
- format.json{ render json: @ecconnect_payment.ecconnect_json }
20
- end
21
- else
22
- respond_to do |format|
23
- format.html{ render 'new' }
24
- format.json{ render json: @ecconnect_payment.ecconnect_json }
25
- end
26
- end
27
- end
28
-
29
- def show
30
- @ecconnect_payment = EcconnectRails::EcconnectPayment.find params[:id]
31
- respond_to do |format|
32
- format.html do
33
- render 'show'
34
- end
35
- format.json{ render json: @ecconnect_payment.ecconnect_json }
36
- end
37
- end
38
-
39
- def check
40
- @ecconnect_payment = EcconnectRails::EcconnectPayment.find params[:id]
41
- respond_to do |format|
42
- format.html do
43
- render 'check'
44
- end
45
- format.json{ render json: @ecconnect_payment.ecconnect_json }
46
- end
47
- end
48
-
49
- def failure
50
- @ecconnect_payment = EcconnectRails::EcconnectPayment.where(order_id: params[:OrderID]).limit(1).first
51
- @ecconnect_payment.update_by params
52
- if @ecconnect_payment.check_signature
53
- failure_right_signature @ecconnect_payment
54
- failure_respond @ecconnect_payment
55
- else
56
- failure_wrong_signature @ecconnect_payment
57
- wrong_signature_respond @ecconnect_payment
58
- end
59
- end
60
-
61
- def success
62
- @ecconnect_payment = EcconnectRails::EcconnectPayment.where(order_id: params[:OrderID]).limit(1).first
63
- @ecconnect_payment.update_by params
64
- if @ecconnect_payment.check_signature
65
- if @ecconnect_payment.tran_code == '000'
66
- success_right_signature @ecconnect_payment
67
- success_respond @ecconnect_payment
68
- else
69
- failure_right_signature @ecconnect_payment
70
- failure_respond @ecconnect_payment
71
- end
72
- else
73
- success_wrong_signature @ecconnect_payment
74
- wrong_signature_respond @ecconnect_payment
75
- end
76
- end
77
-
78
- def notify
79
- @ecconnect_payment = EcconnectRails::EcconnectPayment.where(order_id: params[:OrderID]).limit(1).first
80
- @ecconnect_payment.update_by params
81
- if @ecconnect_payment.check_signature
82
- if @ecconnect_payment.tran_code == '000'
83
- @action = 'approve'
84
- @forward_url = forward_url_success
85
- notify_right_signature_and_code @ecconnect_payment
86
- notify_respond @ecconnect_payment
87
- else
88
- @action = 'reverse'
89
- @reason = I18n.t "ecconnect_rails.codes.code_503"
90
- @forward_url = forward_url_failure
91
- notify_right_signature @ecconnect_payment
92
- notify_respond @ecconnect_payment
93
- end
94
- else
95
- @action = 'reverse'
96
- @reason = I18n.t "ecconnect_rails.codes.code_405"
97
- @forward_url = forward_url_failure
98
- notify_wrong_signature @ecconnect_payment
99
- notify_respond @ecconnect_payment
100
- end
101
- end
102
-
103
- private
104
-
105
- def forward_url_success
106
- end
107
-
108
- def forward_url_failure
109
- end
3
+ extend EcconnectRails::ControllerDefaults
4
+ include EcconnectRails::ControllerActions
110
5
 
111
- def notify_respond ecconnect_payment
112
- respond_to do |format|
113
- format.html do
114
- render 'notify', layout: nil
115
- end
116
- end
117
- end
6
+ defaults resource_class: EcconnectPayment
118
7
 
119
- def success_respond ecconnect_payment
120
- respond_to do |format|
121
- format.html do
122
- flash[:notice] = I18n.t "ecconnect_rails.success"
123
- render 'success'
124
- end
125
- format.json{ render json: @ecconnect_payment.ecconnect_json }
126
- end
127
- end
128
-
129
- def failure_respond ecconnect_payment
130
- respond_to do |format|
131
- format.html do
132
- flash[:error] = I18n.t "ecconnect_rails.codes.code_#{@ecconnect_payment.tran_code}"
133
- render 'failure'
134
- end
135
- format.json{ render json: @ecconnect_payment.ecconnect_json }
136
- end
137
- end
138
-
139
- def wrong_signature_respond ecconnect_payment
140
- respond_to do |format|
141
- format.html do
142
- flash[:error] = I18n.t "ecconnect_rails.wrong_signature"
143
- render 'failure'
144
- end
145
- format.json{ render json: @ecconnect_payment.ecconnect_json }
146
- end
147
- end
148
-
149
- def success_right_signature ecconnect_payment
150
- end
151
-
152
- def success_wrong_signature ecconnect_payment
153
- end
154
-
155
- def failure_right_signature ecconnect_payment
156
- end
157
-
158
- def failure_wrong_signature ecconnect_payment
159
- end
160
-
161
- def notify_right_signature ecconnect_payment
162
- end
163
-
164
- def notify_right_signature_and_code ecconnect_payment
165
- end
166
-
167
- def notify_wrong_signature ecconnect_payment
168
- end
8
+ respond_to :json, :html
169
9
  end
170
10
  end
@@ -1,11 +1,11 @@
1
1
  require 'ecconnect_rails/engine'
2
+ require 'ecconnect_rails/base_model'
3
+ require 'ecconnect_rails/controller_defaults'
4
+ require 'ecconnect_rails/controller_actions'
2
5
 
3
6
  module EcconnectRails
4
7
  ECCONNECT_VERSION = 1
5
8
 
6
9
  @default_options = {}
7
10
  class << self; attr_accessor :default_options; end
8
-
9
- #class Exception < ::Exception; end
10
- #class InvalidResponse < Exception; end
11
11
  end
@@ -1,41 +1,21 @@
1
1
  require 'digest/sha1'
2
2
  require 'base64'
3
3
  require 'openssl'
4
- require 'autoinc'
5
4
  module EcconnectRails
6
- class EcconnectPayment
7
- include Mongoid::Document
8
- include Mongoid::Timestamps
9
- include Mongoid::Autoinc
10
-
11
- CURRENCY = [980, 643, 840, 978]
12
-
13
- field :delay, type: Boolean
14
- field :merchant_id, type: Integer
15
- field :terminal_id, type: String
16
- field :tran_code, type: String
17
- field :approval_code, type: Integer
18
- field :locale, type: String
19
- field :proxy_pan, type: String
20
- field :currency_id, type: Integer
21
- field :alt_currency_id, type: Integer
22
- field :amount, type: Float
23
- field :alt_amount, type: Integer
24
- field :order_id, type: Integer
25
- field :income_signature, type: String
26
- field :purchase_desc, type: String
27
- field :email, type: String
28
- field :sd, type: String
29
- field :xid, type: String
30
- field :rrn, type: String
31
-
32
- increments :order_id, seed: 1
33
-
34
- belongs_to :payer
35
-
36
- validates :merchant_id, :terminal_id, :currency_id, :amount, presence: true
37
- before_validation :set_terminal_id, :set_merchant_id, :set_locale, :set_currency_id
38
- before_create :set_tran_code
5
+ module BaseModel
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ CURRENCY = [980, 643, 840, 978]
10
+ end
11
+
12
+ module ClassMethods
13
+ def ecconnect_payment
14
+ validates :merchant_id, :terminal_id, :currency_id, :amount, presence: true
15
+ before_validation :set_terminal_id, :set_merchant_id, :set_locale, :set_currency_id
16
+ before_create :set_tran_code
17
+ end
18
+ end
39
19
 
40
20
  def purchase_time
41
21
  self.created_at.strftime("%Y%m%d%H%M%S%z") if self.created_at
@@ -69,35 +49,19 @@ module EcconnectRails
69
49
  self.as_json(except: [:income_signature, :proxy_pan, :rrn, :sd, :xid, :approval_code], methods: [:purchase_time, :signature, :code])
70
50
  end
71
51
 
72
- #def check_payment
73
- # uri = URI.parse EcconnectRails.default_options[:check_url]
74
- # http = Net::HTTP.new uri.host, uri.port
75
- # http.use_ssl = true
76
- # request = Net::HTTP::Post.new uri.path
77
- # request.set_form_data check_payment_data
78
- # response = http.request request
79
- #end
80
-
81
52
  def check_signature
82
53
  cert.public_key.verify OpenSSL::Digest::SHA1.new, Base64.decode64(self.income_signature), check_data
83
54
  end
84
55
 
85
56
  def update_by params
86
57
  self.update_attributes :proxy_pan => params[:ProxyPan],
87
- #:currency => params[:Currency],
88
- :approval_code => params[:ApprovalCode],
89
- #:merchant_id => params[:MerchantID],
90
- #:order_id => params[:OrderID],
91
- :income_signature => params[:Signature],
92
- :rrn => params[:Rrn],
93
- :xid => params[:XID],
94
- :email => params[:Email],
95
- :sd => params[:SD],
96
- :tran_code => params[:TranCode]
97
- #:terminal_id => params[:TerminalID],
98
- #:total_amount => params[:TotalAmount],
99
- #:alt_total_amount => params[:AltTotalAmount],
100
- #:alt_currency => params[:AltCurrency]
58
+ :approval_code => params[:ApprovalCode],
59
+ :income_signature => params[:Signature],
60
+ :rrn => params[:Rrn],
61
+ :xid => params[:XID],
62
+ :email => params[:Email],
63
+ :sd => params[:SD],
64
+ :tran_code => params[:TranCode]
101
65
  end
102
66
 
103
67
 
@@ -122,18 +86,6 @@ module EcconnectRails
122
86
  self.tran_code = nil
123
87
  end
124
88
 
125
- #def check_payment_data
126
- # data = {}
127
- # data['MerchantID'] = self.merchant_id if self.merchant_id
128
- # data['TerminalID'] = self.terminal_id if self.terminal_id
129
- # data['TotalAmount'] = self.upc_amount if self.upc_amount
130
- # data['AltTotalAmount'] = self.alt_amount if self.alt_amount
131
- # data['Currency'] = self.currency_id if self.currenc_id
132
- # data['AltCurrency'] = self.alt_currency_id if self.alt_currency_id
133
- # data['OrderID'] = self.order_id if self.order_id
134
- # data
135
- #end
136
-
137
89
  def sign data
138
90
  Base64.encode64(pem.sign(OpenSSL::Digest::SHA1.new, data)).gsub(/\n/, '')
139
91
  end
@@ -0,0 +1,169 @@
1
+ module EcconnectRails
2
+ module ControllerActions
3
+ def new
4
+ @ecconnect_payment = resource_class.new
5
+ respond_to do |format|
6
+ format.html do
7
+ render 'new'
8
+ end
9
+ format.json{ render json: @ecconnect_payment.ecconnect_json }
10
+ end
11
+ end
12
+
13
+ def create
14
+ @ecconnect_payment = resource_class.new params[:ecconnect_payment]
15
+ if @ecconnect_payment.save
16
+ respond_to do |format|
17
+ format.html{ redirect_to ecconnect_payment_path(@ecconnect_payment.to_param) }
18
+ format.json{ render json: @ecconnect_payment.ecconnect_json }
19
+ end
20
+ else
21
+ respond_to do |format|
22
+ format.html{ render 'new' }
23
+ format.json{ render json: @ecconnect_payment.ecconnect_json }
24
+ end
25
+ end
26
+ end
27
+
28
+ def show
29
+ @ecconnect_payment = resource_class.find params[:id]
30
+ respond_to do |format|
31
+ format.html do
32
+ render 'show'
33
+ end
34
+ format.json{ render json: @ecconnect_payment.ecconnect_json }
35
+ end
36
+ end
37
+
38
+ def check
39
+ @ecconnect_payment = resource_class.find params[:id]
40
+ respond_to do |format|
41
+ format.html do
42
+ render 'check'
43
+ end
44
+ format.json{ render json: @ecconnect_payment.ecconnect_json }
45
+ end
46
+ end
47
+
48
+ def failure
49
+ @ecconnect_payment = resource_class.where(order_id: params[:OrderID]).limit(1).first
50
+ @ecconnect_payment.update_by params
51
+ if @ecconnect_payment.check_signature
52
+ failure_right_signature @ecconnect_payment
53
+ failure_respond @ecconnect_payment
54
+ else
55
+ failure_wrong_signature @ecconnect_payment
56
+ wrong_signature_respond @ecconnect_payment
57
+ end
58
+ end
59
+
60
+ def success
61
+ @ecconnect_payment = resource_class.where(order_id: params[:OrderID]).limit(1).first
62
+ @ecconnect_payment.update_by params
63
+ if @ecconnect_payment.check_signature
64
+ if @ecconnect_payment.tran_code == '000'
65
+ success_right_signature @ecconnect_payment
66
+ success_respond @ecconnect_payment
67
+ else
68
+ failure_right_signature @ecconnect_payment
69
+ failure_respond @ecconnect_payment
70
+ end
71
+ else
72
+ success_wrong_signature @ecconnect_payment
73
+ wrong_signature_respond @ecconnect_payment
74
+ end
75
+ end
76
+
77
+ def notify
78
+ @ecconnect_payment = resource_class.where(order_id: params[:OrderID]).limit(1).first
79
+ @ecconnect_payment.update_by params
80
+ if @ecconnect_payment.check_signature
81
+ if @ecconnect_payment.tran_code == '000'
82
+ @action = 'approve'
83
+ @forward_url = forward_url_success
84
+ notify_right_signature_and_code @ecconnect_payment
85
+ notify_respond @ecconnect_payment
86
+ else
87
+ @action = 'reverse'
88
+ @reason = I18n.t "ecconnect_rails.codes.code_503"
89
+ @forward_url = forward_url_failure
90
+ notify_right_signature @ecconnect_payment
91
+ notify_respond @ecconnect_payment
92
+ end
93
+ else
94
+ @action = 'reverse'
95
+ @reason = I18n.t "ecconnect_rails.codes.code_405"
96
+ @forward_url = forward_url_failure
97
+ notify_wrong_signature @ecconnect_payment
98
+ notify_respond @ecconnect_payment
99
+ end
100
+ end
101
+
102
+ private
103
+
104
+ def forward_url_success
105
+ end
106
+
107
+ def forward_url_failure
108
+ end
109
+
110
+ def notify_respond ecconnect_payment
111
+ respond_to do |format|
112
+ format.html do
113
+ render 'notify', layout: nil
114
+ end
115
+ end
116
+ end
117
+
118
+ def success_respond ecconnect_payment
119
+ respond_to do |format|
120
+ format.html do
121
+ flash[:notice] = I18n.t "ecconnect_rails.success"
122
+ render 'success'
123
+ end
124
+ format.json{ render json: @ecconnect_payment.ecconnect_json }
125
+ end
126
+ end
127
+
128
+ def failure_respond ecconnect_payment
129
+ respond_to do |format|
130
+ format.html do
131
+ flash[:error] = I18n.t "ecconnect_rails.codes.code_#{@ecconnect_payment.tran_code}"
132
+ render 'failure'
133
+ end
134
+ format.json{ render json: @ecconnect_payment.ecconnect_json }
135
+ end
136
+ end
137
+
138
+ def wrong_signature_respond ecconnect_payment
139
+ respond_to do |format|
140
+ format.html do
141
+ flash[:error] = I18n.t "ecconnect_rails.wrong_signature"
142
+ render 'failure'
143
+ end
144
+ format.json{ render json: @ecconnect_payment.ecconnect_json }
145
+ end
146
+ end
147
+
148
+ def success_right_signature ecconnect_payment
149
+ end
150
+
151
+ def success_wrong_signature ecconnect_payment
152
+ end
153
+
154
+ def failure_right_signature ecconnect_payment
155
+ end
156
+
157
+ def failure_wrong_signature ecconnect_payment
158
+ end
159
+
160
+ def notify_right_signature ecconnect_payment
161
+ end
162
+
163
+ def notify_right_signature_and_code ecconnect_payment
164
+ end
165
+
166
+ def notify_wrong_signature ecconnect_payment
167
+ end
168
+ end
169
+ end
@@ -0,0 +1,14 @@
1
+ module EcconnectRails
2
+ module ControllerDefaults
3
+
4
+ protected
5
+ def defaults options
6
+ raise ArgumentError, 'Class method :defaults expects a hash of options.' unless options.is_a? Hash
7
+
8
+ options.symbolize_keys!
9
+
10
+ class_attribute :resource_class, :instance_writer => false unless self.respond_to? :resource_class
11
+ self.resource_class = options[:resource_class] if options.key?(:resource_class)
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module EcconnectRails
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe EcconnectRails::EcconnectPaymentsController do
4
- routes { EcconnectRails::Engine.routes }
3
+ describe EcconnectPaymentsController do
4
+ #routes { EcconnectRails::Engine.routes }
5
5
  let(:payment){ FactoryGirl.create :ecconnect_payment }
6
6
  describe "GET new" do
7
7
  before{ get :new }
8
8
  it{ response.status.should == 200 }
9
- it{ assigns(:ecconnect_payment).should be_a_new(EcconnectRails::EcconnectPayment) }
9
+ it{ assigns(:ecconnect_payment).should be_a_new(EcconnectPayment) }
10
10
  end
11
11
 
12
12
  describe "GET show" do
@@ -19,7 +19,7 @@ describe EcconnectRails::EcconnectPaymentsController do
19
19
  before{ post :create, ecconnect_payment: { amount: amount } }
20
20
  context "right data" do
21
21
  let(:amount){ 23 }
22
- it{ response.should redirect_to "/ecconnect/ecconnect_payments/#{EcconnectRails::EcconnectPayment.last.to_param}" }
22
+ it{ response.should redirect_to ecconnect_payment_path EcconnectPayment.last }
23
23
  end
24
24
  context "wrong data" do
25
25
  let(:amount){ nil }
@@ -31,27 +31,26 @@ describe EcconnectRails::EcconnectPaymentsController do
31
31
  ['000', 101, 105, 108, 111, 116, 130, 290, 291, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411,
32
32
  412, 413, 420, 421, 430, 431, 432, 433, 434, 435, 436, 438, 439, 440, 441, 450, 501, 502, 503,
33
33
  504, 505, 506, 507, 508, 509, 510, 511, 601].each do |code|
34
- let(:payment){ FactoryGirl.create :payment }
35
34
  context "right signature" do
36
- before{ EcconnectRails::EcconnectPayment.any_instance.stub(:check_signature).and_return(true) }
37
- before{ post :failure, {'TranCode' => code.to_s} }
35
+ before{ EcconnectPayment.any_instance.stub(:check_signature).and_return(true) }
36
+ before{ post :failure, {'TranCode' => code.to_s, 'OrderID' => payment.order_id.to_s, 'Signature' => payment.income_signature} }
38
37
  it{ response.should render_template 'failure' }
39
38
  it{ flash[:error].should == I18n.t("ecconnect_rails.codes.code_#{code}" ) }
40
39
  end
41
40
  context "wrong signature" do
42
- before{ EcconnectRails::EcconnectPayment.any_instance.stub(:check_signature).and_return(false) }
43
- before{ post :failure, {'TranCode' => code.to_s} }
41
+ before{ EcconnectPayment.any_instance.stub(:check_signature).and_return(false) }
42
+ before{ post :failure, {'TranCode' => code.to_s, 'OrderID' => payment.order_id.to_s, 'Signature' => payment.income_signature} }
44
43
  it{ response.should render_template 'failure' }
45
44
  it{ flash[:error].should == I18n.t("ecconnect_rails.wrong_signature") }
46
45
  end
47
46
  describe "override methods" do
48
47
  context "right signature" do
49
- before{ EcconnectRails::EcconnectPayment.any_instance.stub(:check_signature).and_return(true) }
50
- it{ expect{ post :failure, {'TranCode' => code.to_s} }.to change{TestModel.count}.by(3) }
48
+ before{ EcconnectPayment.any_instance.stub(:check_signature).and_return(true) }
49
+ it{ expect{ post :failure, {'TranCode' => code.to_s, 'OrderID' => payment.order_id.to_s, 'Signature' => payment.income_signature} }.to change{TestModel.count}.by(3) }
51
50
  end
52
51
  context "wrong signature" do
53
- before{ EcconnectRails::EcconnectPayment.any_instance.stub(:check_signature).and_return(false) }
54
- it{ expect{ post :failure, {'TranCode' => code.to_s} }.to change{TestModel.count}.by(4) }
52
+ before{ EcconnectPayment.any_instance.stub(:check_signature).and_return(false) }
53
+ it{ expect{ post :failure, {'TranCode' => code.to_s, 'OrderID' => payment.order_id.to_s, 'Signature' => payment.income_signature} }.to change{TestModel.count}.by(4) }
55
54
  end
56
55
  end
57
56
  end
@@ -61,10 +60,9 @@ describe EcconnectRails::EcconnectPaymentsController do
61
60
  ['000', 101, 105, 108, 111, 116, 130, 290, 291, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411,
62
61
  412, 413, 420, 421, 430, 431, 432, 433, 434, 435, 436, 438, 439, 440, 441, 450, 501, 502, 503,
63
62
  504, 505, 506, 507, 508, 509, 510, 511, 601].each do |code|
64
- let(:payment){ FactoryGirl.create :payment }
65
63
  context "right signature" do
66
- before{ EcconnectRails::EcconnectPayment.any_instance.stub(:check_signature).and_return(true) }
67
- before{ post :success, {'TranCode' => code.to_s} }
64
+ before{ EcconnectPayment.any_instance.stub(:check_signature).and_return(true) }
65
+ before{ post :success, {'TranCode' => code.to_s, 'OrderID' => payment.order_id.to_s, 'Signature' => payment.income_signature} }
68
66
  it do
69
67
  if code == "000"
70
68
  response.should render_template 'success'
@@ -81,24 +79,24 @@ describe EcconnectRails::EcconnectPaymentsController do
81
79
  end
82
80
  end
83
81
  context "wrong signature" do
84
- before{ EcconnectRails::EcconnectPayment.any_instance.stub(:check_signature).and_return(false) }
85
- before{ post :success, {'TranCode' => code.to_s} }
82
+ before{ EcconnectPayment.any_instance.stub(:check_signature).and_return(false) }
83
+ before{ post :success, {'TranCode' => code.to_s, 'OrderID' => payment.order_id.to_s, 'Signature' => payment.income_signature} }
86
84
  it{ response.should render_template 'failure' }
87
85
  it{ flash[:error].should == I18n.t("ecconnect_rails.wrong_signature") }
88
86
  end
89
87
  describe "override methods" do
90
88
  context "right signature" do
91
89
  if code == "000"
92
- before{ EcconnectRails::EcconnectPayment.any_instance.stub(:check_signature).and_return(true) }
93
- it{ expect{ post :success, {'TranCode' => code.to_s} }.to change{TestModel.count}.by(1) }
90
+ before{ EcconnectPayment.any_instance.stub(:check_signature).and_return(true) }
91
+ it{ expect{ post :success, {'TranCode' => code.to_s, 'OrderID' => payment.order_id.to_s, 'Signature' => payment.income_signature} }.to change{TestModel.count}.by(1) }
94
92
  else
95
- before{ EcconnectRails::EcconnectPayment.any_instance.stub(:check_signature).and_return(true) }
96
- it{ expect{ post :success, {'TranCode' => code.to_s} }.to change{TestModel.count}.by(3) }
93
+ before{ EcconnectPayment.any_instance.stub(:check_signature).and_return(true) }
94
+ it{ expect{ post :success, {'TranCode' => code.to_s, 'OrderID' => payment.order_id.to_s, 'Signature' => payment.income_signature} }.to change{TestModel.count}.by(3) }
97
95
  end
98
96
  end
99
97
  context "wrong signature" do
100
- before{ EcconnectRails::EcconnectPayment.any_instance.stub(:check_signature).and_return(false) }
101
- it{ expect{ post :success, {'TranCode' => code.to_s} }.to change{TestModel.count}.by(2) }
98
+ before{ EcconnectPayment.any_instance.stub(:check_signature).and_return(false) }
99
+ it{ expect{ post :success, {'TranCode' => code.to_s, 'OrderID' => payment.order_id.to_s, 'Signature' => payment.income_signature} }.to change{TestModel.count}.by(2) }
102
100
  end
103
101
  end
104
102
  end
@@ -108,10 +106,9 @@ describe EcconnectRails::EcconnectPaymentsController do
108
106
  ['000', 101, 105, 108, 111, 116, 130, 290, 291, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411,
109
107
  412, 413, 420, 421, 430, 431, 432, 433, 434, 435, 436, 438, 439, 440, 441, 450, 501, 502, 503,
110
108
  504, 505, 506, 507, 508, 509, 510, 511, 601].each do |code|
111
- let(:payment){ FactoryGirl.create :payment }
112
109
  context "right signature" do
113
- before{ EcconnectRails::EcconnectPayment.any_instance.stub(:check_signature).and_return(true) }
114
- before{ post :notify, {'TranCode' => code.to_s} }
110
+ before{ EcconnectPayment.any_instance.stub(:check_signature).and_return(true) }
111
+ before{ post :notify, {'TranCode' => code.to_s, 'OrderID' => payment.order_id.to_s, 'Signature' => payment.income_signature} }
115
112
  it do
116
113
  if code == "000"
117
114
  response.should render_template 'notify'
@@ -127,8 +124,8 @@ describe EcconnectRails::EcconnectPaymentsController do
127
124
  end
128
125
  end
129
126
  context "wrong signature" do
130
- before{ EcconnectRails::EcconnectPayment.any_instance.stub(:check_signature).and_return(false) }
131
- before{ post :notify, {'TranCode' => code.to_s} }
127
+ before{ EcconnectPayment.any_instance.stub(:check_signature).and_return(false) }
128
+ before{ post :notify, {'TranCode' => code.to_s, 'OrderID' => payment.order_id.to_s, 'Signature' => payment.income_signature} }
132
129
  it{ response.should render_template 'notify' }
133
130
  it{ assigns(:action) == 'reverse' }
134
131
  it{ assigns(:reason) == I18n.t("ecconnect_rails.codes.code_405") }
@@ -137,29 +134,29 @@ describe EcconnectRails::EcconnectPaymentsController do
137
134
  describe "override methods" do
138
135
  context "right signature && right signature and code" do
139
136
  if code == "000" #right signature and code
140
- before{ EcconnectRails::EcconnectPayment.any_instance.stub(:check_signature).and_return(true) }
141
- it{ expect{ post :notify, {'TranCode' => code.to_s} }.to change{TestModel.count}.by(6) }
137
+ before{ EcconnectPayment.any_instance.stub(:check_signature).and_return(true) }
138
+ it{ expect{ post :notify, {'TranCode' => code.to_s, 'OrderID' => payment.order_id.to_s, 'Signature' => payment.income_signature} }.to change{TestModel.count}.by(6) }
142
139
  context "override url" do
143
- before{ EcconnectRails::EcconnectPaymentsController.any_instance.stub(:forward_url_success).and_return('http://google.com') }
144
- before{ post :notify, {'TranCode' => code.to_s} }
140
+ before{ EcconnectPaymentsController.any_instance.stub(:forward_url_success).and_return('http://google.com') }
141
+ before{ post :notify, {'TranCode' => code.to_s, 'OrderID' => payment.order_id.to_s, 'Signature' => payment.income_signature} }
145
142
  it{ assigns(:forward_url) == 'http://google.com' }
146
143
  end
147
144
  else #right signature
148
- before{ EcconnectRails::EcconnectPayment.any_instance.stub(:check_signature).and_return(true) }
149
- it{ expect{ post :notify, {'TranCode' => code.to_s} }.to change{TestModel.count}.by(5) }
145
+ before{ EcconnectPayment.any_instance.stub(:check_signature).and_return(true) }
146
+ it{ expect{ post :notify, {'TranCode' => code.to_s, 'OrderID' => payment.order_id.to_s, 'Signature' => payment.income_signature} }.to change{TestModel.count}.by(5) }
150
147
  context "override url" do
151
- before{ EcconnectRails::EcconnectPaymentsController.any_instance.stub(:forward_url_failure).and_return('http://google.com.ua') }
152
- before{ post :notify, {'TranCode' => code.to_s} }
148
+ before{ EcconnectPaymentsController.any_instance.stub(:forward_url_failure).and_return('http://google.com.ua') }
149
+ before{ post :notify, {'TranCode' => code.to_s, 'OrderID' => payment.order_id.to_s, 'Signature' => payment.income_signature} }
153
150
  it{ assigns(:forward_url) == 'http://google.com.ua' }
154
151
  end
155
152
  end
156
153
  end
157
154
  context "wrong signature" do
158
- before{ EcconnectRails::EcconnectPayment.any_instance.stub(:check_signature).and_return(false) }
159
- it{ expect{ post :notify, {'TranCode' => code.to_s} }.to change{TestModel.count}.by(7) }
155
+ before{ EcconnectPayment.any_instance.stub(:check_signature).and_return(false) }
156
+ it{ expect{ post :notify, {'TranCode' => code.to_s, 'OrderID' => payment.order_id.to_s, 'Signature' => payment.income_signature} }.to change{TestModel.count}.by(7) }
160
157
  context "override url" do
161
- before{ EcconnectRails::EcconnectPaymentsController.any_instance.stub(:forward_url_failure).and_return('http://google.com.ua') }
162
- before{ post :notify, {'TranCode' => code.to_s} }
158
+ before{ EcconnectPaymentsController.any_instance.stub(:forward_url_failure).and_return('http://google.com.ua') }
159
+ before{ post :notify, {'TranCode' => code.to_s, 'OrderID' => payment.order_id.to_s, 'Signature' => payment.income_signature} }
163
160
  it{ assigns(:forward_url) == 'http://google.com.ua' }
164
161
  end
165
162
  end
@@ -1,9 +1,7 @@
1
1
  PATH
2
2
  remote: ../../
3
3
  specs:
4
- ecconnect_rails (0.0.2)
5
- mongoid (>= 3.0.0)
6
- mongoid-autoinc (>= 0.3.0)
4
+ ecconnect_rails (0.0.5)
7
5
  rails (>= 3.2)
8
6
 
9
7
  GEM
@@ -1,5 +1,6 @@
1
- module EcconnectRails
1
+ #module EcconnectRails
2
2
  class EcconnectPaymentsController < EcconnectRails::BaseController
3
+
3
4
  private
4
5
  def success_right_signature ecconnect_payment
5
6
  1.times{ TestModel.create! }
@@ -29,4 +30,4 @@ module EcconnectRails
29
30
  7.times{ TestModel.create! }
30
31
  end
31
32
  end
32
- end
33
+ #end
@@ -0,0 +1,35 @@
1
+ require 'autoinc'
2
+
3
+ #module EcconnectRails
4
+ class EcconnectPayment
5
+ include EcconnectRails::BaseModel
6
+ include Mongoid::Document
7
+ include Mongoid::Timestamps
8
+ include Mongoid::Autoinc
9
+
10
+ field :delay, type: Boolean
11
+ field :merchant_id, type: Integer
12
+ field :terminal_id, type: String
13
+ field :tran_code, type: String
14
+ field :approval_code, type: Integer
15
+ field :locale, type: String
16
+ field :proxy_pan, type: String
17
+ field :currency_id, type: Integer
18
+ field :alt_currency_id, type: Integer
19
+ field :amount, type: Float
20
+ field :alt_amount, type: Integer
21
+ field :order_id, type: Integer
22
+ field :income_signature, type: String
23
+ field :purchase_desc, type: String
24
+ field :email, type: String
25
+ field :sd, type: String
26
+ field :xid, type: String
27
+ field :rrn, type: String
28
+
29
+ increments :order_id, seed: 1
30
+
31
+ ecconnect_payment
32
+
33
+ belongs_to :user
34
+ end
35
+ #end
@@ -0,0 +1,5 @@
1
+ class User
2
+ include Mongoid::Document
3
+
4
+ has_many :ecconnect_payments
5
+ end
@@ -1,4 +1,11 @@
1
1
  Rails.application.routes.draw do
2
2
 
3
- mount EcconnectRails::Engine => "/ecconnect"
3
+ #mount EcconnectRails::Engine => "/ecconnect"
4
+ resources :ecconnect_payments, only: [:new, :create, :show] do
5
+ collection do
6
+ post 'success'
7
+ post 'failure'
8
+ post 'notify'
9
+ end
10
+ end
4
11
  end
@@ -0,0 +1,46 @@
1
+ MOPED: 127.0.0.1:27017 COMMAND database=admin command={:ismaster=>1} (0.5901ms)
2
+ MOPED: 127.0.0.1:27017 COMMAND database=ecconnect_rails_test command={:count=>"auto_increment_counters", :query=>{"_id"=>"ecconnect_payment_order_id"}} (1.6110ms)
3
+ MOPED: 127.0.0.1:27017 COMMAND database=ecconnect_rails_test command={:findAndModify=>"auto_increment_counters", :query=>{"_id"=>"ecconnect_payment_order_id"}, :new=>true, :upsert=>true, :update=>{"$inc"=>{"c"=>1}}} (0.3541ms)
4
+ MOPED: 127.0.0.1:27017 INSERT database=ecconnect_rails_test collection=ecconnect_payments documents=[{"_id"=>"524b093c0f1d0e11bd000001", "amount"=>20.22, "income_signature"=>"123", "terminal_id"=>"E7881970", "merchant_id"=>1753970, "locale"=>"en", "currency_id"=>980, "updated_at"=>2013-10-01 17:41:16 UTC, "created_at"=>2013-10-01 17:41:16 UTC, "order_id"=>15431, "tran_code"=>nil}] flags=[] (0.1159ms)
5
+ MOPED: 127.0.0.1:27017 COMMAND database=ecconnect_rails_test command={:count=>"auto_increment_counters", :query=>{"_id"=>"ecconnect_payment_order_id"}} (0.3116ms)
6
+ MOPED: 127.0.0.1:27017 COMMAND database=ecconnect_rails_test command={:findAndModify=>"auto_increment_counters", :query=>{"_id"=>"ecconnect_payment_order_id"}, :new=>true, :upsert=>true, :update=>{"$inc"=>{"c"=>1}}} (0.3052ms)
7
+ MOPED: 127.0.0.1:27017 INSERT database=ecconnect_rails_test collection=ecconnect_payments documents=[{"_id"=>"524b093c0f1d0e11bd000002", "amount"=>20.22, "income_signature"=>"123", "terminal_id"=>"E7881970", "merchant_id"=>1753970, "locale"=>"en", "currency_id"=>980, "updated_at"=>2013-10-01 17:41:16 UTC, "created_at"=>2013-10-01 17:41:16 UTC, "order_id"=>15432, "tran_code"=>nil}] flags=[] (0.0987ms)
8
+ MOPED: 127.0.0.1:27017 COMMAND database=ecconnect_rails_test command={:count=>"auto_increment_counters", :query=>{"_id"=>"ecconnect_payment_order_id"}} (0.3870ms)
9
+ MOPED: 127.0.0.1:27017 COMMAND database=ecconnect_rails_test command={:findAndModify=>"auto_increment_counters", :query=>{"_id"=>"ecconnect_payment_order_id"}, :new=>true, :upsert=>true, :update=>{"$inc"=>{"c"=>1}}} (0.4389ms)
10
+ MOPED: 127.0.0.1:27017 INSERT database=ecconnect_rails_test collection=ecconnect_payments documents=[{"_id"=>"524b093c0f1d0e11bd000003", "amount"=>20.22, "income_signature"=>"123", "terminal_id"=>"E7881970", "merchant_id"=>1753970, "locale"=>"en", "currency_id"=>980, "updated_at"=>2013-10-01 17:41:16 UTC, "created_at"=>2013-10-01 17:41:16 UTC, "order_id"=>15433, "tran_code"=>nil}] flags=[] (0.0992ms)
11
+ MOPED: 127.0.0.1:27017 COMMAND database=ecconnect_rails_test command={:count=>"auto_increment_counters", :query=>{"_id"=>"ecconnect_payment_order_id"}} (0.3021ms)
12
+ MOPED: 127.0.0.1:27017 COMMAND database=ecconnect_rails_test command={:findAndModify=>"auto_increment_counters", :query=>{"_id"=>"ecconnect_payment_order_id"}, :new=>true, :upsert=>true, :update=>{"$inc"=>{"c"=>1}}} (0.3588ms)
13
+ MOPED: 127.0.0.1:27017 INSERT database=ecconnect_rails_test collection=ecconnect_payments documents=[{"_id"=>"524b093c0f1d0e11bd000004", "amount"=>20.22, "income_signature"=>"123", "terminal_id"=>"E7881970", "merchant_id"=>1753970, "locale"=>"en", "currency_id"=>980, "updated_at"=>2013-10-01 17:41:16 UTC, "created_at"=>2013-10-01 17:41:16 UTC, "order_id"=>15434, "tran_code"=>nil}] flags=[] (0.1030ms)
14
+ MOPED: 127.0.0.1:27017 COMMAND database=ecconnect_rails_test command={:count=>"auto_increment_counters", :query=>{"_id"=>"ecconnect_payment_order_id"}} (0.2630ms)
15
+ MOPED: 127.0.0.1:27017 COMMAND database=ecconnect_rails_test command={:findAndModify=>"auto_increment_counters", :query=>{"_id"=>"ecconnect_payment_order_id"}, :new=>true, :upsert=>true, :update=>{"$inc"=>{"c"=>1}}} (0.3259ms)
16
+ MOPED: 127.0.0.1:27017 INSERT database=ecconnect_rails_test collection=ecconnect_payments documents=[{"_id"=>"524b093c0f1d0e11bd000005", "amount"=>20.22, "income_signature"=>"123", "terminal_id"=>"E7881970", "merchant_id"=>1753970, "locale"=>"en", "currency_id"=>980, "updated_at"=>2013-10-01 17:41:16 UTC, "created_at"=>2013-10-01 17:41:16 UTC, "order_id"=>15435, "tran_code"=>nil}] flags=[] (0.1030ms)
17
+ MOPED: 127.0.0.1:27017 COMMAND database=ecconnect_rails_test command={:count=>"auto_increment_counters", :query=>{"_id"=>"ecconnect_payment_order_id"}} (0.2730ms)
18
+ MOPED: 127.0.0.1:27017 COMMAND database=ecconnect_rails_test command={:findAndModify=>"auto_increment_counters", :query=>{"_id"=>"ecconnect_payment_order_id"}, :new=>true, :upsert=>true, :update=>{"$inc"=>{"c"=>1}}} (0.3211ms)
19
+ MOPED: 127.0.0.1:27017 INSERT database=ecconnect_rails_test collection=ecconnect_payments documents=[{"_id"=>"524b093c0f1d0e11bd000006", "amount"=>20.22, "income_signature"=>"123", "terminal_id"=>"E7881970", "merchant_id"=>1753970, "locale"=>"en", "currency_id"=>980, "updated_at"=>2013-10-01 17:41:16 UTC, "created_at"=>2013-10-01 17:41:16 UTC, "order_id"=>15436, "tran_code"=>nil}] flags=[] (0.1011ms)
20
+ MOPED: 127.0.0.1:27017 COMMAND database=ecconnect_rails_test command={:count=>"auto_increment_counters", :query=>{"_id"=>"ecconnect_payment_order_id"}} (0.4480ms)
21
+ MOPED: 127.0.0.1:27017 COMMAND database=ecconnect_rails_test command={:findAndModify=>"auto_increment_counters", :query=>{"_id"=>"ecconnect_payment_order_id"}, :new=>true, :upsert=>true, :update=>{"$inc"=>{"c"=>1}}} (0.5109ms)
22
+ MOPED: 127.0.0.1:27017 INSERT database=ecconnect_rails_test collection=ecconnect_payments documents=[{"_id"=>"524b093c0f1d0e11bd000007", "amount"=>20.0, "income_signature"=>"123", "tran_code"=>nil, "terminal_id"=>"E7881970", "merchant_id"=>1753970, "locale"=>"en", "currency_id"=>980, "updated_at"=>2013-10-01 17:41:16 UTC, "created_at"=>2013-10-01 17:41:16 UTC, "order_id"=>15437}] flags=[] (0.1280ms)
23
+ Started GET "/ecconnect_payments/new" for 127.0.0.1 at 2013-10-01 20:41:16 +0300
24
+ Processing by EcconnectPaymentsController#new as HTML
25
+ Rendered ecconnect_payments/new.html.erb (3.9ms)
26
+ Completed 200 OK in 14ms (Views: 13.6ms)
27
+ MOPED: 127.0.0.1:27017 COMMAND database=ecconnect_rails_test command={:count=>"auto_increment_counters", :query=>{"_id"=>"ecconnect_payment_order_id"}} (0.4609ms)
28
+ MOPED: 127.0.0.1:27017 COMMAND database=ecconnect_rails_test command={:findAndModify=>"auto_increment_counters", :query=>{"_id"=>"ecconnect_payment_order_id"}, :new=>true, :upsert=>true, :update=>{"$inc"=>{"c"=>1}}} (0.3121ms)
29
+ MOPED: 127.0.0.1:27017 INSERT database=ecconnect_rails_test collection=ecconnect_payments documents=[{"_id"=>"524b093c0f1d0e11bd000008", "amount"=>20.22, "income_signature"=>"123", "terminal_id"=>"E7881970", "merchant_id"=>1753970, "locale"=>"en", "currency_id"=>980, "updated_at"=>2013-10-01 17:41:16 UTC, "created_at"=>2013-10-01 17:41:16 UTC, "order_id"=>15438, "tran_code"=>nil}] flags=[] (0.1159ms)
30
+ Started POST "/ecconnect_payments" for 127.0.0.1 at 2013-10-01 20:41:16 +0300
31
+ Processing by EcconnectPaymentsController#create as HTML
32
+ Parameters: {"utf8"=>"✓", "ecconnect_payment"=>{"amount"=>"20.22"}, "commit"=>"Create Ecconnect payment"}
33
+ MOPED: 127.0.0.1:27017 COMMAND database=ecconnect_rails_test command={:count=>"auto_increment_counters", :query=>{"_id"=>"ecconnect_payment_order_id"}} (0.4220ms)
34
+ MOPED: 127.0.0.1:27017 COMMAND database=ecconnect_rails_test command={:findAndModify=>"auto_increment_counters", :query=>{"_id"=>"ecconnect_payment_order_id"}, :new=>true, :upsert=>true, :update=>{"$inc"=>{"c"=>1}}} (0.3059ms)
35
+ MOPED: 127.0.0.1:27017 INSERT database=ecconnect_rails_test collection=ecconnect_payments documents=[{"_id"=>"524b093c0f1d0e11bd000009", "amount"=>20.22, "terminal_id"=>"E7881970", "merchant_id"=>1753970, "locale"=>"en", "currency_id"=>980, "updated_at"=>2013-10-01 17:41:16 UTC, "created_at"=>2013-10-01 17:41:16 UTC, "order_id"=>15439, "tran_code"=>nil}] flags=[] (0.1049ms)
36
+ Redirected to http://www.example.com/ecconnect_payments/524b093c0f1d0e11bd000009
37
+ Completed 302 Found in 3ms
38
+ Started GET "/ecconnect_payments/524b093c0f1d0e11bd000009" for 127.0.0.1 at 2013-10-01 20:41:16 +0300
39
+ Processing by EcconnectPaymentsController#show as HTML
40
+ Parameters: {"id"=>"524b093c0f1d0e11bd000009"}
41
+ MOPED: 127.0.0.1:27017 QUERY database=ecconnect_rails_test collection=ecconnect_payments selector={"_id"=>"524b093c0f1d0e11bd000009"} flags=[:slave_ok] limit=0 skip=0 batch_size=nil fields=nil (0.3707ms)
42
+ Rendered ecconnect_payments/show.html.erb (1.8ms)
43
+ Completed 200 OK in 4ms (Views: 2.6ms)
44
+ MOPED: 127.0.0.1:27017 COMMAND database=ecconnect_rails_test command={:count=>"auto_increment_counters", :query=>{"_id"=>"ecconnect_payment_order_id"}} (0.6170ms)
45
+ MOPED: 127.0.0.1:27017 COMMAND database=ecconnect_rails_test command={:findAndModify=>"auto_increment_counters", :query=>{"_id"=>"ecconnect_payment_order_id"}, :new=>true, :upsert=>true, :update=>{"$inc"=>{"c"=>1}}} (0.5162ms)
46
+ MOPED: 127.0.0.1:27017 INSERT database=dummy_development collection=ecconnect_payments documents=[{"_id"=>"524b093f0f1d0e11bd00000a", "amount"=>20.22, "income_signature"=>"123", "terminal_id"=>"E7881970", "merchant_id"=>1753970, "locale"=>"en", "currency_id"=>980, "updated_at"=>2013-10-01 17:41:19 UTC, "created_at"=>2013-10-01 17:41:19 UTC, "order_id"=>15440, "tran_code"=>nil}] flags=[] (0.2339ms)
@@ -1,11 +1,13 @@
1
1
  # Read about factories at https://github.com/thoughtbot/factory_girl
2
2
 
3
3
  FactoryGirl.define do
4
- factory :ecconnect_payment, :class => EcconnectRails::EcconnectPayment do
4
+ factory :ecconnect_payment do #, :class => EcconnectRails::EcconnectPayment do
5
5
  amount 20.22
6
+ income_signature '123'
6
7
  factory :ecconnect_payment_tran_code do
7
8
  amount 20
8
9
  tran_code '000'
10
+ income_signature '123'
9
11
  end
10
12
  end
11
13
  end
@@ -10,14 +10,14 @@ feature "Sources" do
10
10
  describe "payments" do
11
11
  context "payment new" do
12
12
  before do
13
- visit '/ecconnect/ecconnect_payments/new'
13
+ visit '/ecconnect_payments/new'
14
14
  fill_in('ecconnect_payment_amount', with: payment.amount)
15
15
  click_button('Create Ecconnect payment')
16
16
  end
17
17
  it{ find(:css, '#TotalAmount').value.should == payment.upc_amount.to_s }
18
18
  end
19
19
  context "payment show" do
20
- before{ visit "/ecconnect/ecconnect_payments/#{payment.to_param}" }
20
+ before{ visit "/ecconnect_payments/#{payment.to_param}" }
21
21
  it{ find(:css, '#TerminalID').value.should == payment.terminal_id.to_s }
22
22
  it{ find(:css, '#MerchantID').value.should == payment.merchant_id.to_s }
23
23
  it{ find(:css, '#Currency').value.should == payment.currency_id.to_s }
@@ -43,7 +43,7 @@ feature "Sources" do
43
43
  end
44
44
  end
45
45
  before(:each) do
46
- session.visit("http://127.0.0.1/ecconnect/ecconnect_payments/new")
46
+ session.visit("http://127.0.0.1:3000/ecconnect_payments/new")
47
47
  session.fill_in('ecconnect_payment_amount', with: payment.amount)
48
48
  session.click_button('Create Ecconnect payment')
49
49
  session.click_button(I18n.t('ecconnect_rails.ecconnect_form.submit'))
@@ -59,7 +59,7 @@ feature "Sources" do
59
59
  describe "000" do
60
60
  let(:card){ 4999999999990011 }
61
61
  before{ session.driver.browser.switch_to.alert.accept; }
62
- it{ session.current_path.should == "/ecconnect/ecconnect_payments/success" }
62
+ it{ session.current_path.should == "/ecconnect_payments/success" }
63
63
  end
64
64
  describe "403" do
65
65
  let(:card){ 4999999999990102 }
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe EcconnectRails::EcconnectPayment do
3
+ describe EcconnectPayment do
4
4
  let(:payment){ FactoryGirl.build :ecconnect_payment }
5
5
 
6
- it{ should belong_to(:payer) }
6
+ #it{ should belong_to(:payer) }
7
7
 
8
8
  it{ should have_field(:delay).of_type(Boolean) }
9
9
  it{ should have_field(:merchant_id).of_type(Integer) }
@@ -1,15 +1,15 @@
1
1
  require "spec_helper"
2
2
 
3
- describe EcconnectRails::EcconnectPaymentsController do
4
- routes { EcconnectRails::Engine.routes }
3
+ describe EcconnectPaymentsController do
4
+ #routes { EcconnectRails::Engine.routes }
5
5
  it{ expect(get: '/ecconnect_payments').not_to be_routable }
6
- it{ get('/ecconnect_payments/1').should route_to(controller: 'ecconnect_rails/ecconnect_payments', action: 'show', id: '1') }
7
- it{ get('/ecconnect_payments/new').should route_to(controller: 'ecconnect_rails/ecconnect_payments', action: 'new') }
8
- it{ post('/ecconnect_payments/success').should route_to(controller: 'ecconnect_rails/ecconnect_payments', action: 'success') }
9
- it{ post('/ecconnect_payments/failure').should route_to(controller: 'ecconnect_rails/ecconnect_payments', action: 'failure') }
10
- it{ post('/ecconnect_payments/notify').should route_to(controller: 'ecconnect_rails/ecconnect_payments', action: 'notify') }
6
+ it{ get('/ecconnect_payments/1').should route_to(controller: 'ecconnect_payments', action: 'show', id: '1') }
7
+ it{ get('/ecconnect_payments/new').should route_to(controller: 'ecconnect_payments', action: 'new') }
8
+ it{ post('/ecconnect_payments/success').should route_to(controller: 'ecconnect_payments', action: 'success') }
9
+ it{ post('/ecconnect_payments/failure').should route_to(controller: 'ecconnect_payments', action: 'failure') }
10
+ it{ post('/ecconnect_payments/notify').should route_to(controller: 'ecconnect_payments', action: 'notify') }
11
11
  it{ expect(get: 'ecconnect_payments/1/edit').not_to be_routable }
12
- it{ post('/ecconnect_payments').should route_to(controller: 'ecconnect_rails/ecconnect_payments', action: 'create') }
12
+ it{ post('/ecconnect_payments').should route_to(controller: 'ecconnect_payments', action: 'create') }
13
13
  it{ expect(put: 'ecconnect_payments/1').not_to be_routable }
14
14
  it{ expect(delete: 'ecconnect_payments/1').not_to be_routable }
15
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecconnect_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Budnikov Roman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-25 00:00:00.000000000 Z
11
+ date: 2013-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,34 +24,6 @@ dependencies:
24
24
  - - ! '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.2'
27
- - !ruby/object:Gem::Dependency
28
- name: mongoid
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ! '>='
32
- - !ruby/object:Gem::Version
33
- version: 3.0.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ! '>='
39
- - !ruby/object:Gem::Version
40
- version: 3.0.0
41
- - !ruby/object:Gem::Dependency
42
- name: mongoid-autoinc
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ! '>='
46
- - !ruby/object:Gem::Version
47
- version: 0.3.0
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: 0.3.0
55
27
  - !ruby/object:Gem::Dependency
56
28
  name: capybara
57
29
  requirement: !ruby/object:Gem::Requirement
@@ -129,25 +101,19 @@ executables: []
129
101
  extensions: []
130
102
  extra_rdoc_files: []
131
103
  files:
132
- - app/controllers/ecconnect_rails/application_controller.rb
133
104
  - app/controllers/ecconnect_rails/base_controller.rb
134
- - app/controllers/ecconnect_rails/ecconnect_payments_controller.rb
135
105
  - app/helpers/ecconnect_rails/application_helper.rb
136
- - app/models/ecconnect_rails/ecconnect_payment.rb
137
- - app/views/ecconnect_rails/ecconnect_payments/failure.html.erb
138
- - app/views/ecconnect_rails/ecconnect_payments/new.html.erb
139
- - app/views/ecconnect_rails/ecconnect_payments/notify.html.erb
140
- - app/views/ecconnect_rails/ecconnect_payments/show.html.erb
141
- - app/views/ecconnect_rails/ecconnect_payments/success.html.erb
142
106
  - config/locales/ecconnect_rails_en.yml
143
- - config/routes.rb
107
+ - lib/ecconnect_rails/base_model.rb
108
+ - lib/ecconnect_rails/controller_actions.rb
109
+ - lib/ecconnect_rails/controller_defaults.rb
144
110
  - lib/ecconnect_rails/engine.rb
145
111
  - lib/ecconnect_rails/version.rb
146
112
  - lib/ecconnect_rails.rb
147
113
  - lib/tasks/ecconnect_rails_tasks.rake
148
114
  - MIT-LICENSE
149
115
  - Rakefile
150
- - README.rdoc
116
+ - README.md
151
117
  - spec/certs/1753970.crt
152
118
  - spec/certs/1753970.pem
153
119
  - spec/certs/test-server.cert
@@ -157,7 +123,14 @@ files:
157
123
  - spec/dummy/app/controllers/application_controller.rb
158
124
  - spec/dummy/app/controllers/ecconnect_payments_controller.rb
159
125
  - spec/dummy/app/helpers/application_helper.rb
126
+ - spec/dummy/app/models/ecconnect_payment.rb
160
127
  - spec/dummy/app/models/test.rb
128
+ - spec/dummy/app/models/user.rb
129
+ - spec/dummy/app/views/ecconnect_payments/failure.html.erb
130
+ - spec/dummy/app/views/ecconnect_payments/new.html.erb
131
+ - spec/dummy/app/views/ecconnect_payments/notify.html.erb
132
+ - spec/dummy/app/views/ecconnect_payments/show.html.erb
133
+ - spec/dummy/app/views/ecconnect_payments/success.html.erb
161
134
  - spec/dummy/app/views/layouts/application.html.erb
162
135
  - spec/dummy/config/application.rb
163
136
  - spec/dummy/config/boot.rb
@@ -178,6 +151,7 @@ files:
178
151
  - spec/dummy/config.ru
179
152
  - spec/dummy/Gemfile
180
153
  - spec/dummy/Gemfile.lock
154
+ - spec/dummy/log/test.log
181
155
  - spec/dummy/public/404.html
182
156
  - spec/dummy/public/422.html
183
157
  - spec/dummy/public/500.html
@@ -190,7 +164,8 @@ files:
190
164
  - spec/routing/ecconnect_rails/ecconnect_payments_routing_spec.rb
191
165
  - spec/spec_helper.rb
192
166
  homepage: http://github.com/supro/ecconnect_rails
193
- licenses: []
167
+ licenses:
168
+ - MIT
194
169
  metadata: {}
195
170
  post_install_message:
196
171
  rdoc_options: []
@@ -222,7 +197,14 @@ test_files:
222
197
  - spec/dummy/app/controllers/application_controller.rb
223
198
  - spec/dummy/app/controllers/ecconnect_payments_controller.rb
224
199
  - spec/dummy/app/helpers/application_helper.rb
200
+ - spec/dummy/app/models/ecconnect_payment.rb
225
201
  - spec/dummy/app/models/test.rb
202
+ - spec/dummy/app/models/user.rb
203
+ - spec/dummy/app/views/ecconnect_payments/failure.html.erb
204
+ - spec/dummy/app/views/ecconnect_payments/new.html.erb
205
+ - spec/dummy/app/views/ecconnect_payments/notify.html.erb
206
+ - spec/dummy/app/views/ecconnect_payments/show.html.erb
207
+ - spec/dummy/app/views/ecconnect_payments/success.html.erb
226
208
  - spec/dummy/app/views/layouts/application.html.erb
227
209
  - spec/dummy/config/application.rb
228
210
  - spec/dummy/config/boot.rb
@@ -243,6 +225,7 @@ test_files:
243
225
  - spec/dummy/config.ru
244
226
  - spec/dummy/Gemfile
245
227
  - spec/dummy/Gemfile.lock
228
+ - spec/dummy/log/test.log
246
229
  - spec/dummy/public/404.html
247
230
  - spec/dummy/public/422.html
248
231
  - spec/dummy/public/500.html
@@ -1,5 +0,0 @@
1
- = EcconnectRails
2
-
3
- == Gem use mongoid orm
4
-
5
- Readme will be soon
@@ -1,4 +0,0 @@
1
- module EcconnectRails
2
- class ApplicationController < ActionController::Base
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module EcconnectRails
2
- class EcconnectPaymentsController < EcconnectRails::BaseController
3
- end
4
- end
@@ -1,9 +0,0 @@
1
- EcconnectRails::Engine.routes.draw do
2
- resources :ecconnect_payments, only: [:new, :create, :show] do
3
- collection do
4
- post 'success'
5
- post 'failure'
6
- post 'notify'
7
- end
8
- end
9
- end