fix: 切换antom支付

This commit is contained in:
周俊耀 2025-04-14 16:12:37 +08:00
parent eae408d711
commit e869c22742
9 changed files with 11484 additions and 1 deletions

8719
api/payment/payment.pb.go Normal file

File diff suppressed because it is too large Load Diff

742
api/payment/payment.proto Normal file
View File

@ -0,0 +1,742 @@
syntax = "proto3";
package payment;
option go_package = "./payment";
//import "pb/descriptor.proto";
service Payment{
//
rpc CreatePay(CreatePayRequest) returns (CreatePayResponse); //
rpc NotifyPay(NotifyPayRequest) returns (NotifyPayResponse); //
rpc QueryPayByOutTradeNo(PayQueryRequest) returns (PayQueryResponse);//
rpc QueryExportPay(ExportPayRequest) returns (ExportPayResponse); //
rpc CreateRefund(CreateRefundRequest) returns (CreateRefundResponse); // 退
rpc StripeGermanyWebhook(GetCheckoutWebhookRequest) returns(GetCheckoutWebhookResponse){};// stripe支付回调,
rpc AliCommonWebhook(NotifyPayRequest) returns (NotifyPayResponse){}; //
rpc WechatFengLianWebhook(NotifyPayRequest) returns (NotifyPayResponse){}; //
rpc AntomWebhook(AntomNotifyPayRequest) returns (AntomNotifyPayResponse){}; // Antom支付回调
rpc QueryAntomPayByCheckoutSessionId(AntomPayQueryRequest) returns (AntomPayQueryResponse){}; // checkoutSessionIds查询支付情况
// ==========
// stripe支付
rpc CreateStripeCheckoutSession(CreateStripeCheckoutSessionRequest) returns (CreateStripeCheckoutSessionResponse){}; //
// rpc CommonCheckoutWebhook(GetCheckoutWebhookRequest) returns(GetCheckoutWebhookResponse){}; // ,
//
rpc AliWapPay(AliWapPayRequest) returns (AliWapPayResponse) {}; // ali网页支付
rpc AliAppPay(AliAppPayRequest) returns (AliAppPayResponse) {}; // aliApp支付
rpc AliNativePay(AliNativePayRequest) returns (AliNativePayResponse) {}; // aliApp当面支付
rpc AliPcWabPay(AliPcWabPayRequest) returns (AliPcWabPayResponse) {}; // ali电脑网页支付
rpc AliReFund(AliReFundRequest) returns (AliReFundResponse) {}; // ali退款
rpc AliNotify(AliNotifyRequest) returns (AliNotifyResponse) {}; // ali回调
rpc AliQueryByOutTradeNo(AliQueryByOutTradeNoRequest) returns (AliQueryByOutTradeNoResponse) {}; // ali查询订单
rpc AliRefundQueryByOutTradeNo(AliRefundQueryByOutTradeNoRequest) returns (AliRefundQueryByOutTradeNoResponse) {}; // ali查询退款订单
//
rpc WechatJsApiPay(WechatJsApiPayRequest) returns (WechatJsApiPayResponse) {}; // jsapi +
rpc WechatJsApiQueryByOutTradeNo(WechatJsApiQueryByOutTradeNoRequest) returns (WechatJsApiQueryByOutTradeNoResponse) {}; // outTrandeNo jsapi
rpc GetPayByOutTradeNo(GetPayByOutTradeNoRequest) returns (GetPayByOutTradeNoResponse) {}; // outTrandeNo id
rpc WechatJsApiRefunds(WechatJsApiRefundsRequest) returns (WechatJsApiRefundsResponse) {}; //
rpc SetPayOk(WechatPayOkRequest) returns (CommonResponse) {}; //
rpc WechatAppPay(WechatAppPayRequest) returns (WechatAppPayResponse) {}; // app +
rpc WechatAppQueryByOutTradeNo(WechatAppQueryByOutTradeNoRequest) returns (WechatAppQueryByOutTradeNoResponse) {}; // outTrandeNo App
rpc WechatNativePay(WechatNativePayRequest) returns (WechatNativePayResponse) {}; // native +
rpc WechatNativeQueryByOutTradeNo(WechatNativeQueryByOutTradeNoRequest) returns (WechatNativeQueryByOutTradeNoResponse) {}; // outTrandeNo App
rpc WechatRefundQueryByOutRefundNo(WechatRefundQueryByOutRefundNoRequest) returns (WechatRefundQueryByOutRefundNoResponse) {}; // wx查询退款订单
rpc WechatH5Pay(WechatH5PayRequest) returns (WechatH5PayResponse) {}; // H5 +
rpc WechatH5QueryByOutTradeNo(WechatH5QueryByOutTradeNoRequest) returns (WechatH5QueryByOutTradeNoResponse) {}; // outTrandeNo H5
}
message AntomPayQueryRequest {
repeated string checkoutSessionIds = 1 [json_name = "checkoutSessionIds"];
}
message AntomPayQueryResponse {
repeated PaymentOrderInfo infos = 1 [json_name = "infos"];
}
message AntomNotifyPayRequest {
string notifyType = 1 [json_name = "notifyType"];
string requestId = 2 [json_name = "requestId"];
string paymentId = 3 [json_name = "paymentId"];
string paymentTime = 4 [json_name = "paymentTime"];
string resultStatus = 5 [json_name = "resultStatus"];
string resultMessage = 6 [json_name = "resultMessage"];
}
message AntomNotifyPayResponse {
string status = 1 [json_name = "status"];
string outTradeNo = 2 [json_name = "outTradeNo"];
}
message CreatePayRequest {
string postUrl = 1 [json_name = "postUrl"]; //
string subject = 2 [json_name = "subject"]; //
string productUUID = 3 [json_name = "productUUID"]; // uid
string productName = 4 [json_name = "productName"]; //
string productImg = 5 [json_name = "productImg"]; //
string productDescription = 6 [json_name = "productDescription"]; //
string quitUrl = 7 [json_name = "quitUrl"]; // 退url
string notifyUrl = 8 [json_name = "notifyUrl"]; // url
string returnUrl = 9 [json_name = "returnUrl"]; // url
string outTradeNo = 10 [json_name = "outTradeNo"]; //
string channelTradeNo = 11 [json_name = "channelTradeNo"]; //
string checkSessionId = 12 [json_name = "checkSessionId"]; // stripe的支付会话id
int64 amount = 13 [json_name = "amount"]; //
string currency = 14 [json_name = "currency"]; //
string payee = 15 [json_name = "payee"]; //
string channelType = 16 [json_name = "channelType"]; // alipay- wxpay- stripe-Stripe支付
string platform = 17 [json_name = "platform"]; // app还是h5还是jsapi还是wap
string domain = 18 [json_name = "domain"]; // 使
string businessType = 19 [json_name = "businessType"]; // mq发送
string language = 20 [json_name = "language"]; //
string clientIp = 21 [json_name = "clientIp"];
string openID = 22 [json_name = "openID"]; //
int32 timeExpire = 23 [json_name = "timeExpire"]; //
string locale = 24 [json_name = "locale"]; // stripe参数
}
message CreatePayResponse {
string url = 1 [json_name = "url"];
string logRecordID = 2 [json_name = "log_record_ID"];
string msg = 3 [json_name="msg"];
string appid = 4 [json_name = "appid"];
string timeStamp = 5 [json_name = "timeStamp"];
string package = 6 [json_name = "package"];
string signType = 7 [json_name = "signType"];
string nonceStr = 8 [json_name = "nonceStr"];
string paySign = 9 [json_name = "paySign"];
string prepayId = 10 [json_name = "prepayId"];
string partnerId = 11 [json_name = "partnerId"];
string checkoutSessionId = 12 [json_name = "checkoutSessionId"];
}
message CreateRefundRequest {
string postUrl = 1 [json_name = "postUrl"]; //
string subject = 2 [json_name = "subject"]; //
string productUUID = 3 [json_name = "productUUID"]; // uid
string outTradeNo = 4 [json_name = "outTradeNo"]; //
string channelTradeNo = 5 [json_name = "channelTradeNo"]; //
string checkSessionId = 6 [json_name = "checkSessionId"]; // stripe的支付会话id
int64 refundAmount = 7 [json_name = "refundAmount"]; // 退
string currency = 8 [json_name = "currency"]; //
string payee = 9 [json_name = "payee"]; //
string channelType = 10 [json_name = "channelType"]; // alipay- wxpay- stripe-Stripe支付
string platform = 11 [json_name = "platform"]; // app还是h5还是jsapi还是wap
string domain = 12 [json_name = "domain"]; // 使
string businessType = 13 [json_name = "businessType"]; // mq发送
string language = 14 [json_name = "language"]; //
string clientIp = 15 [json_name = "clientIp"];
string openID = 16 [json_name = "openID"]; //
int64 creatorId = 17 [json_name = "creatorId"]; // id
string creatorName = 18 [json_name = "creatorName"]; //
string refundReason = 19 [json_name = "refundReason"]; // 退
}
message CreateRefundResponse {
int64 code = 1 [json_name = "code"];
string msg = 2 [json_name="msg"];
}
message NotifyPayRequest {
string postUrl = 1; //
HttpRequest http_request = 2;
string rawQuery = 3 [json_name="raw_query"];
}
message NotifyPayResponse {
string msg = 1;
string outTradeNo = 2;
}
message HttpRequest {
string method = 1;
string url = 2;
map<string, string> headers = 3;
bytes body = 4;
}
message CommonMsg{
string msg = 1;
}
message EmptyRequest{}
message CreateStripeCheckoutSessionRequest {
string productUUID = 1 [json_name = "productUUID"];
string productName = 2 [json_name = "productName"];
int64 productQuantity = 3 [json_name = "productQuantity"];
int64 productAllPrice = 4 [json_name = "productAllPrice"];
string productDescription = 5 [json_name = "productDescription"];
string productImageUrl = 6 [json_name = "productImageUrl"];
string productPriceCurrency = 7 [json_name = "productPriceCurrency"];
string createrID = 8 [json_name = "createrID"];
string createrName = 9 [json_name = "createrName"];
string domain = 10 [json_name = "domain"];
string successUrl = 11 [json_name = "successUrl"];
string cancelUrl = 12 [json_name = "cancelUrl"];
string outTradeNo = 13 [json_name = "outTradeNo"];
string locale = 14 [json_name = "locale"];
}
message CreateStripeCheckoutSessionResponse {
string checkoutSessionId = 1 [json_name = "checkoutSessionId"];
string checkoutSessionUrl = 2 [json_name = "checkoutSessionUrl"];
}
message GetCheckoutWebhookRequest {
string postUrl = 1; //
string type = 2; // "payment_intent.succeeded"
string payload = 3; // JSON payload
string signature = 4; // Stripe-Signature头的值
string webhookKey = 5; // Webhook密钥
}
message GetCheckoutWebhookResponse {
bool success = 1; //
string message = 2; //
string outTradeNo = 3 [json_name = "outTradeNo"];
string paymentIntentStatus = 4 [json_name = "paymentIntentStatus"];
}
message GetStripePaymentIntentInfoRequest {
string checkoutSessionId = 1 [json_name = "checkoutSessionId"];
string createrID = 2 [json_name = "createrID"];
}
message GetStripePaymentIntentInfoResponse {
string checkoutSessionId = 1 [json_name = "checkoutSessionId"];
string checkoutSessionStatus = 2 [json_name = "checkoutSessionStatus"];
string paymentIntentId = 3 [json_name = "paymentIntentId"];
string paymentIntentCreated = 4 [json_name = "paymentIntentCreated"];
string paymentIntentStatus = 5 [json_name = "paymentIntentStatus"];
string chargeId = 6 [json_name = "chargeId"];
int64 payPrice = 7 [json_name = "payPrice"];
string payExchangeRate = 8 [json_name = "payExchangeRate"];
string payCurrency = 9 [json_name = "payCurrency"];
string accountCurrency = 10 [json_name = "accountCurrency"];
int64 afterRatePayPrice = 11 [json_name = "afterRatePayPrice"];
int64 payHandingFee = 12 [json_name = "payHandingFee"];
int64 afterRatePayNetAmount = 13 [json_name = "afterRatePayNetAmount"];
string customerId = 14 [json_name = "customerId"];
int64 refundPrice = 15 [json_name = "refundPrice"];
string outTradeNo = 16 [json_name = "outTradeNo"];
}
message GetRefundInfoRequest {
string refundId = 1 [json_name = "refundId"];
string createrID = 2 [json_name = "createrID"];
}
message GetRefundInfoResponse {
string refundStatus = 1 [json_name = "refundStatus"];
}
message AliWapPayRequest {
string subject = 1 [json_name = "subject"];
string productCode = 2 [json_name = "product_code"];
string outTradeNo = 3 [json_name = "out_trade_no"];
string quitUrl = 4 [json_name = "quit_url"];
string notifyUrl = 5 [json_name = "notify_url"];
string returnUrl = 6 [json_name = "return_url"];
int32 totalAmount = 7 [json_name = "total_amount"];
int32 timeExpire = 8 [json_name = "time_expire"];
string domain = 9 ;
string platform = 10 ;
}
message AliWapPayResponse {
string url = 1 [json_name = "url"];
string logRecordID = 2 [json_name = "log_record_ID"];
string msg = 3 [json_name="msg"];
}
message AliAppPayRequest {
string subject = 1 [json_name = "subject"];
string productCode = 2 [json_name = "product_code"];
string outTradeNo = 3 [json_name = "out_trade_no"];
string quitUrl = 4 [json_name = "quit_url"];
string notifyUrl = 5 [json_name = "notify_url"];
string returnUrl = 6 [json_name = "return_url"];
string totalAmount = 7 [json_name = "total_amount"];
int32 timeExpire = 8 [json_name = "time_expire"];
string domain = 9 ;
string platform = 10 ;
int32 payType = 11 ;
}
message AliAppPayResponse {
string url = 1 [json_name = "url"];
string logRecordID = 2 [json_name = "log_record_ID"];
string msg = 3 [json_name="msg"];
}
message AliNativePayRequest {
string subject = 1 [json_name = "subject"];
string outTradeNo = 2 [json_name = "out_trade_no"];
string notifyUrl = 3 [json_name = "notify_url"];
int32 totalAmount = 4 [json_name = "total_amount"];
int32 timeExpire = 5 [json_name = "time_expire"];
string domain = 6 [json_name = "domain"];
string platform = 7 [json_name = "platform"];
}
message AliNativePayResponse {
string url = 1 [json_name = "url"];
string msg = 2 [json_name="msg"];
}
message AliPcWabPayRequest {
string subject = 1 [json_name = "subject"];
string outTradeNo = 2 [json_name = "out_trade_no"];
string notifyUrl = 3 [json_name = "notify_url"];
int32 totalAmount = 4 [json_name = "total_amount"];
int32 timeExpire = 5 [json_name = "time_expire"];
string domain = 6 [json_name = "domain"];
string platform = 7 [json_name = "platform"];
string quitUrl = 8 [json_name = "quit_url"];
string returnUrl = 9 [json_name = "return_url"];
}
message AliPcWabPayResponse {
string pageRedirectionData = 1 [json_name = "page_redirection_data"];
string msg = 2 [json_name="msg"];
}
message AliReFundRequest {
string outTradeNo = 1 [json_name = "out_trade_no"];
int32 totalAmount = 2 [json_name = "total_amount"];
}
message AliReFundResponse {
string tradeNo = 1 [json_name = "trade_no"];
string outTradeNo = 2 [json_name = "out_trade_no"];
string buyer_logon_id = 3 [json_name = "buyer_logon_id"];
string refund_fee = 4 [json_name = "refund_fee"];
string msg = 5 [json_name="msg"];
}
message AliNotifyRequest {
string rawQuery = 1 [json_name="raw_query"];
}
message AliNotifyResponse {
string notifyTime = 1 [json_name="notify_time"];
string notifyType = 2 [json_name="notify_type"];
string notifyId = 3 [json_name="notify_id"];
string appId = 4 [json_name="app_id"];
string version = 5 [json_name="version"];
string signType = 6 [json_name="sign_type"];
string sign = 7 [json_name="sign"];
string tradeNo = 8 [json_name="trade_no"];
string outTradeNo = 9 [json_name="out_trade_no"] ;
string buyerLogonId = 10 [json_name="buyer_logon_id"] ;
string buyerId = 11 [json_name="buyer_id"] ;
string tradeStatus = 12 [json_name="trade_status"] ;
}
message AliQueryByOutTradeNoRequest {
string outTradeNo = 1 [json_name = "outTradeNo"];
}
message AliQueryByOutTradeNoResponse {
string tradeNo = 1 [json_name = "trade_no"];
string outTradeNo = 2 [json_name = "out_trade_no"];
string buyerLogonId = 3 [json_name = "buyer_logon_id"];
string tradeStatus = 4 [json_name = "trade_status"];
string totalAmount = 5 [json_name = "total_amount"];
string buyerUserID = 6 [json_name = "buyer_user_id"];
}
message AliRefundQueryByOutTradeNoRequest {
string outTradeNo = 1 [json_name = "outTradeNo"];
}
message AliRefundQueryByOutTradeNoResponse {
string tradeNo = 1 [json_name = "trade_no"];
string outTradeNo = 2 [json_name = "out_trade_no"];
string out_request_no = 3 [json_name = "out_request_no"];
string total_amount = 4 [json_name = "total_amount"];
string refund_amount = 5 [json_name = "refund_amount"];
string refund_status = 6 [json_name = "refund_status"];
}
message WechatJsApiPayRequest {
string Description = 1 [json_name = "description"];
string OutTradeNo = 2 [json_name = "outTradeNo"];
int64 Cent = 3 [json_name = "cent"];
string OpenID = 4 [json_name = "openID"];
string NotifyUrl = 5 [json_name = "notifyUrl"];
string AppID = 6 [json_name = "appID"];
string ClientIP = 7 [json_name = "ClientIP"];
uint32 recordId = 9 ;
string domain = 10 ;
string platform = 11 ;
string scene = 12 ;
int32 timeExpire = 13 [json_name = "time_expire"];
}
message WechatJsApiPayResponse {
string Appid = 1 [json_name = "appid"];
string TimeStamp = 2 [json_name = "timeStamp"];
string Package = 3 [json_name = "package"];
string SignType = 4 [json_name = "signType"];
string NonceStr = 5 [json_name = "nonceStr"];
string PaySign = 6 [json_name = "paySign"];
string PrepayId = 7 [json_name = "prepayId"];
}
message WechatAppPayResponse {
string Appid = 1 [json_name = "appid"];
string TimeStamp = 2 [json_name = "timeStamp"];
string Package = 3 [json_name = "package"];
string SignType = 4 [json_name = "signType"];
string NonceStr = 5 [json_name = "nonceStr"];
string PaySign = 6 [json_name = "paySign"];
string PrepayId = 7 [json_name = "prepayId"];
string PartnerId = 8 [json_name = "partnerId"];
string msg = 9 [json_name="msg"];
}
message WechatJsApiQueryByOutTradeNoRequest {
string outTradeNo = 1 [json_name = "outTradeNo"];
}
message WechatJsApiQueryByOutTradeNoResponse {
string appID = 1 [json_name = "appID"];
string mchID = 2 [json_name = "mch_id"];
string outTradeNo = 3 [json_name = "out_trade_no"];
string transactionId = 4 [json_name = "transaction_id"];
string tradeType = 5 [json_name = "trade_type"];
string tradeState = 6 [json_name = "trade_state"];
string bankType = 7 [json_name = "bank_ype"];
string successTime = 8 [json_name = "success_time"];
string openID = 9 [json_name = "open_id"];
int32 total = 10 [json_name = "total"];
}
message WechatAppQueryByOutTradeNoRequest {
string outTradeNo = 1 [json_name = "outTradeNo"];
}
message WechatAppQueryByOutTradeNoResponse {
string appID = 1 [json_name = "appID"];// ID
string mchID = 2 [json_name = "mch_id"];// ID
// string subAppId = 3 [json_name = "sub_appid"]; // ID
// string subMchId = 4 [json_name = "sub_mchid"];// ID
string outTradeNo = 5 [json_name = "out_trade_no"];//
string transactionId = 6 [json_name = "transaction_id"];// ID
string tradeType = 7 [json_name = "trade_type"];//
string tradeState = 8 [json_name = "trade_state"];//
string tradeStateDesc = 9 [json_name = "trade_state_desc"]; //
string bankType = 10 [json_name = "bank_type"]; //
string attach = 11 [json_name = "attach"]; //
string successTime = 12 [json_name = "success_time"];//
message Payer {//
string openid = 1 [json_name = "openid"];
}
message Amount {//
int64 total = 1 [json_name = "total"];//
int64 payerTotal = 2 [json_name = "payer_total"];//
string currency = 3 [json_name = "currency"];//
string payerCurrency = 4 [json_name = "payer_currency"];//
}
message PromotionDetail {//
string couponId = 1 [json_name = "coupon_id"];// ID
string name = 2 [json_name = "name"];//
string scope = 3 [json_name = "scope"];//
string type = 4 [json_name = "type"];//
int64 amount = 5 [json_name = "amount"];//
string stockId = 6 [json_name = "stock_id"];// ID
int64 wechatpayContribute = 7 [json_name = "wechatpay_contribute"];//
int64 merchantContribute = 8 [json_name = "merchant_contribute"];//
int64 otherContribute = 9 [json_name = "other_contribute"];//
string currency = 10 [json_name = "currency"];//
}
//
repeated PromotionDetail promotionDetail = 13 [json_name = "promotion_detail"];
//
Payer payer = 14;
//
Amount amount = 15;
}
message GetPayByOutTradeNoRequest {
string OutTradeNo = 4 [json_name = "OutTradeNo"];
}
message GetPayByOutTradeNoResponse {
string outTradeNo = 1 ;
uint32 recordId = 2 ;
string cent = 3 ;
string platform = 4 ;
string domain = 5 ;
string scene = 6 ;
}
message WechatJsApiRefundsResponse {
string RefundId = 1 [json_name = "RefundId"];
string OutRefundNo = 2 [json_name = "OutRefundNo"];
string TransactionId = 3 [json_name = "TransactionId"];
string OutTradeNo = 4 [json_name = "OutTradeNo"];
string SuccessTime = 5 [json_name = "SuccessTime"];
string CreateTime = 6 [json_name = "CreateTime"];
string Status = 7 [json_name = "Status"];
string Amount = 8 [json_name = "Amount"];
}
message WechatNativePayRequest {
string description = 1 [json_name = "description"];
string outTradeNo = 2 [json_name = "outTradeNo"];
int32 cent = 3 [json_name = "cent"];
string notifyUrl = 5 [json_name = "notifyUrl"];
string appID = 6 [json_name = "appID"];
string clientIP = 7 [json_name = "ClientIP"];
uint32 recordId = 8 ;
string domain = 9 ;
string platform = 10 ;
string scene = 11 ;
int32 timeExpire = 12 [json_name = "time_expire"];
}
message WechatNativePayResponse {
string codeUrl = 1 [json_name = "code_url"];
}
message WechatNativeQueryByOutTradeNoRequest {
string outTradeNo = 1 [json_name = "outTradeNo"];
}
message WechatRefundQueryByOutRefundNoRequest {
string outRefundNo = 1 [json_name = "out_refund_no"];
}
message WechatRefundQueryByOutRefundNoResponse {
string refundId = 1 [json_name = "refund_id"];
string outRefundNo = 2 [json_name = "out_refund_no"];
string transactionId = 3 [json_name = "transaction_id"];
string outTradeNo = 4 [json_name = "out_trade_no"];
string channel = 5 [json_name = "channel"];
string userReceivedAccount = 6 [json_name = "user_received_account"];
string successTime = 7 [json_name = "success_time"];
string createTime = 8 [json_name = "create_time"];
string status = 9 [json_name = "status"];
int32 total = 10 [json_name = "total"];
}
message WechatNativeQueryByOutTradeNoResponse {
string appID = 1 [json_name = "appID"];
string mchID = 2 [json_name = "mch_id"];
string outTradeNo = 3 [json_name = "out_trade_no"];
string transactionId = 4 [json_name = "transaction_id"];
string tradeType = 5 [json_name = "trade_type"];
string tradeState = 6 [json_name = "trade_state"];
string bankType = 7 [json_name = "bank_ype"];
string successTime = 8 [json_name = "success_time"];
string openID = 9 [json_name = "open_id"];
int32 total = 10 [json_name = "total"];
}
message WechatAppPayRequest {
string Description = 1 [json_name = "description"];
string OutTradeNo = 2 [json_name = "outTradeNo"];
int64 Cent = 3 [json_name = "cent"];
string OpenID = 4 [json_name = "openID"];
string NotifyUrl = 5 [json_name = "notifyUrl"];
string AppID = 6 [json_name = "appID"];
string ClientIP = 7 [json_name = "ClientIP"];
uint32 recordId = 9 ;
string domain = 10 ;
string platform = 11 ;
string scene = 12 ;
int32 timeExpire = 13 [json_name = "time_expire"];
}
message WechatJsApiRefundsRequest {
string Reason = 1 [json_name = "Reason"];
string OutTradeNo = 2 [json_name = "OutTradeNo"];
string OutRefundNo = 3 [json_name = "OutRefundNo"];
string NotifyUrl = 4 [json_name = "NotifyUrl"];
int64 Cent = 5 [json_name = "Cent"];
string OpenID = 6 [json_name = "OpenID"];
int64 Total =7[json_name = "Total"];
}
message WechatH5PayRequest {
string Description = 1 [json_name = "description"];
string OutTradeNo = 2 [json_name = "outTradeNo"];
int64 Cent = 3 [json_name = "cent"];
string OpenID = 4 [json_name = "openID"];
string NotifyUrl = 5 [json_name = "notifyUrl"];
string AppID = 6 [json_name = "appID"];
string ClientIP = 7 [json_name = "ClientIP"];
uint32 recordId = 9 ;
string domain = 10 ;
string platform = 11 ;
string scene = 12 ;
int32 timeExpire = 13 [json_name = "time_expire"];
}
message WechatH5PayResponse {
string h5Url = 1 [json_name = "h5_url"];
}
message WechatH5QueryByOutTradeNoRequest {
string outTradeNo = 1 [json_name = "outTradeNo"];
}
message WechatH5QueryByOutTradeNoResponse {
string appID = 1 [json_name = "appID"];
string mchID = 2 [json_name = "mch_id"];
string outTradeNo = 3 [json_name = "out_trade_no"];
string transactionId = 4 [json_name = "transaction_id"];
string tradeType = 5 [json_name = "trade_type"];
string tradeState = 6 [json_name = "trade_state"];
string tradeStateDesc = 7 [json_name = "trade_state_desc"];
string bankType = 8 [json_name = "bank_ype"];
string successTime = 9 [json_name = "success_time"];
string openID = 10 [json_name = "open_id"];
int32 total = 11 [json_name = "total"];
}
message WechatPayOkRequest {
string outTradeNo = 1 ;
string body = 2 ;
}
message CommonResponse {
bool Success = 1 [json_name = "success"];
uint32 ID = 2 ;
}
message PayQueryRequest {
string payType = 1;
string outTradeNo = 2;
}
message PayQueryResponse {
repeated PaymentOrderInfo infos = 1;
}
message PaymentOrderInfo {
int64 id = 1;
string createdAt = 2;
string updatedAt = 3;
string outTradeNo = 4; //
string channelTradeNo = 5; //
int64 amount = 6; //
string currency = 7; //
string status = 8;
string payTime = 9;
string refundTime = 10;
string payee = 11;
string channelType = 12; // alipay- wxpay- stripe-Stripe支付
string platform = 13; // app还是h5还是jsapi还是wap
string domain = 14; // 使
string businessType = 15; // mq发送
int64 logId = 16;
string checkSessionId = 17;
string productUUID = 18;
string productName = 19;
string productImg = 20;
string productDescription = 21;
int64 fee = 22; //
int64 netIncome = 23; // 退
}
message ExportPayRequest {
string startTime = 1; //
string endTime = 2; //
string reportType = 3;
string reportRangeNum = 4; //
string channelType = 5; //
string currency = 6;
string sortBy = 7; // asc,desc
}
message ExportPayResponse {
string reportType = 1; //
int32 orderNum = 2; //
repeated Overview overview = 3; //
repeated ChannelIncome channelIncomes = 4; //
repeated BusinessInfo businessInfos = 5; //
repeated OrderDetail orderDetails = 6; // sheet2,
}
message OrderDetail {
int64 paymentOrderId = 1;
string createdAt = 2;
string updatedAt = 3;
string outTradeNo = 4; //
string channelTradeNo = 5; //
string currency = 6; //
int64 payAmount = 7; //
int64 fee = 8; //
int64 netIncome = 9; //
string status = 10;
string payTime = 11;
string channelType = 12; // alipay- wxpay- stripe-Stripe支付
string platform = 13; // app还是h5还是jsapi还是wap
string domain = 14; // 使
string businessType = 15; // mq发送
int64 logId = 16;
string checkSessionId = 17;
string productUUID = 18;
string productName = 19;
string productImg = 20;
string productDescription = 21;
}
message BusinessInfo {
string BusinessName = 1; //
string currency = 2; //
int32 orderNum = 3; //
int64 totalIncome = 4; //
int64 totalFee = 5; //
int64 totalRefundAmount = 6; // 退
int64 netIncome = 7; //
}
message Overview {
string currency = 1; //
int32 orderNum = 2; //
int64 totalIncome = 3; //
int64 totalFee = 4; //
int64 totalRefundAmount = 5; // 退
int64 netIncome = 6; //
}
message ChannelIncome {
string channelType = 1; //
string currency = 2; //
int32 orderNum = 3; //
int64 totalIncome = 4; //
int64 totalFee = 5; //
int64 totalRefundAmount = 6; // 退
int64 netIncome = 7; //
}

View File

@ -0,0 +1,301 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: pb/payment.proto
package payment
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
func (this *AntomPayQueryRequest) Validate() error {
return nil
}
func (this *AntomPayQueryResponse) Validate() error {
for _, item := range this.Infos {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Infos", err)
}
}
}
return nil
}
func (this *AntomNotifyPayRequest) Validate() error {
return nil
}
func (this *AntomNotifyPayResponse) Validate() error {
return nil
}
func (this *CreatePayRequest) Validate() error {
return nil
}
func (this *CreatePayResponse) Validate() error {
return nil
}
func (this *CreateRefundRequest) Validate() error {
return nil
}
func (this *CreateRefundResponse) Validate() error {
return nil
}
func (this *NotifyPayRequest) Validate() error {
if this.HttpRequest != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.HttpRequest); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("HttpRequest", err)
}
}
return nil
}
func (this *NotifyPayResponse) Validate() error {
return nil
}
func (this *HttpRequest) Validate() error {
// Validation of proto3 map<> fields is unsupported.
return nil
}
func (this *CommonMsg) Validate() error {
return nil
}
func (this *EmptyRequest) Validate() error {
return nil
}
func (this *CreateStripeCheckoutSessionRequest) Validate() error {
return nil
}
func (this *CreateStripeCheckoutSessionResponse) Validate() error {
return nil
}
func (this *GetCheckoutWebhookRequest) Validate() error {
return nil
}
func (this *GetCheckoutWebhookResponse) Validate() error {
return nil
}
func (this *GetStripePaymentIntentInfoRequest) Validate() error {
return nil
}
func (this *GetStripePaymentIntentInfoResponse) Validate() error {
return nil
}
func (this *GetRefundInfoRequest) Validate() error {
return nil
}
func (this *GetRefundInfoResponse) Validate() error {
return nil
}
func (this *AliWapPayRequest) Validate() error {
return nil
}
func (this *AliWapPayResponse) Validate() error {
return nil
}
func (this *AliAppPayRequest) Validate() error {
return nil
}
func (this *AliAppPayResponse) Validate() error {
return nil
}
func (this *AliNativePayRequest) Validate() error {
return nil
}
func (this *AliNativePayResponse) Validate() error {
return nil
}
func (this *AliPcWabPayRequest) Validate() error {
return nil
}
func (this *AliPcWabPayResponse) Validate() error {
return nil
}
func (this *AliReFundRequest) Validate() error {
return nil
}
func (this *AliReFundResponse) Validate() error {
return nil
}
func (this *AliNotifyRequest) Validate() error {
return nil
}
func (this *AliNotifyResponse) Validate() error {
return nil
}
func (this *AliQueryByOutTradeNoRequest) Validate() error {
return nil
}
func (this *AliQueryByOutTradeNoResponse) Validate() error {
return nil
}
func (this *AliRefundQueryByOutTradeNoRequest) Validate() error {
return nil
}
func (this *AliRefundQueryByOutTradeNoResponse) Validate() error {
return nil
}
func (this *WechatJsApiPayRequest) Validate() error {
return nil
}
func (this *WechatJsApiPayResponse) Validate() error {
return nil
}
func (this *WechatAppPayResponse) Validate() error {
return nil
}
func (this *WechatJsApiQueryByOutTradeNoRequest) Validate() error {
return nil
}
func (this *WechatJsApiQueryByOutTradeNoResponse) Validate() error {
return nil
}
func (this *WechatAppQueryByOutTradeNoRequest) Validate() error {
return nil
}
func (this *WechatAppQueryByOutTradeNoResponse) Validate() error {
for _, item := range this.PromotionDetail {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("PromotionDetail", err)
}
}
}
if this.Payer != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Payer); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Payer", err)
}
}
if this.Amount != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Amount); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Amount", err)
}
}
return nil
}
func (this *WechatAppQueryByOutTradeNoResponse_Payer) Validate() error {
return nil
}
func (this *WechatAppQueryByOutTradeNoResponse_Amount) Validate() error {
return nil
}
func (this *WechatAppQueryByOutTradeNoResponse_PromotionDetail) Validate() error {
return nil
}
func (this *GetPayByOutTradeNoRequest) Validate() error {
return nil
}
func (this *GetPayByOutTradeNoResponse) Validate() error {
return nil
}
func (this *WechatJsApiRefundsResponse) Validate() error {
return nil
}
func (this *WechatNativePayRequest) Validate() error {
return nil
}
func (this *WechatNativePayResponse) Validate() error {
return nil
}
func (this *WechatNativeQueryByOutTradeNoRequest) Validate() error {
return nil
}
func (this *WechatRefundQueryByOutRefundNoRequest) Validate() error {
return nil
}
func (this *WechatRefundQueryByOutRefundNoResponse) Validate() error {
return nil
}
func (this *WechatNativeQueryByOutTradeNoResponse) Validate() error {
return nil
}
func (this *WechatAppPayRequest) Validate() error {
return nil
}
func (this *WechatJsApiRefundsRequest) Validate() error {
return nil
}
func (this *WechatH5PayRequest) Validate() error {
return nil
}
func (this *WechatH5PayResponse) Validate() error {
return nil
}
func (this *WechatH5QueryByOutTradeNoRequest) Validate() error {
return nil
}
func (this *WechatH5QueryByOutTradeNoResponse) Validate() error {
return nil
}
func (this *WechatPayOkRequest) Validate() error {
return nil
}
func (this *CommonResponse) Validate() error {
return nil
}
func (this *PayQueryRequest) Validate() error {
return nil
}
func (this *PayQueryResponse) Validate() error {
for _, item := range this.Infos {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Infos", err)
}
}
}
return nil
}
func (this *PaymentOrderInfo) Validate() error {
return nil
}
func (this *ExportPayRequest) Validate() error {
return nil
}
func (this *ExportPayResponse) Validate() error {
for _, item := range this.Overview {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Overview", err)
}
}
}
for _, item := range this.ChannelIncomes {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("ChannelIncomes", err)
}
}
}
for _, item := range this.BusinessInfos {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("BusinessInfos", err)
}
}
}
for _, item := range this.OrderDetails {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("OrderDetails", err)
}
}
}
return nil
}
func (this *OrderDetail) Validate() error {
return nil
}
func (this *BusinessInfo) Validate() error {
return nil
}
func (this *Overview) Validate() error {
return nil
}
func (this *ChannelIncome) Validate() error {
return nil
}

File diff suppressed because it is too large Load Diff

View File

@ -28,3 +28,9 @@ dubbo:
retries: 3
interface: com.fontree.microservices.common.micro.account
# filter: echo,metrics,token,accesslog,sign,tps,generic_service,execute,pshutdown,auth,fonValidateFilter
PaymentClientImpl:
interface: com.fontree.microservices.common.payment # must be compatible with grpc or dubbo-java
filter: cshutdown,sign,auth
params:
.accessKeyId: "Paymentksl"
.secretAccessKey: "BSDY-FDF1-Fontree_payment"

View File

@ -26,3 +26,9 @@ dubbo:
protocol: tri
retries: 0
interface: com.fontree.microservices.common.micro.account
PaymentClientImpl:
interface: com.fontree.microservices.common.payment # must be compatible with grpc or dubbo-java
filter: cshutdown,sign,auth
params:
.accessKeyId: "Paymentksl"
.secretAccessKey: "BSDY-FDF1-Fontree_payment"

View File

@ -11,6 +11,7 @@ import (
func BundleOrderRouter(r *gin.RouterGroup) {
r.POST("/stripe-pay/callback", bundle.StripeCheckoutSessionWebhook)
r.POST("/antom/callback", bundle.AntomWebhook) // Antom回调
bundleOrderRoute := r.Group("bundle-order")
bundleOrderRoute.Use(middleware.CheckLogin(service.AccountProvider))
@ -29,7 +30,8 @@ func BundleOrderRouter(r *gin.RouterGroup) {
bundleOrderAppRoute.POST("order-detail", bundle.OrderRecordsDetail)
// stripe
bundleOrderAppRoute.POST("create-stripe-pay", bundle.CreateStripeCheckoutSession)
//bundleOrderAppRoute.POST("create-stripe-pay", bundle.CreateStripeCheckoutSession) // stripe支付
bundleOrderAppRoute.POST("create-stripe-pay", bundle.CreateAntomPay) // Antom国际支付
}
}

View File

@ -2,10 +2,12 @@ package bundle
import (
"context"
"encoding/json"
"errors"
"fmt"
"fonchain-fiee/api/bundle"
"fonchain-fiee/api/order"
"fonchain-fiee/api/payment"
"fonchain-fiee/pkg/config"
"fonchain-fiee/pkg/model/login"
"fonchain-fiee/pkg/service"
@ -127,6 +129,125 @@ func CreateStripeCheckoutSession(c *gin.Context) {
}
func CreateAntomPay(c *gin.Context) {
var req order.CreateStripeCheckoutSessionRequest
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
service.Error(c, err)
return
}
// 获取 用户信息
userInfo := login.GetUserInfoFromC(c)
// 检查 订单信息
detail, detailErr := service.BundleProvider.OrderRecordsDetail(context.Background(), &bundle.OrderRecordsDetailRequest{
OrderNo: req.OutTradeNo,
})
if detailErr != nil {
service.Error(c, detailErr)
return
}
fmt.Println("detail.OrderRecord.CustomerID :", detail.OrderRecord.CustomerID)
// 判断 是否是 本人操作
if strconv.FormatUint(userInfo.ID, 10) != detail.OrderRecord.CustomerID {
service.Error(c, errors.New(common.NotMatchOrderInfo))
return
}
fmt.Println("detail.OrderRecord.TotalAmount :", detail.OrderRecord.TotalAmount)
fmt.Println("req.ProductAllPrice :", req.ProductAllPrice)
fmt.Println("detail.OrderRecord.TotalAmount*100 :", detail.OrderRecord.TotalAmount*100)
//金额校验
orderAmountInCents := int64(math.Round(float64(detail.OrderRecord.TotalAmount * 100)))
reqAmountInCents := int64(math.Round(float64(req.ProductAllPrice)))
if orderAmountInCents != reqAmountInCents {
fmt.Println("111111111111111111111111111111111111")
service.Error(c, errors.New(common.InvalidOrderAmount))
return
}
fmt.Println("detail.OrderRecord.Status :", detail.OrderRecord.Status)
fmt.Println("detail.OrderRecord.CheckoutSessionId :", detail.OrderRecord.CheckoutSessionId)
fmt.Println("detail.OrderRecord.PayTime :", detail.OrderRecord.PayTime)
// 如果 当前订单 是 已签未支付 且 存在 checkoutSessionId 需要 查询 支付结果
if detail.OrderRecord.Status == bundleModel.OrderSigned && detail.OrderRecord.CheckoutSessionId != "" && detail.OrderRecord.PayTime == "" {
// 查询支付结果
stripeInfosRes, stripeInfosErr := service.PaymentProvider.QueryAntomPayByCheckoutSessionId(context.Background(), &payment.AntomPayQueryRequest{
CheckoutSessionIds: []string{detail.OrderRecord.CheckoutSessionId},
})
if stripeInfosErr != nil {
service.Error(c, errors.New(common.ErrorQueryStripeInfo))
return
}
if stripeInfosRes != nil && len(stripeInfosRes.Infos) > 0 {
for _, info := range stripeInfosRes.Infos {
if info.OutTradeNo == detail.OrderRecord.OrderNo && info.Status == "paid" {
_, updateOrderRecordErr := service.BundleProvider.UpdateOrderRecord(context.Background(), &bundle.OrderRecord{
Uuid: detail.OrderRecord.Uuid,
Status: bundleModel.OrderPaid,
PayTime: common.GetBeijingTime(),
})
fmt.Println("detail.OrderRecord.Uuid :", detail.OrderRecord.Uuid)
if updateOrderRecordErr != nil {
service.Error(c, detailErr)
return
}
service.Success(c, &service.Response{
Msg: common.HadPay,
Code: 0,
})
return
}
}
}
}
var antomReq payment.CreatePayRequest
antomReq.Payee = "Antom"
antomReq.Platform = "antom"
antomReq.ChannelType = "antom"
antomReq.ProductDescription = req.ProductDescription
antomReq.BusinessType = "useless"
antomReq.Domain = "fiee"
antomReq.Amount = req.ProductAllPrice
antomReq.Currency = req.ProductPriceCurrency
antomReq.OutTradeNo = req.OutTradeNo
antomReq.ReturnUrl = req.SuccessUrl
//调用微服务获取支付地址
result, err := service.PaymentProvider.CreatePay(context.Background(), &antomReq)
if err != nil {
service.Error(c, err)
return
}
fmt.Println("result.CheckoutSessionId :", result.CheckoutSessionId)
fmt.Println("result.Url :", result.Url)
//更新订单状态
_, updateOrderRecordErr := service.BundleProvider.UpdateOrderRecord(context.Background(), &bundle.OrderRecord{
Uuid: detail.OrderRecord.Uuid,
CheckoutSessionId: result.CheckoutSessionId,
CheckoutSessionUrl: result.Url,
})
if updateOrderRecordErr != nil {
service.Error(c, updateOrderRecordErr)
return
}
service.Success(c, result)
}
func StripeCheckoutSessionWebhook(c *gin.Context) {
var req order.GetCheckoutWebhookRequest
c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, int64(65536))
@ -160,3 +281,81 @@ func StripeCheckoutSessionWebhook(c *gin.Context) {
}
service.Success(c)
}
func AntomWebhook(c *gin.Context) {
var err error
data, err := io.ReadAll(c.Request.Body)
if err != nil {
service.Error(c, err)
return
}
// 将数据转换为字符串形式并记录日志(如果数据过大则不记录)
dataStr := string(data)
fmt.Println("================ Antom回调参数", dataStr)
// 将读取到的数据解析为 map[string]interface{}
var reqMap map[string]interface{}
if err := json.Unmarshal(data, &reqMap); err != nil {
service.Error(c, err)
return
}
// 提取需要的字段
notifyType, _ := reqMap["notifyType"].(string)
resultMap, resultExists := reqMap["result"].(map[string]interface{})
if !resultExists {
service.Error(c, errors.New("result 字段不存在或类型错误"))
return
}
requestId, _ := reqMap["paymentRequestId"].(string)
paymentId, _ := reqMap["paymentId"].(string)
paymentTime, _ := reqMap["paymentTime"].(string)
// 提取 result 字段中的子字段
resultStatus, _ := resultMap["resultStatus"].(string)
resultMessage, _ := resultMap["resultMessage"].(string)
// 打印提取的字段(可以根据需要处理)
fmt.Println("通知类型:", notifyType)
fmt.Println("订单号:", requestId)
fmt.Println("支付ID:", paymentId)
fmt.Println("支付时间:", paymentTime)
fmt.Println("支付结果状态:", resultStatus)
fmt.Println("支付结果消息:", resultMessage)
/*
* S: notifyType 为PAYMENT_RESULT时表示支付成功 notifyType 为PAYMENT_PENDING时表示支付处理中
* F: 表示支付失败
* */
params := &payment.AntomNotifyPayRequest{
NotifyType: notifyType,
RequestId: requestId,
PaymentId: paymentId,
PaymentTime: paymentTime,
ResultStatus: resultStatus,
ResultMessage: resultMessage,
}
resp, err := service.PaymentProvider.AntomWebhook(c, params)
if err != nil {
service.Error(c, err)
return
}
fmt.Println("resp.Status:", resp.Status)
if resp.Status == "paid" {
//支付成功
_, updateStatusErr := service.BundleProvider.UpdateOrderRecordByOrderNo(context.Background(), &bundle.OrderRecord{
OrderNo: resp.OutTradeNo,
PayTime: common.GetBeijingTime(),
Status: bundleModel.OrderPaid,
})
if updateStatusErr != nil {
service.Error(c, err)
return
}
}
service.Success(c)
}

View File

@ -8,6 +8,7 @@ import (
"fonchain-fiee/api/account"
"fonchain-fiee/api/bundle"
"fonchain-fiee/api/order"
"fonchain-fiee/api/payment"
pkConfig "fonchain-fiee/pkg/config"
"os"
)
@ -16,11 +17,13 @@ var AccountProvider = new(account.AccountClientImpl)
var BundleProvider = new(bundle.BundleClientImpl)
var OrderProvider = new(order.OrderClientImpl)
var PaymentProvider = new(payment.PaymentClientImpl)
func init() {
config.SetConsumerService(BundleProvider)
config.SetConsumerService(OrderProvider)
config.SetConsumerService(AccountProvider)
config.SetConsumerService(PaymentProvider)
if err := config.Load(); err != nil {
panic(err)