playstore

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: MIT Imports: 13 Imported by: 13

Documentation

Index

Constants

View Source
const (
	VoidedPurchaseProductTypeSubscription = iota + 1
	VoidedPurchaseProductTypeOneTime
)

Variables

This section is empty.

Functions

func VerifySignature

func VerifySignature(base64EncodedPublicKey string, receipt []byte, signature string) (isValid bool, err error)

VerifySignature verifies in app billing signature. You need to prepare a public key for your Android app's in app billing at https://play.google.com/apps/publish/

Types

type Client

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

The Client type implements VerifySubscription method

func New

func New(jsonKey []byte) (*Client, error)

New returns http client which includes the credentials to access androidpublisher API. You should create a service account for your project at https://console.developers.google.com and download a JSON key file to set this argument.

func NewDefaultTokenSourceClient added in v1.3.29

func NewDefaultTokenSourceClient() (*Client, error)

NewDefaultTokenSourceClient returns a client that authenticates using Google Application Default Credentials. See https://pkg.go.dev/golang.org/x/oauth2/google#DefaultTokenSource

func NewWithClient

func NewWithClient(jsonKey []byte, cli *http.Client) (*Client, error)

NewWithClient returns http client which includes the custom http client.

func (*Client) AcknowledgeProduct added in v1.3.0

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

func (*Client) AcknowledgeSubscription added in v1.1.0

func (c *Client) AcknowledgeSubscription(
	ctx context.Context,
	packageName string,
	subscriptionID string,
	token string,
	req *androidpublisher.SubscriptionPurchasesAcknowledgeRequest,
) error

AcknowledgeSubscription acknowledges a subscription purchase.

func (*Client) CancelSubscription

func (c *Client) CancelSubscription(ctx context.Context, packageName string, subscriptionID string, token string) error

CancelSubscription cancels a user's subscription purchase.

func (*Client) ConsumeProduct added in v1.6.2

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

func (*Client) DeferSubscription added in v1.26.2

DeferSubscription refunds and immediately defers a user's subscription purchase. Access to the subscription will be terminated immediately and it will stop recurring.

func (*Client) GetSubscriptionOffer added in v1.21.5

func (c *Client) GetSubscriptionOffer(ctx context.Context,
	packageName string,
	productID string,
	basePlanID string,
	offerID string,
) (*androidpublisher.SubscriptionOffer, error)

GetSubscriptionOffer reads a single subscription offer.

func (*Client) RefundSubscription

func (c *Client) RefundSubscription(ctx context.Context, packageName string, subscriptionID string, token string) error

RefundSubscription refunds a user's subscription purchase, but the subscription remains valid until its expiration time and it will continue to recur.

func (*Client) RevokeSubscription

func (c *Client) RevokeSubscription(ctx context.Context, packageName string, subscriptionID string, token string) error

RevokeSubscription refunds and immediately revokes a user's subscription purchase. Access to the subscription will be terminated immediately and it will stop recurring.

func (*Client) RevokeSubscriptionV2 added in v1.26.2

RevokeSubscriptionV2 verifies subscription status

func (*Client) VerifyProduct

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

VerifyProduct verifies product status

func (*Client) VerifySubscription

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

VerifySubscription verifies subscription status Deprecated

func (*Client) VerifySubscriptionV2 added in v1.3.28

func (c *Client) VerifySubscriptionV2(
	ctx context.Context,
	packageName string,
	token string,
) (*androidpublisher.SubscriptionPurchaseV2, error)

VerifySubscriptionV2 verifies subscription status

func (*Client) VoidedPurchases added in v1.7.0

func (c *Client) VoidedPurchases(
	ctx context.Context,
	packageName string,
	startTime int64,
	endTime int64,
	maxResult int64,
	token string,
	startIndex int64,
	productType VoidedPurchaseType,
) (*androidpublisher.VoidedPurchasesListResponse, error)

VoidedPurchases list of orders that are associated with purchases that a user has voided Quotas: 1. 6000 queries per day. (The day begins and ends at midnight Pacific Time.) 2. 30 queries during any 30-second period.

type DeveloperNotification

type DeveloperNotification struct {
	Version                    string                     `json:"version"`
	PackageName                string                     `json:"packageName"`
	EventTimeMillis            string                     `json:"eventTimeMillis"`
	SubscriptionNotification   SubscriptionNotification   `json:"subscriptionNotification,omitempty"`
	OneTimeProductNotification OneTimeProductNotification `json:"oneTimeProductNotification,omitempty"`
	VoidedPurchaseNotification VoidedPurchaseNotification `json:"voidedPurchaseNotification,omitempty"`
	TestNotification           TestNotification           `json:"testNotification,omitempty"`
}

DeveloperNotification is sent by a Pub/Sub topic. Detailed description is following. https://developer.android.com/google/play/billing/rtdn-reference#json_specification Depreacated: use DeveloperNotificationV2 instead.

type DeveloperNotificationV2 added in v1.28.0

type DeveloperNotificationV2 struct {
	Version                    string                      `json:"version"`
	PackageName                string                      `json:"packageName"`
	EventTimeMillis            string                      `json:"eventTimeMillis"`
	SubscriptionNotification   *SubscriptionNotification   `json:"subscriptionNotification,omitempty"`
	OneTimeProductNotification *OneTimeProductNotification `json:"oneTimeProductNotification,omitempty"`
	VoidedPurchaseNotification *VoidedPurchaseNotification `json:"voidedPurchaseNotification,omitempty"`
	TestNotification           *TestNotification           `json:"testNotification,omitempty"`
}

DeveloperNotificationV2 is sent by a Pub/Sub topic. Detailed description is following. https://developer.android.com/google/play/billing/rtdn-reference#json_specification

type IABMonetization added in v1.21.5

type IABMonetization interface {
	GetSubscriptionOffer(context.Context, string, string, string, string) (*androidpublisher.SubscriptionOffer, error)
}

The IABMonetization type is an interface for monetization service

type IABProduct added in v1.1.0

type IABProduct interface {
	VerifyProduct(context.Context, string, string, string) (*androidpublisher.ProductPurchase, error)
	AcknowledgeProduct(context.Context, string, string, string, string) error
	ConsumeProduct(context.Context, string, string, string) error
}

The IABProduct type is an interface for product service

type IABSubscription added in v1.1.0

The IABSubscription type is an interface for subscription service

type IABSubscriptionV2 added in v1.26.2

The IABSubscriptionV2 type is an interface for subscriptionV2 service

type OneTimeProductNotification added in v1.3.3

type OneTimeProductNotification struct {
	Version          string                         `json:"version"`
	NotificationType OneTimeProductNotificationType `json:"notificationType,omitempty"`
	PurchaseToken    string                         `json:"purchaseToken,omitempty"`
	SKU              string                         `json:"sku,omitempty"`
}

OneTimeProductNotification has one-time product status as notificationType, token and sku (product id) to confirm status by calling Google Android Publisher API.

type OneTimeProductNotificationType added in v1.3.3

type OneTimeProductNotificationType int

https://developer.android.com/google/play/billing/rtdn-reference#one-time

const (
	OneTimeProductNotificationTypePurchased OneTimeProductNotificationType = iota + 1
	OneTimeProductNotificationTypeCanceled
)

type SubscriptionNotification

type SubscriptionNotification struct {
	Version          string                       `json:"version"`
	NotificationType SubscriptionNotificationType `json:"notificationType,omitempty"`
	PurchaseToken    string                       `json:"purchaseToken,omitempty"`
	SubscriptionID   string                       `json:"subscriptionId,omitempty"`
}

SubscriptionNotification has subscription status as notificationType, token and subscription id to confirm status by calling Google Android Publisher API.

type SubscriptionNotificationType added in v1.3.3

type SubscriptionNotificationType int

https://developer.android.com/google/play/billing/rtdn-reference#sub

const (
	SubscriptionNotificationTypeRecovered SubscriptionNotificationType = iota + 1
	SubscriptionNotificationTypeRenewed
	SubscriptionNotificationTypeCanceled
	SubscriptionNotificationTypePurchased
	SubscriptionNotificationTypeAccountHold
	SubscriptionNotificationTypeGracePeriod
	SubscriptionNotificationTypeRestarted
	SubscriptionNotificationTypePriceChangeConfirmed
	SubscriptionNotificationTypeDeferred
	SubscriptionNotificationTypePaused
	SubscriptionNotificationTypePauseScheduleChanged
	SubscriptionNotificationTypeRevoked
	SubscriptionNotificationTypeExpired
)

type TestNotification added in v1.3.3

type TestNotification struct {
	Version string `json:"version"`
}

TestNotification is the test publish that are sent only through the Google Play Developer Console

type VoidedPurchaseNotification added in v1.26.0

type VoidedPurchaseNotification struct {
	PurchaseToken string                    `json:"purchaseToken"`
	OrderID       string                    `json:"orderId"`
	ProductType   VoidedPurchaseProductType `json:"productType"`
	RefundType    VoidedPurchaseRefundType  `json:"refundType"`
}

VoidedPurchaseNotification has token, order and product type to locate the right purchase and order. To learn how to get additional information about the voided purchase, check out the Google Play Voided Purchases API, which is a pull model that provides additional data for voided purchases between a given timestamp. https://developer.android.com/google/play/billing/rtdn-reference#voided-purchase

type VoidedPurchaseRefundType added in v1.30.0

type VoidedPurchaseRefundType int
const (
	VoidedPurchaseRefundTypeFullRefund VoidedPurchaseRefundType = iota + 1
	VoidedPurchaseRefundTypePartialRefund
)

type VoidedPurchaseType added in v1.7.0

type VoidedPurchaseType int64
const (
	VoidedPurchaseTypeWithoutSubscription VoidedPurchaseType = 0
	VoidedPurchaseTypeWithSubscription    VoidedPurchaseType = 1
)

Directories

Path Synopsis
Code generated by MockGen.
Code generated by MockGen.

Jump to

Keyboard shortcuts

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