Skip to content

Commit

Permalink
Merge pull request #46 from alexanderjordanbaker/AppStoreServerAPI110
Browse files Browse the repository at this point in the history
Updating new fields added in App Store Server API v1.10
  • Loading branch information
alexanderjordanbaker authored Nov 4, 2023
2 parents 7c7c8ea + 0f6fe50 commit 2d11b06
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
28 changes: 28 additions & 0 deletions appstoreserverlibrary/models/JWSTransactionDecodedPayload.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from attr import define
import attr

from .OfferDiscountType import OfferDiscountType
from .Environment import Environment
from .InAppOwnershipType import InAppOwnershipType
from .LibraryUtility import AttrsRawValueAware
Expand Down Expand Up @@ -209,4 +211,30 @@ class JWSTransactionDecodedPayload(AttrsRawValueAware):
rawTransactionReason: Optional[str] = TransactionReason.create_raw_attr('transactionReason')
"""
See transactionReason
"""

currency: Optional[str] = attr.ib(default=None)
"""
The three-letter ISO 4217 currency code for the price of the product.
https://developer.apple.com/documentation/appstoreserverapi/currency
"""

price: Optional[int] = attr.ib(default=None)
"""
The price of the in-app purchase or subscription offer that you configured in App Store Connect, as an integer.
https://developer.apple.com/documentation/appstoreserverapi/price
"""

offerDiscountType: Optional[OfferDiscountType] = OfferDiscountType.create_main_attr('rawOfferDiscountType')
"""
The payment mode you configure for an introductory offer, promotional offer, or offer code on an auto-renewable subscription.
https://developer.apple.com/documentation/appstoreserverapi/offerdiscounttype
"""

rawOfferDiscountType: Optional[str] = OfferDiscountType.create_raw_attr('offerDiscountType')
"""
See offerDiscountType
"""
15 changes: 15 additions & 0 deletions appstoreserverlibrary/models/OfferDiscountType.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2023 Apple Inc. Licensed under MIT License.

from enum import Enum

from .LibraryUtility import AppStoreServerLibraryEnumMeta

class OfferDiscountType(str, Enum, metaclass=AppStoreServerLibraryEnumMeta):
"""
The payment mode you configure for an introductory offer, promotional offer, or offer code on an auto-renewable subscription.
https://developer.apple.com/documentation/appstoreserverapi/offerdiscounttype
"""
FREE_TRIAL = "FREE_TRIAL"
PAY_AS_YOU_GO = "PAY_AS_YOU_GO"
PAY_UP_FRONT = "PAY_UP_FRONT"
5 changes: 4 additions & 1 deletion tests/resources/models/signedTransaction.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@
"environment":"LocalTesting",
"transactionReason":"PURCHASE",
"storefront":"USA",
"storefrontId":"143441"
"storefrontId":"143441",
"price": 10990,
"currency": "USD",
"offerDiscountType": "PAY_AS_YOU_GO"
}
5 changes: 5 additions & 0 deletions tests/test_decoded_payloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from appstoreserverlibrary.models.ExpirationIntent import ExpirationIntent
from appstoreserverlibrary.models.InAppOwnershipType import InAppOwnershipType
from appstoreserverlibrary.models.NotificationTypeV2 import NotificationTypeV2
from appstoreserverlibrary.models.OfferDiscountType import OfferDiscountType
from appstoreserverlibrary.models.OfferType import OfferType
from appstoreserverlibrary.models.PriceIncreaseStatus import PriceIncreaseStatus
from appstoreserverlibrary.models.RevocationReason import RevocationReason
Expand Down Expand Up @@ -72,6 +73,10 @@ def test_transaction_decoding(self):
self.assertEqual("PURCHASE", transaction.rawTransactionReason)
self.assertEqual(Environment.LOCAL_TESTING, transaction.environment)
self.assertEqual("LocalTesting", transaction.rawEnvironment)
self.assertEqual(10990, transaction.price)
self.assertEqual("USD", transaction.currency)
self.assertEqual(OfferDiscountType.PAY_AS_YOU_GO, transaction.offerDiscountType)
self.assertEqual("PAY_AS_YOU_GO", transaction.rawOfferDiscountType)


def test_renewal_info_decoding(self):
Expand Down

0 comments on commit 2d11b06

Please sign in to comment.