Module: Paytm
- Defined in:
- lib/paytm/encryption_new_pg.rb,
lib/paytm.rb,
lib/paytm/request.rb,
lib/paytm/version.rb,
lib/paytm/gratification.rb,
lib/paytm/transaction_request.rb
Overview
New PG Encryption ##########################################
Defined Under Namespace
Modules: EncryptionNewPG, Request Classes: Gratification, TransactionRequest
Constant Summary collapse
- VERSION =
"0.1.3"
Class Attribute Summary collapse
-
.aes_key ⇒ Object
Returns the value of attribute aes_key.
-
.api_url(url) ⇒ Object
Returns the value of attribute api_url.
-
.guid ⇒ Object
Returns the value of attribute guid.
-
.mode ⇒ Object
Returns the value of attribute mode.
-
.open_timeout ⇒ Object
Returns the value of attribute open_timeout.
-
.production_url ⇒ Object
Returns the value of attribute production_url.
-
.read_timeout ⇒ Object
Returns the value of attribute read_timeout.
-
.test_url ⇒ Object
Returns the value of attribute test_url.
Class Method Summary collapse
- .api_base_url ⇒ Object
- .execute_request(opts) ⇒ Object
- .request(method, url, params = {}) ⇒ Object
- .request_headers(params) ⇒ Object
- .setup(merchant_guid, sales_wallet_guid, aes_key, mode) ⇒ Object
Class Attribute Details
.aes_key ⇒ Object
Returns the value of attribute aes_key.
21 22 23 |
# File 'lib/paytm.rb', line 21 def aes_key @aes_key end |
.api_url(url) ⇒ Object
Returns the value of attribute api_url.
21 22 23 |
# File 'lib/paytm.rb', line 21 def api_url @api_url end |
.guid ⇒ Object
Returns the value of attribute guid.
21 22 23 |
# File 'lib/paytm.rb', line 21 def guid @guid end |
.mode ⇒ Object
Returns the value of attribute mode.
21 22 23 |
# File 'lib/paytm.rb', line 21 def mode @mode end |
.open_timeout ⇒ Object
Returns the value of attribute open_timeout.
21 22 23 |
# File 'lib/paytm.rb', line 21 def open_timeout @open_timeout end |
.production_url ⇒ Object
Returns the value of attribute production_url.
21 22 23 |
# File 'lib/paytm.rb', line 21 def production_url @production_url end |
.read_timeout ⇒ Object
Returns the value of attribute read_timeout.
21 22 23 |
# File 'lib/paytm.rb', line 21 def read_timeout @read_timeout end |
.test_url ⇒ Object
Returns the value of attribute test_url.
21 22 23 |
# File 'lib/paytm.rb', line 21 def test_url @test_url end |
Class Method Details
.api_base_url ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/paytm.rb', line 33 def self.api_base_url case mode when :production self.production_url when :test self.test_url else raise StandardError, "Integration mode set to an invalid value: #{mode}" end end |
.execute_request(opts) ⇒ Object
88 89 90 |
# File 'lib/paytm.rb', line 88 def self.execute_request(opts) RestClient::Request.execute(opts) end |
.request(method, url, params = {}) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/paytm.rb', line 59 def self.request(method, url, params={}) unless aes_key ||= @aes_key raise AuthenticationError.new('No AES key provided.') end request_opts = {:verify_ssl => OpenSSL::SSL::VERIFY_NONE, :use_ssl => true} url = api_url(url) case method.to_s.downcase.to_sym when :get, :head, :delete # Make params into GET parameters url += "#{URI.parse(url).query ? '&' : '?'}#{Util.encode_parameters(params)}" if params && params.any? payload = nil else payload = params.to_json end request_opts.update(:headers => request_headers(payload), :method => method, :open_timeout => open_timeout, :payload => payload, :url => url, :timeout => read_timeout) puts request_opts response = execute_request(request_opts) puts response end |
.request_headers(params) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/paytm.rb', line 48 def self.request_headers(params) check_sum_hash = EncryptionNewPG.new_pg_checksum_by_str(params, aes_key) headers = { :user_agent => "github.com/ronakjain90/paytm/#{Paytm::VERSION}", :MID => guid[:merchant_guid], :checksumhash => check_sum_hash, :content_type => 'application/json' } headers end |
.setup(merchant_guid, sales_wallet_guid, aes_key, mode) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/paytm.rb', line 24 def self.setup(merchant_guid, sales_wallet_guid, aes_key, mode) self.guid = { merchant_guid: merchant_guid, sales_wallet_guid: sales_wallet_guid } self.aes_key = aes_key self.mode = mode end |