przelewy24_payment 0.1.4 → 0.2.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 +4 -4
- data/README.md +64 -33
- data/Rakefile +1 -0
- data/app/helpers/przelewy24_payment/payment_helper.rb +2 -2
- data/app/views/przelewy24_payment/_payment_form.html.haml +25 -42
- data/lib/generators/przelewy24_payment/install/templates/przelewy24_payment.rb +8 -4
- data/lib/przelewy24_payment.rb +145 -22
- data/lib/przelewy24_payment/przelewy24_payment_controller.rb +17 -12
- data/lib/przelewy24_payment/version.rb +1 -1
- data/lib/tasks/test_connection.rake +18 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef6372b0ee892f95bae1a5cbd55216b1a8ef1422
|
4
|
+
data.tar.gz: 24ac8d0e94cbdb452fc8b451fa450fb637b4248d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca83a8e926443b7df9690f4a3e6190248b63157b051a87e87ee5345be32131541072875e9fc26081e2e3b51e557e28c59bf529699d108e704966126c7ec97a26
|
7
|
+
data.tar.gz: 663cc01f72c1ebf01ce4a34b4d4664a98850a2d5437afdc4b93b0b576a51705bb65b9a2eedab9d8051e243a597d9df6230130fdd2265d27f6b656e2a3f31bf12
|
data/README.md
CHANGED
@@ -24,19 +24,28 @@ And you can there "config/initializers/przelewy24_payment.rb" setup your setting
|
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
Przelewy24Payment.setup do |config|
|
27
|
-
config.
|
27
|
+
config.merchant_id = 'your_merchant_id'
|
28
|
+
config.pos_id = 'your_shop_id_default_merchant_id'
|
29
|
+
config.crc_key = 'crc_key'
|
28
30
|
config.language = 'pl'
|
29
|
-
config.
|
30
|
-
config.
|
31
|
-
config.
|
31
|
+
config.currency = 'PLN'
|
32
|
+
config.country = 'PL'
|
33
|
+
config.mode = :development
|
34
|
+
config.url_status = '/your_controller/comeback'
|
35
|
+
config.url_return = '/your_controller/comeback'
|
32
36
|
config.hostname = {
|
33
|
-
:development => "http://
|
37
|
+
:development => "http://127.0.0.1:3000",
|
34
38
|
:production => "your.domain",
|
35
39
|
:staging => "staging.domain"
|
36
40
|
}
|
37
41
|
end
|
42
|
+
|
38
43
|
```
|
39
44
|
|
45
|
+
Test connection
|
46
|
+
```
|
47
|
+
rake przelewy24_payment:test_connection
|
48
|
+
```
|
40
49
|
## Usage
|
41
50
|
|
42
51
|
Your controller e.g 'PaymentController' should only include:
|
@@ -58,12 +67,16 @@ class YourPaymentController < ApplicationController
|
|
58
67
|
# so you can do whatever you want
|
59
68
|
def payment_success(payment_params)
|
60
69
|
# payment_params returns hash with:
|
70
|
+
# p24_merchant_id
|
71
|
+
# p24_pos_id
|
61
72
|
# p24_session_id
|
62
73
|
# p24_order_id
|
63
|
-
#
|
74
|
+
# p24_amount
|
75
|
+
# p24_currency
|
76
|
+
# p24_method
|
77
|
+
# p24_sign
|
64
78
|
# p24_karta
|
65
|
-
#
|
66
|
-
# p24_crc
|
79
|
+
# payment_id
|
67
80
|
|
68
81
|
# e.g
|
69
82
|
# payment = Payment.find_by_session_id(payment_params[:p24_session_id])
|
@@ -73,12 +86,16 @@ class YourPaymentController < ApplicationController
|
|
73
86
|
# so you can do whatever you want
|
74
87
|
def payment_error(payment_params, code, description)
|
75
88
|
# payment_params returns hash with:
|
89
|
+
# p24_merchant_id
|
90
|
+
# p24_pos_id
|
76
91
|
# p24_session_id
|
77
92
|
# p24_order_id
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#
|
93
|
+
# p24_amount
|
94
|
+
# p24_currency
|
95
|
+
# p24_method
|
96
|
+
# p24_sign
|
97
|
+
# p24_karta
|
98
|
+
# payment_id
|
82
99
|
#
|
83
100
|
# code return error code
|
84
101
|
# description return error description
|
@@ -88,15 +105,13 @@ class YourPaymentController < ApplicationController
|
|
88
105
|
# so you can do whatever you want
|
89
106
|
def payment_verify(response_params)
|
90
107
|
# e.g:
|
91
|
-
#
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
# optional variant:
|
99
|
-
return data = { :amount => your_payment_value, :crc_key => your_crc_key }
|
108
|
+
# you must return hash with amount which was save in your db and your crc_key
|
109
|
+
payment = Payment::Payment.where(session_id: response_params['p24_session_id']).first
|
110
|
+
if payment
|
111
|
+
{ amount: payment.amount, crc_key: Przelewy24Payment.crc_key }
|
112
|
+
else
|
113
|
+
{}
|
114
|
+
end
|
100
115
|
end
|
101
116
|
```
|
102
117
|
|
@@ -114,21 +129,37 @@ class YourPaymentController < ApplicationController
|
|
114
129
|
...
|
115
130
|
|
116
131
|
def your_payment
|
117
|
-
session_id = Przelewy24Payment.friendly_token[0,20]
|
118
|
-
value = give_your_amount
|
132
|
+
session_id = Przelewy24Payment.friendly_token[0,20] # assign this to payment
|
119
133
|
@data = { :session_id => session_id,
|
120
|
-
:description => "opis",
|
121
|
-
:
|
122
|
-
:client => 'Adam Nowak', # optional param
|
123
|
-
:address => 'Powstancow 22/2', # optional param
|
124
|
-
:zipcode => '53-456', # optional param
|
125
|
-
:city => 'Wroclaw', # optional param
|
126
|
-
:country => 'Polska', # optional param
|
134
|
+
:description => "opis",
|
135
|
+
:amount => 1.23,
|
127
136
|
:email => 'payment@example.com',
|
137
|
+
:country => 'PL',
|
128
138
|
# adding this params, you overwrite your config settings so this param is optional
|
129
|
-
# :
|
130
|
-
# :
|
131
|
-
# :
|
139
|
+
# :merchant_id => merchant_id
|
140
|
+
# :pos_id => pos_id
|
141
|
+
# :api_version => api_version,
|
142
|
+
# :crc_key => crc_key,
|
143
|
+
# :currency => currency,
|
144
|
+
# :country => country,
|
145
|
+
# :url_return => url_return,
|
146
|
+
# :url_status => url_status,
|
147
|
+
|
148
|
+
# other optional params
|
149
|
+
# :language => pl/en/de/es/it
|
150
|
+
# :method => method,
|
151
|
+
# :client => 'Adam Nowak',
|
152
|
+
# :address => 'Powstancow 22/2',
|
153
|
+
# :zipcode => '53-456',
|
154
|
+
# :city => 'Wroclaw',
|
155
|
+
# :phone => '481321132123',
|
156
|
+
# :time_limit => INT,
|
157
|
+
# :wait_for_result => INT,
|
158
|
+
# :channel => INT,
|
159
|
+
# :shipping => INT,
|
160
|
+
# :transfer_label => STRING(20)
|
161
|
+
# :encoding => ISO-8859-2/UTF-8/Windows-1250
|
162
|
+
|
132
163
|
}
|
133
164
|
end
|
134
165
|
|
data/Rakefile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Przelewy24Payment::PaymentHelper
|
2
|
-
def payment_button(
|
3
|
-
render :partial => 'przelewy24_payment/payment_form', :locals => { :data =>
|
2
|
+
def payment_button(data)
|
3
|
+
render :partial => 'przelewy24_payment/payment_form', :locals => { :data => Przelewy24Payment.prepare_form(data)}
|
4
4
|
end
|
5
5
|
end
|
@@ -1,45 +1,28 @@
|
|
1
|
-
= form_tag Przelewy24Payment.
|
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]
|
2
4
|
= hidden_field_tag 'p24_session_id', data[:session_id]
|
3
|
-
= hidden_field_tag '
|
4
|
-
= hidden_field_tag '
|
5
|
-
= hidden_field_tag '
|
6
|
-
= hidden_field_tag 'p24_adres', data[:address]
|
7
|
-
= hidden_field_tag 'p24_kod', data[:zipcode]
|
8
|
-
= hidden_field_tag 'p24_miasto', data[:city]
|
9
|
-
= hidden_field_tag 'p24_kraj', data[:country]
|
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]
|
10
8
|
= hidden_field_tag 'p24_email', data[:email]
|
11
|
-
= hidden_field_tag '
|
12
|
-
= hidden_field_tag '
|
13
|
-
= hidden_field_tag '
|
14
|
-
= hidden_field_tag '
|
15
|
-
= hidden_field_tag '
|
16
|
-
=
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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]
|
45
27
|
|
28
|
+
= button_tag( t("activerecord.models.p24_payment.buy"))
|
@@ -1,11 +1,15 @@
|
|
1
1
|
Przelewy24Payment.setup do |config|
|
2
|
-
config.
|
2
|
+
config.merchant_id = 'your_merchant_id'
|
3
|
+
config.pos_id = 'your_shop_id_default_merchant_id'
|
4
|
+
config.crc_key = 'crc_key'
|
3
5
|
config.language = 'pl'
|
6
|
+
config.currency = 'PLN'
|
7
|
+
config.country = 'PL'
|
4
8
|
config.mode = :development
|
5
|
-
config.
|
6
|
-
config.
|
9
|
+
config.url_status = '/your_controller/comeback'
|
10
|
+
config.url_return = '/your_controller/comeback'
|
7
11
|
config.hostname = {
|
8
|
-
:development => "http://
|
12
|
+
:development => "http://127.0.0.1:3000",
|
9
13
|
:production => "your.domain",
|
10
14
|
:staging => "staging.domain"
|
11
15
|
}
|
data/lib/przelewy24_payment.rb
CHANGED
@@ -4,74 +4,197 @@ require "przelewy24_payment/przelewy24_payment_controller"
|
|
4
4
|
|
5
5
|
module Przelewy24Payment
|
6
6
|
|
7
|
-
mattr_accessor :
|
8
|
-
@@
|
7
|
+
mattr_accessor :merchant_id
|
8
|
+
@@merchant_id = ''
|
9
|
+
|
10
|
+
mattr_accessor :pos_id
|
11
|
+
@@pos_id = ''
|
9
12
|
|
10
13
|
mattr_accessor :language
|
11
14
|
@@language = 'pl'
|
12
15
|
|
16
|
+
mattr_accessor :currency
|
17
|
+
@@language = 'PLN'
|
18
|
+
|
13
19
|
mattr_accessor :mode
|
14
20
|
@@mode = :development
|
15
21
|
|
16
|
-
mattr_accessor :
|
17
|
-
@@
|
22
|
+
mattr_accessor :url_status
|
23
|
+
@@url_status = ''
|
24
|
+
|
25
|
+
mattr_accessor :url_return
|
26
|
+
@@url_return = ''
|
18
27
|
|
19
|
-
mattr_accessor :
|
20
|
-
@@
|
28
|
+
mattr_accessor :api_version
|
29
|
+
@@api_version = '3.2'
|
21
30
|
|
22
31
|
mattr_accessor :crc_key
|
23
32
|
@@crc_key = ''
|
24
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)
|
39
|
+
|
40
|
+
mattr_accessor :country
|
41
|
+
@@country = 'PL'
|
42
|
+
|
43
|
+
mattr_accessor :allowed_countries
|
44
|
+
@@allowed_countries = %w(AD AT BE CY CZ DK EE FI FR EL ES NO PL PT SM SK SI CH SE HU GB IT NL IE IS LT LV LU MT US CA JP UA BY RY RU)
|
45
|
+
|
25
46
|
mattr_accessor :hostname
|
26
|
-
@@hostname = { :development => "http://
|
47
|
+
@@hostname = { :development => "http://127.0.0.1:3000" }
|
27
48
|
|
28
49
|
def self.setup
|
29
50
|
yield self
|
30
51
|
end
|
31
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
|
+
|
32
61
|
def self.complete_url(params)
|
33
62
|
params
|
34
63
|
end
|
35
64
|
|
36
|
-
def self.
|
65
|
+
def self.test_connection_url
|
37
66
|
if @@mode == :production
|
38
|
-
'https://secure.przelewy24.pl/
|
67
|
+
'https://secure.przelewy24.pl/testConnection'
|
39
68
|
else
|
40
|
-
'https://sandbox.przelewy24.pl/
|
69
|
+
'https://sandbox.przelewy24.pl/testConnection'
|
41
70
|
end
|
42
71
|
end
|
43
72
|
|
44
|
-
def self.
|
73
|
+
def self.transaction_request_url
|
45
74
|
if @@mode == :production
|
46
|
-
'https://secure.przelewy24.pl/
|
75
|
+
'https://secure.przelewy24.pl/trnDirect'
|
47
76
|
else
|
48
|
-
'https://sandbox.przelewy24.pl/
|
77
|
+
'https://sandbox.przelewy24.pl/trnDirect'
|
49
78
|
end
|
50
79
|
end
|
51
80
|
|
52
|
-
def self.
|
53
|
-
|
81
|
+
def self.verification_request_url
|
82
|
+
if @@mode == :production
|
83
|
+
'https://secure.przelewy24.pl/trnVerify'
|
84
|
+
else
|
85
|
+
'https://sandbox.przelewy24.pl/trnVerify'
|
86
|
+
end
|
54
87
|
end
|
55
88
|
|
56
89
|
def self.friendly_token
|
57
90
|
SecureRandom.base64(15).tr('+/=lIO0', 'aqrsxyz')
|
58
91
|
end
|
59
92
|
|
60
|
-
def self.
|
61
|
-
|
62
|
-
return calc_md5
|
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)
|
63
95
|
end
|
64
96
|
|
65
97
|
def self.get_hostname
|
66
98
|
@@hostname[@@mode]
|
67
99
|
end
|
68
100
|
|
69
|
-
def self.
|
70
|
-
get_hostname + @@
|
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
|
+
|
113
|
+
def self.make_p24_language(data_language)
|
114
|
+
lang = (data_language || language)
|
115
|
+
if allowed_languages.include?(lang)
|
116
|
+
lang
|
117
|
+
else
|
118
|
+
'pl'
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.make_p24_country(data_country)
|
123
|
+
country_code = (data_country || country)
|
124
|
+
if allowed_countries.include?(country_code)
|
125
|
+
country_code
|
126
|
+
else
|
127
|
+
'PL'
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def self.make_p24_currency(data_currency)
|
132
|
+
(data_currency || currency).upcase
|
71
133
|
end
|
72
134
|
|
73
|
-
def self.
|
74
|
-
|
135
|
+
def self.prepare_form(data)
|
136
|
+
#prepare mandatory fields
|
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")
|
168
|
+
end
|
169
|
+
ret
|
75
170
|
end
|
76
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
|
77
200
|
end
|
@@ -19,41 +19,46 @@ module Przelewy24PaymentController
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def payment_verify(response_params)
|
22
|
-
return data = { :amount => 100.0, :crc_key =>
|
22
|
+
return data = { :amount => 100.0, :crc_key => Przelewy24Payment.crc_key }
|
23
23
|
end
|
24
24
|
|
25
25
|
def comeback
|
26
|
-
|
27
|
-
result
|
28
|
-
if result[1] == "TRUE"
|
26
|
+
result = przelewy24_verify(params,request.remote_ip)
|
27
|
+
if result.error == "0"
|
29
28
|
payment_success(params)
|
30
29
|
else
|
31
|
-
payment_error(params,
|
30
|
+
payment_error(params, result.error, result.errorMessage)
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|
35
34
|
private
|
36
35
|
|
37
|
-
def przelewy24_verify(params)
|
36
|
+
def przelewy24_verify(params,ip)
|
37
|
+
return '' unless Przelewy24Payment.check_ip(ip)
|
38
38
|
require 'net/https'
|
39
39
|
require 'net/http'
|
40
40
|
require 'open-uri'
|
41
41
|
require 'openssl'
|
42
42
|
|
43
43
|
data = payment_verify(params)
|
44
|
-
params_new = {
|
45
|
-
|
46
|
-
|
47
|
-
|
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)
|
48
53
|
|
49
|
-
url = URI.parse(Przelewy24Payment.
|
54
|
+
url = URI.parse(Przelewy24Payment.verification_request_url)
|
50
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"})
|
51
56
|
req.form_data = params_new
|
52
57
|
con = Net::HTTP.new(url.host, 443)
|
53
58
|
con.use_ssl = true
|
54
59
|
con.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
55
60
|
response = con.start {|http| http.request(req)}
|
56
|
-
return response.body
|
61
|
+
return Przelewy24Payment.parse_response response.body
|
57
62
|
end
|
58
63
|
|
59
64
|
end # InstanceMethods
|
@@ -0,0 +1,18 @@
|
|
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
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: przelewy24_payment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Cieślar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'Integration with polish payment method: Przelewy24'
|
14
14
|
email:
|
@@ -31,6 +31,7 @@ files:
|
|
31
31
|
- lib/przelewy24_payment/engine.rb
|
32
32
|
- lib/przelewy24_payment/przelewy24_payment_controller.rb
|
33
33
|
- lib/przelewy24_payment/version.rb
|
34
|
+
- lib/tasks/test_connection.rake
|
34
35
|
- przelewy24_payment.gemspec
|
35
36
|
homepage: https://github.com/jcieslar/przelewy24_payment
|
36
37
|
licenses: []
|