Documentation ¶
Index ¶
- func SetTimeout(t time.Duration)
- func VerifySignature(base64EncodedPublicKey string, receipt []byte, signature string) (isValid bool, err error)
- type Client
- func (c *Client) CancelSubscription(packageName string, subscriptionID string, token string) error
- func (c *Client) RefundSubscription(packageName string, subscriptionID string, token string) error
- func (c *Client) RevokeSubscription(packageName string, subscriptionID string, token string) error
- func (c *Client) VerifyProduct(packageName string, productID string, token string) (*androidpublisher.ProductPurchase, error)
- func (c *Client) VerifySubscription(packageName string, subscriptionID string, token string) (*androidpublisher.SubscriptionPurchase, error)
- type DeveloperNotification
- type IABClient
- type NotificationType
- type SubscriptionNotification
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 ¶
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 (*Client) CancelSubscription ¶
CancelSubscription cancels a user's subscription purchase.
func (*Client) RefundSubscription ¶
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 ¶
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( packageName string, productID string, token string, ) (*androidpublisher.ProductPurchase, error)
VerifyProduct verifies product status
func (*Client) VerifySubscription ¶
func (c *Client) VerifySubscription( 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(string, string, string) (*androidpublisher.SubscriptionPurchase, error) VerifyProduct(string, string, string) (*androidpublisher.ProductPurchase, error) CancelSubscription(string, string, string) error RefundSubscription(string, string, string) error RevokeSubscription(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.