Skip to content

hocgin/golang-pay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

golang-pay

支付宝

package alipay

import (
    "fmt"
    "testing"
)

var (
    alipayConfig = CreateConfigStorage("2016080300154586",
        "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAh+PU20M0Q4g6GEzM4o3OYfeZFUX3r0p+IxMlTbUal1zIOPCLOm1jemZk+QUaBfRCFsjUA18BTOosBXkXI7LzdUlAGIx9P8q/W2PHqfx53yRdoqKVr6bYu4gH2ryM7baE7D/R7BVp2/CD0j6vUEwSiR8GpSSbEAua5Apc8FvZ8F3OHh/gLUYz0W+VEyrcDrquR2+Xz3R5Rd9Yob1CAwNtzjAgpALkTRTKcQ5EG8p0+UsjxjRoM69xNjtK8gXr61R5LxlyvcCCHSOIHomcyeRnSwUvSmrr3tQ0bSanzBiyOs4sFt+uCcAansMvrn2CxVFYD0JJBQG/Is9AOdeF/f4NCQIDAQAB",
        "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC2X977LaTocs9QuSleAx1gibGvMhAFW3bBAf1wr3YP26ckOIqa+FIcET4tiBlCleq+Ci4sRBBdcKPtU0c/f6SlDPP9OqnqRXUEuXsiUMJ7OPrstoIddLCFqHHmaRpXINfZjmgGtKvruDf78bX2FnYa2uRGNhw3ckIOlF4A7NEIiJZl3fum1/qA6oEGTjn1QiB5//8EN3ERYCDBkhgS1g2T0kuL6Ank+0+SWuE0Fm08vU4uP4icb5LRdRHfoerfHcEIxhbVtihWHSmLgGibNEI7dxFiAz3Wotp8zsonwF9Q5cEbpYPpHVpx/i7RpF7yFUm5M61uzonQah7UNrV1Ww4JAgMBAAECggEAf8bJ9tgzCz2tbRReHGU4RvQSTvpXaTl9CZt4U2RL5q5x+5m12wASn2GhW8tYT2O0NXPyh8ckZCNQZy4K5D1tQMrDg+9/Lwl9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qSY45Yu6DBLop37/VzWwqBitcKWRmyQzfF9BPObV1xR7lD",
        IsDev(true))
    service = alipayConfig.CreateService()
)

func TestTradePreCreate(t *testing.T) {
    request := &TradePreCreateRequest{
        BizContent: TradePreCreateBizContent{
            Subject:     "测试订单",
            OutTradeNo:  "201911270908381158722",
            TotalAmount: 1.0,
        },
    }
    response, _ := service.TradePreCreate(request)
    fmt.Print(response)
}

微信支付

package wxpay

import (
    "fmt"
    "testing"
)

var (
    wxpayConfig = CreateConfigStorage("appid",
        "mchid", "key",
        IsDev(false), CertFileText(`密钥文件内容`))
    service = wxpayConfig.CreateService()
)

func TestUnifiedOrderRequest(t *testing.T) {
    request := &UnifiedOrderRequest{
        OutTradeNo:     "112",
        Body:           "xx",
        TotalFee:       1.00,
        SpbillCreateIp: "127.0.0.1",
        TradeType:      "JSAPI",
        NotifyUrl:      "http://www.baidu.com",
        Openid:         "opQx55EOxwwO8kyQKrQePlHTOBAg",
    }
    response, _ := service.UnifiedOrder(request)
    fmt.Sprint(response)
}

About

微信支付/支付宝支付

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages