payu 0.7.3 → 0.7.4

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 CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YWRkYjBjMGNjMTI0ZjkzMDUxN2ViMmViZjViMjc1M2IzNjIxYWY0ZQ==
5
- data.tar.gz: !binary |-
6
- YjljYTFiM2ZiZGY5MDZiMmMyMWFhNTdiNzMyZGVjNmU4ZTBmYTY5OA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- YmFmZDA5NjQ2NmIxY2FiM2Q0YWNjOGQ5ZTA1MDk3ZjJkMDFhMzRkM2QzZTUz
10
- ZWVmZTMyZTcyZmZjOWQxNDNmMjk5OTAxNWI0ZDIxNDYwMDA4MGMwYjY0NTVl
11
- MTlkZTM1NDNhZDM5MjI4ZTY3MzQzZDU4NDNkYjFmMmI5ZDJjNzk=
12
- data.tar.gz: !binary |-
13
- OTdmZmQ1YzliODkxYTQ4MmY0ZDUyYTQ5MDliNzJmZjliMzQ3NjcxNWRjYzFh
14
- NWU5ODExMmVhZjYwMjMwZDRiYmM5N2VjMTRjOTkzNmY2ODZlOGFmMTg3NWYw
15
- MmNmODI3ZDlhMDE0ZDhiYTdlODJmMmJhYzk0MTFlOWNlNjg4OWU=
2
+ SHA1:
3
+ metadata.gz: 8b7d6caf80eebf80d8b0ee844c5467eed9442f80
4
+ data.tar.gz: 91288618837686e9f56c20c65d7f4ebef4f7a493
5
+ SHA512:
6
+ metadata.gz: 2dec29b250f0c003ebcfc5674c46916cdbe707444797c71428713e6e8b02b9788e981a67d061868793180dafc2333b050a87fb0cdecbf963a083079b67668e1f
7
+ data.tar.gz: 02f7612460be7e6002e7795593878b25fc28618f0d70c2ecd2a1ba6a865a0e4afd750cb9207d84283c034643048b7a9f6aa78b64cc77b87b30c20636913bcd80
data/.gitignore CHANGED
@@ -3,5 +3,7 @@
3
3
  .rvmrc
4
4
  .ruby-version
5
5
  .ruby-gemset
6
+ .DS_Store
6
7
  Gemfile.lock
8
+ coverage/*
7
9
  pkg/*
@@ -5,9 +5,5 @@ rvm:
5
5
  - "1.9.3"
6
6
  - "jruby-18mode"
7
7
  - "jruby-19mode"
8
- - "rbx-18mode"
9
- - "rbx-19mode"
10
- - "ruby-head"
11
- - "jruby-head"
12
8
  - "ree"
13
9
  - "2.0.0"
data/Gemfile CHANGED
@@ -4,6 +4,8 @@ source "http://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  group :test do
7
+ gem 'simplecov'
7
8
  gem 'rake'
8
9
  gem 'rspec'
10
+ gem 'webmock'
9
11
  end
data/README.md CHANGED
@@ -73,12 +73,31 @@ Payu[12345]
73
73
  Payu['56789']
74
74
  ```
75
75
 
76
+ ### Change gateway url
77
+
78
+ If you are in different country you can change default gateway url (www.platnosci.pl). Just set gateway_url option in YAML configuration file or pass this option to Pos.new.
79
+
80
+ ```yaml
81
+ bank:
82
+ pos_id: 12345
83
+ pos_auth_key: XXX
84
+ key1: XXX
85
+ key2: XXX
86
+ type: default
87
+ add_signature: true
88
+ gateway_url: 'www.payu.cz'
89
+ ```
90
+
91
+ ```ruby
92
+ pos = Payu::Pos.new :pos_id => '12345', :pos_auth_key => 'abcdefghijk', :key1 => 'xxxxxxxx', :key2 => 'xxxxxxxx', :add_signature => true, :gateway_url => 'www.payu.cz'
93
+ ```
94
+
76
95
  ### Create new payment
77
96
 
78
97
  To create new payment:
79
98
 
80
99
  ```ruby
81
- @transaction = pos.new_transaction(:first_name => 'John', :last_name => 'Doe', :email => 'john.doe@example.org', :client_ip => '1.2.3.4', :amount => 10000)
100
+ @transaction = pos.new_transaction(:first_name => 'John', :last_name => 'Doe', :email => 'john.doe@example.org', :client_ip => '1.2.3.4', :amount => 10000, :desc => 'Transaction description')
82
101
  ```
83
102
 
84
103
  Now you need to build form with this transaction object:
@@ -4,6 +4,7 @@ require 'yaml'
4
4
 
5
5
  require 'payu/version'
6
6
  require 'payu/pos'
7
+ require 'payu/timestamp'
7
8
  require 'payu/transaction'
8
9
  require 'payu/response'
9
10
  require 'payu/signature'
@@ -32,6 +33,7 @@ module Payu
32
33
  :pos_auth_key => config['pos_auth_key'],
33
34
  :key1 => config['key1'],
34
35
  :key2 => config['key2'],
36
+ :gateway_url => config['gateway_url'],
35
37
  :variant => config['variant'],
36
38
  :add_signature => config['add_signature'],
37
39
  :test_payment => config['test_payment']
@@ -5,13 +5,14 @@ require 'net/https'
5
5
 
6
6
  module Payu
7
7
  class Gateway
8
- attr_reader :encoding, :key1, :key2, :pos_id
8
+ attr_reader :encoding, :key1, :key2, :pos_id, :gateway_url
9
9
 
10
10
  def initialize(options = {})
11
- @encoding = options[:encoding]
12
- @key1 = options[:key1]
13
- @key2 = options[:key2]
14
- @pos_id = options[:pos_id]
11
+ @encoding = options[:encoding]
12
+ @key1 = options[:key1]
13
+ @key2 = options[:key2]
14
+ @pos_id = options[:pos_id]
15
+ @gateway_url = options[:gateway_url] || 'www.platnosci.pl'
15
16
  end
16
17
 
17
18
  # Gets transaction status
@@ -32,7 +33,7 @@ module Payu
32
33
  private
33
34
  def send_request(url, session_id)
34
35
  data = prepare_data(session_id)
35
- connection = Net::HTTP.new('www.platnosci.pl', 443)
36
+ connection = Net::HTTP.new(gateway_url, 443)
36
37
  connection.use_ssl = true
37
38
 
38
39
  http_response = connection.start do |http|
@@ -52,7 +53,7 @@ module Payu
52
53
  end
53
54
 
54
55
  def prepare_data(session_id)
55
- ts = (Time.now.to_f * 1000).to_i
56
+ ts = Timestamp.generate
56
57
  sig = Signature.generate(pos_id, session_id, ts, key1)
57
58
 
58
59
  {
@@ -7,7 +7,8 @@ module Payu
7
7
  class Pos
8
8
  TYPES = ['default', 'sms']
9
9
 
10
- attr_reader :pos_id, :pos_auth_key, :key1, :key2, :type, :encoding, :variant
10
+ attr_reader :pos_id, :pos_auth_key, :key1, :key2, :type, :encoding,
11
+ :variant, :gateway_url
11
12
 
12
13
  # Creates new Pos instance
13
14
  # @param [Hash] options options hash
@@ -17,11 +18,16 @@ module Payu
17
18
  @pos_auth_key = options[:pos_auth_key]
18
19
  @key1 = options[:key1]
19
20
  @key2 = options[:key2]
21
+ @gateway_url = options[:gateway_url] || 'www.platnosci.pl'
20
22
  @variant = options[:variant] || 'default'
21
23
  @encoding = options[:encoding] || 'UTF'
22
- @test_payment = options[:test_payment] || false
23
- @add_signature = options[:add_signature] || true
24
+ @test_payment = options.fetch(:test_payment, false)
25
+ @add_signature = options.fetch(:add_signature, true)
24
26
 
27
+ validate_options!
28
+ end
29
+
30
+ def validate_options!
25
31
  raise PosInvalid.new('Missing pos_id parameter') if pos_id.nil? || pos_id == 0
26
32
  raise PosInvalid.new('Missing pos_auth_key parameter') if pos_auth_key.nil? || pos_auth_key == ''
27
33
  raise PosInvalid.new('Missing key1 parameter') if key1.nil? || key1 == ''
@@ -39,6 +45,7 @@ module Payu
39
45
  options.merge!({
40
46
  :pos_id => @pos_id,
41
47
  :pos_auth_key => @pos_auth_key,
48
+ :gateway_url => options[:gateway_url] || @gateway_url,
42
49
  :key1 => @key1,
43
50
  :encoding => encoding,
44
51
  :variant => variant
@@ -73,7 +80,13 @@ module Payu
73
80
 
74
81
  private
75
82
  def get_gateway
76
- Gateway.new(:encoding => encoding, :key1 => key1, :key2 => key2, :pos_id => pos_id)
83
+ Gateway.new(
84
+ :encoding => encoding,
85
+ :key1 => key1,
86
+ :key2 => key2,
87
+ :pos_id => pos_id,
88
+ :gateway_url => gateway_url
89
+ )
77
90
  end
78
91
 
79
92
  def test_payment?
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+
3
+ module Payu
4
+ class Timestamp
5
+ def self.generate
6
+ (Time.now.to_f * 1000).to_i
7
+ end
8
+ end
9
+ end
@@ -5,10 +5,11 @@ module Payu
5
5
  attr_accessor :pos_id, :pos_auth_key, :pay_type, :session_id, :amount, :amount_netto, :desc,
6
6
  :order_id, :desc2, :trsDesc, :first_name, :last_name, :street, :street_hn,
7
7
  :street_an, :city, :post_code, :country, :email, :phone, :language, :client_ip,
8
- :js, :payback_login, :sig, :ts, :key1, :add_signature, :variant, :encoding
8
+ :js, :payback_login, :sig, :ts, :key1, :add_signature, :variant, :encoding,
9
+ :gateway_url
9
10
 
10
11
  def initialize(options = {})
11
- options[:session_id] ||= generate_timestamp
12
+ options[:session_id] ||= Timestamp.generate
12
13
 
13
14
  options.each do |name, value|
14
15
  send("#{name.to_s}=", value)
@@ -17,7 +18,7 @@ module Payu
17
18
  validate!
18
19
 
19
20
  if options[:add_signature]
20
- self.ts = generate_timestamp
21
+ self.ts = Timestamp.generate
21
22
  self.sig = generate_signature
22
23
  end
23
24
 
@@ -29,17 +30,13 @@ module Payu
29
30
 
30
31
  def new_url
31
32
  if variant == 'sms'
32
- return "https://www.platnosci.pl/paygw/#{encoding}/NewSMS"
33
+ return "https://#{gateway_url}/paygw/#{encoding}/NewSMS"
33
34
  else
34
- return "https://www.platnosci.pl/paygw/#{encoding}/NewPayment"
35
+ return "https://#{gateway_url}/paygw/#{encoding}/NewPayment"
35
36
  end
36
37
  end
37
38
 
38
39
  private
39
- def generate_timestamp
40
- (Time.now.to_f * 100).to_i
41
- end
42
-
43
40
  def generate_signature
44
41
  Signature.generate(
45
42
  pos_id,
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Payu
4
- VERSION = '0.7.3'
4
+ VERSION = '0.7.4'
5
5
  end
@@ -0,0 +1,112 @@
1
+ # encoding: utf-8
2
+
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+
6
+ require 'spec_helper'
7
+ require 'webmock/rspec'
8
+
9
+ describe 'Payu::Gateway' do
10
+ def build_response(options)
11
+ options.map { |key, value| "#{key}:#{value}" }.join("\n")
12
+ end
13
+
14
+ before(:all) do
15
+ @gateway = Payu::Gateway.new(
16
+ :encoding => 'UTF', :key1 => '3d91f185cacad7c1d830d1472dfaacc5',
17
+ :key2 => 'a747e4b3e49e17459a8a402518d36022',:pos_id => 1
18
+ )
19
+
20
+ @get_response_body = build_response(
21
+ :status => 'OK',
22
+ :trans_id => 7,
23
+ :trans_pos_id => 1,
24
+ :trans_session_id => 417419,
25
+ :trans_amount => 200,
26
+ :trans_status => 5,
27
+ :trans_desc => 'Wpłata dla test@test.pl',
28
+ :trans_ts => '1094205761232',
29
+ :trans_sig => 'd06d215fa021e68f1cd82f2951a1134b'
30
+ )
31
+
32
+ @forged_get_response_body = build_response(
33
+ :status => 'OK',
34
+ :trans_id => 7,
35
+ :trans_pos_id => 1,
36
+ :trans_session_id => 417419,
37
+ :trans_amount => 200,
38
+ :trans_status => 5,
39
+ :trans_desc => 'Wpłata dla test@test.pl',
40
+ :trans_ts => '1094205761232',
41
+ :trans_sig => 'x06d215fa021e68f1cd82f2951a1134b'
42
+ )
43
+
44
+ @modify_response_body = build_response(
45
+ :status => 'OK',
46
+ :trans_id => 7,
47
+ :trans_pos_id => 1,
48
+ :trans_session_id => 417419,
49
+ :trans_ts => '1094205761232',
50
+ :trans_sig => '72e5062fecea369a32152a302f6089e4'
51
+ )
52
+
53
+ @forged_modify_response_body = build_response(
54
+ :status => 'OK',
55
+ :trans_id => 7,
56
+ :trans_pos_id => 1,
57
+ :trans_session_id => 417419,
58
+ :trans_ts => '1094205761232',
59
+ :trans_sig => 'x2e5062fecea369a32152a302f6089e4'
60
+ )
61
+ end
62
+
63
+ it 'should send request to platnosci.pl endpoint and return Response object' do
64
+ stub_request(:post, 'https://www.platnosci.pl/paygw/UTF/Payment/get/txt').to_return(:body => @get_response_body, :status => 200)
65
+ @gateway.get(417419).should be_a(Payu::Response)
66
+
67
+ stub_request(:post, 'https://www.platnosci.pl/paygw/UTF/Payment/confirm/txt').to_return(:body => @modify_response_body, :status => 200)
68
+ @gateway.confirm(417419).should be_a(Payu::Response)
69
+
70
+ stub_request(:post, 'https://www.platnosci.pl/paygw/UTF/Payment/cancel/txt').to_return(:body => @modify_response_body, :status => 200)
71
+ @gateway.cancel(417419).should be_a(Payu::Response)
72
+ end
73
+
74
+ it 'should send request to payu.cz endpoint and return Response object' do
75
+ @gateway = Payu::Gateway.new(
76
+ :encoding => 'UTF', :key1 => '3d91f185cacad7c1d830d1472dfaacc5',
77
+ :key2 => 'a747e4b3e49e17459a8a402518d36022',:pos_id => 1,
78
+ :gateway_url => 'www.payu.cz'
79
+ )
80
+
81
+ stub_request(:post, 'https://www.payu.cz/paygw/UTF/Payment/get/txt').to_return(:body => @get_response_body, :status => 200)
82
+ @gateway.get(417419).should be_a(Payu::Response)
83
+
84
+ stub_request(:post, 'https://www.payu.cz/paygw/UTF/Payment/confirm/txt').to_return(:body => @modify_response_body, :status => 200)
85
+ @gateway.confirm(417419).should be_a(Payu::Response)
86
+
87
+ stub_request(:post, 'https://www.payu.cz/paygw/UTF/Payment/cancel/txt').to_return(:body => @modify_response_body, :status => 200)
88
+ @gateway.cancel(417419).should be_a(Payu::Response)
89
+ end
90
+
91
+ it 'should raise exception on failed connection' do
92
+ stub_request(:post, 'https://www.platnosci.pl/paygw/UTF/Payment/get/txt').to_return(:status => 500)
93
+ lambda { @gateway.get(1) }.should raise_exception(Payu::RequestFailed)
94
+
95
+ stub_request(:post, 'https://www.platnosci.pl/paygw/UTF/Payment/confirm/txt').to_return(:status => 500)
96
+ lambda { @gateway.confirm(1) }.should raise_exception(Payu::RequestFailed)
97
+
98
+ stub_request(:post, 'https://www.platnosci.pl/paygw/UTF/Payment/cancel/txt').to_return(:status => 500)
99
+ lambda { @gateway.cancel(1) }.should raise_exception(Payu::RequestFailed)
100
+ end
101
+
102
+ it 'should validate response signature' do
103
+ stub_request(:post, 'https://www.platnosci.pl/paygw/UTF/Payment/get/txt').to_return(:body => @forged_get_response_body, :status => 200)
104
+ lambda { @gateway.get(417419) }.should raise_exception(Payu::SignatureInvalid)
105
+
106
+ stub_request(:post, 'https://www.platnosci.pl/paygw/UTF/Payment/confirm/txt').to_return(:body => @forged_modify_response_body, :status => 200)
107
+ lambda { @gateway.confirm(417419) }.should raise_exception(Payu::SignatureInvalid)
108
+
109
+ stub_request(:post, 'https://www.platnosci.pl/paygw/UTF/Payment/cancel/txt').to_return(:body => @forged_modify_response_body, :status => 200)
110
+ lambda { @gateway.cancel(417419) }.should raise_exception(Payu::SignatureInvalid)
111
+ end
112
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'Payu::Timestamp' do
6
+ it 'should generate timestamp using current time' do
7
+ Time.should_receive(:now)
8
+ Payu::Timestamp.generate
9
+ end
10
+ end
@@ -4,19 +4,27 @@ require 'spec_helper'
4
4
 
5
5
  describe 'Transaction' do
6
6
  before do
7
- @pos1 = Payu::Pos.new(
7
+ @pos_signed = Payu::Pos.new(
8
8
  :pos_id => 1,
9
9
  :pos_auth_key => 'abcde',
10
10
  :key1 => '3d91f185cacad7c1d830d1472dfaacc5',
11
11
  :key2 => 'a747e4b3e49e17459a8a402518d36022'
12
12
  )
13
13
 
14
- @pos2 = Payu::Pos.new(
14
+ @pos_with_gateway = Payu::Pos.new(
15
+ :pos_id => 1,
16
+ :pos_auth_key => 'abcde',
17
+ :gateway_url => 'www.payu.cz',
18
+ :key1 => '3d91f185cacad7c1d830d1472dfaacc5',
19
+ :key2 => 'a747e4b3e49e17459a8a402518d36022'
20
+ )
21
+
22
+ @pos_unsigned = Payu::Pos.new(
15
23
  :pos_id => 1,
16
24
  :pos_auth_key => 'abcde',
17
25
  :key1 => '3d91f185cacad7c1d830d1472dfaacc5',
18
26
  :key2 => 'a747e4b3e49e17459a8a402518d36022',
19
- :add_signature => true
27
+ :add_signature => false
20
28
  )
21
29
 
22
30
  @sms_pos = Payu::Pos.new(
@@ -31,12 +39,12 @@ describe 'Transaction' do
31
39
 
32
40
  it "should raise exception when required attributes are empty" do
33
41
  lambda do
34
- @pos1.new_transaction
42
+ @pos_signed.new_transaction
35
43
  end.should raise_exception(Payu::TransactionInvalid)
36
44
  end
37
45
 
38
46
  it 'should generate session_id when empty' do
39
- transaction = @pos1.new_transaction(
47
+ transaction = @pos_signed.new_transaction(
40
48
  :amount => 100,
41
49
  :desc => 'Description',
42
50
  :first_name => 'John',
@@ -50,7 +58,7 @@ describe 'Transaction' do
50
58
  end
51
59
 
52
60
  it 'should not overwrite passed session_id' do
53
- transaction = @pos1.new_transaction(
61
+ transaction = @pos_signed.new_transaction(
54
62
  :session_id => 123,
55
63
  :amount => 100,
56
64
  :desc => 'Description',
@@ -63,8 +71,83 @@ describe 'Transaction' do
63
71
  transaction.session_id.should == 123
64
72
  end
65
73
 
66
- it 'should generate signature' do
67
- transaction = @pos2.new_transaction(
74
+ describe "signature" do
75
+ context "should be generated" do
76
+ it do
77
+ transaction = @pos_signed.new_transaction(
78
+ :session_id => '123',
79
+ :amount => 100,
80
+ :desc => 'Description',
81
+ :first_name => 'John',
82
+ :last_name => 'Doe',
83
+ :email => 'john.doe@example.org',
84
+ :client_ip => '127.0.0.1'
85
+ )
86
+
87
+ transaction.ts.should_not be_nil
88
+ transaction.ts.class.should == Fixnum
89
+
90
+ signature_keys = [1, '123', 'abcde', 100, 'Description', 'John', 'Doe', 'john.doe@example.org', '127.0.0.1', transaction.ts, '3d91f185cacad7c1d830d1472dfaacc5']
91
+ expected_signature = Digest::MD5.hexdigest(signature_keys.join)
92
+
93
+ transaction.sig.should == expected_signature
94
+ end
95
+
96
+ it 'from all keys' do
97
+ transaction = @pos_signed.new_transaction(
98
+ :pos_auth_key => 'abcde',
99
+ :pay_type => 't',
100
+ :amount => 15000,
101
+ :desc => 'Testowa',
102
+ :desc2 => 'Szczegółowy opis',
103
+ :trsDesc => 'Dodatkowy opis dla banku',
104
+ :order_id => 69,
105
+ :first_name => 'Jan',
106
+ :last_name => 'Kowalski',
107
+ :payback_login => 'jankowalski',
108
+ :street => 'Warszawska',
109
+ :street_hn => '21',
110
+ :street_an => '18',
111
+ :city => 'Szczecin',
112
+ :post_code => '01-259',
113
+ :country => 'PL',
114
+ :email => 'jan.kowalski@example.org',
115
+ :phone => '505-606-100',
116
+ :language => 'pl',
117
+ :client_ip => '192.168.1.1'
118
+ )
119
+
120
+ signature_keys = [
121
+ 1, 't', transaction.session_id, 'abcde', 15000, 'Testowa',
122
+ 'Szczegółowy opis', 'Dodatkowy opis dla banku', 69, 'Jan', 'Kowalski',
123
+ 'jankowalski', 'Warszawska', '21', '18', 'Szczecin', '01-259', 'PL',
124
+ 'jan.kowalski@example.org', '505-606-100', 'pl', '192.168.1.1',
125
+ transaction.ts, '3d91f185cacad7c1d830d1472dfaacc5'
126
+ ]
127
+ expected_signature = Digest::MD5.hexdigest(signature_keys.join)
128
+
129
+ transaction.sig.should == expected_signature
130
+ end
131
+ end
132
+
133
+ context "shouldn't be generated" do
134
+ it do
135
+ transaction = @pos_unsigned.new_transaction(
136
+ :session_id => '123',
137
+ :amount => 100,
138
+ :desc => 'Description',
139
+ :first_name => 'John',
140
+ :last_name => 'Doe',
141
+ :email => 'john.doe@example.org',
142
+ :client_ip => '127.0.0.1'
143
+ )
144
+ transaction.sig.should == nil
145
+ end
146
+ end
147
+ end
148
+
149
+ it 'should set amount_netto attribute for sms variant' do
150
+ transaction = @sms_pos.new_transaction(
68
151
  :session_id => '123',
69
152
  :amount => 100,
70
153
  :desc => 'Description',
@@ -74,54 +157,49 @@ describe 'Transaction' do
74
157
  :client_ip => '127.0.0.1'
75
158
  )
76
159
 
77
- transaction.ts.should_not be_nil
78
- transaction.ts.class.should == Fixnum
79
-
80
- signature_keys = [1, '123', 'abcde', 100, 'Description', 'John', 'Doe', 'john.doe@example.org', '127.0.0.1', transaction.ts, '3d91f185cacad7c1d830d1472dfaacc5']
81
- expected_signature = Digest::MD5.hexdigest(signature_keys.join)
82
-
83
- transaction.sig.should == expected_signature
160
+ transaction.amount_netto.should == 100
161
+ transaction.amount.should be_nil
84
162
  end
85
163
 
86
- it 'should generate signature from all keys' do
87
- transaction = @pos2.new_transaction(
88
- :pos_auth_key => 'abcde',
89
- :pay_type => 't',
90
- :amount => 15000,
91
- :desc => 'Testowa',
92
- :desc2 => 'Szczegółowy opis',
93
- :trsDesc => 'Dodatkowy opis dla banku',
94
- :order_id => 69,
95
- :first_name => 'Jan',
96
- :last_name => 'Kowalski',
97
- :payback_login => 'jankowalski',
98
- :street => 'Warszawska',
99
- :street_hn => '21',
100
- :street_an => '18',
101
- :city => 'Szczecin',
102
- :post_code => '01-259',
103
- :country => 'PL',
104
- :email => 'jan.kowalski@example.org',
105
- :phone => '505-606-100',
106
- :language => 'pl',
107
- :client_ip => '192.168.1.1'
164
+ it 'should generate url for new payment' do
165
+ transaction = @pos_signed.new_transaction(
166
+ :amount => 100,
167
+ :desc => 'Description',
168
+ :first_name => 'John',
169
+ :last_name => 'Doe',
170
+ :email => 'john.doe@example.org',
171
+ :client_ip => '127.0.0.1'
108
172
  )
173
+ transaction.new_url.should == 'https://www.platnosci.pl/paygw/UTF/NewPayment'
174
+ end
109
175
 
110
- signature_keys = [
111
- 1, 't', transaction.session_id, 'abcde', 15000, 'Testowa',
112
- 'Szczegółowy opis', 'Dodatkowy opis dla banku', 69, 'Jan', 'Kowalski',
113
- 'jankowalski', 'Warszawska', '21', '18', 'Szczecin', '01-259', 'PL',
114
- 'jan.kowalski@example.org', '505-606-100', 'pl', '192.168.1.1',
115
- transaction.ts, '3d91f185cacad7c1d830d1472dfaacc5'
116
- ]
117
- expected_signature = Digest::MD5.hexdigest(signature_keys.join)
176
+ it 'should generate url for new payment with specified gateway url' do
177
+ transaction = @pos_signed.new_transaction(
178
+ :amount => 100,
179
+ :desc => 'Description',
180
+ :first_name => 'John',
181
+ :last_name => 'Doe',
182
+ :email => 'john.doe@example.org',
183
+ :gateway_url => 'www.payu.cz',
184
+ :client_ip => '127.0.0.1'
185
+ )
186
+ transaction.new_url.should == 'https://www.payu.cz/paygw/UTF/NewPayment'
187
+ end
118
188
 
119
- transaction.sig.should == expected_signature
189
+ it 'should generate url for new payment wit specified gateway url from POS' do
190
+ transaction = @pos_with_gateway.new_transaction(
191
+ :amount => 100,
192
+ :desc => 'Description',
193
+ :first_name => 'John',
194
+ :last_name => 'Doe',
195
+ :email => 'john.doe@example.org',
196
+ :client_ip => '127.0.0.1'
197
+ )
198
+ transaction.new_url.should == 'https://www.payu.cz/paygw/UTF/NewPayment'
120
199
  end
121
200
 
122
- it "should set amount_netto attribute for sms variant" do
201
+ it 'should generate url for new sms payment' do
123
202
  transaction = @sms_pos.new_transaction(
124
- :session_id => '123',
125
203
  :amount => 100,
126
204
  :desc => 'Description',
127
205
  :first_name => 'John',
@@ -129,8 +207,6 @@ describe 'Transaction' do
129
207
  :email => 'john.doe@example.org',
130
208
  :client_ip => '127.0.0.1'
131
209
  )
132
-
133
- transaction.amount_netto.should == 100
134
- transaction.amount.should be_nil
210
+ transaction.new_url.should == 'https://www.platnosci.pl/paygw/UTF/NewSMS'
135
211
  end
136
212
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michał Młoźniak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-11 00:00:00.000000000 Z
11
+ date: 2014-12-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Simple integration with PayU gateway
14
14
  email: michal.mlozniak@visuality.pl
@@ -16,9 +16,9 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
- - .gitignore
20
- - .rspec
21
- - .travis.yml
19
+ - ".gitignore"
20
+ - ".rspec"
21
+ - ".travis.yml"
22
22
  - Gemfile
23
23
  - LICENSE
24
24
  - README.md
@@ -31,12 +31,15 @@ files:
31
31
  - lib/payu/pos.rb
32
32
  - lib/payu/response.rb
33
33
  - lib/payu/signature.rb
34
+ - lib/payu/timestamp.rb
34
35
  - lib/payu/transaction.rb
35
36
  - lib/payu/version.rb
36
37
  - payu.gemspec
38
+ - spec/gateway_spec.rb
37
39
  - spec/response_spec.rb
38
40
  - spec/signature_spec.rb
39
41
  - spec/spec_helper.rb
42
+ - spec/timestamp_spec.rb
40
43
  - spec/transaction_spec.rb
41
44
  homepage: http://github.com/ronin/payu
42
45
  licenses: []
@@ -47,22 +50,24 @@ require_paths:
47
50
  - lib
48
51
  required_ruby_version: !ruby/object:Gem::Requirement
49
52
  requirements:
50
- - - ! '>='
53
+ - - ">="
51
54
  - !ruby/object:Gem::Version
52
55
  version: '0'
53
56
  required_rubygems_version: !ruby/object:Gem::Requirement
54
57
  requirements:
55
- - - ! '>='
58
+ - - ">="
56
59
  - !ruby/object:Gem::Version
57
60
  version: '0'
58
61
  requirements: []
59
62
  rubyforge_project:
60
- rubygems_version: 2.0.3
63
+ rubygems_version: 2.2.2
61
64
  signing_key:
62
65
  specification_version: 4
63
66
  summary: Simple integration with PayU gateway
64
67
  test_files:
68
+ - spec/gateway_spec.rb
65
69
  - spec/response_spec.rb
66
70
  - spec/signature_spec.rb
67
71
  - spec/spec_helper.rb
72
+ - spec/timestamp_spec.rb
68
73
  - spec/transaction_spec.rb