playstore

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 NewWithClient

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

NewWithClient returns http client which includes the custom http client.

func (*Client) AcknowledgeProduct

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

func (*Client) AcknowledgeSubscription

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, _ string, token string) error

CancelSubscription cancels a user's subscription purchase.

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) 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

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"`
	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

type IABProduct

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

The IABProduct type is an interface for product service

type IABSubscription

type IABSubscription interface {
	AcknowledgeSubscription(context.Context, string, string, string, *androidpublisher.SubscriptionPurchasesAcknowledgeRequest) error
	VerifySubscription(context.Context, string, string, string) (*androidpublisher.SubscriptionPurchase, error)
	CancelSubscription(context.Context, string, string, string) error
	RefundSubscription(context.Context, string, string, string) error
	RevokeSubscription(context.Context, string, string, string) error
}

The IABSubscription type is an interface for subscription service

type OneTimeProductNotification

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

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

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

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

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

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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