-
Notifications
You must be signed in to change notification settings - Fork 390
/
service.go
104 lines (84 loc) · 2.28 KB
/
service.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package payments
import (
"context"
"time"
)
// Service is interfaces that defines behavior for working with payments
type Service interface {
CreateCustomer(ctx context.Context, params CreateCustomerParams) (*Customer, error)
GetCustomer(ctx context.Context, id []byte) (*Customer, error)
GetCustomerDefaultPaymentMethod(ctx context.Context, customerID []byte) (*PaymentMethod, error)
GetCustomerPaymentsMethods(ctx context.Context, customerID []byte) ([]PaymentMethod, error)
GetPaymentMethod(ctx context.Context, id []byte) (*PaymentMethod, error)
CreateProjectInvoice(ctx context.Context, params CreateProjectInvoiceParams) (*Invoice, error)
GetInvoice(ctx context.Context, id []byte) (*Invoice, error)
}
// CreateCustomerParams contains info needed to create new customer
type CreateCustomerParams struct {
Email string
Name string
}
// Customer contains customer info
type Customer struct {
ID []byte
Name string
Email string
CreatedAt time.Time
}
// Card contains credit card info
type Card struct {
Country string
Brand string
Name string
ExpMonth int64
ExpYear int64
LastFour string
}
// PaymentMethod contains payment method description.
// Credit cards are the only allowed payment methods so far
type PaymentMethod struct {
ID []byte
CustomerID []byte
Card Card
CreatedAt time.Time
}
// CreateProjectInvoiceParams contains info needed to create project invoice
type CreateProjectInvoiceParams struct {
ProjectName string
CustomerID []byte
PaymentMethodID []byte
Storage float64
Egress float64
ObjectCount float64
StartDate time.Time
EndDate time.Time
}
// Currency is type for allowed currency
type Currency string
const (
// CurrencyUSD is USA default currency
CurrencyUSD Currency = "usd"
)
// LineItem contains invoice line item info
type LineItem struct {
Key string
Quantity int64
Amount int64
}
// CustomField represents custom field/value field
type CustomField struct {
Name string
Value string
}
// Invoice holds invoice information
type Invoice struct {
ID []byte
PaymentMethodID []byte
Amount int64
Currency Currency
LineItems []LineItem
CustomFields []CustomField
CreatedAt time.Time
}