Documentation ¶
Index ¶
- Constants
- func VerifySignature(base64EncodedPublicKey string, receipt []byte, signature string) (isValid bool, err error)
- type Client
- func (c *Client) AcknowledgeProduct(ctx context.Context, packageName, productID, token, developerPayload string) error
- func (c *Client) AcknowledgeSubscription(ctx context.Context, packageName string, subscriptionID string, token string, ...) error
- func (c *Client) CancelSubscription(ctx context.Context, packageName string, subscriptionID string, token string) error
- func (c *Client) ConsumeProduct(ctx context.Context, packageName, productID, token string) error
- func (c *Client) DeferSubscription(ctx context.Context, packageName string, subscriptionID string, token string, ...) (*androidpublisher.SubscriptionPurchasesDeferResponse, error)
- func (c *Client) GetProduct(ctx context.Context, packageName string, skuID string) (*androidpublisher.InAppProduct, error)
- func (c *Client) GetSubscriptionOffer(ctx context.Context, packageName string, productID string, basePlanID string, ...) (*androidpublisher.SubscriptionOffer, error)
- func (c *Client) RefundSubscription(ctx context.Context, packageName string, subscriptionID string, token string) error
- func (c *Client) RevokeSubscription(ctx context.Context, packageName string, subscriptionID string, token string) error
- func (c *Client) RevokeSubscriptionV2(ctx context.Context, packageName string, token string, ...) (*androidpublisher.RevokeSubscriptionPurchaseResponse, error)
- func (c *Client) VerifyProduct(ctx context.Context, packageName string, productID string, token string) (*androidpublisher.ProductPurchase, error)
- func (c *Client) VerifySubscription(ctx context.Context, packageName string, subscriptionID string, token string) (*androidpublisher.SubscriptionPurchase, error)
- func (c *Client) VerifySubscriptionV2(ctx context.Context, packageName string, token string) (*androidpublisher.SubscriptionPurchaseV2, error)
- func (c *Client) VoidedPurchases(ctx context.Context, packageName string, startTime int64, endTime int64, ...) (*androidpublisher.VoidedPurchasesListResponse, error)
- type DeveloperNotification
- type DeveloperNotificationV2
- type IABMonetization
- type IABProduct
- type IABSubscription
- type IABSubscriptionV2
- type OneTimeProductNotification
- type OneTimeProductNotificationType
- type SubscriptionNotification
- type SubscriptionNotificationType
- type TestNotification
- type VoidedPurchaseNotification
- type VoidedPurchaseProductType
- type VoidedPurchaseRefundType
- type VoidedPurchaseType
Constants ¶
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 ¶
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 ¶
NewDefaultTokenSourceClient returns a client that authenticates using Google Application Default Credentials. See https://pkg.go.dev/golang.org/x/oauth2/google#DefaultTokenSource
func NewWithClient ¶
NewWithClient returns http client which includes the custom http client.
func (*Client) AcknowledgeProduct ¶
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, subscriptionID string, token string) error
CancelSubscription cancels a user's subscription purchase.
func (*Client) ConsumeProduct ¶
func (*Client) DeferSubscription ¶
func (c *Client) DeferSubscription(ctx context.Context, packageName string, subscriptionID string, token string, req *androidpublisher.SubscriptionPurchasesDeferRequest) (*androidpublisher.SubscriptionPurchasesDeferResponse, error)
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) GetProduct ¶
func (c *Client) GetProduct( ctx context.Context, packageName string, skuID string, ) (*androidpublisher.InAppProduct, error)
GetProduct gets product
func (*Client) GetSubscriptionOffer ¶
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 ¶
func (c *Client) RevokeSubscriptionV2( ctx context.Context, packageName string, token string, req *androidpublisher.RevokeSubscriptionPurchaseRequest, ) (*androidpublisher.RevokeSubscriptionPurchaseResponse, error)
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 ¶
func (c *Client) VerifySubscriptionV2( ctx context.Context, packageName string, token string, ) (*androidpublisher.SubscriptionPurchaseV2, error)
VerifySubscriptionV2 verifies subscription status
func (*Client) VoidedPurchases ¶
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 ¶
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 ¶
type IABMonetization interface {
GetSubscriptionOffer(context.Context, string, string, string, string) (*androidpublisher.SubscriptionOffer, error)
}
The IABMonetization type is an interface for monetization service
type IABProduct ¶
type IABProduct interface { GetProduct(context.Context, string, string) (*androidpublisher.InAppProduct, error) 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 ¶
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 DeferSubscription(context.Context, string, string, string, *androidpublisher.SubscriptionPurchasesDeferRequest) (*androidpublisher.SubscriptionPurchasesDeferResponse, error) }
The IABSubscription type is an interface for subscription service
type IABSubscriptionV2 ¶
type IABSubscriptionV2 interface { VerifySubscriptionV2(context.Context, string, string, string) (*androidpublisher.SubscriptionPurchaseV2, error) RevokeSubscriptionV2(context.Context, string, string, *androidpublisher.RevokeSubscriptionPurchaseRequest) (*androidpublisher.RevokeSubscriptionPurchaseResponse, error) }
The IABSubscriptionV2 type is an interface for subscriptionV2 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
type VoidedPurchaseNotification ¶
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 VoidedPurchaseProductType ¶
type VoidedPurchaseProductType int
https://developer.android.com/google/play/billing/rtdn-reference#voided-purchase
type VoidedPurchaseRefundType ¶
type VoidedPurchaseRefundType int
const ( VoidedPurchaseRefundTypeFullRefund VoidedPurchaseRefundType = iota + 1 VoidedPurchaseRefundTypePartialRefund )
type VoidedPurchaseType ¶
type VoidedPurchaseType int64
const ( VoidedPurchaseTypeWithoutSubscription VoidedPurchaseType = 0 VoidedPurchaseTypeWithSubscription VoidedPurchaseType = 1 )