ls 4 years ago
parent
commit
a5168ab295
5 changed files with 13 additions and 4 deletions
  1. 1 0
      tcp/server.go
  2. 3 0
      unionpay/cert.go
  3. 3 0
      unionpay/client.go
  4. 3 3
      utils.go
  5. 3 1
      wechat/pap.go

+ 1 - 0
tcp/server.go

@@ -40,6 +40,7 @@ func NewTCPServer(addr string, cb func(*net.TCPConn)) {
 			if err != nil {
 				errc <- err
 				logger.Fatalf("accept error: %v", err)
+				//util.LogDebug("accept error:", err)
 				break
 			}
 			go cb(conn)

+ 3 - 0
unionpay/cert.go

@@ -47,6 +47,9 @@ func getPrivateCert(filename, password string) (key *rsa.PrivateKey, cert *x509.
 		}
 		cert = &x509.Certificate{}
 		private, err = x509.ParsePKCS8PrivateKey(block.Bytes)
+		if err != nil {
+			return
+		}
 		// */
 
 	//*

+ 3 - 0
unionpay/client.go

@@ -9,6 +9,7 @@ import (
 	"crypto/x509"
 	"encoding/hex"
 	"errors"
+	"fmt"
 	"net/url"
 	"strconv"
 )
@@ -115,11 +116,13 @@ func NewMerchantInfo(merID, certPath, keyPath, password string) (mi *MerchantInf
 
 	mi.PrivateKey, _, err = getPrivateCert(keyPath, password)
 	if err != nil {
+		fmt.Println("getPrivateCert", err)
 		return
 	}
 
 	mi.Cert, _, err = getPublicCert(certPath)
 	if err != nil {
+		fmt.Println("getPublicCert", err)
 		return
 	}
 	mi.PublicKey = mi.Cert.PublicKey.(*rsa.PublicKey)

+ 3 - 3
utils.go

@@ -14,9 +14,9 @@ const (
 	// GB giga byte
 	GB
 	// TB tera byte
-	TB
+	//TB
 	// PB peta byte
-	PB
+	//PB
 )
 
 // Map is a shortcut for map[string]interface{}
@@ -54,4 +54,4 @@ func (m Map) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
 	}
 
 	return e.EncodeToken(xml.EndElement{Name: start.Name})
-}
+}

+ 3 - 1
wechat/pap.go

@@ -1,4 +1,6 @@
-// 委托代扣
+// 微信委托代扣
+// 在线文档:
+// https://pay.weixin.qq.com/wiki/doc/api/pap.php?chapter=18_17&index=6
 
 package wechat