Go package for interacting with the RevenueCat API.
package main
import (
"fmt"
"github.com/mhemmings/revenuecat"
)
func main() {
rc := revenuecat.New("apikey")
sub, _ := rc.GetSubscriber("123")
entitled := sub.IsEntitledTo("premium")
fmt.Println("user entitled: %t", entitled)
}
For full documentation, see pkg.go.dev/github.com/mhemmings/revenuecat
func (c *Client) AddUserAttribution(userID string, network Network, data AttributionData) error
AddUserAttribution attaches attribution data to a subscriber from specific supported networks. https://docs.revenuecat.com/reference#subscribersattribution
func (c *Client) CreatePurchase(userID string, receipt string, opt *CreatePurchaseOptions) (Subscriber, error)
CreatePurchase records a purchase for a user from iOS, Android, or Stripe and will create a user if they don't already exist. https://docs.revenuecat.com/reference#receipts
func (c *Client) DeferGoogleSubscription(userID string, id string, nextExpiry time.Time) (Subscriber, error)
DeferGoogleSubscription defers the purchase of a Google Subscription to a later date. https://docs.revenuecat.com/reference#defer-a-google-subscription
func (c *Client) DeleteOfferingOverride(userID string) (Subscriber, error)
DeleteOfferingOverride reset the offering overrides back to the current offering for a specific user. https://docs.revenuecat.com/reference#delete-offering-override
func (c *Client) DeleteSubscriber(userID string) error
DeleteSubscriber permanently deletes a subscriber. https://docs.revenuecat.com/reference#subscribersapp_user_id
func (c *Client) GetSubscriber(userID string) (Subscriber, error)
GetSubscriber gets the latest subscriber info or creates one if it doesn't exist. https://docs.revenuecat.com/reference#subscribers
func (c *Client) GetSubscriberWithPlatform(userID string, platform string) (Subscriber, error)
GetSubscriberWithPlatform gets the latest subscriber info or creates one if it doesn't exist, updating the subscriber record's last_seen value for the platform provided. https://docs.revenuecat.com/reference#subscribers
func (c *Client) GrantEntitlement(userID string, id string, duration Duration, startTime time.Time) (Subscriber, error)
GrantEntitlement grants a user a promotional entitlement. https://docs.revenuecat.com/reference#grant-a-promotional-entitlement
func (c *Client) OverrideOffering(userID string, offeringUUID string) (Subscriber, error)
OverrideOffering overrides the current Offering for a specific user. https://docs.revenuecat.com/reference#override-offering
func (c *Client) RefundGoogleSubscription(userID string, id string) (Subscriber, error)
RefundGoogleSubscription immediately revokes access to a Google Subscription and issues a refund for the last purchase. https://docs.revenuecat.com/reference#revoke-a-google-subscription
func (c *Client) RevokeEntitlement(userID string, id string) (Subscriber, error)
RevokeEntitlement revokes all promotional entitlements for a given entitlement identifier and app user ID. https://docs.revenuecat.com/reference#revoke-promotional-entitlements
func (c *Client) UpdateSubscriberAttributes(userID string, attributes map[string]SubscriberAttribute) error
UpdateSubscriberAttributes updates subscriber attributes for a user. https://docs.revenuecat.com/reference#update-subscriber-attributes