przelewy24_payment 0.2.0 → 2.0.0
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 +5 -5
- data/CHANGELOG.md +11 -0
- data/LICENSE.txt +17 -18
- data/README.md +345 -139
- data/app/controllers/przelewy24_payment/webhooks_controller.rb +63 -0
- data/app/jobs/przelewy24_payment/application_job.rb +6 -0
- data/app/jobs/przelewy24_payment/charge_due_subscriptions_job.rb +13 -0
- data/app/models/przelewy24_payment/application_record.rb +7 -0
- data/app/models/przelewy24_payment/payment.rb +177 -0
- data/app/models/przelewy24_payment/refund.rb +33 -0
- data/app/models/przelewy24_payment/subscription.rb +147 -0
- data/config/routes.rb +6 -0
- data/lib/generators/przelewy24_payment/install/install_generator.rb +60 -5
- data/lib/generators/przelewy24_payment/install/templates/README +14 -0
- data/lib/generators/przelewy24_payment/install/templates/create_przelewy24_payments.rb.tt +21 -0
- data/lib/generators/przelewy24_payment/install/templates/create_przelewy24_refunds.rb.tt +14 -0
- data/lib/generators/przelewy24_payment/install/templates/create_przelewy24_subscriptions.rb.tt +28 -0
- data/lib/generators/przelewy24_payment/install/templates/initializer.rb.tt +47 -0
- data/lib/przelewy24_payment/api/base.rb +17 -0
- data/lib/przelewy24_payment/api/blik.rb +41 -0
- data/lib/przelewy24_payment/api/cards.rb +26 -0
- data/lib/przelewy24_payment/api/payment_methods.rb +11 -0
- data/lib/przelewy24_payment/api/refunds.rb +25 -0
- data/lib/przelewy24_payment/api/transactions.rb +51 -0
- data/lib/przelewy24_payment/client.rb +66 -0
- data/lib/przelewy24_payment/configuration.rb +81 -0
- data/lib/przelewy24_payment/engine.rb +12 -1
- data/lib/przelewy24_payment/errors.rb +45 -0
- data/lib/przelewy24_payment/instrumentation.rb +16 -0
- data/lib/przelewy24_payment/money.rb +26 -0
- data/lib/przelewy24_payment/notification.rb +55 -0
- data/lib/przelewy24_payment/payable.rb +20 -0
- data/lib/przelewy24_payment/refund_notification.rb +44 -0
- data/lib/przelewy24_payment/signature.rb +64 -0
- data/lib/przelewy24_payment/test_helpers.rb +20 -0
- data/lib/przelewy24_payment/version.rb +3 -1
- data/lib/przelewy24_payment.rb +26 -187
- metadata +83 -24
- data/.gitignore +0 -1
- data/Gemfile +0 -4
- data/Rakefile +0 -2
- data/app/helpers/przelewy24_payment/payment_helper.rb +0 -5
- data/app/views/przelewy24_payment/_payment_form.html.haml +0 -28
- data/lib/generators/przelewy24_payment/install/USAGE +0 -8
- data/lib/generators/przelewy24_payment/install/templates/przelewy24_payment.rb +0 -16
- data/lib/przelewy24_payment/przelewy24_payment_controller.rb +0 -67
- data/lib/tasks/test_connection.rake +0 -18
- data/przelewy24_payment.gemspec +0 -19
data/lib/przelewy24_payment.rb
CHANGED
|
@@ -1,200 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
require "przelewy24_payment/engine"
|
|
3
|
-
require "przelewy24_payment/przelewy24_payment_controller"
|
|
4
|
-
|
|
5
|
-
module Przelewy24Payment
|
|
6
|
-
|
|
7
|
-
mattr_accessor :merchant_id
|
|
8
|
-
@@merchant_id = ''
|
|
9
|
-
|
|
10
|
-
mattr_accessor :pos_id
|
|
11
|
-
@@pos_id = ''
|
|
12
|
-
|
|
13
|
-
mattr_accessor :language
|
|
14
|
-
@@language = 'pl'
|
|
15
|
-
|
|
16
|
-
mattr_accessor :currency
|
|
17
|
-
@@language = 'PLN'
|
|
18
|
-
|
|
19
|
-
mattr_accessor :mode
|
|
20
|
-
@@mode = :development
|
|
21
|
-
|
|
22
|
-
mattr_accessor :url_status
|
|
23
|
-
@@url_status = ''
|
|
24
|
-
|
|
25
|
-
mattr_accessor :url_return
|
|
26
|
-
@@url_return = ''
|
|
27
|
-
|
|
28
|
-
mattr_accessor :api_version
|
|
29
|
-
@@api_version = '3.2'
|
|
30
|
-
|
|
31
|
-
mattr_accessor :crc_key
|
|
32
|
-
@@crc_key = ''
|
|
33
|
-
|
|
34
|
-
mattr_accessor :allowed_ips
|
|
35
|
-
@@allowed_ips = %w(91.216.191.181 91.216.191.182 91.216.191.183 91.216.191.184 91.216.191.185)
|
|
36
|
-
|
|
37
|
-
mattr_accessor :allowed_languages
|
|
38
|
-
@@allowed_languages = %w(pl en de es it)
|
|
1
|
+
# frozen_string_literal: true
|
|
39
2
|
|
|
40
|
-
|
|
41
|
-
|
|
3
|
+
require "rails"
|
|
4
|
+
require "active_record/railtie"
|
|
5
|
+
require "active_job/railtie"
|
|
6
|
+
require "securerandom"
|
|
7
|
+
require "ipaddr"
|
|
8
|
+
require "zeitwerk"
|
|
42
9
|
|
|
43
|
-
|
|
44
|
-
|
|
10
|
+
loader = Zeitwerk::Loader.for_gem
|
|
11
|
+
loader.ignore("#{__dir__}/generators")
|
|
12
|
+
loader.ignore("#{__dir__}/przelewy24_payment/version.rb")
|
|
13
|
+
loader.ignore("#{__dir__}/przelewy24_payment/errors.rb")
|
|
14
|
+
loader.setup
|
|
45
15
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def self.setup
|
|
50
|
-
yield self
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def self.check_ip(ip)
|
|
54
|
-
if @@mode == :production
|
|
55
|
-
allowed_ips.include?(ip)
|
|
56
|
-
else
|
|
57
|
-
true
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def self.complete_url(params)
|
|
62
|
-
params
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def self.test_connection_url
|
|
66
|
-
if @@mode == :production
|
|
67
|
-
'https://secure.przelewy24.pl/testConnection'
|
|
68
|
-
else
|
|
69
|
-
'https://sandbox.przelewy24.pl/testConnection'
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def self.transaction_request_url
|
|
74
|
-
if @@mode == :production
|
|
75
|
-
'https://secure.przelewy24.pl/trnDirect'
|
|
76
|
-
else
|
|
77
|
-
'https://sandbox.przelewy24.pl/trnDirect'
|
|
78
|
-
end
|
|
79
|
-
end
|
|
16
|
+
require_relative "przelewy24_payment/version"
|
|
17
|
+
require_relative "przelewy24_payment/errors"
|
|
80
18
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
'https://sandbox.przelewy24.pl/trnVerify'
|
|
19
|
+
module Przelewy24Payment
|
|
20
|
+
class << self
|
|
21
|
+
def configuration
|
|
22
|
+
@configuration ||= Configuration.new
|
|
86
23
|
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def self.friendly_token
|
|
90
|
-
SecureRandom.base64(15).tr('+/=lIO0', 'aqrsxyz')
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def self.calculate_sign(session,merchant,amount,currency,crc)
|
|
94
|
-
Digest::MD5.hexdigest(session.to_s + "|" + merchant.to_s + "|" + amount.to_s + "|" + currency.to_s + "|" + crc.to_s)
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def self.get_hostname
|
|
98
|
-
@@hostname[@@mode]
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def self.get_url_status
|
|
102
|
-
get_hostname + @@url_status
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def self.get_url_return
|
|
106
|
-
get_hostname + @@url_return
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def self.make_p24_amount(price)
|
|
110
|
-
price.present? ? (price.to_f.round(2) * 100).to_i : 0
|
|
111
|
-
end
|
|
112
24
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if allowed_languages.include?(lang)
|
|
116
|
-
lang
|
|
117
|
-
else
|
|
118
|
-
'pl'
|
|
25
|
+
def configure
|
|
26
|
+
yield configuration
|
|
119
27
|
end
|
|
120
|
-
end
|
|
121
28
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if allowed_countries.include?(country_code)
|
|
125
|
-
country_code
|
|
126
|
-
else
|
|
127
|
-
'PL'
|
|
29
|
+
def client
|
|
30
|
+
Client.new(configuration)
|
|
128
31
|
end
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
def self.make_p24_currency(data_currency)
|
|
132
|
-
(data_currency || currency).upcase
|
|
133
|
-
end
|
|
134
32
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
data[:merchant_id] ||= merchant_id
|
|
138
|
-
data[:pos_id] ||= pos_id
|
|
139
|
-
data[:api_version] ||= api_version
|
|
140
|
-
data[:p24_amount] = make_p24_amount(data[:amount])
|
|
141
|
-
data[:currency] = make_p24_currency (data[:currency])
|
|
142
|
-
data[:language] = make_p24_language(data[:language]) if data[:language]
|
|
143
|
-
data[:country] = make_p24_country(data[:country])
|
|
144
|
-
data[:url_return] ||= get_url_return
|
|
145
|
-
data[:url_status] ||= get_url_status
|
|
146
|
-
data[:crc_key] ||= crc_key
|
|
147
|
-
data[:encoding] ||= 'UTF-8'
|
|
148
|
-
data[:p24_sign] = calculate_sign(data[:session_id],data[:merchant_id],data[:p24_amount],data[:currency], data[:crc_key])
|
|
149
|
-
data
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def self.test_connection_params(data={})
|
|
153
|
-
data[:p24_merchant_id] ||= merchant_id
|
|
154
|
-
data[:p24_pos_id] ||= pos_id
|
|
155
|
-
data[:p24_sign] = Digest::MD5.hexdigest(data[:p24_pos_id].to_s + "|" + crc_key.to_s)
|
|
156
|
-
data
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
def self.verify_sign(data,params_new)
|
|
160
|
-
Digest::MD5.hexdigest(params_new[:p24_session_id].to_s+"|"+params_new[:p24_order_id].to_s+"|"+make_p24_amount(data[:amount]).to_s+"|"+params_new[:p24_currency].to_s+"|"+data[:crc_key].to_s)
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
def self.parse_response(response)
|
|
164
|
-
ret = OpenStruct.new
|
|
165
|
-
response.split("&").each do |arg|
|
|
166
|
-
line = arg.split('=')
|
|
167
|
-
ret[line[0].strip] = line[1].force_encoding("ISO-8859-2").encode!("UTF-8")
|
|
33
|
+
def reset_configuration!
|
|
34
|
+
@configuration = Configuration.new
|
|
168
35
|
end
|
|
169
|
-
ret
|
|
170
36
|
end
|
|
171
|
-
|
|
172
|
-
## P24 Error codes
|
|
173
|
-
# err00: Incorrect call
|
|
174
|
-
# err01: Authorization answer confirmation was not received.
|
|
175
|
-
# err02: Authorization answer was not received.
|
|
176
|
-
# err03: This query has been already processed.
|
|
177
|
-
# err04: Authorization query incomplete or incorrect.
|
|
178
|
-
# err05: Store configuration cannot be read.
|
|
179
|
-
# err06: Saving of authorization query failed.
|
|
180
|
-
# err07: Another payment is being concluded.
|
|
181
|
-
# err08: Undetermined store connection status.
|
|
182
|
-
# err09: Permitted corrections amount has been exceeded.
|
|
183
|
-
# err10: Incorrect transaction value!
|
|
184
|
-
# err49: To high transaction risk factor.
|
|
185
|
-
# err51: Incorrect reference method.
|
|
186
|
-
# err52: Incorrect feedback on session information!
|
|
187
|
-
# err53: Transaction error !: err54: Incorrect transaction value!
|
|
188
|
-
# err55: Incorrect transaction id!
|
|
189
|
-
# err56: Incorrect card
|
|
190
|
-
# err57: Incompatibility of TEST flag
|
|
191
|
-
# err58: Incorrect sequence number !
|
|
192
|
-
# err101: Incorrect call
|
|
193
|
-
# err102: Allowed transaction time has expired
|
|
194
|
-
# err103: Incorrect transfer value.
|
|
195
|
-
# err104: Transaction awaits confirmation.
|
|
196
|
-
# err105: Transaction finished after allowed time.
|
|
197
|
-
# err106: Transaction result verification error
|
|
198
|
-
# err161: Transaction request terminated by user
|
|
199
|
-
# err162: Transaction request terminated by user
|
|
200
37
|
end
|
|
38
|
+
|
|
39
|
+
require "przelewy24_payment/engine"
|
metadata
CHANGED
|
@@ -1,42 +1,103 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: przelewy24_payment
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jakub Cieślar
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
|
|
11
|
+
date: 2026-10-25 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: faraday
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.0'
|
|
20
|
+
type: :runtime
|
|
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: rails
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '7.1'
|
|
34
|
+
- - "<"
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: '9.0'
|
|
37
|
+
type: :runtime
|
|
38
|
+
prerelease: false
|
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '7.1'
|
|
44
|
+
- - "<"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '9.0'
|
|
47
|
+
description: 'Rails engine for the Przelewy24 REST API v1: transaction registration,
|
|
48
|
+
signed webhook handling with verification, refunds, payment methods, install generator
|
|
49
|
+
and test helpers.'
|
|
14
50
|
email:
|
|
15
51
|
- cieslar.jakub@gmail.com
|
|
16
52
|
executables: []
|
|
17
53
|
extensions: []
|
|
18
54
|
extra_rdoc_files: []
|
|
19
55
|
files:
|
|
20
|
-
-
|
|
21
|
-
- Gemfile
|
|
56
|
+
- CHANGELOG.md
|
|
22
57
|
- LICENSE.txt
|
|
23
58
|
- README.md
|
|
24
|
-
-
|
|
25
|
-
- app/
|
|
26
|
-
- app/
|
|
27
|
-
-
|
|
59
|
+
- app/controllers/przelewy24_payment/webhooks_controller.rb
|
|
60
|
+
- app/jobs/przelewy24_payment/application_job.rb
|
|
61
|
+
- app/jobs/przelewy24_payment/charge_due_subscriptions_job.rb
|
|
62
|
+
- app/models/przelewy24_payment/application_record.rb
|
|
63
|
+
- app/models/przelewy24_payment/payment.rb
|
|
64
|
+
- app/models/przelewy24_payment/refund.rb
|
|
65
|
+
- app/models/przelewy24_payment/subscription.rb
|
|
66
|
+
- config/routes.rb
|
|
28
67
|
- lib/generators/przelewy24_payment/install/install_generator.rb
|
|
29
|
-
- lib/generators/przelewy24_payment/install/templates/
|
|
68
|
+
- lib/generators/przelewy24_payment/install/templates/README
|
|
69
|
+
- lib/generators/przelewy24_payment/install/templates/create_przelewy24_payments.rb.tt
|
|
70
|
+
- lib/generators/przelewy24_payment/install/templates/create_przelewy24_refunds.rb.tt
|
|
71
|
+
- lib/generators/przelewy24_payment/install/templates/create_przelewy24_subscriptions.rb.tt
|
|
72
|
+
- lib/generators/przelewy24_payment/install/templates/initializer.rb.tt
|
|
30
73
|
- lib/przelewy24_payment.rb
|
|
74
|
+
- lib/przelewy24_payment/api/base.rb
|
|
75
|
+
- lib/przelewy24_payment/api/blik.rb
|
|
76
|
+
- lib/przelewy24_payment/api/cards.rb
|
|
77
|
+
- lib/przelewy24_payment/api/payment_methods.rb
|
|
78
|
+
- lib/przelewy24_payment/api/refunds.rb
|
|
79
|
+
- lib/przelewy24_payment/api/transactions.rb
|
|
80
|
+
- lib/przelewy24_payment/client.rb
|
|
81
|
+
- lib/przelewy24_payment/configuration.rb
|
|
31
82
|
- lib/przelewy24_payment/engine.rb
|
|
32
|
-
- lib/przelewy24_payment/
|
|
83
|
+
- lib/przelewy24_payment/errors.rb
|
|
84
|
+
- lib/przelewy24_payment/instrumentation.rb
|
|
85
|
+
- lib/przelewy24_payment/money.rb
|
|
86
|
+
- lib/przelewy24_payment/notification.rb
|
|
87
|
+
- lib/przelewy24_payment/payable.rb
|
|
88
|
+
- lib/przelewy24_payment/refund_notification.rb
|
|
89
|
+
- lib/przelewy24_payment/signature.rb
|
|
90
|
+
- lib/przelewy24_payment/test_helpers.rb
|
|
33
91
|
- lib/przelewy24_payment/version.rb
|
|
34
|
-
- lib/tasks/test_connection.rake
|
|
35
|
-
- przelewy24_payment.gemspec
|
|
36
92
|
homepage: https://github.com/jcieslar/przelewy24_payment
|
|
37
|
-
licenses:
|
|
38
|
-
|
|
39
|
-
|
|
93
|
+
licenses:
|
|
94
|
+
- MIT
|
|
95
|
+
metadata:
|
|
96
|
+
homepage_uri: https://github.com/jcieslar/przelewy24_payment
|
|
97
|
+
source_code_uri: https://github.com/jcieslar/przelewy24_payment
|
|
98
|
+
changelog_uri: https://github.com/jcieslar/przelewy24_payment/blob/main/CHANGELOG.md
|
|
99
|
+
rubygems_mfa_required: 'true'
|
|
100
|
+
post_install_message:
|
|
40
101
|
rdoc_options: []
|
|
41
102
|
require_paths:
|
|
42
103
|
- lib
|
|
@@ -44,17 +105,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
44
105
|
requirements:
|
|
45
106
|
- - ">="
|
|
46
107
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
108
|
+
version: 3.2.0
|
|
48
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
110
|
requirements:
|
|
50
111
|
- - ">="
|
|
51
112
|
- !ruby/object:Gem::Version
|
|
52
113
|
version: '0'
|
|
53
114
|
requirements: []
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
signing_key:
|
|
115
|
+
rubygems_version: 3.5.16
|
|
116
|
+
signing_key:
|
|
57
117
|
specification_version: 4
|
|
58
|
-
summary: '
|
|
118
|
+
summary: 'Przelewy24 payments for Rails: REST API client, webhooks engine and generators.'
|
|
59
119
|
test_files: []
|
|
60
|
-
has_rdoc:
|
data/.gitignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
*.swp
|
data/Gemfile
DELETED
data/Rakefile
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
= form_tag Przelewy24Payment.transaction_request_url, :method => "post" do
|
|
2
|
-
= hidden_field_tag 'p24_merchant_id', data[:merchant_id]
|
|
3
|
-
= hidden_field_tag 'p24_pos_id', data[:pos_id]
|
|
4
|
-
= hidden_field_tag 'p24_session_id', data[:session_id]
|
|
5
|
-
= hidden_field_tag 'p24_amount', data[:p24_amount]
|
|
6
|
-
= hidden_field_tag 'p24_currency', data[:currency]
|
|
7
|
-
= hidden_field_tag 'p24_description', data[:description]
|
|
8
|
-
= hidden_field_tag 'p24_email', data[:email]
|
|
9
|
-
= hidden_field_tag 'p24_client', data[:client]
|
|
10
|
-
= hidden_field_tag 'p24_address', data[:address]
|
|
11
|
-
= hidden_field_tag 'p24_zip', data[:zip]
|
|
12
|
-
= hidden_field_tag 'p24_city', data[:city]
|
|
13
|
-
= hidden_field_tag 'p24_country', data[:country]
|
|
14
|
-
= hidden_field_tag 'p24_phone', data[:phone]
|
|
15
|
-
= hidden_field_tag 'p24_language',data[:language]
|
|
16
|
-
= hidden_field_tag 'p24_method', data[:method]
|
|
17
|
-
= hidden_field_tag 'p24_url_return', data[:url_return]
|
|
18
|
-
= hidden_field_tag 'p24_url_status', data[:url_status]
|
|
19
|
-
= hidden_field_tag 'p24_time_limit', data[:time_limit]
|
|
20
|
-
= hidden_field_tag 'p24_wait_for_result', data[:wait_for_result]
|
|
21
|
-
= hidden_field_tag 'p24_channel', data[:channel]
|
|
22
|
-
= hidden_field_tag 'p24_shipping', data[:shipping]
|
|
23
|
-
= hidden_field_tag 'p24_transfer_label', data[:transfer_label]
|
|
24
|
-
= hidden_field_tag 'p24_sign', data[:p24_sign]
|
|
25
|
-
= hidden_field_tag 'p24_encoding', data[:encoding]
|
|
26
|
-
= hidden_field_tag 'p24_api_version', data[:api_version]
|
|
27
|
-
|
|
28
|
-
= button_tag( t("activerecord.models.p24_payment.buy"))
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
Przelewy24Payment.setup do |config|
|
|
2
|
-
config.merchant_id = 'your_merchant_id'
|
|
3
|
-
config.pos_id = 'your_shop_id_default_merchant_id'
|
|
4
|
-
config.crc_key = 'crc_key'
|
|
5
|
-
config.language = 'pl'
|
|
6
|
-
config.currency = 'PLN'
|
|
7
|
-
config.country = 'PL'
|
|
8
|
-
config.mode = :development
|
|
9
|
-
config.url_status = '/your_controller/comeback'
|
|
10
|
-
config.url_return = '/your_controller/comeback'
|
|
11
|
-
config.hostname = {
|
|
12
|
-
:development => "http://127.0.0.1:3000",
|
|
13
|
-
:production => "your.domain",
|
|
14
|
-
:staging => "staging.domain"
|
|
15
|
-
}
|
|
16
|
-
end
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
module Przelewy24PaymentController
|
|
2
|
-
|
|
3
|
-
def self.included(base)
|
|
4
|
-
base.class_eval do
|
|
5
|
-
include InstanceMethods
|
|
6
|
-
extend ClassMethods
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
module ClassMethods
|
|
11
|
-
|
|
12
|
-
end # ClassMethods
|
|
13
|
-
|
|
14
|
-
module InstanceMethods
|
|
15
|
-
def payment_success(payment_params)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def payment_error(payment_params, code, description)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def payment_verify(response_params)
|
|
22
|
-
return data = { :amount => 100.0, :crc_key => Przelewy24Payment.crc_key }
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def comeback
|
|
26
|
-
result = przelewy24_verify(params,request.remote_ip)
|
|
27
|
-
if result.error == "0"
|
|
28
|
-
payment_success(params)
|
|
29
|
-
else
|
|
30
|
-
payment_error(params, result.error, result.errorMessage)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
private
|
|
35
|
-
|
|
36
|
-
def przelewy24_verify(params,ip)
|
|
37
|
-
return '' unless Przelewy24Payment.check_ip(ip)
|
|
38
|
-
require 'net/https'
|
|
39
|
-
require 'net/http'
|
|
40
|
-
require 'open-uri'
|
|
41
|
-
require 'openssl'
|
|
42
|
-
|
|
43
|
-
data = payment_verify(params)
|
|
44
|
-
params_new = {
|
|
45
|
-
:p24_merchant_id => params[:p24_merchant_id],
|
|
46
|
-
:p24_pos_id => params[:p24_pos_id],
|
|
47
|
-
:p24_session_id => params[:p24_session_id],
|
|
48
|
-
:p24_amount => Przelewy24Payment.make_p24_amount(data[:amount]),
|
|
49
|
-
:p24_currency => params[:p24_currency],
|
|
50
|
-
:p24_order_id => params[:p24_order_id]
|
|
51
|
-
}
|
|
52
|
-
params_new[:p24_sign] = Przelewy24Payment.verify_sign(data,params_new)
|
|
53
|
-
|
|
54
|
-
url = URI.parse(Przelewy24Payment.verification_request_url)
|
|
55
|
-
req = Net::HTTP::Post.new(url.path,{"User-Agent" => "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.10) Gecko/20100915 Ubuntu/10.04 (lucid) Firefox/3.6.10"})
|
|
56
|
-
req.form_data = params_new
|
|
57
|
-
con = Net::HTTP.new(url.host, 443)
|
|
58
|
-
con.use_ssl = true
|
|
59
|
-
con.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
60
|
-
response = con.start {|http| http.request(req)}
|
|
61
|
-
return Przelewy24Payment.parse_response response.body
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
end # InstanceMethods
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
require 'net/https'
|
|
2
|
-
require 'net/http'
|
|
3
|
-
require 'open-uri'
|
|
4
|
-
require 'openssl'
|
|
5
|
-
namespace :przelewy24_payment do
|
|
6
|
-
desc "Test if the connection with Przelewy24 is correct"
|
|
7
|
-
task :test_connection => :environment do
|
|
8
|
-
url = URI.parse(Przelewy24Payment.test_connection_url)
|
|
9
|
-
req = Net::HTTP::Post.new(url.path,{"User-Agent" => "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.10) Gecko/20100915 Ubuntu/10.04 (lucid) Firefox/3.6.10"})
|
|
10
|
-
req.form_data = Przelewy24Payment.test_connection_params
|
|
11
|
-
con = Net::HTTP.new(url.host, 443)
|
|
12
|
-
con.use_ssl = true
|
|
13
|
-
con.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
14
|
-
response = con.start {|http| http.request(req)}
|
|
15
|
-
puts Przelewy24Payment.parse_response response.body
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
end
|
data/przelewy24_payment.gemspec
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require 'przelewy24_payment/version'
|
|
5
|
-
|
|
6
|
-
Gem::Specification.new do |gem|
|
|
7
|
-
gem.name = "przelewy24_payment"
|
|
8
|
-
gem.version = Przelewy24Payment::VERSION
|
|
9
|
-
gem.authors = ["Jakub Cieślar"]
|
|
10
|
-
gem.email = ["cieslar.jakub@gmail.com"]
|
|
11
|
-
gem.description = %q{Integration with polish payment method: Przelewy24}
|
|
12
|
-
gem.summary = %q{Integration with polish payment method: Przelewy24}
|
|
13
|
-
gem.homepage = "https://github.com/jcieslar/przelewy24_payment"
|
|
14
|
-
|
|
15
|
-
gem.files = `git ls-files`.split($/)
|
|
16
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
17
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
18
|
-
gem.require_paths = ["lib"]
|
|
19
|
-
end
|