Jelajahi Sumber

App Store服务器通知 - 用户取消订阅

linhaohong 1 tahun lalu
induk
melakukan
ea62433cda
1 mengubah file dengan 9 tambahan dan 0 penghapusan
  1. 9 0
      Controller/InAppPurchaseController.py

+ 9 - 0
Controller/InAppPurchaseController.py

@@ -476,6 +476,15 @@ class InAppPurchaseView(View):
                 # 一种通知类型,指示客户发起了消费型 App 内购买项目或自动续期订阅的退款请求,并且 App Store 要求您提供消费数据。有关详细信息,请参阅发送消耗信息。
                 pass
 
+            elif str(decoded_payload.rawNotificationType) == "DID_CHANGE_RENEWAL_STATUS":
+                if decoded_payload.rawSubtype == "AUTO_RENEW_DISABLED":
+                    # 自动续订被禁用
+                    decoded_transaction_information = verifier.verify_and_decode_signed_transaction(
+                        decoded_payload.data.signedTransactionInfo)
+                    original_transaction_id = decoded_transaction_information.originalTransactionId
+                    if original_transaction_id:
+                        DeviceApplePackage.objects.filter(original_transaction_id=original_transaction_id).update(
+                            subscription_status=0)
             else:
                 logger.info(f"App Store服务器通知decoded_payload.rawNotificationType 未处理")
                 return HttpResponse(status=500)