forked from stripe/stripe-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
38 lines (30 loc) · 1.08 KB
/
client.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
32
33
34
35
36
37
38
// Package discount provides the discount-related APIs
package discount
import (
"fmt"
stripe "github.com/stripe/stripe-go"
)
// Client is used to invoke discount-related APIs.
type Client struct {
B stripe.Backend
Key string
}
// Del removes a discount from a customer.
// For more details see https://stripe.com/docs/api#delete_discount.
func Del(customerID string) error {
return getC().Del(customerID)
}
func (c Client) Del(customerID string) error {
return c.B.Call("DELETE", fmt.Sprintf("/customers/%v/discount", customerID), c.Key, nil, nil, nil)
}
// DelSub removes a discount from a customer's subscription.
// For more details see https://stripe.com/docs/api#delete_subscription_discount.
func DelSub(customerID, subscriptionID string) error {
return getC().DelSub(customerID, subscriptionID)
}
func (c Client) DelSub(customerID, subscriptionID string) error {
return c.B.Call("DELETE", fmt.Sprintf("/customers/%v/subscriptions/%v/discount", customerID, subscriptionID), c.Key, nil, nil, nil)
}
func getC() Client {
return Client{stripe.GetBackend(stripe.APIBackend), stripe.Key}
}