przelewy24 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- @gateway_url = 'sandbox.przelewy24.pl'
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: 'PLN',
31
+ p24_currency: currency,
24
32
  p24_description: description,
25
33
  p24_email: email,
26
- p24_country: 'PL',
27
- p24_url_return: 'http://54e3607b.ngrok.com/report',
28
- p24_url_status: 'http://54e3607b.ngrok.com/report',
29
- p24_wait_for_result: '1',
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: 'UTF-8',
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
- 'PLN',
51
+ currency,
44
52
  crc
45
53
  ].join('|'))
46
54
  end
@@ -1,3 +1,3 @@
1
1
  module Przelewy24
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: przelewy24
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: