module PayTM::Merchant
Constants
- End_Points
- Staging_Base_Uri
Constants
- VERSION
Attributes
amount[RW]
Attr_accessors
email[RW]
Attr_accessors
metadata[RW]
Attr_accessors
phone[RW]
Attr_accessors
recipient[RW]
Attr_accessors
Public Class Methods
included(base)
click to toggle source
# File lib/paytm/merchant.rb, line 8 def self.included(base) base.send :include, HTTParty base.extend EncryptionNewPG base.extend ClassMethods end
new(data = {})
click to toggle source
Instance Methods
# File lib/paytm/merchant.rb, line 46 def initialize(data = {}) @amount = data[:amount] @recipient = data[:recipient] @phone = data[:phone] @email = data[:email] end
Public Instance Methods
check_transaction_status_for(transaction_id, options = {})
click to toggle source
# File lib/paytm/merchant.rb, line 66 def check_transaction_status_for(transaction_id, options = {}) check_transaction_body = paytm_check_transation_status_body(transaction_id, options) @response = self.class.post( End_Points[:checkstatus], { body: check_transaction_body.to_json, headers: paytm_check_transation_status_header(check_transaction_body), verify: (options[:verify] == false ? false : true) } ) end
transfer(options = {})
click to toggle source
# File lib/paytm/merchant.rb, line 53 def transfer(options = {}) @amount = amount if options[:amount] @response = self.class.post( End_Points[:salestouser], { body: paytm_request_body(options).to_json, headers: paytm_request_headers, verify: (options[:verify] == false ? false : true) } ) end
Private Instance Methods
generate_hash(key, params={})
click to toggle source
# File lib/paytm/merchant.rb, line 142 def generate_hash(key, params={}) @checksum = Paytm.new_pg_checksum_by_String(params.to_json, key).gsub("\n",'') end
paytm_check_transation_status_body(transaction_id, options = {})
click to toggle source
# File lib/paytm/merchant.rb, line 81 def paytm_check_transation_status_body(transaction_id, options = {}) case options[:transaction_id_type] when :paytm_transaction_id request_type = 'wallettxnid' # Default when :merchant_order_id request_type = 'merchanttxnid' when :refund_reference_id request_type = 'refundreftxnid' else request_type = 'wallettxnid' end transaction_type = options[:transaction_type] || 'salestouser' { request: { requestType: request_type, txnType: transaction_type, txnId: transaction_id, merchantGuid: self.class.merchant_guid }, platformName: 'PayTM', operationType: 'CHECK_TXN_STATUS' } end
paytm_check_transation_status_header(check_transaction_body)
click to toggle source
# File lib/paytm/merchant.rb, line 107 def paytm_check_transation_status_header(check_transaction_body) paytm_request_headers(check_transaction_body) end
paytm_request_body(options = {})
click to toggle source
# File lib/paytm/merchant.rb, line 111 def paytm_request_body(options = {}) { request: { requestType: options[:request_type], merchantGuid: self.class.merchant_guid, merchantOrderId: options[:merchant_order_id] || "#{ @phone }-#{ Time.now.to_i }", salesWalletName: options[:sales_wallet_name], salesWalletGuid: self.class.sales_wallet_id, payeeEmailId: @email, payeePhoneNumber: @phone, payeeSsoId: options[:payee_sso_id] || '', appliedToNewUsers: options[:applied_to_new_users] || 'Y', amount: @amount, currencyCode: options[:currency_code] || 'INR' }, metadata: options[:metadata] || '', ipAddress: options[:ip_address] || '127.0.0.1', platformName: 'PayTM', operationType: 'SALES_TO_USER_CREDIT' } end
paytm_request_headers(request_body = paytm_request_body)
click to toggle source
# File lib/paytm/merchant.rb, line 133 def paytm_request_headers(request_body = paytm_request_body) { 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'mid' => self.class.merchant_guid, 'checksumhash' => generate_hash(self.class.aes_key, request_body) } end