feat(apple): 新增苹果订阅通知接口并补充测试
- AppleReceiptController 新增 /apple/notification 端点,用于接收苹果服务器通知 - 调整路径前缀为 /apple,开放 /apple/receipt 与 /apple/notification 免登录
This commit is contained in:
@@ -98,7 +98,9 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
"/products/detail",
|
||||
"/products/inApp/list",
|
||||
"/products/subscription/list",
|
||||
"/purchase/handle"
|
||||
"/purchase/handle",
|
||||
"/apple/notification",
|
||||
"/apple/receipt"
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,15 +8,18 @@ import com.yolo.keyborad.exception.BusinessException;
|
||||
import com.yolo.keyborad.model.dto.AppleReceiptValidationResult;
|
||||
import com.yolo.keyborad.service.ApplePurchaseService;
|
||||
import com.yolo.keyborad.service.AppleReceiptService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/apple")
|
||||
@RequestMapping("/apple")
|
||||
@Slf4j
|
||||
public class AppleReceiptController {
|
||||
|
||||
private final AppleReceiptService appleReceiptService;
|
||||
@@ -28,11 +31,11 @@ public class AppleReceiptController {
|
||||
this.applePurchaseService = applePurchaseService;
|
||||
}
|
||||
|
||||
// @PostMapping("/validate-receipt")
|
||||
// public AppleReceiptValidationResult validateReceipt(@RequestBody Map<String, String> body) {
|
||||
// String receipt = body.get("receipt");
|
||||
// return appleReceiptService.validateReceipt(receipt);
|
||||
// }
|
||||
@PostMapping("/receipt")
|
||||
public AppleReceiptValidationResult validateReceipt(@RequestBody Map<String, String> body) {
|
||||
String receipt = body.get("receipt");
|
||||
return appleReceiptService.validateReceipt(receipt);
|
||||
}
|
||||
|
||||
@PostMapping("/validate-receipt")
|
||||
public BaseResponse<Boolean> handlePurchase(@RequestBody Map<String, String> body) {
|
||||
@@ -46,6 +49,11 @@ public class AppleReceiptController {
|
||||
return ResultUtils.success(Boolean.TRUE);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/notification")
|
||||
public BaseResponse<Boolean> receiveNotification(@RequestBody Map<String, Object> body, HttpServletRequest request) {
|
||||
log.info(request.getQueryString());
|
||||
log.info("Apple server notification: {}", body);
|
||||
return ResultUtils.success(Boolean.TRUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user