简体   繁体   中英

PayPal IPN not connecting with canceling recurring billing

I need help to understand how to mark user as cancelled in my database when the user cancels the recurring payment via PayPal.

Notifications controller:

 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

Hm,, I think you have to uncommend the lines you have commented,, somehting like this:

  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

I'm using php api and have this 'subscr_cancel' when user cancels subscription

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM