notify wcs of paid items
This commit is contained in:
parent
9a3856b5c5
commit
af28ed5275
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('lingo', '0003_auto_20150306_1047'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='basketitem',
|
||||
name='notification_date',
|
||||
field=models.DateTimeField(null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
|
@ -14,6 +14,10 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import datetime
|
||||
import json
|
||||
import requests
|
||||
|
||||
import eopayment
|
||||
from jsonfield import JSONField
|
||||
|
||||
|
@ -24,6 +28,7 @@ from django.utils.translation import ugettext_lazy as _
|
|||
|
||||
from combo.data.models import CellBase
|
||||
from combo.data.library import register_cell_class
|
||||
from combo.utils import sign_url
|
||||
|
||||
|
||||
SERVICES = [
|
||||
|
@ -69,6 +74,16 @@ class BasketItem(models.Model):
|
|||
creation_date = models.DateTimeField(auto_now_add=True)
|
||||
cancellation_date = models.DateTimeField(null=True)
|
||||
payment_date = models.DateTimeField(null=True)
|
||||
notification_date = models.DateTimeField(null=True)
|
||||
|
||||
def notify(self):
|
||||
# TODO: sign with real values
|
||||
url = self.source_url + 'jump/trigger/paid?email=trigger@localhost&orig=combo'
|
||||
url = sign_url(url, key='xxx')
|
||||
message = {'result': 'ok'}
|
||||
r = requests.post(url, data=json.dumps(message))
|
||||
self.notification_date = datetime.datetime.now()
|
||||
self.save()
|
||||
|
||||
|
||||
class Transaction(models.Model):
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
import datetime
|
||||
from decimal import Decimal
|
||||
import json
|
||||
import thread
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.urlresolvers import reverse
|
||||
|
@ -134,4 +135,5 @@ class CallbackView(View):
|
|||
for item in transaction.items.all():
|
||||
item.payment_date = transaction.end_date
|
||||
item.save()
|
||||
thread.start_new_thread(item.notify, ())
|
||||
return HttpResponseRedirect('/')
|
||||
|
|
Reference in New Issue