package com.sonic.lion.controller.web;

import com.sonic.common.auth.IgnoreAuth;
import com.sonic.common.rpc.Result;
import com.sonic.lion.domain.req.GoogleUploadReceiptReqV2;
import com.sonic.lion.service.WebhookHandlerService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import static com.sonic.common.rpc.Result.success;

/**
 * Google回调
 * @author: code
 */
@Slf4j
@RestController
public class WebhookGoogleController {

    @Autowired
    private WebhookHandlerService webhookHandlerService;

    @IgnoreAuth
    @ApiOperation(value = "Google前端上传收据", tags = "Google回调")
    @PostMapping("/web/pay/webhooks/google")
    public Result<Void> google(@RequestBody @Validated GoogleUploadReceiptReqV2 req) {
        webhookHandlerService.googleHandler(req);
        return success();
    }

}
