Reputation: 1395
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
Upvotes: 4
Views: 104
Reputation: 3614
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
Upvotes: 2