Skip to content

Commit 2d11b06

Browse files
Merge pull request #46 from alexanderjordanbaker/AppStoreServerAPI110
Updating new fields added in App Store Server API v1.10
2 parents 7c7c8ea + 0f6fe50 commit 2d11b06

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

appstoreserverlibrary/models/JWSTransactionDecodedPayload.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
from attr import define
55
import attr
6+
7+
from .OfferDiscountType import OfferDiscountType
68
from .Environment import Environment
79
from .InAppOwnershipType import InAppOwnershipType
810
from .LibraryUtility import AttrsRawValueAware
@@ -209,4 +211,30 @@ class JWSTransactionDecodedPayload(AttrsRawValueAware):
209211
rawTransactionReason: Optional[str] = TransactionReason.create_raw_attr('transactionReason')
210212
"""
211213
See transactionReason
214+
"""
215+
216+
currency: Optional[str] = attr.ib(default=None)
217+
"""
218+
The three-letter ISO 4217 currency code for the price of the product.
219+
220+
https://developer.apple.com/documentation/appstoreserverapi/currency
221+
"""
222+
223+
price: Optional[int] = attr.ib(default=None)
224+
"""
225+
The price of the in-app purchase or subscription offer that you configured in App Store Connect, as an integer.
226+
227+
https://developer.apple.com/documentation/appstoreserverapi/price
228+
"""
229+
230+
offerDiscountType: Optional[OfferDiscountType] = OfferDiscountType.create_main_attr('rawOfferDiscountType')
231+
"""
232+
The payment mode you configure for an introductory offer, promotional offer, or offer code on an auto-renewable subscription.
233+
234+
https://developer.apple.com/documentation/appstoreserverapi/offerdiscounttype
235+
"""
236+
237+
rawOfferDiscountType: Optional[str] = OfferDiscountType.create_raw_attr('offerDiscountType')
238+
"""
239+
See offerDiscountType
212240
"""
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) 2023 Apple Inc. Licensed under MIT License.
2+
3+
from enum import Enum
4+
5+
from .LibraryUtility import AppStoreServerLibraryEnumMeta
6+
7+
class OfferDiscountType(str, Enum, metaclass=AppStoreServerLibraryEnumMeta):
8+
"""
9+
The payment mode you configure for an introductory offer, promotional offer, or offer code on an auto-renewable subscription.
10+
11+
https://developer.apple.com/documentation/appstoreserverapi/offerdiscounttype
12+
"""
13+
FREE_TRIAL = "FREE_TRIAL"
14+
PAY_AS_YOU_GO = "PAY_AS_YOU_GO"
15+
PAY_UP_FRONT = "PAY_UP_FRONT"

tests/resources/models/signedTransaction.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,8 @@
2121
"environment":"LocalTesting",
2222
"transactionReason":"PURCHASE",
2323
"storefront":"USA",
24-
"storefrontId":"143441"
24+
"storefrontId":"143441",
25+
"price": 10990,
26+
"currency": "USD",
27+
"offerDiscountType": "PAY_AS_YOU_GO"
2528
}

tests/test_decoded_payloads.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from appstoreserverlibrary.models.ExpirationIntent import ExpirationIntent
77
from appstoreserverlibrary.models.InAppOwnershipType import InAppOwnershipType
88
from appstoreserverlibrary.models.NotificationTypeV2 import NotificationTypeV2
9+
from appstoreserverlibrary.models.OfferDiscountType import OfferDiscountType
910
from appstoreserverlibrary.models.OfferType import OfferType
1011
from appstoreserverlibrary.models.PriceIncreaseStatus import PriceIncreaseStatus
1112
from appstoreserverlibrary.models.RevocationReason import RevocationReason
@@ -72,6 +73,10 @@ def test_transaction_decoding(self):
7273
self.assertEqual("PURCHASE", transaction.rawTransactionReason)
7374
self.assertEqual(Environment.LOCAL_TESTING, transaction.environment)
7475
self.assertEqual("LocalTesting", transaction.rawEnvironment)
76+
self.assertEqual(10990, transaction.price)
77+
self.assertEqual("USD", transaction.currency)
78+
self.assertEqual(OfferDiscountType.PAY_AS_YOU_GO, transaction.offerDiscountType)
79+
self.assertEqual("PAY_AS_YOU_GO", transaction.rawOfferDiscountType)
7580

7681

7782
def test_renewal_info_decoding(self):

0 commit comments

Comments
 (0)