Skip to content

Commit fc278a9

Browse files
Merge pull request #188 from riyazpanjwani/main
Adding Advanced Commerce API objects
2 parents 100dfea + 8739245 commit fc278a9

83 files changed

Lines changed: 2298 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Apple App Store Server Python Library
2-
The [Python](https://github.com/apple/app-store-server-library-python) server library for the [App Store Server API](https://developer.apple.com/documentation/appstoreserverapi), [App Store Server Notifications](https://developer.apple.com/documentation/appstoreservernotifications), and [Retention Messaging API](https://developer.apple.com/documentation/retentionmessaging). Also available in [Swift](https://github.com/apple/app-store-server-library-swift), [Node.js](https://github.com/apple/app-store-server-library-node), and [Java](https://github.com/apple/app-store-server-library-java).
2+
The [Python](https://github.com/apple/app-store-server-library-python) server library for the [App Store Server API](https://developer.apple.com/documentation/appstoreserverapi), [App Store Server Notifications](https://developer.apple.com/documentation/appstoreservernotifications), [Retention Messaging API](https://developer.apple.com/documentation/retentionmessaging), and [Advanced Commerce API](https://developer.apple.com/documentation/AdvancedCommerceAPI). Also available in [Swift](https://github.com/apple/app-store-server-library-swift), [Node.js](https://github.com/apple/app-store-server-library-node), and [Java](https://github.com/apple/app-store-server-library-java).
33

44
## Table of Contents
55
1. [Installation](#installation)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2026 Apple Inc. Licensed under MIT License.
2+
3+
from abc import ABC
4+
5+
from attr import define
6+
import attr
7+
8+
from .AdvancedCommerceValidationUtils import AdvancedCommerceValidationUtils
9+
from .LibraryUtility import AttrsRawValueAware
10+
11+
@define
12+
class AbstractAdvancedCommerceBaseItem(AttrsRawValueAware, ABC):
13+
SKU: str = attr.ib(validator=AdvancedCommerceValidationUtils.sku_validator)
14+
"""
15+
The product identifier of an in-app purchase product you manage in your own system.
16+
17+
https://developer.apple.com/documentation/advancedcommerceapi/sku
18+
"""
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (c) 2026 Apple Inc. Licensed under MIT License.
2+
3+
from abc import ABC
4+
5+
from attr import define
6+
import attr
7+
8+
from .AdvancedCommerceRequest import AdvancedCommerceRequest
9+
from ..jws_signature_creator import AdvancedCommerceAPIInAppRequest
10+
11+
@define
12+
class AbstractAdvancedCommerceInAppRequest(AdvancedCommerceRequest, AdvancedCommerceAPIInAppRequest, ABC):
13+
operation: str = attr.ib()
14+
version: str = attr.ib()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) 2026 Apple Inc. Licensed under MIT License.
2+
3+
from attr import define
4+
import attr
5+
6+
from .AbstractAdvancedCommerceBaseItem import AbstractAdvancedCommerceBaseItem
7+
from .AdvancedCommerceValidationUtils import AdvancedCommerceValidationUtils
8+
9+
@define
10+
class AbstractAdvancedCommerceItem(AbstractAdvancedCommerceBaseItem):
11+
description: str = attr.ib(validator=AdvancedCommerceValidationUtils.description_validator)
12+
"""
13+
A string you provide that describes a SKU.
14+
15+
https://developer.apple.com/documentation/advancedcommerceapi/description
16+
"""
17+
18+
displayName: str = attr.ib(validator=AdvancedCommerceValidationUtils.display_name_validator)
19+
"""
20+
A string with a product name that you can localize and is suitable for display to customers.
21+
22+
https://developer.apple.com/documentation/advancedcommerceapi/displayname
23+
"""
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) 2026 Apple Inc. Licensed under MIT License.
2+
3+
from abc import ABC
4+
from typing import Optional
5+
6+
from attr import define
7+
import attr
8+
9+
@define
10+
class AbstractAdvancedCommerceResponse(ABC):
11+
signedRenewalInfo: Optional[str] = attr.ib(default=None)
12+
"""
13+
Subscription renewal information, signed by the App Store, in JSON Web Signature (JWS) format.
14+
15+
https://developer.apple.com/documentation/appstoreserverapi/jwsrenewalinfo
16+
"""
17+
18+
signedTransactionInfo: Optional[str] = attr.ib(default=None)
19+
"""
20+
Transaction information signed by the App Store, in JSON Web Signature (JWS) Compact Serialization format.
21+
22+
https://developer.apple.com/documentation/appstoreserverapi/jwstransaction
23+
"""
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright (c) 2026 Apple Inc. Licensed under MIT License.
2+
3+
from attr import define
4+
import attr
5+
6+
from .AdvancedCommerceValidationUtils import AdvancedCommerceValidationUtils
7+
8+
@define
9+
class AdvancedCommerceDescriptors:
10+
"""
11+
The display name and description of a subscription product.
12+
13+
https://developer.apple.com/documentation/advancedcommerceapi/descriptors
14+
"""
15+
description: str = attr.ib(validator=AdvancedCommerceValidationUtils.description_validator)
16+
"""
17+
A string you provide that describes a SKU.
18+
19+
https://developer.apple.com/documentation/advancedcommerceapi/description
20+
"""
21+
22+
displayName: str = attr.ib(validator=AdvancedCommerceValidationUtils.display_name_validator)
23+
"""
24+
A string with a product name that you can localize and is suitable for display to customers.
25+
26+
https://developer.apple.com/documentation/advancedcommerceapi/displayname
27+
"""
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (c) 2026 Apple Inc. Licensed under MIT License.
2+
3+
from enum import Enum
4+
5+
from .LibraryUtility import AppStoreServerLibraryEnumMeta
6+
7+
class AdvancedCommerceEffective(str, Enum, metaclass=AppStoreServerLibraryEnumMeta):
8+
"""
9+
A string value that indicates when a requested change to an auto-renewable subscription goes into effect.
10+
11+
https://developer.apple.com/documentation/advancedcommerceapi/effective
12+
"""
13+
IMMEDIATELY = "IMMEDIATELY"
14+
NEXT_BILL_CYCLE = "NEXT_BILL_CYCLE"
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Copyright (c) 2026 Apple Inc. Licensed under MIT License.
2+
from typing import Optional
3+
4+
from attr import define
5+
import attr
6+
7+
from .AdvancedCommerceOfferPeriod import AdvancedCommerceOfferPeriod
8+
from .AdvancedCommerceOfferReason import AdvancedCommerceOfferReason
9+
from .AdvancedCommerceValidationUtils import AdvancedCommerceValidationUtils
10+
from .LibraryUtility import AttrsRawValueAware
11+
12+
@define
13+
class AdvancedCommerceOffer(AttrsRawValueAware):
14+
"""
15+
A discount offer for an auto-renewable subscription.
16+
17+
https://developer.apple.com/documentation/advancedcommerceapi/offer
18+
"""
19+
20+
periodCount: int = attr.ib(validator=AdvancedCommerceValidationUtils.period_count_validator)
21+
"""
22+
The number of periods the offer is active.
23+
"""
24+
25+
price: int = attr.ib()
26+
"""
27+
The offer price, in milliunits.
28+
29+
https://developer.apple.com/documentation/advancedcommerceapi/price
30+
"""
31+
32+
period: AdvancedCommerceOfferPeriod = AdvancedCommerceOfferPeriod.create_main_attr('rawPeriod', raw_required=True)
33+
"""
34+
The period of the offer.
35+
"""
36+
37+
rawPeriod: str = AdvancedCommerceOfferPeriod.create_raw_attr('period', required=True)
38+
"""
39+
See period
40+
"""
41+
42+
reason: AdvancedCommerceOfferReason = AdvancedCommerceOfferReason.create_main_attr('rawReason', raw_required=True)
43+
"""
44+
The reason for the offer.
45+
"""
46+
47+
rawReason: str = AdvancedCommerceOfferReason.create_raw_attr('reason', required=True)
48+
"""
49+
See reason
50+
"""
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (c) 2026 Apple Inc. Licensed under MIT License.
2+
3+
from enum import Enum
4+
5+
from .LibraryUtility import AppStoreServerLibraryEnumMeta
6+
7+
class AdvancedCommerceOfferPeriod(str, Enum, metaclass=AppStoreServerLibraryEnumMeta):
8+
"""
9+
The period of the offer.
10+
11+
https://developer.apple.com/documentation/advancedcommerceapi/offer
12+
"""
13+
P3D = "P3D"
14+
P1W = "P1W"
15+
P2W = "P2W"
16+
P1M = "P1M"
17+
P2M = "P2M"
18+
P3M = "P3M"
19+
P6M = "P6M"
20+
P9M = "P9M"
21+
P1Y = "P1Y"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) 2026 Apple Inc. Licensed under MIT License.
2+
3+
from enum import Enum
4+
5+
from .LibraryUtility import AppStoreServerLibraryEnumMeta
6+
7+
class AdvancedCommerceOfferReason(str, Enum, metaclass=AppStoreServerLibraryEnumMeta):
8+
"""
9+
The reason for the offer.
10+
11+
https://developer.apple.com/documentation/advancedcommerceapi/offer
12+
"""
13+
ACQUISITION = "ACQUISITION"
14+
WIN_BACK = "WIN_BACK"
15+
RETENTION = "RETENTION"

0 commit comments

Comments
 (0)