|
@@ -4,6 +4,8 @@
|
|
|
import logging
|
|
|
import time
|
|
|
import json
|
|
|
+
|
|
|
+import requests
|
|
|
from appstoreserverlibrary.api_client import AppStoreServerAPIClient, GetTransactionHistoryVersion
|
|
|
from appstoreserverlibrary.models.Environment import Environment
|
|
|
from appstoreserverlibrary.receipt_utility import ReceiptUtility
|
|
@@ -18,7 +20,7 @@ from django.db.models import Q
|
|
|
from django.views import View
|
|
|
from django.http import HttpResponse
|
|
|
|
|
|
-from Ansjer.config import LOGGER, CONFIG_INFO, CONFIG_TEST, PAY_TYPE_IN_APP_PURCHASE, BASE_DIR
|
|
|
+from Ansjer.config import LOGGER, CONFIG_INFO, CONFIG_TEST, PAY_TYPE_IN_APP_PURCHASE, BASE_DIR, CONFIG_US
|
|
|
from Controller.CheckUserData import DataValid
|
|
|
from Model.models import Order_Model, Store_Meal, Device_Info, UID_Bucket, Unused_Uid_Meal, AiService, Device_User, \
|
|
|
SysMsgModel
|
|
@@ -306,6 +308,7 @@ class InAppPurchaseView(View):
|
|
|
root_certificates, enable_online_checks, environment, bundle_id, app_apple_id)
|
|
|
decoded_payload = verifier.verify_and_decode_notification(signed_payload)
|
|
|
logger.info('App Store服务器通知decoded_payload: {}'.format(decoded_payload))
|
|
|
+ status_code = 200
|
|
|
if str(decoded_payload.rawNotificationType) == "REFUND":
|
|
|
# 一种通知类型,表示 App Store 成功退还了消耗性应用内购买、非消耗性应用内购买、自动续订或不可续订的交易。
|
|
|
# revocationDate 包含退款交易的时间戳。originalTransactionId 和 productId 用于标识原始交易和产品。revocationReason 包含原因。
|
|
@@ -340,9 +343,12 @@ class InAppPurchaseView(View):
|
|
|
LOGGER.info(f'App Store服务器通知用户退款, 关闭AI:{req_success}')
|
|
|
|
|
|
# 4.发送邮件告知用户退款
|
|
|
- email_content = f'用户{user_id}, 订单:{orderID}, 设备{uid}退款'
|
|
|
+ email_content = f'{CONFIG_INFO}用户{user_id}, 订单:{orderID}, 设备{uid}退款'
|
|
|
+ S3Email().faEmail(email_content, 'servers@ansjer.com')
|
|
|
else:
|
|
|
- email_content = f'transaction_id:{transaction_id}退款, 未查询到订单'
|
|
|
- S3Email().faEmail(email_content, 'servers@ansjer.com')
|
|
|
+ if CONFIG_INFO == CONFIG_US:
|
|
|
+ url = "https://api.zositeche.com/inAppPurchase/AppStoreServerNotifications"
|
|
|
+ eur_response = requests.post(url=url, json=json.loads(request.body))
|
|
|
+ status_code = eur_response.status_code
|
|
|
|
|
|
- return HttpResponse(status=200)
|
|
|
+ return HttpResponse(status=status_code)
|