diff --git a/subscriptions/models.py b/subscriptions/models.py index c8c0c5e..cc890a1 100644 --- a/subscriptions/models.py +++ b/subscriptions/models.py @@ -29,6 +29,36 @@ class ASSNotification(models.Model): requestIdentifier = models.CharField(max_length=100, null=True, blank=True) # Offers - offerDiscountType = 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) + # offerDiscountType = 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) + 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." + ) diff --git a/subscriptions/views.py b/subscriptions/views.py index 9c62f9a..2d55b36 100644 --- a/subscriptions/views.py +++ b/subscriptions/views.py @@ -75,6 +75,14 @@ def decodePayload(signedPayload): if transaction_info.revocationDate: 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( notificationType=payload.notificationType, subtype=payload.subtype, @@ -93,9 +101,9 @@ def decodePayload(signedPayload): storefront=transaction_info.storefront, transactionId=transaction_info.transactionId, transactionReason=transaction_info.rawTransactionReason, - offerDiscountType=payload.offerDiscountType, + offerDiscountType=offer_discount_type, offerIdentifier=payload.offerIdentifier, - offerType=payload.offerType, + offerType=offer_type, ) notification.save() elif payload.summary: