From ca7a3eae0cb32aea6ea7fde2c9dfd456cb28a1c8 Mon Sep 17 00:00:00 2001 From: wuqunlin Date: Sat, 27 May 2017 10:07:53 +0800 Subject: [PATCH] use alipay response code to decide result --- const.go | 4 ++++ trade_type.go | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/const.go b/const.go index b205f51..63d9a1c 100644 --- a/const.go +++ b/const.go @@ -15,4 +15,8 @@ const ( FixCharset = "utf-8" FixVersion = "1.0" FixSignType = "RSA2" + + // https://doc.open.alipay.com/docs/doc.htm?treeId=291&articleId=105806&docType=1 + // TODO:返回码根据文档统一处理,供外部调用解析 + SUCCESS_CODE = "10000" ) diff --git a/trade_type.go b/trade_type.go index 2261598..f2262b4 100644 --- a/trade_type.go +++ b/trade_type.go @@ -71,7 +71,7 @@ type VoucherDetail struct { } func (this *AliPayTradeQueryResponse) IsSuccess() bool { - if this.AliPayTradeQuery.Msg == "Success" { + if this.AliPayTradeQuery.Code == SUCCESS_CODE { return true } return false @@ -174,7 +174,7 @@ type AliPayTradeRefundResponse struct { } func (this *AliPayTradeRefundResponse) IsSuccess() bool { - if this.AliPayTradeRefund.Msg == "Success" { + if this.AliPayTradeRefund.Code == SUCCESS_CODE { return true } return false @@ -224,7 +224,7 @@ type AliPayFastpayTradeRefundQueryResponse struct { } func (this *AliPayFastpayTradeRefundQueryResponse) IsSuccess() bool { - if this.AliPayTradeFastpayRefundQueryResponse.Msg == "Success" { + if this.AliPayTradeFastpayRefundQueryResponse.Code == SUCCESS_CODE { return true } return false @@ -408,7 +408,7 @@ type AliPayTradePayResponse struct { } func (this *AliPayTradePayResponse) IsSuccess() bool { - if this.AliPayTradePay.Msg == "Success" { + if this.AliPayTradePay.Code == SUCCESS_CODE { return true } return false