refactor(service): 改用JWS验签,移除旧收据解析

废弃ReceiptUtility与AppStoreServerAPIClient,直接以SignedDataVerifier校验客户端传来的signedPayload(JWS),简化流程并减少一次网络IO。
This commit is contained in:
2025-12-16 15:06:41 +08:00
parent c305dfaae4
commit c54c14de58
3 changed files with 33 additions and 72 deletions

View File

@@ -62,12 +62,12 @@ public class AppleReceiptController {
if (body == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "body 不能为空");
}
String receipt = body.get("receipt");
if (receipt == null || receipt.isBlank()) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "receipt 不能为空");
String signedPayload = body.get("signedPayload");
if (signedPayload == null || signedPayload.isBlank()) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "signedPayload 不能为空");
}
Long userId = StpUtil.getLoginIdAsLong();
AppleReceiptValidationResult validationResult = appleReceiptService.validateReceipt(receipt);
AppleReceiptValidationResult validationResult = appleReceiptService.validateReceipt(signedPayload);
applePurchaseService.processPurchase(userId, validationResult);
return ResultUtils.success(Boolean.TRUE);
}