doku_library 0.0.1

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/doku.rb +117 -0
  3. metadata +44 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f3404662818083beff4bf7c5c652e8024d959094
4
+ data.tar.gz: c5aac19c82d080a47949aafac3306c0018e3e9a7
5
+ SHA512:
6
+ metadata.gz: 41771534275fcda933587564f39d8b15e3c352d89a1e54f12c77a78a7525f029310c04eca6bac7a00ec3cb1310ba4285b5c3f14bc9e076b5c13db9f96ccf5ba5
7
+ data.tar.gz: 3832012779448d34a72a00f54b0718bcd3dcb97155c7936c3ee74cc43f93ab358b8068d0883b94be18fab775e2430eb47240790f4ec2d5305b78ebc3f0189968
@@ -0,0 +1,117 @@
1
+ require 'digest/sha1'
2
+ require 'net/http'
3
+
4
+ require 'openssl'
5
+ OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
6
+ require 'yaml'
7
+
8
+ class Doku
9
+ @properties = YAML.load_file('properties.yml')
10
+ def self.get_times
11
+ Time.now.strftime("%d%m%Y%H%M%S")
12
+ end
13
+
14
+ def self.do_sha1(data)
15
+ Digest::SHA1.hexdigest(data)
16
+ end
17
+
18
+ def self.format_basket(basket)
19
+ if !basket.nil?
20
+ basket.to_sentence(two_words_connector: ';')
21
+ end
22
+ end
23
+
24
+ def self.do_create_words(data, sharekey, withreq)
25
+ p 'Data -> ' + ActiveSupport::JSON.encode(data)
26
+ device_id = 'device_id'
27
+ pairing_codes = 'pairing_code'
28
+ amount = 'amount'
29
+ mall_id = 'mall_id'
30
+ trans_id = 'trans_id'
31
+ currency = 'currency'
32
+ token = 'token'
33
+ if withreq == 1
34
+ device_id = 'req_device_id'
35
+ pairing_codes = 'req_pairing_code'
36
+ amount = 'req_amount'
37
+ mall_id = 'req_mall_id'
38
+ trans_id = 'req_trans_id_merchant'
39
+ currency = 'req_currency'
40
+ token = 'req_token_id'
41
+ end
42
+
43
+ if data.with_indifferent_access[device_id].to_s != ''
44
+ if data.with_indifferent_access[pairing_codes].to_s != ''
45
+ Digest::SHA1.hexdigest(data.with_indifferent_access[amount].to_s + data.with_indifferent_access[mall_id].to_s + sharekey + data.with_indifferent_access[trans_id].to_s + data.with_indifferent_access[currency].to_s + data.with_indifferent_access[token].to_s + data.with_indifferent_access[pairing_codes].to_s + data.with_indifferent_access[device_id].to_s)
46
+ else
47
+ Digest::SHA1.hexdigest(data.with_indifferent_access[amount].to_s + data.with_indifferent_access[mall_id].to_s + sharekey + data.with_indifferent_access[trans_id].to_s + data.with_indifferent_access[currency].to_s + data.with_indifferent_access[device_id].to_s)
48
+ end
49
+ elsif data.with_indifferent_access[pairing_codes].to_s != ''
50
+ # p '3 --> ' + data.with_indifferent_access[amount].to_s + ' ' + data.with_indifferent_access[mall_id].to_s + ' ' + sharekey + ' ' + data.with_indifferent_access[trans_id].to_s + ' ' + data.with_indifferent_access[currency].to_s + ' ' + data.with_indifferent_access[token].to_s + ' ' + data.with_indifferent_access[pairing_codes].to_s
51
+ Digest::SHA1.hexdigest(data.with_indifferent_access[amount].to_s + data.with_indifferent_access[mall_id].to_s + sharekey + data.with_indifferent_access[trans_id].to_s + data.with_indifferent_access[currency].to_s + data.with_indifferent_access[token].to_s + data.with_indifferent_access[pairing_codes].to_s)
52
+ elsif data.with_indifferent_access[currency].to_s != ''
53
+ # p '4 --> ' + data.with_indifferent_access[amount].to_s + ' ' + data.with_indifferent_access[mall_id].to_s + ' ' + sharekey + ' ' + data.with_indifferent_access[trans_id].to_s + ' ' + data.with_indifferent_access[currency].to_s
54
+ Digest::SHA1.hexdigest(data.with_indifferent_access[amount].to_s + data.with_indifferent_access[mall_id].to_s + sharekey + data.with_indifferent_access[trans_id].to_s + data.with_indifferent_access[currency].to_s)
55
+ else
56
+ Digest::SHA1.hexdigest(data.with_indifferent_access[amount].to_s + data.with_indifferent_access[mall_id].to_s + sharekey + data.with_indifferent_access[trans_id].to_s)
57
+ end
58
+
59
+ end
60
+
61
+ def self.do_create_words_raw(data, sharekey)
62
+ if data.with_indifferent_access['device_id'].to_s != ''
63
+ if data.with_indifferent_access['pairing_code'].to_s != ''
64
+ (data.with_indifferent_access['amount'].to_s + data.with_indifferent_access['mall_id'].to_s + sharekey + data.with_indifferent_access['trans_id'].to_s + data.with_indifferent_access['currency'].to_s + data.with_indifferent_access['token'].to_s + data.with_indifferent_access['pairing_code'].to_s + data.with_indifferent_access['device_id'].to_s)
65
+ else
66
+ (data.with_indifferent_access['amount'].to_s + data.with_indifferent_access['mall_id'].to_s + sharekey + data.with_indifferent_access['trans_id'].to_s + data.with_indifferent_access['currency'].to_s + data.with_indifferent_access['device_id'].to_s)
67
+ end
68
+ elsif data.with_indifferent_access['pairing_code'].to_s != ''
69
+ (data.with_indifferent_access['amount'].to_s + data.with_indifferent_access['mall_id'].to_s + sharekey + data.with_indifferent_access['trans_id'].to_s + data.with_indifferent_access['currency'].to_s + data.with_indifferent_access['token'].to_s + data.with_indifferent_access['pairing_code'].to_s)
70
+ elsif data.with_indifferent_access['currency'].to_s != ''
71
+ (data.with_indifferent_access['amount'].to_s + data.with_indifferent_access['mall_id'].to_s + sharekey + data.with_indifferent_access['trans_id'].to_s + data.with_indifferent_access['currency'].to_s)
72
+ else
73
+ (data.with_indifferent_access['amount'].to_s + data.with_indifferent_access['mall_id'].to_s + sharekey + data.with_indifferent_access['trans_id'].to_s)
74
+ end
75
+ end
76
+
77
+ def self.do_pre_payment(param_data)
78
+ if !param_data.nil?
79
+ uri = URI.parse(@properties['production']['prepayment_url'])
80
+ response = Net::HTTP.post_form(uri, {"data" => param_data})
81
+ response.body
82
+ end
83
+ end
84
+
85
+ def self.do_payment(param_data)
86
+ if !param_data.nil?
87
+ uri = URI.parse(@properties['production']['payment_url'])
88
+ response = Net::HTTP.post_form(uri, {"data" => param_data})
89
+ response.body
90
+ end
91
+ end
92
+
93
+ def self.do_direct_payment(param_data)
94
+ if !param_data.nil?
95
+ uri = URI.parse(@properties['direct_payment_url'])
96
+ response = Net::HTTP.post_form(uri, {"data" => param_data})
97
+ response.body
98
+ end
99
+ end
100
+
101
+ def self.do_generate_paycode(param_data)
102
+ if !param_data.nil?
103
+ uri = URI.parse(@properties['production']['generate_code_url'])
104
+ response = Net::HTTP.post_form(uri, {"data" => param_data})
105
+ response.body
106
+ end
107
+ end
108
+
109
+ def self.do_redirect_payment(param_data)
110
+ if !param_data.nil?
111
+ uri = URI.parse(@properties['production']['redirect_payment_url'])
112
+ response = Net::HTTP.post_form(uri, {"data" => param_data})
113
+ response.body
114
+ end
115
+ end
116
+
117
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: doku_library
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Codeplush
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-06 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Doku Payment Gateway for ruby (rails)
14
+ email: codeplush@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/doku.rb
20
+ homepage: http://codeplush.com
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.6.7
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: doku_library
44
+ test_files: []