lib/middles/alipay.rb in magpie-0.8.6.2 vs lib/middles/alipay.rb in magpie-0.8.8
- old
+ new
@@ -7,25 +7,15 @@
include Utils
def initialize(app, pay_gateway = "https://www.alipay.com/cooperate/gateway.do")
@app = app
@pay_gateway = pay_gateway
+ @red_xpath = "//div[@id='Info']/div[@class='ErrorInfo']/div[@class='Todo']"
end
def call(env)
- status, header, body = @app.call(env)
- req = Rack::Request.new(env)
- doc = send_req_to @pay_gateway, req
- red_text = (doc/"//div[@id='Info']/div[@class='ErrorInfo']/div[@class='Todo']").inner_text
- red_text = Iconv.iconv("UTF-8//IGNORE","GBK//IGNORE", red_text).to_s
- am = AlipayModel.new(req.params)
- [status, header, get_xml_body(env, am, red_text)]
- end
-
- private
-
- def get_final_error(red_text)
- red_text
+ status, header, body, req, red_text = dig env
+ [status, header, get_xml_body(env, AlipayModel.new(req.params), red_text)]
end
end
end