Documentation
¶
Index ¶
- Constants
- func NewNonceString() string
- func NewTimestampString() string
- func Sign(param map[string]string, key string) string
- func SortAndConcat(param map[string]string) string
- func ToMap(in interface{}) (map[string]string, error)
- func ToXmlString(param map[string]string) string
- type AppTrans
- type PaymentRequest
- type PlaceOrderResult
- type QueryOrderResult
- type WxConfig
Constants ¶
const ChinaTimeZoneOffset = 8 * 60 * 60 //Beijing(UTC+8:00)
Variables ¶
This section is empty.
Functions ¶
func NewNonceString ¶
func NewNonceString() string
NewNonceString return random string in 32 characters
func Sign ¶
Sign the parameter in form of map[string]string with app key. Empty string and "sign" key is excluded before sign. Please refer to http://pay.weixin.qq.com/wiki/doc/api/app.php?chapter=4_3
func SortAndConcat ¶
SortAndConcat sort the map by key in ASCII order, and concat it in form of "k1=v1&k2=2"
func ToXmlString ¶
ToXmlString convert the map[string]string to xml string
Types ¶
type AppTrans ¶
type AppTrans struct {
Config *WxConfig
}
AppTrans is abstact of Transaction handler. With AppTrans, we can get prepay id
func NewAppTrans ¶
Initialized the AppTrans with specific config
func (*AppTrans) NewPaymentRequest ¶
func (this *AppTrans) NewPaymentRequest(prepayId string) PaymentRequest
NewPaymentRequest build the payment request structure for app to start a payment. Return stuct of PaymentRequest, please refer to http://pay.weixin.qq.com/wiki/doc/api/app.php?chapter=9_12&index=2
func (*AppTrans) Query ¶
func (this *AppTrans) Query(transId string) (QueryOrderResult, error)
Query the order from weixin pay server by transaction id of weixin pay
func (*AppTrans) Submit ¶
func (this *AppTrans) Submit(orderId string, amount float64, desc string, clientIp string) (string, error)
Submit the order to weixin pay and return the prepay id if success, Prepay id is used for app to start a payment If fail, error is not nil, check error for more information
type PaymentRequest ¶
type PlaceOrderResult ¶
type PlaceOrderResult struct {
XMLName xml.Name `xml:"xml"`
ReturnCode string `xml:"return_code"`
ReturnMsg string `xml:"return_msg"`
AppId string `xml:"appid"`
MchId string `xml:"mch_id"`
DeviceInfo string `xml:"device_info"`
NonceStr string `xml:"nonce_str"`
Sign string `xml:"sign"`
ResultCode string `xml:"result_code"`
ErrCode string `xml:"err_code"`
ErrCodeDesc string `xml:"err_code_des"`
TradeType string `xml:"trade_type"`
PrepayId string `xml:"prepay_id"`
CodeUrl string `xml:"code_url"`
}
PlaceOrderResult represent place order reponse message from weixin pay. For field explanation refer to: http://pay.weixin.qq.com/wiki/doc/api/app.php?chapter=9_1
func ParsePlaceOrderResult ¶
func ParsePlaceOrderResult(resp []byte) (PlaceOrderResult, error)
Parse the reponse message from weixin pay to struct of PlaceOrderResult
func (*PlaceOrderResult) ToMap ¶
func (this *PlaceOrderResult) ToMap() map[string]string
type QueryOrderResult ¶
type QueryOrderResult struct {
XMLName xml.Name `xml:"xml"`
Appid string `xml:"appid"`
Attach string `xml:"attach"`
BankType string `xml:"bank_type"`
CashFee string `xml:"cash_fee"`
CashFeeType string `xml:"cash_fee_type"`
CouponCount string `xml:"coupon_count"`
CouponFee string `xml:"coupon_fee"`
CouponFee0 string `xml:"coupon_fee_0"`
CouponFee1 string `xml:"coupon_fee_1"`
CouponFee2 string `xml:"coupon_fee_2"`
CouponFee3 string `xml:"coupon_fee_3"`
CouponFee4 string `xml:"coupon_fee_4"`
CouponFee5 string `xml:"coupon_fee_5"`
CouponFee6 string `xml:"coupon_fee_6"`
CouponFee7 string `xml:"coupon_fee_7"`
CouponFee8 string `xml:"coupon_fee_8"`
CouponFee9 string `xml:"coupon_fee_9"`
CouponID0 string `xml:"coupon_id_0"`
CouponID1 string `xml:"coupon_id_1"`
CouponID2 string `xml:"coupon_id_2"`
CouponID3 string `xml:"coupon_id_3"`
CouponID4 string `xml:"coupon_id_4"`
CouponID5 string `xml:"coupon_id_5"`
CouponID6 string `xml:"coupon_id_6"`
CouponID7 string `xml:"coupon_id_7"`
CouponID8 string `xml:"coupon_id_8"`
CouponID9 string `xml:"coupon_id_9"`
CouponType0 string `xml:"coupon_type_0"`
CouponType1 string `xml:"coupon_type_1"`
CouponType2 string `xml:"coupon_type_2"`
CouponType3 string `xml:"coupon_type_3"`
CouponType4 string `xml:"coupon_type_4"`
CouponType5 string `xml:"coupon_type_5"`
CouponType6 string `xml:"coupon_type_6"`
CouponType7 string `xml:"coupon_type_7"`
CouponType8 string `xml:"coupon_type_8"`
CouponType9 string `xml:"coupon_type_9"`
FeeType string `xml:"fee_type"`
IsSubscribe string `xml:"is_subscribe"`
MchID string `xml:"mch_id"`
NonceStr string `xml:"nonce_str"`
Openid string `xml:"openid"`
OutTradeNo string `xml:"out_trade_no"`
ResultCode string `xml:"result_code"`
ReturnCode string `xml:"return_code"`
SettlementTotalFee string `xml:"settlement_total_fee"`
Sign string `xml:"sign"`
SignType string `xml:"sign_type"`
SubMchID string `xml:"sub_mch_id"`
TimeEnd string `xml:"time_end"`
TotalFee string `xml:"total_fee"`
TradeType string `xml:"trade_type"`
TransactionID string `xml:"transaction_id"`
}
QueryOrder Result represent query response message from weixin pay Refer to https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7&index=8
func ParseQueryOrderResult ¶
func ParseQueryOrderResult(resp []byte) (QueryOrderResult, error)
func (*QueryOrderResult) ToMap ¶
func (this *QueryOrderResult) ToMap() map[string]string