-
Notifications
You must be signed in to change notification settings - Fork 8
/
events_billing.go
54 lines (42 loc) · 1.22 KB
/
events_billing.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
45
46
47
48
49
50
51
52
53
54
package scalingo
import (
"fmt"
"github.com/Scalingo/go-scalingo/v7/billing"
)
type EventAddCreditType struct {
Event
TypeData EventAddCreditTypeData `json:"type_data"`
}
func (ev *EventAddCreditType) String() string {
return fmt.Sprintf(
"%f€ of credit added to your account (%s)", ev.TypeData.Amount, ev.TypeData.PaymentMethod,
)
}
type EventAddCreditTypeData struct {
PaymentMethod string `json:"payment_method"`
Amount float64 `json:"amount"`
}
type EventAddPaymentMethodType struct {
Event
TypeData EventAddPaymentMethodTypeData `json:"type_data"`
}
func (ev *EventAddPaymentMethodType) String() string {
if ev.TypeData.Profile.PaymentMethodType == billing.Stripe {
p := ev.TypeData.Profile.Stripe
return fmt.Sprintf("%s card ending with ...%s, expiring in %s", p.Brand, p.Last4, p.Exp)
}
return fmt.Sprintf("'%s' payment method added", ev.TypeData.Profile.PaymentMethodType)
}
type EventAddPaymentMethodTypeData struct {
billing.Profile
}
type EventAddVoucherType struct {
Event
TypeData EventAddVoucherTypeData `json:"type_data"`
}
func (ev *EventAddVoucherType) String() string {
return fmt.Sprintf("code: '%s'", ev.TypeData.Code)
}
type EventAddVoucherTypeData struct {
Code string `json:"code"`
}