/*
 * Copyright (c) 2018-2999 广州亚米信息科技有限公司 All rights reserved.
 *
 * https://www.gz-yami.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */

package com.yami.shop.service;

import com.alipay.api.AlipayApiException;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.yami.shop.bean.bo.PayInfoBo;
import com.yami.shop.bean.bo.RefundInfoBo;
import com.yami.shop.bean.pay.PayInfoDto;
import com.yami.shop.bean.pay.RefundInfoDto;
import com.yami.shop.common.enums.PayType;
import org.springframework.http.ResponseEntity;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

/**
 * 支付相关
 */
public interface PayManagerService {


	/**
	 * 进行支付
	 * @param httpResponse
	 * @param payInfo
	 * @return
	 * @throws WxPayException
	 * @throws IOException
	 */
	ResponseEntity<?> doPay(HttpServletResponse httpResponse, PayInfoDto payInfo) throws WxPayException, IOException, AlipayApiException;


	/**
	 * 校验支付结果，并返回支付单号
	 * @param request
	 * @param payType
	 * @param xmlData
	 * @return
	 * @throws UnsupportedEncodingException
	 * @throws WxPayException
	 * @throws AlipayApiException
	 */
	PayInfoBo validateAndGetPayInfo(HttpServletRequest request, PayType payType, String xmlData) throws UnsupportedEncodingException, WxPayException, AlipayApiException;


	/**
	 * 主动查单，看看订单是否已经支付
	 * @param payNo 支付单号
	 * @return
	 */
	PayInfoBo getPayInfo(PayType payType,String payNo);


	/**
	 * 退款
	 */
	boolean doRefund(RefundInfoDto refundInfo);



	/**
	 * 校验支付结果，并返回支付单号
	 * @param request
	 * @param payType
	 * @param xmlData
	 * @return
	 * @throws UnsupportedEncodingException
	 * @throws WxPayException
	 * @throws AlipayApiException
	 */
	RefundInfoBo validateAndGetRefundInfo(HttpServletRequest request, PayType payType, String xmlData) throws UnsupportedEncodingException, WxPayException, AlipayApiException;

}
