|
|
|
|
@ -22,6 +22,8 @@ from myauth.models import DokUser |
|
|
|
|
from commons.utils import only_numerics |
|
|
|
|
from robokassa.signals import result_received, success_page_visited |
|
|
|
|
|
|
|
|
|
from . import emails |
|
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__) |
|
|
|
|
|
|
|
|
|
# куда сохранять загруженные изображения |
|
|
|
|
@ -755,8 +757,7 @@ class Payment(models.Model): |
|
|
|
|
return f'{self.user}-{self.order_number}-{self.get_status_display()}' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@receiver(result_received) |
|
|
|
|
def order_completed(sender, **kwargs): |
|
|
|
|
def confirmed_purchase(**kwargs): |
|
|
|
|
try: |
|
|
|
|
payment = Payment.objects.get( |
|
|
|
|
pk=kwargs['InvId'], |
|
|
|
|
@ -770,29 +771,25 @@ def order_completed(sender, **kwargs): |
|
|
|
|
lic.paid_date = datetime.now().date() |
|
|
|
|
lic.save() |
|
|
|
|
|
|
|
|
|
emails.send_license_successful_purchased.delay( |
|
|
|
|
payment.user.email, |
|
|
|
|
lic.pk, |
|
|
|
|
lic.get_term(), |
|
|
|
|
lic.date_from |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
except Payment.DoesNotExist: |
|
|
|
|
log.info(f"payment with id={kwargs['InvId']} not found") |
|
|
|
|
except License.DoesNotExist: |
|
|
|
|
log.info(f"payment with id={kwargs['InvId']} not found") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@receiver(result_received) |
|
|
|
|
def order_completed(sender, **kwargs): |
|
|
|
|
confirmed_purchase(**kwargs) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@receiver(success_page_visited) |
|
|
|
|
def success_page_visited_completed(sender, **kwargs): |
|
|
|
|
if settings.DEBUG: |
|
|
|
|
try: |
|
|
|
|
payment = Payment.objects.get( |
|
|
|
|
pk=kwargs['InvId'], |
|
|
|
|
order_amount=kwargs['OutSum'] |
|
|
|
|
) |
|
|
|
|
payment.status = Payment.SUCCESS |
|
|
|
|
payment.save() |
|
|
|
|
|
|
|
|
|
lic = License.objects.get(pk=payment.order_number) |
|
|
|
|
lic.status = consts.STATUS_PAID |
|
|
|
|
lic.paid_date = datetime.now().date() |
|
|
|
|
lic.save() |
|
|
|
|
|
|
|
|
|
except Payment.DoesNotExist: |
|
|
|
|
log.info(f"payment with id={kwargs['InvId']} not found") |
|
|
|
|
except License.DoesNotExist: |
|
|
|
|
log.info(f"payment with id={kwargs['InvId']} not found") |
|
|
|
|
confirmed_purchase(**kwargs) |
|
|
|
|
|