Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

accept tenpay pay result. #308

  • Loading branch information...
commit 1ba7148a5fcca21bb591c41ed4d4a38dc9211bdd 1 parent be72b61
@saberma saberma authored
View
4 app/controllers/shop/order_controller.rb
@@ -166,9 +166,11 @@ def done # 支付后从浏览器前台直接返回(return_url)
begin '财付通'
def tenpay_notify # 此action只供支付网关(财付通)服务器的外部通知接口使用,通知我们订单支付状态(return_url)
- notification = ActiveMerchant::Billing::Integrations::Tenpay::Return.new(request.raw_post)
+ query_string = request.raw_post.blank? ? request.query_string : request.raw_post # 支持get和post方式
+ notification = ActiveMerchant::Billing::Integrations::Tenpay::Return.new(query_string)
@order = Order.find_by_token(notification.order)
if @order and notification.success?(@order.payment.key, @order.payment.account)
+ @_resources = { shop: @order.shop } # checkout.haml中expose的shop
@order.pay!(notification.total_fee) if @order.financial_status_pending? # 要支持重复请求
render
else
View
2  app/views/shop/order/tenpay_notify.html.erb
@@ -2,7 +2,7 @@
<head>
<meta name="TENCENT_ONLINE_PAYMENT" content="China TENCENT">
<script language="javascript">
- window.location.href='<%= tenpay_done_order_url(@order) %>';
+ window.location.href='<%= tenpay_done_order_url(token: @order.token) %>';
</script>
</head>
<body></body>
View
2  config/routes.rb
@@ -63,7 +63,7 @@
match '/orders/:shop_id/:token/commit' , to: 'order#commit' , as: :commit_order
post '/orders/notify' , to: 'order#notify' , as: :notify_order
get '/orders/done' , to: 'order#done' , as: :done_order
- post '/orders/tenpay_notify' , to: 'order#tenpay_notify' , as: :tenpay_notify_order
+ match '/orders/tenpay_notify' , to: 'order#tenpay_notify' , as: :tenpay_notify_order
get '/orders/tenpay_done/:token' , to: 'order#tenpay_done' , as: :tenpay_done_order
post '/orders/:shop_id/:token/update_total_price' , to: 'order#update_total_price', as: :update_order_total_price
post '/carts/:shop_id/:cart_token/update_tax_price', to: 'order#update_tax_price' , as: :update_order_tax_price

0 comments on commit 1ba7148

Please sign in to comment.
Something went wrong with that request. Please try again.