payzilla 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/.gitignore +23 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +23 -0
  5. data/README.md +82 -0
  6. data/Rakefile +4 -0
  7. data/init.rb +1 -0
  8. data/lib/encoding/converter.rb +5 -0
  9. data/lib/payzilla/config.rb +224 -0
  10. data/lib/payzilla/gateways/akado.rb +59 -0
  11. data/lib/payzilla/gateways/beeline.rb +205 -0
  12. data/lib/payzilla/gateways/cyberplat.rb +97 -0
  13. data/lib/payzilla/gateways/dummy.rb +72 -0
  14. data/lib/payzilla/gateways/gorod.rb +80 -0
  15. data/lib/payzilla/gateways/mailru.rb +56 -0
  16. data/lib/payzilla/gateways/matrix.rb +66 -0
  17. data/lib/payzilla/gateways/megafon.rb +120 -0
  18. data/lib/payzilla/gateways/mts.rb +200 -0
  19. data/lib/payzilla/gateways/osmp.rb +85 -0
  20. data/lib/payzilla/gateways/rapida.rb +127 -0
  21. data/lib/payzilla/gateways/skylink.rb +105 -0
  22. data/lib/payzilla/gateways/webmoney.rb +102 -0
  23. data/lib/payzilla/gateways/yamoney.rb +93 -0
  24. data/lib/payzilla/gateways/yota.rb +63 -0
  25. data/lib/payzilla/gateways.rb +173 -0
  26. data/lib/payzilla/payment.rb +161 -0
  27. data/lib/payzilla/revision.rb +18 -0
  28. data/lib/payzilla/transports/http.rb +62 -0
  29. data/lib/payzilla/utils/string_file.rb +14 -0
  30. data/lib/payzilla/version.rb +3 -0
  31. data/lib/payzilla.rb +19 -0
  32. data/lib/string.rb +12 -0
  33. data/payzilla.gemspec +33 -0
  34. data/schemas/.gitkeep +0 -0
  35. data/schemas/beeline.wsdl +538 -0
  36. data/spec/lib/payzilla/gateways/akado_spec.rb +31 -0
  37. data/spec/lib/payzilla/gateways/beeline_spec.rb +52 -0
  38. data/spec/lib/payzilla/gateways/cyberplat_spec.rb +44 -0
  39. data/spec/lib/payzilla/gateways/gorod_spec.rb +36 -0
  40. data/spec/lib/payzilla/gateways/mailru_spec.rb +24 -0
  41. data/spec/lib/payzilla/gateways/matrix_spec.rb +35 -0
  42. data/spec/lib/payzilla/gateways/megafon_spec.rb +45 -0
  43. data/spec/lib/payzilla/gateways/mts_spec.rb +55 -0
  44. data/spec/lib/payzilla/gateways/osmp_spec.rb +30 -0
  45. data/spec/lib/payzilla/gateways/rapida_spec.rb +48 -0
  46. data/spec/lib/payzilla/gateways/skylink_spec.rb +39 -0
  47. data/spec/lib/payzilla/gateways/webmoney_spec.rb +38 -0
  48. data/spec/lib/payzilla/gateways/yamoney_spec.rb +31 -0
  49. data/spec/lib/payzilla/gateways/yota_spec.rb +30 -0
  50. data/spec/spec_helper.rb +9 -0
  51. data/spec/support/config_stub.rb +7 -0
  52. metadata +236 -0
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe Payzilla::Gateways::Cyberplat do
4
+ before(:all) do
5
+ config = ConfigStub.new('cyberplat')
6
+
7
+ config.setting_host = 'payment.cyberplat.ru'
8
+ config.setting_operator = '1007033'
9
+ config.setting_point = '1007031'
10
+ config.setting_dealer = '1007026'
11
+ config.setting_key_password = '11111%%%'
12
+
13
+ config.attachment_private_key = File.new('certificates/cyberplat.priv.key')
14
+ config.attachment_public_key = File.new('certificates/cyberplat.pub.key')
15
+
16
+ @transport = Payzilla::Gateways::Cyberplat.new(config, './log/cyberplat.log')
17
+ end
18
+
19
+ it "checks" do
20
+ payment = OpenStruct.new(
21
+ :id => Time.now.to_i,
22
+ :gateway_provider_id => 'es',
23
+ :account => '8888888888',
24
+ :fields => {},
25
+ :agent_id => 1
26
+ )
27
+ result = @transport.check(payment)
28
+ result[:success].should == true
29
+ end
30
+
31
+ it "pays" do
32
+ payment = OpenStruct.new(
33
+ :id => Time.now.to_i,
34
+ :gateway_provider_id => 'es',
35
+ :account => '8888888888',
36
+ :fields => {},
37
+ :terminal_id => 1,
38
+ :agent_id => 1,
39
+ :enrolled_amount => 100
40
+ )
41
+ result = @transport.pay(payment)
42
+ result[:success].should == true
43
+ end
44
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe Payzilla::Gateways::Gorod do
4
+ before(:all) do
5
+ config = ConfigStub.new('gorod')
6
+
7
+ config.setting_domain = 'https://194.85.126.106:4567'
8
+ config.setting_password = '1234'
9
+
10
+ config.attachment_cert = File.new('certificates/gorod.pem')
11
+ config.attachment_key = File.new('certificates/gorod.pem')
12
+
13
+ @transport = Payzilla::Gateways::Gorod.new(config, './log/gorod.log')
14
+
15
+ @services = %w(515 615)
16
+
17
+ @services = @services.each_with_index.map do |x,i|
18
+ OpenStruct.new(
19
+ :service => x,
20
+ :account => 9026475359,
21
+ :enrolled_amount => 100,
22
+ )
23
+ end
24
+ end
25
+
26
+ it "checks" do
27
+ @transport.check(@payments.first)[:success].should == true
28
+
29
+ payment = OpenStruct.new(:account => '123')
30
+ @transport.check(payment)[:success].should == false
31
+ end
32
+
33
+ it "pays" do
34
+ @transport.pay(@payments.first)[:success].should == true
35
+ end
36
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Payzilla::Gateways::Mailru do
4
+ before(:all) do
5
+ config = ConfigStub.new('mailru')
6
+
7
+ config.setting_key = "KEY"
8
+
9
+ @transport = Payzilla::Gateways::Mailru.new(config, './log/mailru.log')
10
+
11
+ @payment = OpenStruct.new(
12
+ :account => 1234567891011121,
13
+ :enrolled_amount => 100
14
+ )
15
+ end
16
+
17
+ it "checks" do
18
+ @transport.check(@payment)[:success].should == true
19
+ end
20
+
21
+ it "pays" do
22
+ @transport.pay(@payment)[:success].should == true
23
+ end
24
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe Payzilla::Gateways::Matrix do
4
+ before(:all) do
5
+ config = ConfigStub.new('matrix')
6
+
7
+ config.setting_dealer_id = 123
8
+ config.setting_key_password = "qwer"
9
+ config.setting_url = "https://customer.matrixtelecom.ru:7778/pls/dp/ps$http_payments."
10
+
11
+ config.attachment_cert = File.new("certificates/matrix.pem")
12
+ config.attachment_key = File.new("certificates/matrix.pem")
13
+ config.attachment_ca = File.new("certificates/matrix.pem")
14
+
15
+ @transport = Payzilla::Gateways::Matrix.new(config, './log/matrix.log')
16
+
17
+ @payment = OpenStruct.new(
18
+ :account => 9260029939,
19
+ :enrolled_amount => 100,
20
+ :created_at => DateTime.now.strftime("%Y-%m-%d %H:%M:%S"),
21
+ :id => Time.now.to_i/1000
22
+ )
23
+ end
24
+
25
+ it "checks" do
26
+ result = @transport.check(@payment)
27
+ @payment_id = result[:gateway_payment_id]
28
+ result[:success].should == true
29
+ end
30
+
31
+ it "pays" do
32
+ @payment.gateway_payment_id = @payment_id
33
+ @transport.pay(@payment)[:success].should == true
34
+ end
35
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe Payzilla::Gateways::Megafon do
4
+ before(:all) do
5
+ config = ConfigStub.new('megafon')
6
+
7
+ config.setting_domain = '193.201.228.9'
8
+ config.setting_client = 'MKB'
9
+ config.setting_password = '1234'
10
+
11
+ config.attachment_cert = File.new('certificates/megafon.cer')
12
+ config.attachment_key = File.new('certificates/megafon.key')
13
+
14
+ @transport = Payzilla::Gateways::Megafon.new(config, './log/megafon.log')
15
+
16
+ @date = DateTime.now
17
+ @payments = %w(9268123698)
18
+
19
+ @payments = @payments.each_with_index.map do |x,i|
20
+ OpenStruct.new(
21
+ :id => Time.now.to_i+i,
22
+ :account => x,
23
+ :enrolled_amount => 100,
24
+ :created_at => @date
25
+ )
26
+ end
27
+
28
+ @revision = OpenStruct.new(:id => Time.now.to_i, :payments => @payments, :date => @date.to_date)
29
+ end
30
+
31
+ it "checks" do
32
+ @transport.check(@payments.first)[:success].should == true
33
+
34
+ payment = OpenStruct.new(:account => '123')
35
+ @transport.check(payment)[:success].should == false
36
+ end
37
+
38
+ it "pays" do
39
+ @transport.pay(@payments.first)[:success].should == true
40
+ end
41
+
42
+ it "revises" do
43
+ @transport.revise(@revision)[:success].should == true
44
+ end
45
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+ require 'crack'
3
+
4
+ describe Payzilla::Gateways::Mts do
5
+ before(:all) do
6
+ config = ConfigStub.new('mts')
7
+
8
+ config.setting_url = 'https://194.54.148.89/PaymentProcessingXMLEndpointTestProxy/TestPaymentProcessorDispatcher'
9
+ config.setting_agent = '13802005013'
10
+ config.setting_contract = '97018117111'
11
+ config.setting_key_password = 'round'
12
+ config.setting_signature_key_password = 'round'
13
+ config.setting_terminal_prefix = 'smkiosk'
14
+
15
+ config.attachment_cert = File.new('certificates/mtscert.pem')
16
+ config.attachment_key = File.new('certificates/mtscert.pem')
17
+ config.attachment_signature_key = File.new('certificates/mtscert.pem')
18
+
19
+ @transport = Payzilla::Gateways::Mts.new(config, './log/mts.log')
20
+
21
+ @date = DateTime.now - 1
22
+ @payments = %w(0950000001 0950000002 0950000003 0950000004 0950000005 0950000006 0950000007 0950000008 0950000009 0950000010 0950000011 0950000012 0950000013 0950000014 0950000015 0950000016 0950000017 0950000018 0950000019 0950000025 0950000026 0950000027 0950000030)
23
+ @errors = %w(201 64 65 66 103 106 200 201 202 203 204 205 299 300 301 350 351 353 354 400 501 502 0 502 )
24
+
25
+ @payments = @payments.each_with_index.map do |x,i|
26
+ OpenStruct.new(
27
+ :id => Time.now.to_i+i,
28
+ :account => x,
29
+ :created_at => @date,
30
+ :enrolled_amount => 100,
31
+ :terminal_id => 1,
32
+ :gateway_provider_id => 'MTS'
33
+ )
34
+ end
35
+
36
+ @revision = OpenStruct.new(:id => 1, :payments => @payments, :date => @date)
37
+ end
38
+
39
+ it "checks and pays" do
40
+ @payments.each_with_index do |pay,i|
41
+ check = @transport.check(pay)
42
+ check[:error].to_s.should == @errors[i]
43
+ if check[:error].to_s == "0"
44
+ pay.gateway_payment_id = check[:gateway_payment_id]
45
+ result = @transport.pay(pay)
46
+ result[:error].to_s.should == "0"
47
+ end
48
+ end
49
+ end
50
+
51
+ it "generates revision" do
52
+ data = Crack::XML.parse(@transport.generate_revision(@revision)[1])
53
+ data['comparePacket']['summary']['totalAmountOfPayments'].should == "23"
54
+ end
55
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe Payzilla::Gateways::Osmp do
4
+ before(:all) do
5
+ config = ConfigStub.new('osmp')
6
+ config.setting_domain = 'https://w.qiwi.ru/term2/xmlutf.jsp'
7
+ config.setting_client = '44'
8
+ config.setting_password = 'vC2VNgAv'
9
+ config.setting_terminal = 'MKB'
10
+
11
+ @payment = OpenStruct.new(
12
+ :id => 1,
13
+ :account => 8888888888,
14
+ :paid_amount => '1',
15
+ :enrolled_amount => '1',
16
+ :gateway_provider_id => 44,
17
+ )
18
+
19
+ @transport = Payzilla::Gateways::Osmp.new(config, './log/osmp.log')
20
+ end
21
+
22
+ it "checks" do
23
+ @transport.check(@payment)[:success].should == true
24
+ end
25
+
26
+ it "pays" do
27
+ @transport.pay(@payment)[:success].should == true
28
+ end
29
+ end
30
+
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe Payzilla::Gateways::Rapida do
4
+ before(:all) do
5
+ config = ConfigStub.new('rapida')
6
+
7
+ config.setting_url = 'https://gate.rapida.ru/test/'
8
+ config.setting_key_password = 'processing5x'
9
+
10
+ config.attachment_cert = File.new('certificates/rapida.cer')
11
+ config.attachment_key = File.new('certificates/rapida.key')
12
+
13
+ @transport = Payzilla::Gateways::Rapida.new(config, './log/rapida.log')
14
+ end
15
+
16
+ it "checks" do
17
+ payment = OpenStruct.new(
18
+ :id => Time.now.to_i,
19
+ :gateway_provider_id => '111', # megafon
20
+ :fields => {
21
+ '150' => '9268123698'
22
+ },
23
+ :terminal_id => 1
24
+ )
25
+ result = @transport.check(payment)
26
+ result[:success].should == true
27
+ end
28
+
29
+ it "pays" do
30
+ payment = OpenStruct.new(
31
+ :id => Time.now.to_i,
32
+ :gateway_provider_id => '111', # megafon
33
+ :fields => {
34
+ '150' => '9268123698'
35
+ },
36
+ :enrolled_amount => 100,
37
+ :commission_amount => 10,
38
+ :terminal_id => 1
39
+ )
40
+ result = @transport.pay(payment)
41
+ result[:success].should == true
42
+ end
43
+
44
+ it "lists providers" do
45
+ providers = @transport.providers
46
+ providers.should be_a_kind_of(Hash)
47
+ end
48
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe Payzilla::Gateways::Skylink do
4
+ before(:all) do
5
+ config = ConfigStub.new('skylink')
6
+
7
+ config.setting_url = "https://pay.msk.skylink.ru/srv_main_v2.asmx"
8
+ config.setting_client = 4
9
+
10
+ @payments = %w(9015041214 4959781777)
11
+ @payments = @payments.map do |p|
12
+ OpenStruct.new(
13
+ :account => p,
14
+ :paid_amount => 100,
15
+ :enrolled_amount => 100,
16
+ :created_at => DateTime.now,
17
+ :id => 1
18
+ )
19
+ end
20
+
21
+ @transport = Payzilla::Gateways::Skylink.new(config, './log/skylink.log')
22
+ end
23
+
24
+ it "checks" do
25
+ @payments.each do |payment|
26
+ @transport.check(payment)[:success].should == true
27
+ end
28
+ end
29
+
30
+ it "pays" do
31
+ @payments.each do |payment|
32
+ @transport.pay(payment)[:success].should == true
33
+ end
34
+ end
35
+
36
+ it "revises" do
37
+ @transport.revise(@payments, Time.now - 86400)[:success].should == true
38
+ end
39
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe Payzilla::Gateways::Webmoney do
4
+ before(:all) do
5
+ config = ConfigStub.new('webmoney')
6
+
7
+ config.setting_wmid = 273862024286
8
+ config.setting_kiosk_id = 12345
9
+ config.setting_key_password = "qwerty"
10
+
11
+ config.attachment_cert = File.new('certificates/webmoney.cer')
12
+ config.attachment_key = File.new('certificates/webmoney.key')
13
+
14
+ config.switch_test_mode = 1
15
+
16
+ @transport = Payzilla::Gateways::Webmoney.new(config, './log/webmoney.log')
17
+
18
+ @payment = OpenStruct.new(
19
+ :fields => {
20
+ 'phone' => 123456789,
21
+ 'purse' => "RUR",
22
+ 'name' => "Vasilij Pupkin",
23
+ 'passport_serie' => "KB",
24
+ 'passport_date' => "2009-12-12",
25
+ },
26
+ :id => 1234,
27
+ :enrolled_amount => 100,
28
+ )
29
+ end
30
+
31
+ it "checks" do
32
+ @transport.check(@payment)[:success].should == true
33
+ end
34
+
35
+ it "pays" do
36
+ @transport.pay(@payment)[:success].should == true
37
+ end
38
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Payzilla::Gateways::Yamoney do
4
+ before(:all) do
5
+ config = ConfigStub.new('yamoney')
6
+
7
+ config.setting_url = "https://bo-demo02.yamoney.ru/onlinegates/mkb.aspx"
8
+ config.setting_currency = 10643
9
+ config.setting_password = "round345"
10
+ config.setting_gpg_key = "MKB"
11
+
12
+ config.attachment_public_key = File.new('certificates/yandex_public.asc')
13
+ config.attachment_secret_key = File.new('certificates/yandex_private.gpg')
14
+
15
+ @transport = Payzilla::Gateways::Yamoney.new(config, './log/yamoney.log')
16
+
17
+ @payment = OpenStruct.new(
18
+ :id => Time.now.to_i.to_s,
19
+ :account => 4100175017397,
20
+ :enrolled_amount => 100.25
21
+ )
22
+ end
23
+
24
+ it "checks" do
25
+ @transport.check(@payment)[:success].should == true
26
+ end
27
+
28
+ it "pays" do
29
+ @transport.pay(@payment)[:success].should == true
30
+ end
31
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe Payzilla::Gateways::Yota do
4
+ before(:all) do
5
+ config = ConfigStub.new('yota')
6
+
7
+ config.setting_url = "https://yota.ru/pay"
8
+ config.setting_key_password = "qwerty"
9
+
10
+ config.attachment_cert = File.new("certificates/yota.cer")
11
+ config.attachment_key = File.new("certificates/yota.key")
12
+ config.attachment_ca = File.new("certificates/yota.key")
13
+
14
+ @transport = Payzilla::Gateways::Yota.new(config, './log/yota.log')
15
+
16
+ @payment = OpenStruct.new(
17
+ :account => 123456789,
18
+ :id => 123,
19
+ :created_at => DateTime.now.strftime("%Y-%m-%dT%H:%M:%S")
20
+ )
21
+ end
22
+
23
+ it "checks" do
24
+ @transport.check(@payment)[:success].should == true
25
+ end
26
+
27
+ it "pays" do
28
+ @transport.pay(@payment)[:success].should == true
29
+ end
30
+ end
@@ -0,0 +1,9 @@
1
+ require 'payzilla'
2
+ require 'pry'
3
+ require 'rspec/expectations'
4
+
5
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
6
+
7
+ RSpec.configure do |config|
8
+ config.include RSpec::Matchers
9
+ end
@@ -0,0 +1,7 @@
1
+ require 'ostruct'
2
+
3
+ class ConfigStub < OpenStruct
4
+ def initialize(keyword)
5
+ super :keyword => keyword, :debug_level => Logger::DEBUG
6
+ end
7
+ end