google

package
v0.0.0-...-7d8afc6 Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: GPL-3.0 Imports: 14 Imported by: 0

README

Documentation

Index

Constants

View Source
const (
	PurchaseStatePurchased = 0
	PurchaseStateCanceled  = 1
	PurchaseStatePending   = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	GetToken(ctx context.Context) (*oauth2.Token, error)

	GetPurchase(ctx context.Context, packageName string, productID string, purchaseToken string) (*androidpublisher.ProductPurchase, error)
	GetPurchaseByReceipt(ctx context.Context, receipt Receipt) (*androidpublisher.ProductPurchase, error)

	GetSubscription(ctx context.Context, packageName, subscriptionID, purchaseToken string) (*androidpublisher.SubscriptionPurchase, error)
	GetSubscriptionByReceipt(ctx context.Context, receipt Receipt) (*androidpublisher.SubscriptionPurchase, error)

	Acknowledge(ctx context.Context, packageName string, productID string, token string) error
	AcknowledgeByReceipt(ctx context.Context, receipt Receipt) error

	GetVoidedPurchase(ctx context.Context, v VoidedPurchase) (voidedPurchases []*androidpublisher.VoidedPurchase, nextPageToken string, err error)
	DealVoidPurchase(ctx context.Context, d DealVoidedPurchase) (dealFailed []*androidpublisher.VoidedPurchase, err error)

	// ReceiveRealTimeDeveloperNotification ...
	// RTDN means RealTimeDeveloperNotification
	// https://developer.android.google.cn/google/play/billing/rtdn-reference?hl=zh-cn
	ReceiveRealTimeDeveloperNotification(ctx context.Context, req *http.Request) error
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(credentialsJSON []byte) (*Client, error)

func (*Client) Acknowledge

func (c *Client) Acknowledge(ctx context.Context, packageName string, productID string, token string) error

func (*Client) AcknowledgeByReceipt

func (c *Client) AcknowledgeByReceipt(ctx context.Context, receipt Receipt) error

func (*Client) DealVoidPurchase

func (c *Client) DealVoidPurchase(ctx context.Context, d DealVoidedPurchase) (dealFailed []*androidpublisher.VoidedPurchase, err error)

func (*Client) GetPurchase

func (c *Client) GetPurchase(ctx context.Context, packageName string, productID string, purchaseToken string) (*androidpublisher.ProductPurchase, error)

func (*Client) GetPurchaseByReceipt

func (c *Client) GetPurchaseByReceipt(ctx context.Context, receipt Receipt) (*androidpublisher.ProductPurchase, error)

func (*Client) GetSubscription

func (c *Client) GetSubscription(ctx context.Context, packageName, subscriptionID, purchaseToken string) (*androidpublisher.SubscriptionPurchase, error)

func (*Client) GetSubscriptionByReceipt

func (c *Client) GetSubscriptionByReceipt(ctx context.Context, receipt Receipt) (*androidpublisher.SubscriptionPurchase, error)

func (*Client) GetToken

func (c *Client) GetToken(ctx context.Context) (tokenInfo *oauth2.Token, err error)

func (*Client) GetVoidedPurchase

func (c *Client) GetVoidedPurchase(ctx context.Context, v VoidedPurchase) (voidedPurchases []*androidpublisher.VoidedPurchase, nextPageToken string, err error)

func (*Client) ReceiveRealTimeDeveloperNotification

func (c *Client) ReceiveRealTimeDeveloperNotification(ctx context.Context, req *http.Request) error

type DealVoidedPurchase

type DealVoidedPurchase struct {
	PackageName string
	StartTime   time.Time
	EndTime     time.Time
	DealFunc    func(ctx context.Context, voidedPurchase *androidpublisher.VoidedPurchase) error
}

type NotificationType

type NotificationType int
const (
	SUBSCRIPTION_RECOVERED              NotificationType = 1  //- 从帐号保留状态恢复了订阅。
	SUBSCRIPTION_RENEWED                NotificationType = 2  //- 续订了处于活动状态的订阅。
	SUBSCRIPTION_CANCELED               NotificationType = 3  //- 自愿或非自愿地取消了订阅。如果是自愿取消,在用户取消时发送。
	SUBSCRIPTION_PURCHASED              NotificationType = 4  //- 购买了新的订阅。
	SUBSCRIPTION_ON_HOLD                NotificationType = 5  //- 订阅已进入帐号保留状态(如果已启用)。
	SUBSCRIPTION_IN_GRACE_PERIOD        NotificationType = 6  //- 订阅已进入宽限期(如果已启用)。
	SUBSCRIPTION_RESTARTED              NotificationType = 7  // - 用户已通过 Play > 帐号 > 订阅恢复了订阅。订阅已取消,但在用户恢复时尚未到期。如需了解详情,请参阅 [恢复](/google/play/billing/subscriptions#restore)。
	SUBSCRIPTION_PRICE_CHANGE_CONFIRMED NotificationType = 8  //- 用户已成功确认订阅价格变动。
	SUBSCRIPTION_DEFERRED               NotificationType = 9  //- 订阅的续订时间点已延期。
	SUBSCRIPTION_PAUSED                 NotificationType = 10 //- 订阅已暂停。
	SUBSCRIPTION_PAUSE_SCHEDULE_CHANGED NotificationType = 11 // - 订阅暂停计划已更改。
	SUBSCRIPTION_REVOKED                NotificationType = 12 //- 用户在到期时间之前已撤消订阅。
	SUBSCRIPTION_EXPIRED                NotificationType = 13 //- 订阅已到期。

	// 通知的类型。它可以具有以下值:
	ONE_TIME_PRODUCT_PURCHASED NotificationType = 1 //- 用户成功购买了一次性商品。
	ONE_TIME_PRODUCT_CANCELED  NotificationType = 2 // - 用户已取消待处理的一次性商品购买交易。
)

type RTDNBody

type RTDNBody struct {
	Message struct {
		Attributes struct {
			Key string `json:"key"`
		} `json:"attributes"`
		Data      string `json:"data"`
		MessageId string `json:"messageId"`
	} `json:"message"`
	Subscription string `json:"subscription"`
}

type RTDNData

type RTDNData struct {
	Version                    string `json:"version"`
	PackageName                string `json:"packageName"`
	EventTimeMillis            string `json:"eventTimeMillis"`
	OneTimeProductNotification *struct {
		Version          string           `json:"version"`
		NotificationType NotificationType `json:"notificationType"`
		PurchaseToken    string           `json:"purchaseToken"`
		Sku              string           `json:"sku"`
	} `json:"oneTimeProductNotification"`
	SubscriptionNotification *struct {
		Version          string           `json:"version"`
		NotificationType NotificationType `json:"notificationType"`
		PurchaseToken    string           `json:"purchaseToken"`
		SubscriptionID   string           `json:"subscriptionId"`
	} `json:"subscriptionnotification"`
	TestNotification *struct {
		Version string `json:"version"`
	} `json:"testNotification"`
}

type Receipt

type Receipt struct {
	ReceiptCore
	State            int    `json:"purchaseState"`
	Time             int    `json:"purchaseTime"`
	OrderID          string `json:"orderId"`
	Acknowledged     bool   `json:"acknowledged"`
	DeveloperPayload string `json:"developerPayload"`
}

type ReceiptCore

type ReceiptCore struct {
	PackageName    string `json:"packageName"`
	ProductID      string `json:"productId"`
	SubscriptionID string `json:"subscriptionId"`
	Token          string `json:"purchaseToken"`
}

type VoidedPurchase

type VoidedPurchase struct {
	PackageName string
	StartTime   *time.Time
	EndTime     *time.Time
	Token       string
}

Jump to

Keyboard shortcuts

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