forked from stripe/stripe-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
44 lines (34 loc) · 1.22 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
39
40
41
42
43
44
// 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) (*stripe.Discount, error) {
return getC().Del(customerID)
}
func (c Client) Del(customerID string) (*stripe.Discount, error) {
discount := &stripe.Discount{}
err := c.B.Call("DELETE", fmt.Sprintf("/customers/%v/discount", customerID), c.Key, nil, nil, discount)
return discount, err
}
// DelSub removes a discount from a customer's subscription.
// For more details see https://stripe.com/docs/api#delete_subscription_discount.
func DelSub(subscriptionID string) (*stripe.Discount, error) {
return getC().DelSub(subscriptionID)
}
func (c Client) DelSub(subscriptionID string) (*stripe.Discount, error) {
discount := &stripe.Discount{}
err := c.B.Call("DELETE", fmt.Sprintf("/subscriptions/%v/discount", subscriptionID), c.Key, nil, nil, discount)
return discount, err
}
func getC() Client {
return Client{stripe.GetBackend(stripe.APIBackend), stripe.Key}
}