Skip to content

Commit 374fb84

Browse files
author
Riyaz Panjwani
committed
Update finish transaction and anyTransactionId
1 parent 6d7c32b commit 374fb84

3 files changed

Lines changed: 70 additions & 34 deletions

File tree

appstoreserverlibrary/api_client.py

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -800,28 +800,28 @@ def extend_subscription_renewal_date(self, original_transaction_id: str, extend_
800800
"""
801801
return self._make_request(f"/inApps/v1/subscriptions/extend/{original_transaction_id}", "PUT", {}, extend_renewal_date_request, ExtendRenewalDateResponse, None)
802802

803-
def get_all_subscription_statuses(self, transaction_id: str, status: Optional[List[Status]] = None) -> StatusResponse:
803+
def get_all_subscription_statuses(self, any_transaction_id: str, status: Optional[List[Status]] = None) -> StatusResponse:
804804
"""
805805
Get the statuses for all of a customer's auto-renewable subscriptions in your app.
806806
https://developer.apple.com/documentation/appstoreserverapi/get_all_subscription_statuses
807-
808-
:param transaction_id: The identifier of a transaction that belongs to the customer, and which may be an original transaction identifier.
807+
808+
:param any_transaction_id: Any transactionId, originalTransactionId, or appTransactionId that belongs to the customer for your app.
809809
:param status: An optional filter that indicates the status of subscriptions to include in the response. Your query may specify more than one status query parameter.
810810
:return: A response that contains status information for all of a customer's auto-renewable subscriptions in your app.
811811
:throws APIException: If a response was returned indicating the request could not be processed
812812
"""
813813
queryParameters: Dict[str, List[str]] = dict()
814814
if status is not None:
815815
queryParameters["status"] = [s.value for s in status]
816-
817-
return self._make_request(f"/inApps/v1/subscriptions/{transaction_id}", "GET", queryParameters, None, StatusResponse, None)
816+
817+
return self._make_request(f"/inApps/v1/subscriptions/{any_transaction_id}", "GET", queryParameters, None, StatusResponse, None)
818818

819-
def get_refund_history(self, transaction_id: str, revision: Optional[str]) -> RefundHistoryResponse:
819+
def get_refund_history(self, any_transaction_id: str, revision: Optional[str]) -> RefundHistoryResponse:
820820
"""
821821
Get a paginated list of all of a customer's refunded in-app purchases for your app.
822822
https://developer.apple.com/documentation/appstoreserverapi/get_refund_history
823823
824-
:param transaction_id: The identifier of a transaction that belongs to the customer, and which may be an original transaction identifier.
824+
:param any_transaction_id: Any transactionId, originalTransactionId, or appTransactionId that belongs to the customer for your app.
825825
:param revision: A token you provide to get the next set of up to 20 transactions. All responses include a revision token. Use the revision token from the previous RefundHistoryResponse.
826826
:return: A response that contains status information for all of a customer's auto-renewable subscriptions in your app.
827827
:throws APIException: If a response was returned indicating the request could not be processed
@@ -830,8 +830,8 @@ def get_refund_history(self, transaction_id: str, revision: Optional[str]) -> Re
830830
queryParameters: Dict[str, List[str]] = dict()
831831
if revision is not None:
832832
queryParameters["revision"] = [revision]
833-
834-
return self._make_request(f"/inApps/v2/refund/lookup/{transaction_id}", "GET", queryParameters, None, RefundHistoryResponse, None)
833+
834+
return self._make_request(f"/inApps/v2/refund/lookup/{any_transaction_id}", "GET", queryParameters, None, RefundHistoryResponse, None)
835835

836836
def get_status_of_subscription_renewal_date_extensions(self, request_identifier: str, product_id: str) -> MassExtendRenewalDateStatusResponse:
837837
"""
@@ -872,12 +872,12 @@ def get_notification_history(self, pagination_token: Optional[str], notification
872872

873873
return self._make_request("/inApps/v1/notifications/history", "POST", queryParameters, notification_history_request, NotificationHistoryResponse, None)
874874

875-
def get_transaction_history(self, transaction_id: str, revision: Optional[str], transaction_history_request: TransactionHistoryRequest, version: GetTransactionHistoryVersion = GetTransactionHistoryVersion.V1) -> HistoryResponse:
875+
def get_transaction_history(self, any_transaction_id: str, revision: Optional[str], transaction_history_request: TransactionHistoryRequest, version: GetTransactionHistoryVersion = GetTransactionHistoryVersion.V1) -> HistoryResponse:
876876
"""
877877
Get a customer's in-app purchase transaction history for your app.
878878
https://developer.apple.com/documentation/appstoreserverapi/get_transaction_history
879879
880-
:param transaction_id: The identifier of a transaction that belongs to the customer, and which may be an original transaction identifier.
880+
:param any_transaction_id: Any transactionId, originalTransactionId, or appTransactionId that belongs to the customer for your app.
881881
:param revision: A token you provide to get the next set of up to 20 transactions. All responses include a revision token. Note: For requests that use the revision token, include the same query parameters from the initial request. Use the revision token from the previous HistoryResponse.
882882
:param transaction_history_request: The request parameters that includes the startDate,endDate,productIds,productTypes and optional query constraints.
883883
:param version: The version of the Get Transaction History endpoint to use. V2 is recommended.
@@ -912,8 +912,8 @@ def get_transaction_history(self, transaction_id: str, revision: Optional[str],
912912
if transaction_history_request.revoked is not None:
913913
queryParameters["revoked"] = [str(transaction_history_request.revoked)]
914914

915-
return self._make_request("/inApps/{}/history/{}".format(version.value, transaction_id), "GET", queryParameters, None, HistoryResponse, None)
916-
915+
return self._make_request("/inApps/{}/history/{}".format(version.value, any_transaction_id), "GET", queryParameters, None, HistoryResponse, None)
916+
917917
def get_transaction_info(self, transaction_id: str) -> TransactionInfoResponse:
918918
"""
919919
Get information about a single transaction for your app.
@@ -1135,16 +1135,26 @@ def get_performance_test_results(self, request_id: str) -> PerformanceTestResult
11351135
"""
11361136
return self._make_request(f"/inApps/v1/messaging/performanceTest/result/{request_id}", "GET", {}, None, PerformanceTestResultResponse, None)
11371137

1138-
def get_app_transaction_info(self, transaction_id: str) -> AppTransactionInfoResponse:
1138+
def get_app_transaction_info(self, any_transaction_id: str) -> AppTransactionInfoResponse:
11391139
"""
11401140
Get a customer's app transaction information for your app.
1141-
1142-
:param transaction_id Any originalTransactionId, transactionId or appTransactionId that belongs to the customer for your app.
1141+
1142+
:param any_transaction_id: Any transactionId, originalTransactionId, or appTransactionId that belongs to the customer for your app.
11431143
:return: A response that contains signed app transaction information for a customer.
11441144
:raises APIException: If a response was returned indicating the request could not be processed
11451145
:see: https://developer.apple.com/documentation/appstoreserverapi/get-app-transaction-info
11461146
"""
1147-
return self._make_request(f"/inApps/v1/transactions/appTransactions/{transaction_id}", "GET", {}, None, AppTransactionInfoResponse, None)
1147+
return self._make_request(f"/inApps/v1/transactions/appTransactions/{any_transaction_id}", "GET", {}, None, AppTransactionInfoResponse, None)
1148+
1149+
def finish_transaction(self, transaction_id: str):
1150+
"""
1151+
Notifies the App Store server that your system has finished processing the customer's transaction.
1152+
https://developer.apple.com/documentation/appstoreserverapi/finish-transaction
1153+
1154+
:param transaction_id The transaction identifier of the transaction to mark as finished.
1155+
:raises APIException: If a response was returned indicating the request could not be processed
1156+
"""
1157+
self._make_request(f"/inApps/v1/transactions/{transaction_id}/finish", "POST", {}, None, None, None)
11481158

11491159
class AsyncAppStoreServerAPIClient(BaseAppStoreServerAPIClient):
11501160
def __init__(self, signing_key: bytes, key_id: str, issuer_id: str, bundle_id: str, environment: Environment):
@@ -1200,28 +1210,28 @@ async def extend_subscription_renewal_date(self, original_transaction_id: str, e
12001210
"""
12011211
return await self._make_request(f"/inApps/v1/subscriptions/extend/{original_transaction_id}", "PUT", {}, extend_renewal_date_request, ExtendRenewalDateResponse, None)
12021212

1203-
async def get_all_subscription_statuses(self, transaction_id: str, status: Optional[List[Status]] = None) -> StatusResponse:
1213+
async def get_all_subscription_statuses(self, any_transaction_id: str, status: Optional[List[Status]] = None) -> StatusResponse:
12041214
"""
12051215
Get the statuses for all of a customer's auto-renewable subscriptions in your app.
12061216
https://developer.apple.com/documentation/appstoreserverapi/get_all_subscription_statuses
1207-
1208-
:param transaction_id: The identifier of a transaction that belongs to the customer, and which may be an original transaction identifier.
1217+
1218+
:param any_transaction_id: Any transactionId, originalTransactionId, or appTransactionId that belongs to the customer for your app.
12091219
:param status: An optional filter that indicates the status of subscriptions to include in the response. Your query may specify more than one status query parameter.
12101220
:return: A response that contains status information for all of a customer's auto-renewable subscriptions in your app.
12111221
:throws APIException: If a response was returned indicating the request could not be processed
12121222
"""
12131223
queryParameters: Dict[str, List[str]] = dict()
12141224
if status is not None:
12151225
queryParameters["status"] = [s.value for s in status]
1216-
1217-
return await self._make_request(f"/inApps/v1/subscriptions/{transaction_id}", "GET", queryParameters, None, StatusResponse, None)
1226+
1227+
return await self._make_request(f"/inApps/v1/subscriptions/{any_transaction_id}", "GET", queryParameters, None, StatusResponse, None)
12181228

1219-
async def get_refund_history(self, transaction_id: str, revision: Optional[str]) -> RefundHistoryResponse:
1229+
async def get_refund_history(self, any_transaction_id: str, revision: Optional[str]) -> RefundHistoryResponse:
12201230
"""
12211231
Get a paginated list of all of a customer's refunded in-app purchases for your app.
12221232
https://developer.apple.com/documentation/appstoreserverapi/get_refund_history
12231233
1224-
:param transaction_id: The identifier of a transaction that belongs to the customer, and which may be an original transaction identifier.
1234+
:param any_transaction_id: Any transactionId, originalTransactionId, or appTransactionId that belongs to the customer for your app.
12251235
:param revision: A token you provide to get the next set of up to 20 transactions. All responses include a revision token. Use the revision token from the previous RefundHistoryResponse.
12261236
:return: A response that contains status information for all of a customer's auto-renewable subscriptions in your app.
12271237
:throws APIException: If a response was returned indicating the request could not be processed
@@ -1230,8 +1240,8 @@ async def get_refund_history(self, transaction_id: str, revision: Optional[str])
12301240
queryParameters: Dict[str, List[str]] = dict()
12311241
if revision is not None:
12321242
queryParameters["revision"] = [revision]
1233-
1234-
return await self._make_request(f"/inApps/v2/refund/lookup/{transaction_id}", "GET", queryParameters, None, RefundHistoryResponse, None)
1243+
1244+
return await self._make_request(f"/inApps/v2/refund/lookup/{any_transaction_id}", "GET", queryParameters, None, RefundHistoryResponse, None)
12351245

12361246
async def get_status_of_subscription_renewal_date_extensions(self, request_identifier: str, product_id: str) -> MassExtendRenewalDateStatusResponse:
12371247
"""
@@ -1272,12 +1282,12 @@ async def get_notification_history(self, pagination_token: Optional[str], notifi
12721282

12731283
return await self._make_request("/inApps/v1/notifications/history", "POST", queryParameters, notification_history_request, NotificationHistoryResponse, None)
12741284

1275-
async def get_transaction_history(self, transaction_id: str, revision: Optional[str], transaction_history_request: TransactionHistoryRequest, version: GetTransactionHistoryVersion = GetTransactionHistoryVersion.V1) -> HistoryResponse:
1285+
async def get_transaction_history(self, any_transaction_id: str, revision: Optional[str], transaction_history_request: TransactionHistoryRequest, version: GetTransactionHistoryVersion = GetTransactionHistoryVersion.V1) -> HistoryResponse:
12761286
"""
12771287
Get a customer's in-app purchase transaction history for your app.
12781288
https://developer.apple.com/documentation/appstoreserverapi/get_transaction_history
12791289
1280-
:param transaction_id: The identifier of a transaction that belongs to the customer, and which may be an original transaction identifier.
1290+
:param any_transaction_id: Any transactionId, originalTransactionId, or appTransactionId that belongs to the customer for your app.
12811291
:param revision: A token you provide to get the next set of up to 20 transactions. All responses include a revision token. Note: For requests that use the revision token, include the same query parameters from the initial request. Use the revision token from the previous HistoryResponse.
12821292
:param transaction_history_request: The request parameters that includes the startDate,endDate,productIds,productTypes and optional query constraints.
12831293
:param version: The version of the Get Transaction History endpoint to use. V2 is recommended.
@@ -1312,8 +1322,8 @@ async def get_transaction_history(self, transaction_id: str, revision: Optional[
13121322
if transaction_history_request.revoked is not None:
13131323
queryParameters["revoked"] = [str(transaction_history_request.revoked)]
13141324

1315-
return await self._make_request("/inApps/" + version + "/history/" + transaction_id, "GET", queryParameters, None, HistoryResponse, None)
1316-
1325+
return await self._make_request("/inApps/" + version + "/history/" + any_transaction_id, "GET", queryParameters, None, HistoryResponse, None)
1326+
13171327
async def get_transaction_info(self, transaction_id: str) -> TransactionInfoResponse:
13181328
"""
13191329
Get information about a single transaction for your app.
@@ -1534,14 +1544,24 @@ async def get_performance_test_results(self, request_id: str) -> PerformanceTest
15341544
"""
15351545
return await self._make_request(f"/inApps/v1/messaging/performanceTest/result/{request_id}", "GET", {}, None, PerformanceTestResultResponse, None)
15361546

1537-
async def get_app_transaction_info(self, transaction_id: str) -> AppTransactionInfoResponse:
1547+
async def get_app_transaction_info(self, any_transaction_id: str) -> AppTransactionInfoResponse:
15381548
"""
15391549
Get a customer's app transaction information for your app.
1540-
1541-
:param transaction_id Any originalTransactionId, transactionId or appTransactionId that belongs to the customer for your app.
1550+
1551+
:param any_transaction_id: Any transactionId, originalTransactionId, or appTransactionId that belongs to the customer for your app.
15421552
:return: A response that contains signed app transaction information for a customer.
15431553
:raises APIException: If a response was returned indicating the request could not be processed
15441554
:see: https://developer.apple.com/documentation/appstoreserverapi/get-app-transaction-info
15451555
"""
1546-
return await self._make_request(f"/inApps/v1/transactions/appTransactions/{transaction_id}", "GET", {}, None, AppTransactionInfoResponse, None)
1556+
return await self._make_request(f"/inApps/v1/transactions/appTransactions/{any_transaction_id}", "GET", {}, None, AppTransactionInfoResponse, None)
1557+
1558+
async def finish_transaction(self, transaction_id: str):
1559+
"""
1560+
Notifies the App Store server that your system has finished processing the customer's transaction.
1561+
https://developer.apple.com/documentation/appstoreserverapi/finish-transaction
1562+
1563+
:param transaction_id The transaction identifier of the transaction to mark as finished.
1564+
:raises APIException: If a response was returned indicating the request could not be processed
1565+
"""
1566+
await self._make_request(f"/inApps/v1/transactions/{transaction_id}/finish", "POST", {}, None, None, None)
15471567

tests/test_api_client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,14 @@ def test_get_app_transaction_info_transaction_id_not_found(self):
858858

859859
self.assertFalse(True)
860860

861+
def test_finish_transaction(self):
862+
client = self.get_client_with_body(b'',
863+
'POST',
864+
'https://local-testing-base-url/inApps/v1/transactions/1234/finish',
865+
{},
866+
None)
867+
client.finish_transaction('1234')
868+
861869

862870
def get_signing_key(self):
863871
return read_data_from_binary_file('tests/resources/certs/testSigningKey.p8')

tests/test_api_client_async.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,14 @@ async def test_get_app_transaction_info_transaction_id_not_found(self):
863863

864864
self.assertFalse(True)
865865

866+
async def test_finish_transaction(self):
867+
client = self.get_client_with_body(b'',
868+
'POST',
869+
'https://local-testing-base-url/inApps/v1/transactions/1234/finish',
870+
{},
871+
None)
872+
await client.finish_transaction('1234')
873+
866874
def get_signing_key(self):
867875
return read_data_from_binary_file('tests/resources/certs/testSigningKey.p8')
868876

0 commit comments

Comments
 (0)