package org.wfc.payment.pay.stripe.controller;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wfc.common.core.domain.R;
import org.wfc.payment.pay.stripe.service.IStripeService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @description: stripe controller
 * @author: cyc
 * @since: 2025-04-24
 */
@RestController
@RequestMapping("/stripe")
public class StripeController {

    @Resource
    private IStripeService stripeService;

    @PostMapping("/pay/{orderId}")
    public R<String> stripePay(@PathVariable Long orderId) {

        return R.ok(stripeService.stripePay(orderId));
    }

    @PostMapping("/callback")
    public String webhook(HttpServletRequest request, HttpServletResponse response) {
        String result = stripeService.webhook(request, response);
        return result;
    }
}
