ruby-on-rails – PayPal IPN无法连接取消定期结算

当用户通过PayPal取消定期付款时,我需要帮助以了解如何在用户数据库中将用户标记为已取消.

通知控制器:

 def create
    params.permit! # Permit all Paypal input params
    #query = params
    puts "in method*************************************"   
    #query[:cmd] = "_notify-validate"
    #if  params[:txn_type] == 'subscr_cancel'
    #   user_subscription = Subscription.find_by(paypal_customer_token: params[:payer_id])
        #   user_subscription.update_column("cancelled",1) if user_subscription.present?
    #els
    if  params[:txn_type] == 'recurring_payment_profile_cancel'
      user_subscription = Subscription.find_by(paypal_recurring_profile_token: params[:recurring_payment_id])
      user_subscription.update_column("cancelled",1) if user_subscription.present?
    end
    render :text => 'OK'
  end
end

最佳答案 嗯,我想你必须推荐你评论过的行,有点像这样:

  if  params[:txn_type] == 'subscr_cancel'
   user_subscription = Subscription.find_by(paypal_customer_token: params[:payer_id])
   user_subscription.update_column("cancelled",1) if user_subscription.present?
  end

我正在使用php api并在用户取消订阅时使用’subscr_cancel’

点赞