Class: WechatPayment::CallbackController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- WechatPayment::CallbackController
- Defined in:
- app/controllers/wechat_payment/callback_controller.rb
Instance Method Summary collapse
-
#payment ⇒ Object
微信支付回调.
- #refund ⇒ Object
Instance Method Details
#payment ⇒ Object
微信支付回调
6 7 8 9 10 11 12 13 14 15 |
# File 'app/controllers/wechat_payment/callback_controller.rb', line 6 def payment result = Hash.from_xml(request.body.read)["xml"] process_result = WechatPayment::Service.handle_payment_notify(result) if process_result.success? render xml: { return_code: "SUCCESS" }.to_xml(root: 'xml', dasherize: false) else render xml: { return_code: "FAIL", return_msg: process_result.error.first }.to_xml(root: 'xml', dasherize: false) end end |
#refund ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/wechat_payment/callback_controller.rb', line 17 def refund callback_info = Hash.from_xml(request.body.read)["xml"]["req_info"] refund_result = WechatPayment::Service.handle_refund_notify(callback_info) if refund_result.success? render xml: {return_code: "SUCCESS"}.to_xml(root: 'xml', dasherize: false) else render xml: {return_code: "FAIL", return_msg: refund_result.error.first}.to_xml(root: 'xml', dasherize: false) end end |