Class: Nicepay::Api::ChargeCard
- Inherits:
-
Object
- Object
- Nicepay::Api::ChargeCard
- Defined in:
- lib/nicepay/api.rb
Instance Method Summary collapse
- #checkParameters ⇒ Object
- #dumpParameters ⇒ Object
- #errorMsg ⇒ Object
-
#initialize(parameters) ⇒ ChargeCard
constructor
A new instance of ChargeCard.
- #parameters ⇒ Object
- #parametersToCheck ⇒ Object
- #response ⇒ Object
Constructor Details
#initialize(parameters) ⇒ ChargeCard
Returns a new instance of ChargeCard.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/nicepay/api.rb', line 94 def initialize(parameters) @parameters = parameters @parametersToCheck = Array[ 'iMid', 'payMethod', 'instmntType', 'instmntMon', 'goodsNm', 'description', 'referenceNo', 'cartData', 'amt', 'currency', 'billingNm', 'billingPhone', 'billingEmail', 'billingAddr', 'billingCity', 'billingState', 'billingPostCd', 'billingCountry', 'userIP', 'dbProcessUrl', 'callBackUrl', 'vat', 'fee', 'notaxAmt', 'merchantToken' ] end |
Instance Method Details
#checkParameters ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/nicepay/api.rb', line 137 def checkParameters @parametersToCheck.each do |param| if @parameters[param] == nil @errorMsg = "\nUndefined mandatory parameter `" + \ param + \ '` please set param using Nicepay.setRequestParam(\'' + \ param + \ '\', \''+ param +' value\')' @checkParameters = false break else @checkParameters = true end end @checkParameters end |
#dumpParameters ⇒ Object
154 155 156 157 158 159 160 |
# File 'lib/nicepay/api.rb', line 154 def dumpParameters @dumpedParameters = "\n///// [POST] Request Parameter Dump /////\n\n" @parameters.each do |key, value| @dumpedParameters += key.to_s + ' = ' + value.to_s + "\n\n" end @dumpedParameters end |
#errorMsg ⇒ Object
133 134 135 |
# File 'lib/nicepay/api.rb', line 133 def errorMsg @errorMsg = errorMsg end |
#parameters ⇒ Object
125 126 127 |
# File 'lib/nicepay/api.rb', line 125 def parameters @parameters end |
#parametersToCheck ⇒ Object
129 130 131 |
# File 'lib/nicepay/api.rb', line 129 def parametersToCheck @parametersToCheck end |
#response ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/nicepay/api.rb', line 162 def response if self.checkParameters == true with_retries(:max_tries => Nicepay.max_retry, :rescue => RestClient::Exception) do @response = RestClient::Request.execute( :method => :post, :url => Nicepay::REQ_CC_URL, :payload => @parameters, :timeout => Nicepay.read_timeout, :open_timeout => Nicepay.connection_timeout ) end @response[0..3]='' @response = JSON.parse(@response) @result = @response["data"] else puts @errorMsg puts self.dumpParameters abort('Exit') end end |