transferuj 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/transferuj.rb +51 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5b47686b0852f5fd3881e8aa2726165b2231a6a3
4
+ data.tar.gz: 1d43e23000b858be7a9b5136d897dffa970a07e7
5
+ SHA512:
6
+ metadata.gz: 971e83ac39388c05c8e60d1747f4d1627ada636dab344805b5294383e13e1d7491ed5a75f8b7e4ac08b8b019cbb88b150bd0b474604b8e7b6e15c7148b2423ab
7
+ data.tar.gz: eda686876e8258a1aa3c786734bc43309ae11d597c84e613ab5db29e07cef072b40e93d659a3cc2aa07923c39e5d9e829b3a30f511e3d9f4ae42fa03f3e2d840
data/lib/transferuj.rb ADDED
@@ -0,0 +1,51 @@
1
+ module Transferuj
2
+
3
+ class Error < Exception; attr_accessor :errors; end
4
+
5
+ # ID of receiver
6
+ @@id = ''
7
+ @@security_code = ''
8
+ def self.id=(new_id)
9
+ @@id = new_id
10
+ end
11
+
12
+ def self.id
13
+ @@id
14
+ end
15
+
16
+ # Security code
17
+ def self.security_code=(new_security_code)
18
+ @@security_code = new_security_code
19
+ end
20
+
21
+ def self.security_code
22
+ @@security_code
23
+ end
24
+
25
+ # Creates URL for redirection to pay page
26
+ def self.pay_url(params = {})
27
+ self.sanity_check!
28
+ md5sum = Digest::MD5.hexdigest(self.id.to_s+params[:kwota].to_s+params[:crc].to_s+self.security_code.to_s)
29
+ params.merge!({:id => self.id, :md5sum => md5sum})
30
+ URI::HTTP.build(:host => "secure.transferuj.pl", :query => params.to_query).to_s
31
+ end
32
+
33
+ # Checks MD5 checksum and IP of request
34
+ def self.webhook_valid?(transaction, ip)
35
+ self.sanity_check!
36
+ md5sum = Digest::MD5.hexdigest(self.id.to_s+transaction[:tr_id].to_s+transaction[:tr_amount].to_s+transaction[:tr_crc].to_s+self.security_code.to_s)
37
+ binding.pry
38
+ ip == '195.149.229.109' && transaction[:md5sum] == md5sum
39
+ end
40
+
41
+ def self.configured?
42
+ self.id.present? && self.security_code.present?
43
+ end
44
+
45
+ def self.sanity_check!
46
+ unless configured?
47
+ raise Exception.new("Transferuj Gem not properly configured. See README to get help how to do it.")
48
+ end
49
+ end
50
+
51
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: transferuj
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Adam Mazur
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-26 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: API wrapper for transferuj.pl payments
14
+ email: mazik.wyry@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/transferuj.rb
20
+ homepage: https://github.com/mazikwyry/transferuj-ruby-gem
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.0.3
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Official Ruby gem for transferuj.pl
44
+ test_files: []