def pagarme_notification(request, user_id: int): if request.method != 'POST': return HttpResponseNotAllowed([request.method]) try: payment_facade.confirm_boleto_payment( user_id, request.POST, request.body.decode('utf8'), request.headers['X-Hub-Signature']) except PagarmeNotPaidTransaction: pass else: user = user_facade.find_user_by_id(user_id) _promote_client_and_remove_tag_boleto(user, request) return HttpResponse('')
def pagarme_notification(request, user_id: int): if request.method != 'POST': return HttpResponseNotAllowed([request.method]) paymento_ok = payment_facade.confirm_boleto_payment( user_id, request.POST, request.body.decode('utf8'), request.headers['X-Hub-Signature']) if paymento_ok: user = get_user_model().objects.get(id=user_id) _promote_client(user) msg = render_to_string( 'payments/pytools_email.txt', { 'user': user, 'ty_url': request.build_absolute_uri(reverse('payments:pytools_thanks')) }) send_mail( 'Inscrição no curso Pytool realizada! Confira o link com detalhes.', msg, settings.DEFAULT_FROM_EMAIL, [user.email]) return HttpResponse('')