playstore

package
v0.0.0-...-12a8101 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2019 License: MIT Imports: 12 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) CancelSubscription

func (c *Client) CancelSubscription(ctx context.Context, packageName string, subscriptionID 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"`
	TestNotification         SubscriptionNotification `json:"testNotification,omitempty"`
}

DeveloperNotification is sent by a Pub/Sub topic. Detailed description is following. https://developer.android.com/google/play/billing/realtime_developer_notifications.html#json_specification

type IABClient

type IABClient interface {
	VerifySubscription(context.Context, string, string, string) (*androidpublisher.SubscriptionPurchase, error)
	VerifyProduct(context.Context, string, string, string) (*androidpublisher.ProductPurchase, error)
	CancelSubscription(context.Context, string, string, string) error
	RefundSubscription(context.Context, string, string, string) error
	RevokeSubscription(context.Context, string, string, string) error
}

The IABClient type is an interface to verify purchase token

type NotificationType

type NotificationType int
const (
	NotificationTypeRecovered NotificationType = iota + 1
	NotificationTypeRenewed
	NotificationTypeCanceled
	NotificationTypePurchased
	NotificationTypeAccountHold
	NotificationTypeGracePeriod
	NotificationTypeReactivated
)

type SubscriptionNotification

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

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

Jump to

Keyboard shortcuts

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