syntax = "v1"

info (
	title:   "支付服务"
	desc:    "支付服务"
	version: "v1"
)

@server (
	prefix: api/v1
	group:  pay
)
service main {
	// 微信支付回调
	@handler WechatPayCallback
	post /pay/wechat/callback

	// 支付宝支付回调
	@handler AlipayCallback
	post /pay/alipay/callback

	// 微信退款回调
	@handler WechatPayRefundCallback
	post /pay/wechat/refund_callback
}

@server (
	prefix: api/v1
	group:  pay
	jwt:    JwtAuth
	middleware: UserAuthInterceptor

)
service main {
	// 支付
	@handler Payment
	post /pay/payment (PaymentReq) returns (PaymentResp)

	@handler IapCallback
	post /pay/iap_callback (IapCallbackReq)

	@handler PaymentCheck
	post /pay/check (PaymentCheckReq) returns (PaymentCheckResp)
}

type (
	PaymentReq {
		Id        string `json:"id"`
		PayMethod string `json:"pay_method"`
		PayType   string `json:"pay_type" validate:"required,oneof=query agent_vip"`
	}
	PaymentResp {
		PrepayData interface{} `json:"prepay_data"`
		PrepayId   string      `json:"prepay_id"`
		OrderNo    string      `json:"order_no"`
	}
	PaymentCheckReq {
		OrderNo string `json:"order_no" validate:"required"`
	}
	PaymentCheckResp {
		Type   string `json:"type"`
		Status string `json:"status"`
	}
)

type (
	IapCallbackReq {
		OrderID            int64  `json:"order_id" validate:"required"`
		TransactionReceipt string `json:"transaction_receipt" validate:"required"`
	}
)