The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
Cluas

简单开发了一个支付宝的 Go 小程序相关的 SDK

  •  
  •   Cluas · May 7, 2020 · 2120 views
    This topic created in 2207 days ago, the information mentioned may be changed or developed.

    最近公司需要接入支付宝第三方小程序业务, 找了下网上的现有的第三方 SDK(基本是支付相关), 均不满足要求。 所以自己简单写了一个, 现已开源。

    目前项目属于初期阶段仅支持小程序相关的接口,欢迎有能力的同学做补充发起 PR 。

    Github 地址:https://github.com/Cluas/go-alipay

    简单的使用用例:

    package main
    
    import (
    	"context"
    	"fmt"
    
    	"github.com/Cluas/go-alipay/alipay"
    )
    
    func main() {
        // 小程序代码上架示例
        encodedKey, _ := base64.StdEncoding.DecodeString("your_private_key")
    	privateKey, _ := x509.ParsePKCS1PrivateKey(encodedKey)
    	publicKey, _ := base64.StdEncoding.DecodeString("your_public_key")
    	pub, _ := x509.ParsePKIXPublicKey(publicKey)
    	client := alipay.NewClient(nil, privateKey, pub.(*rsa.PublicKey))
    
        biz := alipay.OnlineVersionBiz{
            AppVersion: "v0.0.1",
            BundleID: "com.alipay.alipaywallet",
        }
        if err := client.Mini.OnlineVersion(context.Background(), &biz); err != nil {
            fmt.Printf("支付宝小程序代码上架失败: %s", err)
        }
        // 如果是第三方代开发
        // client.Mini.OnlineVersion(context.Background(), &biz, alipay.AppAuthToken(token)) 
    
    }
    

    欢迎各位同学指正批评。

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   937 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 22:39 · PVG 06:39 · LAX 15:39 · JFK 18:39
    ♥ Do have faith in what you're doing.