April 12, 2013
To accepts a payment i do the following steps
# Send requests to the gateway’s test servers
# #first set everything in test mode. later just need to change this environment to production.but for that we need to talk with bank service center to get the details of current live account and its credentials mapped with this account
cardexpdate=Date.civil(params[“credit_card”][“expiring_date(1i)”].to_i,params[“credit_card”][“expiring_date(2i)”].to_i) amount_in_cents = amount_in_cents
http = Net::HTTP.new(uri.host, uri.port)
#http.use_ssl = true
#http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(uri.request_uri)
response = http.request(request)
responsearray=response.body.split(“&”)
responsearray.each do |res|
if res.split(“=”)[0] == “vpc_Message”
if res.split(“=”)[1] ==”Approved”
self.state = ‘online_validated’
self.save
#invoice.validating
elsif res.split(“=”)[1] ==”Declined”
self.state = ‘Declined’
self.save
elsif res.split(“=”)[1] ==”Unspecified+Failure”
self.state = “Unspecified+Failure”
self.save
elsif res.split(“=”)[1] ==”Referred”
self.state = “Referred”
self.save
elsif res.split(“=”)[1] ==”Timed+Out”
self.state = “Timed+Out”
self.save
elsif res.split(“=”)[1] ==”Expired+Card”
self.state = “Expired+Card”
self.save
elsif res.split(“=”)[1] ==”Insufficient+Funds”
self.state = “Insufficient+Funds”
self.save
else
self.state = res.split(“=”)[1]
self.save
end
end
end
Leave a Reply
You must be logged in to post a comment.