upgrade model

main
Laurent 9 months ago
parent b08797d687
commit a1952be519
  1. 36
      subscriptions/models.py
  2. 12
      subscriptions/views.py

@ -29,6 +29,36 @@ class ASSNotification(models.Model):
requestIdentifier = models.CharField(max_length=100, null=True, blank=True) requestIdentifier = models.CharField(max_length=100, null=True, blank=True)
# Offers # Offers
offerDiscountType = models.CharField(max_length=100, null=True, blank=True) # offerDiscountType = models.CharField(max_length=100, null=True, blank=True)
offerIdentifier = models.CharField(max_length=100, null=True, blank=True) # offerIdentifier = models.CharField(max_length=100, null=True, blank=True)
offerType = models.IntegerField(null=True, blank=True) # offerType = models.IntegerField(null=True, blank=True)
offer_type = models.IntegerField(
null=True,
blank=True,
choices=[
(1, 'INTRODUCTORY_OFFER'),
(2, 'PROMOTIONAL_OFFER'),
(3, 'SUBSCRIPTION_OFFER_CODE'),
(4, 'WIN_BACK_OFFER'),
],
help_text="A value that represents the promotional offer type."
)
offer_identifier = models.CharField(
max_length=255,
null=True,
blank=True,
help_text="The identifier that contains the promo code or the promotional offer identifier."
)
offer_discount_type = models.CharField(
max_length=20,
null=True,
blank=True,
choices=[
('FREE_TRIAL', 'FREE_TRIAL'),
('PAY_AS_YOU_GO', 'PAY_AS_YOU_GO'),
('PAY_UP_FRONT', 'PAY_UP_FRONT'),
],
help_text="The payment mode for an introductory offer, promotional offer, or offer code on an auto-renewable subscription."
)

@ -75,6 +75,14 @@ def decodePayload(signedPayload):
if transaction_info.revocationDate: if transaction_info.revocationDate:
revocationDateTime = datetime.datetime.fromtimestamp(transaction_info.revocationDate / 1000) revocationDateTime = datetime.datetime.fromtimestamp(transaction_info.revocationDate / 1000)
offer_type = None
if payload.offerType is not None:
offer_type = int(payload.offerType)
offer_discount_type = None
if payload.offerDiscountType is not None:
offer_discount_type = payload.offerDiscountType.value
notification = ASSNotification( notification = ASSNotification(
notificationType=payload.notificationType, notificationType=payload.notificationType,
subtype=payload.subtype, subtype=payload.subtype,
@ -93,9 +101,9 @@ def decodePayload(signedPayload):
storefront=transaction_info.storefront, storefront=transaction_info.storefront,
transactionId=transaction_info.transactionId, transactionId=transaction_info.transactionId,
transactionReason=transaction_info.rawTransactionReason, transactionReason=transaction_info.rawTransactionReason,
offerDiscountType=payload.offerDiscountType, offerDiscountType=offer_discount_type,
offerIdentifier=payload.offerIdentifier, offerIdentifier=payload.offerIdentifier,
offerType=payload.offerType, offerType=offer_type,
) )
notification.save() notification.save()
elif payload.summary: elif payload.summary:

Loading…
Cancel
Save