forked from stripe/stripe-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathissuing_transaction.go
70 lines (60 loc) · 2.61 KB
/
issuing_transaction.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
package stripe
import "encoding/json"
// IssuingTransactionType is the type of an issuing transaction.
type IssuingTransactionType string
// List of values that IssuingTransactionType can take.
const (
IssuingTransactionTypeCapture IssuingTransactionType = "capture"
IssuingTransactionTypeCashWithdrawal IssuingTransactionType = "cash_withdrawal"
IssuingTransactionTypeRefund IssuingTransactionType = "refund"
IssuingTransactionTypeRefundReversal IssuingTransactionType = "refund_reversal"
)
// IssuingTransactionParams is the set of parameters that can be used when creating or updating an issuing transaction.
type IssuingTransactionParams struct {
Params `form:"*"`
}
// IssuingTransactionListParams is the set of parameters that can be used when listing issuing transactions.
type IssuingTransactionListParams struct {
ListParams `form:"*"`
Card *string `form:"card"`
Cardholder *string `form:"cardholder"`
Created *int64 `form:"created"`
CreatedRange *RangeQueryParams `form:"created"`
}
// IssuingTransaction is the resource representing a Stripe issuing transaction.
type IssuingTransaction struct {
Authorization *IssuingAuthorization `json:"authorization"`
BalanceTransaction *BalanceTransaction `json:"balance_transaction"`
Card *IssuingCard `json:"card"`
Cardholder *IssuingCardholder `json:"cardholder"`
Created int64 `json:"created"`
Currency Currency `json:"currency"`
Dispute *IssuingDispute `json:"dispute"`
ID string `json:"id"`
Livemode bool `json:"livemode"`
MerchantData *IssuingMerchantData `json:"merchant_data"`
Metadata map[string]string `json:"metadata"`
Object string `json:"object"`
Type IssuingTransactionType `json:"type"`
}
// IssuingTransactionList is a list of issuing transactions as retrieved from a list endpoint.
type IssuingTransactionList struct {
ListMeta
Data []*IssuingTransaction `json:"data"`
}
// UnmarshalJSON handles deserialization of an IssuingTransaction.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded.
func (i *IssuingTransaction) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type issuingTransaction IssuingTransaction
var v issuingTransaction
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = IssuingTransaction(v)
return nil
}