refactor(service): 改用JWS验签,移除旧收据解析
废弃ReceiptUtility与AppStoreServerAPIClient,直接以SignedDataVerifier校验客户端传来的signedPayload(JWS),简化流程并减少一次网络IO。
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user