def cancel_subscription(): """Cancel subscription.""" data = request.get_json() user_id = data.get('user', {}).get('id') user = User.get(user_id) if user_id is not None else None if user is not None: if user.stripe_subscription is not None: stripe.Subscription.delete(user.stripe_subscription) user.active = False Activity.cancel(user.id) return jsonify({"done": True})
def deactivate_iap(): """Deactivate in-app purchase.""" data = request.get_json() user_id = data.get('user', {}).get('id') user = User.get(user_id) if user_id is not None else None if user is not None: user.active = False user.promo_id = None user.promo_timestamp = None Activity.cancel(user.id, True) db.session.commit() return jsonify({})