当用户通过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
答案 0 :(得分:2)
嗯,我想你必须取消注释你评论的行,有点像这样:
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并且有这个n#39; subscr_cancel n#39;当用户取消订阅时