func initHandle() {
	http.HandleFunc("callback/aliappcallback", func(w http.ResponseWriter, r *http.Request) {
		aliResult, err := AliAppCallback(w, r)
		if err != nil {
			fmt.Println(err)
			return
		}
		selfHandler(aliResult)
	})
}
func TestPay(t *testing.T) {
initClient()
initHandle()
charge := new(common.Charge)
charge.PayMethod = constant.WECHAT_WEB
charge.MoneyFee = 1
charge.Describe = "test pay"
charge.TradeNum = "11111111122"
charge.CallbackURL = "http://127.0.0.1/callback/aliappcallback"
charge.OpenID = "123"

fdata, err := Pay(charge)
if err != nil {
t.Error(err)
}
fmt.Printf("%+v", fdata)
}

func initClient() {
client.InitWxWebClient(&client.WechatWebClient{
AppID:       "xxxxxxxxxxxx",
MchID:       "xxxxxxxxxxxx",
Key:         "xxxxxxxxxxxx",
CallbackURL: "127.0.0.1/weixin/paycallback",
PayURL:      "https://api.mch.weixin.qq.com/pay/unifiedorder",
})
}
package gopay
import (
	"crypto/rsa"
	"crypto/x509"
	"encoding/pem"
	"fmt"
	"github.com/milkbobo/gopay/client"
	"github.com/milkbobo/gopay/common"
	"github.com/milkbobo/gopay/constant"
	"net/http"
	"testing"
)
func TestPay(t *testing.T) {
	initClient()
	initHandle()
	charge := new(common.Charge)
	charge.PayMethod = constant.ALI_WEB
	charge.MoneyFee = 1
	charge.Describe = "test pay"
	charge.TradeNum = "11111111122"
	charge.CallbackURL = "http://127.0.0.1/callback/aliappcallback"
	fdata, err := Pay(charge)
	if err != nil {
		t.Error(err)
	}
	fmt.Printf("%+v", fdata)
}
func initClient() {
	block, _ := pem.Decode([]byte(`-----BEGIN PRIVATE KEY-----
xxxxxxx
-----END PRIVATE KEY-----`))
	if block == nil {
		panic("Sign private key decode error")
	}
	privateKey, err := x509.ParsePKCS8PrivateKey(block.Bytes)
	if err != nil {
		panic(err)
	}
	block, _ = pem.Decode([]byte(`-----BEGIN PUBLIC KEY-----
xxxxxxxx
-----END PUBLIC KEY-----`))
	if block == nil {
		panic("Sign public key decode error")
	}
	publicKey, err := x509.ParsePKIXPublicKey(block.Bytes)
	if err != nil {
		panic(err)
	}
	client.InitAliWebClient(&client.AliWebClient{
		PartnerID:  "xxxxxxxxxxxx",
		SellerID:   "xxxxxxxxxxxx",
		AppID:      "xxxxxxxxxxxx",
		PrivateKey: privateKey.(*rsa.PrivateKey),
		PublicKey:  publicKey.(*rsa.PublicKey),
		PayURL:     "https://mapi.alipay.com/gateway.do",
	})
}