百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

go-iap

> 编程语言
开源

go-iap 通过 AppStore、GooglePlayStore、AmazonAppStore 和 Huawei HMS 验证购买凭证。

1.1K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

go-iap 通过 AppStore、GooglePlayStore、AmazonAppStore 和 Huawei HMS 验证购买凭证。

go-iap

go-iap 通过 AppStore、GooglePlayStore、Amazon AppStore、HMS 或 MicrosoftStore 验证购买凭证。 当前的 API 文档:

  • AppStore:
  • AppStore 服务器 API:
  • GooglePlay:
  • Amazon AppStore:
  • 华为 HMS:
  • Microsoft Store:

安装

go get github.com/awa/go-iap/appstore
go get github.com/awa/go-iap/playstore
go get github.com/awa/go-iap/amazon
go get github.com/awa/go-iap/hms
go get github.com/awa/go-iap/microsoftstore

快速启动

在 App 中购买 (通过 App Store)

go
import(
    "github.com/awa/go-iap/appstore"
)

func main() {
	client := appstore.New()
	req := appstore.IAPRequest{
		ReceiptData: "your receipt data encoded by base64",
	}
	resp := &appstore.IAPResponse{}
	ctx := context.Background()
	err := client.Verify(ctx, req, resp)
}

注意: 自 2023 年 6 月 5 日起, verifyReceipt API 已被淘汰。请使用 App Store 服务器 API 代替。

应用内购买 (通过 GooglePlay)

go
import(
    "github.com/awa/go-iap/playstore"
)

func main() {
	// You need to prepare a public key for your Android app's in app billing
	// at https://console.developers.google.com.
	jsonKey, err := ioutil.ReadFile("jsonKey.json")
	if err != nil {
		log.Fatal(err)
	}

	client := playstore.New(jsonKey)
	ctx := context.Background()
	resp, err := client.VerifySubscription(ctx, "package", "subscriptionID", "purchaseToken")
}

在 App 中购买 (通过 Amazon App Store)

go
import(
    "github.com/awa/go-iap/amazon"
)

func main() {
	client := amazon.New("developerSecret")

	ctx := context.Background()
	resp, err := client.Verify(ctx, "userID", "receiptID")
}

在 App 中购买 (通过 Huawei 移动服务)

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Goamazonappstroreappstorebillinggoogleplaystore

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言