如何回复标题状态为200的即时付款通知

时间:2014-06-24 21:10:31

标签: ruby-on-rails ruby-on-rails-3

我有一个API,其中包含以下要求; 的 Your application must respond to each IPN message with HTTP header status code 200, whether or not you intend to do anything with it.

这是我尝试过的API处理代码;

def success
    transaction =Transaction.find_by_merchant_reference(params[:external_ref])

    if transaction && transaction.status != "Completed"
        date_time = params[:date_time]
        amount = params[:amount]
        narrative = params[:narrative]
        network_ref = params[:network_ref]
        external_ref = params[:external_ref]
        msisdn = params[:msisdn]
        signature = params[:signature]

        if verfiy_signiture(date_time,amount,narrative,network_ref,external_ref,msisdn) == signature
            user = User.find(transaction.user_id)
            user.balance = (user.balance+transaction.amount*0.975)
            user.save() 
            transaction.status ="Completed"         
            TopUp.account_topup(user.name, user.email, user.currency, transaction.amount, transaction.merchant_reference).deliver
            flash[:notice] = "##################################3"
            user_home_path(@current_user)
        end

    end

    render :status => 200

end

然而,这显示有关丢失模板的错误,但这是即时付款通知。

1 个答案:

答案 0 :(得分:1)

使用:

render nothing: true, status: 200

这告诉rails不要渲染模板