~evanj/cms

ref: 977e0de28ca8f9d30d073665642e89fddfde493f cms/vendor/github.com/stripe/stripe-go/v71/issuing_transaction.go -rw-r--r-- 6.7 KiB
977e0de2Evan J Feat(cms.go): Retrying if requests last too long. Effective max request 1 year, 18 days ago
                                                                                
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
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"
	IssuingTransactionTypeRefund  IssuingTransactionType = "refund"
)

// IssuingTransactionPurchaseDetailsFuelType is the type of fuel purchased in a transaction.
type IssuingTransactionPurchaseDetailsFuelType string

// List of values that IssuingTransactionType can take.
const (
	IssuingTransactionPurchaseDetailsFuelTypeDiesel          IssuingTransactionPurchaseDetailsFuelType = "diesel"
	IssuingTransactionPurchaseDetailsFuelTypeOther           IssuingTransactionPurchaseDetailsFuelType = "other"
	IssuingTransactionPurchaseDetailsFuelTypeUnleadedPlus    IssuingTransactionPurchaseDetailsFuelType = "unleaded_plus"
	IssuingTransactionPurchaseDetailsFuelTypeUnleadedRegular IssuingTransactionPurchaseDetailsFuelType = "unleaded_regular"
	IssuingTransactionPurchaseDetailsFuelTypeUnleadedSuper   IssuingTransactionPurchaseDetailsFuelType = "unleaded_super"
)

// IssuingTransactionPurchaseDetailsFuelUnit is the unit of fuel purchased in a transaction.
type IssuingTransactionPurchaseDetailsFuelUnit string

// List of values that IssuingTransactionPurchaseDetailsFuelUnit can take.
const (
	IssuingTransactionPurchaseDetailsFuelUnitLiter    IssuingTransactionPurchaseDetailsFuelUnit = "liter"
	IssuingTransactionPurchaseDetailsFuelUnitUSGallon IssuingTransactionPurchaseDetailsFuelUnit = "us_gallon"
)

// 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"`
}

// IssuingTransactionPurchaseDetailsFlightSegment contains extra information about the flight in this transaction.
type IssuingTransactionPurchaseDetailsFlightSegment struct {
	ArrivalAirportCode   string `json:"arrival_airport_code"`
	Carrier              string `json:"carrier"`
	DepartureAirportCode string `json:"departure_airport_code"`
	FlightNumber         string `json:"flight_number"`
	ServiceClass         string `json:"service_class"`
	StopoverAllowed      bool   `json:"stopover_allowed"`
}

// IssuingTransactionPurchaseDetailsFlight contains extra information about the flight in this transaction.
type IssuingTransactionPurchaseDetailsFlight struct {
	DepartureAt   int64                                             `json:"departure_at"`
	PassengerName string                                            `json:"passenger_name"`
	Refundable    bool                                              `json:"refundable"`
	Segments      []*IssuingTransactionPurchaseDetailsFlightSegment `json:"segments"`
	TravelAgency  string                                            `json:"travel_agency"`
}

// IssuingTransactionPurchaseDetailsFuel contains extra information about the fuel purchase in this transaction.
type IssuingTransactionPurchaseDetailsFuel struct {
	Type            IssuingTransactionPurchaseDetailsFuelType `json:"type"`
	Unit            IssuingTransactionPurchaseDetailsFuelUnit `json:"unit"`
	UnitCostDecimal float64                                   `json:"unit_cost_decimal,string"`
	VolumeDecimal   float64                                   `json:"volume_decimal,string"`
}

// IssuingTransactionPurchaseDetailsLodging contains extra information about the lodging purchase in this transaction.
type IssuingTransactionPurchaseDetailsLodging struct {
	CheckInAt int64 `json:"check_in_at"`
	Nights    int64 `json:"nights"`
}

// IssuingTransactionPurchaseDetailsReceipt contains extra information about the line items this transaction.
type IssuingTransactionPurchaseDetailsReceipt struct {
	Description string  `json:"description"`
	Quantity    float64 `json:"quantity"`
	Total       int64   `json:"total"`
	UnitCost    int64   `json:"unit_cost"`
}

// IssuingTransactionPurchaseDetails contains extra information provided by the merchant.
type IssuingTransactionPurchaseDetails struct {
	Flight    *IssuingTransactionPurchaseDetailsFlight    `json:"flight"`
	Fuel      *IssuingTransactionPurchaseDetailsFuel      `json:"fuel"`
	Lodging   *IssuingTransactionPurchaseDetailsLodging   `json:"lodging"`
	Receipt   []*IssuingTransactionPurchaseDetailsReceipt `json:"receipt"`
	Reference string                                      `json:"reference"`
}

// IssuingTransaction is the resource representing a Stripe issuing transaction.
type IssuingTransaction struct {
	APIResource
	Amount             int64                              `json:"amount"`
	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       *IssuingAuthorizationMerchantData  `json:"merchant_data"`
	MerchantAmount     int64                              `json:"merchant_amount"`
	MerchantCurrency   Currency                           `json:"merchant_currency"`
	Metadata           map[string]string                  `json:"metadata"`
	Object             string                             `json:"object"`
	PurchaseDetails    *IssuingTransactionPurchaseDetails `json:"purchase_details"`
	Type               IssuingTransactionType             `json:"type"`
}

// IssuingTransactionList is a list of issuing transactions as retrieved from a list endpoint.
type IssuingTransactionList struct {
	APIResource
	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
}