paytm 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/Paytm.gemspec +33 -0
- data/README.md +69 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/paytm.rb +91 -0
- data/lib/paytm/encryption_new_pg.rb +227 -0
- data/lib/paytm/gratification.rb +47 -0
- data/lib/paytm/request.rb +26 -0
- data/lib/paytm/version.rb +3 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c1c27679d334bfdfbf704d2d6ab9c948c8d6679a
|
4
|
+
data.tar.gz: 1988a999dfdaa665c1a3e77a775b1fcea65a1aea
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 54e28457495586a9c3e98a33d94b7cbc59e50aac9e7c29f6d3b49544f5c96a6892b2d9e8ede9eca474f33e2097d98e87af3ed9968d26accf70f68e9b2e751585
|
7
|
+
data.tar.gz: 8bce398326460582ad05b36605b54424838d17fd62dabb6b2aeffec1fd9ec463572362ba88031af82b676e360d540a00ccc9a66e037d71ea9962322ab21d8ae1
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/Paytm.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'paytm/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "paytm"
|
8
|
+
spec.version = Paytm::VERSION
|
9
|
+
spec.authors = ["Ronak Jain"]
|
10
|
+
spec.email = ["ronakjain90@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Paytm integrationg for rails applicaiton}
|
13
|
+
spec.description = %q{This is a Paytm integration for rails applicaiton!}
|
14
|
+
spec.homepage = ""
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
17
|
+
# delete this section to allow pushing this gem to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
|
32
|
+
spec.add_dependency('rest-client', '~> 1.8')
|
33
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Paytm
|
2
|
+
|
3
|
+
This is an unofficial Paytm gratification api ruby-wrapper gem. This helps you to credit money to your users wallet. It will work for a variety of usecase if you wish to reward your users, pay for a service done by them.
|
4
|
+
|
5
|
+
Get the Paytm integration done in less than 5 minutes **¯\\\_(ツ)\_/¯**
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'paytm'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install paytm
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
**1) Setup your Paytm Account by placing the following code**
|
26
|
+
|
27
|
+
Paytm.setup(merchant-guid, sales-wallet-guid, aes-key, :test)
|
28
|
+
|
29
|
+
or
|
30
|
+
|
31
|
+
Paytm.setup(merchant-guid, sales-wallet-guid, aes-key, :production)
|
32
|
+
|
33
|
+
**2) Credit To user Wallet using**
|
34
|
+
|
35
|
+
Paytm::Gratification.credit_to_user({request_type: 'null',
|
36
|
+
merchant_order_id: '<unique_order_id>',
|
37
|
+
payee_email_id: 'email_id_to_credit_money_to',
|
38
|
+
payee_phone_number: 'recipients_phone_number',
|
39
|
+
payee_sso_id: 'sso_id_of_the_reciepients_wallet',
|
40
|
+
applied_to_new_users: 'Y',
|
41
|
+
amount: '10',
|
42
|
+
currency_code: 'INR'},
|
43
|
+
{metadata: 'Testing Data'})
|
44
|
+
|
45
|
+
## Development
|
46
|
+
|
47
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
48
|
+
|
49
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ronakjain90/paytm. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
54
|
+
|
55
|
+
##Commercial license
|
56
|
+
|
57
|
+
If you want to use this gem for a commercial application, commercial license is the appropriate license. With this option, your source code is kept proprietary. This will definitely helps you to save hours worth of effort.
|
58
|
+
|
59
|
+
## Open-source license
|
60
|
+
|
61
|
+
> Copyright (C) 2016 Ronak Jain (ronakjain90@gmail.com)
|
62
|
+
|
63
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
64
|
+
|
65
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
66
|
+
|
67
|
+
## Trademark
|
68
|
+
|
69
|
+
All trademarks and registered trademarks are the property of their respective owners. Gem owner does not own any trademarks.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "paytm"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/paytm.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
require 'rest-client'
|
3
|
+
|
4
|
+
require 'paytm/version'
|
5
|
+
|
6
|
+
require 'paytm/encryption_new_pg'
|
7
|
+
require 'paytm/request'
|
8
|
+
require 'paytm/gratification'
|
9
|
+
|
10
|
+
|
11
|
+
module Paytm
|
12
|
+
|
13
|
+
@test_url = 'https://trust-uat.paytm.in'
|
14
|
+
@production_url = 'https://trust.paytm.in'
|
15
|
+
|
16
|
+
@open_timeout = 30
|
17
|
+
@read_timeout = 80
|
18
|
+
|
19
|
+
class << self
|
20
|
+
attr_accessor :guid, :aes_key, :mode, :api_url, :test_url, :production_url, :open_timeout, :read_timeout
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.setup(merchant_guid, sales_wallet_guid, aes_key, mode)
|
24
|
+
self.guid = {
|
25
|
+
merchant_guid: merchant_guid,
|
26
|
+
sales_wallet_guid: sales_wallet_guid
|
27
|
+
}
|
28
|
+
self.aes_key = aes_key
|
29
|
+
self.mode = mode
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.api_base_url
|
33
|
+
case mode
|
34
|
+
when :production
|
35
|
+
self.production_url
|
36
|
+
when :test
|
37
|
+
self.test_url
|
38
|
+
else
|
39
|
+
raise StandardError, "Integration mode set to an invalid value: #{mode}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.api_url(url)
|
44
|
+
api_base_url + url
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.request_headers(params)
|
48
|
+
check_sum_hash = EncryptionNewPG.new_pg_checksum_by_str(params.to_json, aes_key)
|
49
|
+
headers = {
|
50
|
+
:user_agent => "github.com/ronakjain90/paytm/#{Paytm::VERSION}",
|
51
|
+
:mid => guid[:merchant_guid],
|
52
|
+
:checksumhash => check_sum_hash,
|
53
|
+
:content_type => 'application/json'
|
54
|
+
}
|
55
|
+
headers
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.request(method, url, params={})
|
59
|
+
|
60
|
+
unless aes_key ||= @aes_key
|
61
|
+
raise AuthenticationError.new('No AES key provided.')
|
62
|
+
end
|
63
|
+
|
64
|
+
request_opts = {:verify_ssl => OpenSSL::SSL::VERIFY_NONE, :use_ssl => true}
|
65
|
+
|
66
|
+
url = api_url(url)
|
67
|
+
|
68
|
+
case method.to_s.downcase.to_sym
|
69
|
+
when :get, :head, :delete
|
70
|
+
# Make params into GET parameters
|
71
|
+
url += "#{URI.parse(url).query ? '&' : '?'}#{Util.encode_parameters(params)}" if params && params.any?
|
72
|
+
payload = nil
|
73
|
+
else
|
74
|
+
payload = params.to_json
|
75
|
+
end
|
76
|
+
|
77
|
+
request_opts.update(:headers => request_headers(payload),
|
78
|
+
:method => method, :open_timeout => open_timeout,
|
79
|
+
:payload => payload, :url => url, :timeout => read_timeout)
|
80
|
+
|
81
|
+
puts request_opts
|
82
|
+
response = execute_request(request_opts)
|
83
|
+
|
84
|
+
puts response
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.execute_request(opts)
|
88
|
+
RestClient::Request.execute(opts)
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,227 @@
|
|
1
|
+
######################################## Encryption module #########################################
|
2
|
+
############################ AES 128-bit encryption with SHA256 Hash ###############################
|
3
|
+
|
4
|
+
####################################### New PG Encryption ##########################################
|
5
|
+
module Paytm
|
6
|
+
module EncryptionNewPG
|
7
|
+
|
8
|
+
require 'openssl'
|
9
|
+
require 'base64'
|
10
|
+
require 'digest'
|
11
|
+
require 'securerandom'
|
12
|
+
|
13
|
+
### function returns dictionary of encrypted data ###
|
14
|
+
### accepts a dictionary with data and key to encrypt with ###
|
15
|
+
### can accept multiple key value pairs in the dictionary ###
|
16
|
+
def new_pg_encrypt(params)
|
17
|
+
if (params.class != Hash) || (params.keys == [])
|
18
|
+
return false
|
19
|
+
end
|
20
|
+
if !params.has_key?(:key)
|
21
|
+
return false
|
22
|
+
end
|
23
|
+
encrypted_data = Hash[]
|
24
|
+
key = params.delete(:key)
|
25
|
+
keys = params.keys
|
26
|
+
aes = OpenSSL::Cipher::Cipher.new("aes-128-cbc")
|
27
|
+
begin
|
28
|
+
keys.each do |k|
|
29
|
+
data = params[k]
|
30
|
+
aes.encrypt
|
31
|
+
aes.key = key
|
32
|
+
aes.iv = '@@@@&&&&####$$$$'
|
33
|
+
encrypted_k = aes.update(k.to_s) + aes.final
|
34
|
+
encrypted_k = Base64.encode64(encrypted_k.to_s)
|
35
|
+
aes.encrypt
|
36
|
+
aes.key = key
|
37
|
+
aes.iv = '@@@@&&&&####$$$$'
|
38
|
+
encrypted_data[encrypted_k] = aes.update(data.to_s) + aes.final
|
39
|
+
encrypted_data[encrypted_k] = Base64.encode64(encrypted_data[encrypted_k])
|
40
|
+
end
|
41
|
+
rescue Exception => e
|
42
|
+
return false
|
43
|
+
end
|
44
|
+
return encrypted_data
|
45
|
+
end
|
46
|
+
|
47
|
+
### function returns a single encrypted value ###
|
48
|
+
### input data -> value to be encrypted ###
|
49
|
+
### key -> key to use for encryption ###
|
50
|
+
def self.new_pg_encrypt_variable(data, key)
|
51
|
+
aes = OpenSSL::Cipher::Cipher.new("aes-128-cbc")
|
52
|
+
aes.encrypt
|
53
|
+
aes.key = key
|
54
|
+
aes.iv = '@@@@&&&&####$$$$'
|
55
|
+
encrypted_data = nil
|
56
|
+
begin
|
57
|
+
encrypted_data = aes.update(data.to_s) + aes.final
|
58
|
+
encrypted_data = Base64.encode64(encrypted_data)
|
59
|
+
rescue Exception => e
|
60
|
+
return false
|
61
|
+
end
|
62
|
+
return encrypted_data
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
### function returns dictionary of decrypted data ###
|
67
|
+
### accepts a dictionary with data and key to decrypt with ###
|
68
|
+
### can accept multiple key value pairs in the dictionary ###
|
69
|
+
def new_pg_decrypt(params)
|
70
|
+
if (params.class != Hash) || (params.keys == [])
|
71
|
+
return false
|
72
|
+
end
|
73
|
+
if !params.has_key?(:key)
|
74
|
+
return false
|
75
|
+
end
|
76
|
+
decrypted_data = Hash[]
|
77
|
+
key = params.delete(:key)
|
78
|
+
keys = params.keys
|
79
|
+
aes = OpenSSL::Cipher::Cipher.new("aes-128-cbc")
|
80
|
+
begin
|
81
|
+
keys.each do |k|
|
82
|
+
data = params[k]
|
83
|
+
aes.decrypt
|
84
|
+
aes.key = key
|
85
|
+
aes.iv = '@@@@&&&&####$$$$'
|
86
|
+
decrypted_k = Base64.decode64(k.to_s)
|
87
|
+
decrypted_k = aes.update(decrypted_k.to_s) + aes.final
|
88
|
+
if data.empty?
|
89
|
+
decrypted_data[decrypted_k] = ""
|
90
|
+
next
|
91
|
+
end
|
92
|
+
aes.decrypt
|
93
|
+
aes.key = key
|
94
|
+
aes.iv = '@@@@&&&&####$$$$'
|
95
|
+
data = Base64.decode64(data)
|
96
|
+
decrypted_data[decrypted_k] = aes.update(data) + aes.final
|
97
|
+
end
|
98
|
+
rescue Exception => e
|
99
|
+
return false
|
100
|
+
end
|
101
|
+
return decrypted_data
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
### function returns a single decrypted value ###
|
106
|
+
### input data -> value to be decrypted ###
|
107
|
+
### key -> key to use for decryption ###
|
108
|
+
def self.new_pg_decrypt_variable(data, key)
|
109
|
+
aes = OpenSSL::Cipher::Cipher.new("aes-128-cbc")
|
110
|
+
aes.decrypt
|
111
|
+
aes.key = key
|
112
|
+
aes.iv = '@@@@&&&&####$$$$'
|
113
|
+
decrypted_data = nil
|
114
|
+
begin
|
115
|
+
decrypted_data = Base64.decode64(data.to_s)
|
116
|
+
decrypted_data = aes.update(decrypted_data) + aes.final
|
117
|
+
rescue Exception => e
|
118
|
+
return false
|
119
|
+
end
|
120
|
+
return decrypted_data
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
def self.new_pg_generate_salt(length)
|
125
|
+
salt = SecureRandom.urlsafe_base64(length*(3.0/4.0))
|
126
|
+
return salt.to_s
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
### function returns checksum of given key value pairs ###
|
131
|
+
### accepts a hash with key value pairs ###
|
132
|
+
### calculates sha256 checksum of given values ###
|
133
|
+
def self.new_pg_checksum(params, key, salt_length = 4)
|
134
|
+
if params.class != Hash
|
135
|
+
return false
|
136
|
+
end
|
137
|
+
if key.empty?
|
138
|
+
return false
|
139
|
+
end
|
140
|
+
salt = new_pg_generate_salt(salt_length)
|
141
|
+
keys = params.keys
|
142
|
+
str = nil
|
143
|
+
keys = keys.sort
|
144
|
+
keys.each do |k|
|
145
|
+
if str.nil?
|
146
|
+
str = params[k].to_s
|
147
|
+
next
|
148
|
+
end
|
149
|
+
str = str + '|' + params[k].to_s
|
150
|
+
end
|
151
|
+
str = str + '|' + salt
|
152
|
+
check_sum = Digest::SHA256.hexdigest(str)
|
153
|
+
check_sum = check_sum + salt
|
154
|
+
### encrypting checksum ###
|
155
|
+
check_sum = new_pg_encrypt_variable(check_sum, key)
|
156
|
+
return check_sum.gsub("\n",'')
|
157
|
+
end
|
158
|
+
|
159
|
+
|
160
|
+
def self.new_pg_checksum_by_str(paramstr, key, salt_length = 4)
|
161
|
+
|
162
|
+
salt = new_pg_generate_salt(salt_length)
|
163
|
+
|
164
|
+
str = nil
|
165
|
+
|
166
|
+
str = paramstr + '|' + salt
|
167
|
+
check_sum = Digest::SHA256.hexdigest(str)
|
168
|
+
check_sum = check_sum + salt
|
169
|
+
### encrypting checksum ###
|
170
|
+
check_sum = new_pg_encrypt_variable(check_sum, key)
|
171
|
+
return check_sum.gsub("\n",'')
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
### function returns checksum of given key value pairs (must contain the :checksum key) ###
|
176
|
+
### accepts a hash with key value pairs ###
|
177
|
+
### calculates sha256 checksum of given values ###
|
178
|
+
### returns true if checksum is consistent ###
|
179
|
+
### returns false in case of inconsistency ###
|
180
|
+
def self.new_pg_verify_checksum(params, check_sum, key, salt_length = 4)
|
181
|
+
|
182
|
+
if params.class != Hash
|
183
|
+
return false
|
184
|
+
end
|
185
|
+
|
186
|
+
if key.empty?
|
187
|
+
return false
|
188
|
+
end
|
189
|
+
|
190
|
+
if check_sum.nil? || check_sum.empty?
|
191
|
+
return false
|
192
|
+
end
|
193
|
+
|
194
|
+
generated_check_sum = nil
|
195
|
+
check_sum = new_pg_decrypt_variable(check_sum, key)
|
196
|
+
|
197
|
+
if check_sum == false
|
198
|
+
return false
|
199
|
+
end
|
200
|
+
begin
|
201
|
+
salt = check_sum[(check_sum.length-salt_length), (check_sum.length)]
|
202
|
+
keys = params.keys
|
203
|
+
str = nil
|
204
|
+
keys = keys.sort
|
205
|
+
keys.each do |k|
|
206
|
+
if str.nil?
|
207
|
+
str = params[k].to_s
|
208
|
+
next
|
209
|
+
end
|
210
|
+
str = str + '|' + params[k].to_s
|
211
|
+
end
|
212
|
+
str = str + '|' + salt
|
213
|
+
generated_check_sum = Digest::SHA256.hexdigest(str)
|
214
|
+
generated_check_sum = generated_check_sum + salt
|
215
|
+
rescue Exception => e
|
216
|
+
return false
|
217
|
+
end
|
218
|
+
|
219
|
+
if check_sum == generated_check_sum
|
220
|
+
return true
|
221
|
+
else
|
222
|
+
return false
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
end
|
227
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Paytm
|
2
|
+
class Gratification
|
3
|
+
|
4
|
+
require 'socket'
|
5
|
+
include Paytm::Request
|
6
|
+
|
7
|
+
ip = Socket.ip_address_list.detect{|intf| intf.ipv4_private?}
|
8
|
+
|
9
|
+
@request_params = {}
|
10
|
+
@platform = {
|
11
|
+
platform_name: 'PayTM',
|
12
|
+
operation_type: 'SALES_TO_USER_CREDIT',
|
13
|
+
ip_address: ip.ip_address,
|
14
|
+
metadata: '',
|
15
|
+
}
|
16
|
+
|
17
|
+
class << self
|
18
|
+
attr_accessor :request_params, :platform
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.credit_to_user(params = {}, opts = {})
|
22
|
+
request_params.merge!(params)
|
23
|
+
platform.merge!(opts)
|
24
|
+
request_params.merge!(Paytm.guid)
|
25
|
+
send_request(:post, merchant_to_wallet_url, request_params, platform)
|
26
|
+
end
|
27
|
+
|
28
|
+
def check_status(params = {}, opts = {})
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
def self.base_url
|
35
|
+
"/wallet-web"
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.merchant_to_wallet_url
|
39
|
+
base_url + "/salesToUserCredit"
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.check_status_url
|
43
|
+
base_url + "/txnStatusList"
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class String
|
2
|
+
def camel_case_lower
|
3
|
+
self.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
module Paytm
|
8
|
+
module Request
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
def send_request(method, url, request_params, optional_params)
|
12
|
+
params = {}
|
13
|
+
request_params = Hash[request_params.map{ |k, v| [k.to_s.camel_case_lower, v] }]
|
14
|
+
optional_params = Hash[optional_params.map{ |k, v| [k.to_s.camel_case_lower, v] }]
|
15
|
+
params['request'] = request_params
|
16
|
+
params.merge!(optional_params)
|
17
|
+
Paytm.request(method, url, params)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.included(base)
|
22
|
+
base.extend(ClassMethods)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: paytm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ronak Jain
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rest-client
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.8'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.8'
|
55
|
+
description: This is a Paytm integration for rails applicaiton!
|
56
|
+
email:
|
57
|
+
- ronakjain90@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- CODE_OF_CONDUCT.md
|
64
|
+
- Gemfile
|
65
|
+
- Paytm.gemspec
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- lib/paytm.rb
|
71
|
+
- lib/paytm/encryption_new_pg.rb
|
72
|
+
- lib/paytm/gratification.rb
|
73
|
+
- lib/paytm/request.rb
|
74
|
+
- lib/paytm/version.rb
|
75
|
+
homepage: ''
|
76
|
+
licenses: []
|
77
|
+
metadata:
|
78
|
+
allowed_push_host: https://rubygems.org
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.4.8
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Paytm integrationg for rails applicaiton
|
99
|
+
test_files: []
|