|
@@ -8,7 +8,7 @@ import threading
|
|
|
|
|
|
import requests
|
|
import requests
|
|
from appstoreserverlibrary.models.Environment import Environment
|
|
from appstoreserverlibrary.models.Environment import Environment
|
|
-from appstoreserverlibrary.api_client import AppStoreServerAPIClient, GetTransactionHistoryVersion
|
|
|
|
|
|
+from appstoreserverlibrary.api_client import AppStoreServerAPIClient, GetTransactionHistoryVersion, APIException
|
|
from appstoreserverlibrary.models.AccountTenure import AccountTenure
|
|
from appstoreserverlibrary.models.AccountTenure import AccountTenure
|
|
from appstoreserverlibrary.models.ConsumptionRequest import ConsumptionRequest
|
|
from appstoreserverlibrary.models.ConsumptionRequest import ConsumptionRequest
|
|
from appstoreserverlibrary.models.ConsumptionStatus import ConsumptionStatus
|
|
from appstoreserverlibrary.models.ConsumptionStatus import ConsumptionStatus
|
|
@@ -153,22 +153,15 @@ class InAppPurchaseView(View):
|
|
access_result="SUCCESS")
|
|
access_result="SUCCESS")
|
|
|
|
|
|
# 查询交易信息
|
|
# 查询交易信息
|
|
- transaction_info = ""
|
|
|
|
- attempts = 0
|
|
|
|
- while attempts < 6:
|
|
|
|
- try:
|
|
|
|
- transaction_info = client.get_transaction_info(transaction_id)
|
|
|
|
- break
|
|
|
|
- except ConnectionError as err:
|
|
|
|
- attempts += 1
|
|
|
|
- if attempts == 5:
|
|
|
|
- OrderPayLog.objects.create(order_id=order_id, order_no=transaction_id,
|
|
|
|
- business_name=f"{order_id}获取transactionInfo超时",
|
|
|
|
- created_time=int(time.time()), updated_time=int(time.time()),
|
|
|
|
- access_result="ERROR")
|
|
|
|
- return response.json(5)
|
|
|
|
- logger.info(
|
|
|
|
- f"订单orderId:{order_id}, transaction_id:{transaction_id}, 第{attempts}次获取支付信息超时")
|
|
|
|
|
|
+ try:
|
|
|
|
+ transaction_info = client.get_transaction_info(transaction_id)
|
|
|
|
+ except APIException:
|
|
|
|
+ in_app_purchase = InAppPurchase(bundle_id=bundle_id, user_id=user_id)
|
|
|
|
+ # AppStoreServerAPIClient 用于查询交易信息
|
|
|
|
+ client = in_app_purchase.client
|
|
|
|
+ # SignedDataVerifier 用于解析查询到的交易信息
|
|
|
|
+ signed_data_verifier = in_app_purchase.verifier
|
|
|
|
+ transaction_info = client.get_transaction_info(transaction_id)
|
|
|
|
|
|
signed_transaction_info = transaction_info.signedTransactionInfo
|
|
signed_transaction_info = transaction_info.signedTransactionInfo
|
|
# 解析交易信息
|
|
# 解析交易信息
|