LIL-553. Send order to roistat

remotes/origin/hasaccess
Ivlev Denis 8 years ago
parent 382d9a76e8
commit fd41a6d69a
  1. 19
      apps/payment/tasks.py
  2. 11
      apps/payment/views.py

@ -30,3 +30,22 @@ def product_payment_to_mixpanel(user_id, event_name, time, properties):
event_name,
properties=props,
)
@app.task
def transaction_to_roistat(user_id, payment_id, event_name, amount, time, status, product_type):
body = [{
'id': str(payment_id),
'name': event_name,
'date_create': time,
'status': str(status),
'price': str(amount),
'client_id': str(user_id),
'fields': {
'product_type': product_type,
}
}]
project = settings.ROISTAT_PROJECT
key = settings.ROISTAT_KEY
url = settings.ROISTAT_API_URL + f'/project/add-orders?key={key}&project={project}'
resp = requests.post(url, json=body)

@ -22,7 +22,7 @@ from paymentwall import Pingback, Product, Widget
from apps.course.models import Course
from apps.school.models import SchoolSchedule
from apps.payment.tasks import transaction_to_mixpanel, product_payment_to_mixpanel
from apps.payment.tasks import transaction_to_mixpanel, product_payment_to_mixpanel, transaction_to_roistat
from .models import AuthorBalance, CoursePayment, SchoolPayment
@ -251,6 +251,15 @@ class PaymentwallCallbackView(View):
properties,
)
transaction_to_roistat.delay(
payment.user.id,
payment.id,
f'{product_type_name.title()} payment',
payment.amount,
now().strftime('%Y-%m-%dT%H:%M:%S'),
pingback.get_type(),
product_type_name,
)
author_balance = getattr(payment, 'author_balance', None)
if author_balance and author_balance.type == AuthorBalance.IN:
if pingback.is_deliverable():

Loading…
Cancel
Save