forked from mhemmings/revenuecat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
google.go
31 lines (25 loc) · 1.06 KB
/
google.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package revenuecat
import "time"
// 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) RefundGoogleSubscription(userID string, id string) (Subscriber, error) {
var resp struct {
Subscriber Subscriber `json:"subscriber"`
}
err := c.call("POST", "subscribers/"+userID+"/subscriptions/"+id+"/revoke", nil, "", &resp)
return resp.Subscriber, err
}
// DeferGoogleSubscription defers the purchase of a Google Subscription to a later date.
// https://docs.revenuecat.com/reference#defer-a-google-subscription
func (c *Client) DeferGoogleSubscription(userID string, id string, nextExpiry time.Time) (Subscriber, error) {
var resp struct {
Subscriber Subscriber `json:"subscriber"`
}
req := struct {
ExpiryTime int64 `json:"expiry_time_ms,omitempty"`
}{
ExpiryTime: toMilliseconds(nextExpiry),
}
err := c.call("POST", "subscribers/"+userID+"/subscriptions/"+id+"/defer", req, "", &resp)
return resp.Subscriber, err
}