xiaomi

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BASEURL     = "https://rest-iap.miglobalpay.com"
	ACKNOWLEDGE = "acknowledge"
	CONSUME     = "consume"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MiGlobalIAP

type MiGlobalIAP struct {
	AppID       string
	AppKey      string
	AppSecret   string
	PackageName string
	BaseUrl     string
}

func New

func New(id, key, secret, pkg string, url ...string) *MiGlobalIAP

func (*MiGlobalIAP) Acknowledge

func (mi *MiGlobalIAP) Acknowledge(pid, token string, payload ...string) (bool, error)

Acknowledge 确认购买

func (*MiGlobalIAP) Consume

func (mi *MiGlobalIAP) Consume(pid, token string, payload ...string) (bool, error)

Consume 消耗购买

func (*MiGlobalIAP) PurchaseStatus

func (mi *MiGlobalIAP) PurchaseStatus(pid, token string) (*PurchaseResult, error)

PurchaseStatus 查询交易状态

type PurchaseResult

type PurchaseResult struct {
	Kind                        string `json:"kind"`                        //购买类型:inapp(一次性商品)
	ProductId                   string `json:"productId"`                   //商品ID
	Quantity                    int    `json:"quantity"`                    //商品购买数量
	OrderId                     string `json:"orderId"`                     //订单ID
	PurchaseToken               string `json:"purchaseToken"`               //购买令牌
	PurchaseTimeMillis          string `json:"purchaseTimeMillis"`          //购买时间戳(从1970年1月1日以来的毫秒数)
	PurchaseState               int    `json:"purchaseState"`               //购买状态:0(已购买);1(已退款);2(处理中)
	AcknowledgementState        int    `json:"acknowledgementState"`        //确认状态:0(未确认);1(已确认)
	ConsumptionState            int    `json:"consumptionState"`            //消耗状态:0(未消耗);1(已消耗)
	PurchaseType                int    `json:"purchaseType"`                //购买类型。正常购买时不返回该字段;仅在非正常购买时返回:0(许可测试,通过许可测试白名单账号购买)
	DeveloperPayload            string `json:"developerPayload"`            //开发者在确认/消耗购买时指定的额外信息
	ObfuscatedExternalAccountId string `json:"obfuscatedExternalAccountId"` //开发者在SDK发起购买时设置的用户账号信息
	ObfuscatedExternalProfileId string `json:"obfuscatedExternalProfileId"` //开发者在SDK发起购买时设置的用户相关信息
	RegionCode                  string `json:"regionCode"`                  //购买区域码(遵循ISO 3166-1标准,2位大写字母)
}

func (*PurchaseResult) Acknowledgement

func (s *PurchaseResult) Acknowledgement() bool

Acknowledgement 是否已确认购买

func (*PurchaseResult) Consumption

func (s *PurchaseResult) Consumption() bool

Consumption 是否已消耗购买

type ResponseError

type ResponseError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func (*ResponseError) Error

func (e *ResponseError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL