przelewy24 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/przelewy24/client.rb +7 -3
- data/lib/przelewy24/transaction.rb +16 -8
- data/lib/przelewy24/version.rb +1 -1
- metadata +1 -1
data/lib/przelewy24/client.rb
CHANGED
@@ -1,16 +1,20 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'digest'
|
3
|
-
require 'cgi'
|
4
3
|
|
5
4
|
module Przelewy24
|
6
5
|
class Client
|
7
6
|
attr_reader :merchant_id, :pos_id, :crc, :gateway_url
|
8
7
|
|
9
|
-
def initialize(merchant_id, pos_id, crc)
|
8
|
+
def initialize(merchant_id, pos_id, crc, mode = :sandbox)
|
10
9
|
@merchant_id = merchant_id
|
11
10
|
@pos_id = pos_id
|
12
11
|
@crc = crc
|
13
|
-
|
12
|
+
|
13
|
+
if mode == :production
|
14
|
+
@gateway_url = 'secure.przelewy24.pl'
|
15
|
+
else
|
16
|
+
@gateway_url = 'sandbox.przelewy24.pl'
|
17
|
+
end
|
14
18
|
end
|
15
19
|
|
16
20
|
def test_connection
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Przelewy24
|
2
2
|
class Transaction
|
3
|
-
attr_reader :session_id, :merchant_id, :amount, :crc, :description, :email, :signature
|
3
|
+
attr_reader :session_id, :merchant_id, :amount, :crc, :description, :email, :signature,
|
4
|
+
:url_return, :url_status, :wait_for_result, :currency, :country, :encoding
|
4
5
|
|
5
6
|
def initialize(data = {})
|
6
7
|
@data ||= {}
|
@@ -11,6 +12,13 @@ module Przelewy24
|
|
11
12
|
@amount = data[:amount]
|
12
13
|
@description = data[:description]
|
13
14
|
@email = data[:email]
|
15
|
+
@url_return = data[:url_return]
|
16
|
+
@url_status = data[:url_status]
|
17
|
+
@wait_for_result = data[:wait_for_result]
|
18
|
+
@currency = data[:currency]
|
19
|
+
@country = data[:country]
|
20
|
+
@encoding = data[:encoding]
|
21
|
+
|
14
22
|
@signature = calculate_signature
|
15
23
|
end
|
16
24
|
|
@@ -20,15 +28,15 @@ module Przelewy24
|
|
20
28
|
p24_pos_id: merchant_id,
|
21
29
|
p24_session_id: session_id,
|
22
30
|
p24_amount: amount,
|
23
|
-
p24_currency:
|
31
|
+
p24_currency: currency,
|
24
32
|
p24_description: description,
|
25
33
|
p24_email: email,
|
26
|
-
p24_country:
|
27
|
-
p24_url_return:
|
28
|
-
p24_url_status:
|
29
|
-
p24_wait_for_result:
|
34
|
+
p24_country: country,
|
35
|
+
p24_url_return: url_return,
|
36
|
+
p24_url_status: url_status,
|
37
|
+
p24_wait_for_result: wait_for_result,
|
30
38
|
p24_sign: signature,
|
31
|
-
p24_encoding:
|
39
|
+
p24_encoding: encoding,
|
32
40
|
p24_api_version: '3.2'
|
33
41
|
}
|
34
42
|
end
|
@@ -40,7 +48,7 @@ module Przelewy24
|
|
40
48
|
session_id,
|
41
49
|
merchant_id,
|
42
50
|
amount,
|
43
|
-
|
51
|
+
currency,
|
44
52
|
crc
|
45
53
|
].join('|'))
|
46
54
|
end
|
data/lib/przelewy24/version.rb
CHANGED