module EzpayInvoice::Request
Public Instance Methods
post(path, data)
click to toggle source
# File lib/ezpay-invoice/request.rb, line 9 def post(path, data) uri = Addressable::URI.new uri.query_values = data payload = { 'MerchantID_' => @merchant_id, 'PostData_' => encrypt(uri.query) } request(:post, path, payload) end
Private Instance Methods
api_endpoint()
click to toggle source
# File lib/ezpay-invoice/request.rb, line 20 def api_endpoint subdomain = @mode == 'prod' ? 'inv' : 'cinv' "https://#{subdomain}.ezpay.com.tw/Api/" end
encrypt(data)
click to toggle source
# File lib/ezpay-invoice/request.rb, line 35 def encrypt(data) aes = OpenSSL::Cipher.new('AES-256-CBC') aes.encrypt aes.key = @hash_key aes.iv = @hash_iv (aes.update(data) + aes.final).unpack("H*").first.upcase end
request(method, path, payload)
click to toggle source
# File lib/ezpay-invoice/request.rb, line 25 def request(method, path, payload) response = RestClient::Request.execute( method: method, url: Addressable::URI.parse("#{api_endpoint}#{path}").normalize.to_str, payload: payload ) Response.new(response) end