Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple API Changes #1241

Merged
merged 6 commits into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 78 additions & 9 deletions checkout_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,58 @@ import (
"encoding/json"
)

// CheckoutSessionCustomerDetailsTaxIdsType is the list of allowed values for type
// on the tax_ids inside customer_details of a checkout session.
type CheckoutSessionCustomerDetailsTaxIdsType string
richardm-stripe marked this conversation as resolved.
Show resolved Hide resolved

// List of values that CheckoutSessionCustomerDetailsTaxIdsType can take.
const (
CheckoutSessionCustomerDetailsTaxIdsTypeAETRN CheckoutSessionCustomerDetailsTaxIdsType = "ae_trn"
CheckoutSessionCustomerDetailsTaxIdsTypeAUABN CheckoutSessionCustomerDetailsTaxIdsType = "au_abn"
CheckoutSessionCustomerDetailsTaxIdsTypeBRCNPJ CheckoutSessionCustomerDetailsTaxIdsType = "br_cnpj"
CheckoutSessionCustomerDetailsTaxIdsTypeBRCPF CheckoutSessionCustomerDetailsTaxIdsType = "br_cpf"
CheckoutSessionCustomerDetailsTaxIdsTypeCABN CheckoutSessionCustomerDetailsTaxIdsType = "ca_bn"
CheckoutSessionCustomerDetailsTaxIdsTypeCAQST CheckoutSessionCustomerDetailsTaxIdsType = "ca_qst"
CheckoutSessionCustomerDetailsTaxIdsTypeCHVAT CheckoutSessionCustomerDetailsTaxIdsType = "ch_vat"
CheckoutSessionCustomerDetailsTaxIdsTypeCLTIN CheckoutSessionCustomerDetailsTaxIdsType = "cl_tin"
CheckoutSessionCustomerDetailsTaxIdsTypeESCIF CheckoutSessionCustomerDetailsTaxIdsType = "es_cif"
CheckoutSessionCustomerDetailsTaxIdsTypeEUVAT CheckoutSessionCustomerDetailsTaxIdsType = "eu_vat"
CheckoutSessionCustomerDetailsTaxIdsTypeHKBR CheckoutSessionCustomerDetailsTaxIdsType = "hk_br"
CheckoutSessionCustomerDetailsTaxIdsTypeIDNPWP CheckoutSessionCustomerDetailsTaxIdsType = "id_npwp"
CheckoutSessionCustomerDetailsTaxIdsTypeINGST CheckoutSessionCustomerDetailsTaxIdsType = "in_gst"
CheckoutSessionCustomerDetailsTaxIdsTypeJPCN CheckoutSessionCustomerDetailsTaxIdsType = "jp_cn"
CheckoutSessionCustomerDetailsTaxIdsTypeJPRN CheckoutSessionCustomerDetailsTaxIdsType = "jp_rn"
CheckoutSessionCustomerDetailsTaxIdsTypeKRBRN CheckoutSessionCustomerDetailsTaxIdsType = "kr_brn"
CheckoutSessionCustomerDetailsTaxIdsTypeLIUID CheckoutSessionCustomerDetailsTaxIdsType = "li_uid"
CheckoutSessionCustomerDetailsTaxIdsTypeMXRFC CheckoutSessionCustomerDetailsTaxIdsType = "mx_rfc"
CheckoutSessionCustomerDetailsTaxIdsTypeMYFRP CheckoutSessionCustomerDetailsTaxIdsType = "my_frp"
CheckoutSessionCustomerDetailsTaxIdsTypeMYITN CheckoutSessionCustomerDetailsTaxIdsType = "my_itn"
CheckoutSessionCustomerDetailsTaxIdsTypeMYSST CheckoutSessionCustomerDetailsTaxIdsType = "my_sst"
CheckoutSessionCustomerDetailsTaxIdsTypeNOVAT CheckoutSessionCustomerDetailsTaxIdsType = "no_vat"
CheckoutSessionCustomerDetailsTaxIdsTypeNZGST CheckoutSessionCustomerDetailsTaxIdsType = "nz_gst"
CheckoutSessionCustomerDetailsTaxIdsTypeRUINN CheckoutSessionCustomerDetailsTaxIdsType = "ru_inn"
CheckoutSessionCustomerDetailsTaxIdsTypeRUKPP CheckoutSessionCustomerDetailsTaxIdsType = "ru_kpp"
CheckoutSessionCustomerDetailsTaxIdsTypeSAVAT CheckoutSessionCustomerDetailsTaxIdsType = "sa_vat"
CheckoutSessionCustomerDetailsTaxIdsTypeSGGST CheckoutSessionCustomerDetailsTaxIdsType = "sg_gst"
CheckoutSessionCustomerDetailsTaxIdsTypeSGUEN CheckoutSessionCustomerDetailsTaxIdsType = "sg_uen"
CheckoutSessionCustomerDetailsTaxIdsTypeTHVAT CheckoutSessionCustomerDetailsTaxIdsType = "th_vat"
CheckoutSessionCustomerDetailsTaxIdsTypeTWVAT CheckoutSessionCustomerDetailsTaxIdsType = "tw_vat"
CheckoutSessionCustomerDetailsTaxIdsTypeUnknown CheckoutSessionCustomerDetailsTaxIdsType = "unknown"
CheckoutSessionCustomerDetailsTaxIdsTypeUSEIN CheckoutSessionCustomerDetailsTaxIdsType = "us_ein"
CheckoutSessionCustomerDetailsTaxIdsTypeZAVAT CheckoutSessionCustomerDetailsTaxIdsType = "za_vat"
)

// CheckoutSessionCustomerDetailsTaxExempt is the list of allowed values for
// tax_exempt inside customer_details of a checkout session.
type CheckoutSessionCustomerDetailsTaxExempt string

// List of values that CheckoutSessionCustomerDetailsTaxExempt can take.
const (
CheckoutSessionCustomerDetailsTaxExemptExempt CheckoutSessionCustomerDetailsTaxExempt = "exempt"
CheckoutSessionCustomerDetailsTaxExemptNone CheckoutSessionCustomerDetailsTaxExempt = "none"
CheckoutSessionCustomerDetailsTaxExemptReverse CheckoutSessionCustomerDetailsTaxExempt = "reverse"
)

// CheckoutSessionMode is the list of allowed values for the mode on a Session.
type CheckoutSessionMode string

Expand Down Expand Up @@ -75,15 +127,16 @@ type CheckoutSessionDiscountParams struct {
// CheckoutSessionLineItemParams is the set of parameters allowed for a line item
// on a checkout session.
type CheckoutSessionLineItemParams struct {
Amount *int64 `form:"amount"`
Currency *string `form:"currency"`
Description *string `form:"description"`
Images []*string `form:"images"`
Name *string `form:"name"`
Price *string `form:"price"`
PriceData *CheckoutSessionLineItemPriceDataParams `form:"price_data"`
Quantity *int64 `form:"quantity"`
TaxRates []*string `form:"tax_rates"`
Amount *int64 `form:"amount"`
Currency *string `form:"currency"`
Description *string `form:"description"`
DynamicTaxRates []*string `form:"dynamic_tax_rates"`
Images []*string `form:"images"`
Name *string `form:"name"`
Price *string `form:"price"`
PriceData *CheckoutSessionLineItemPriceDataParams `form:"price_data"`
Quantity *int64 `form:"quantity"`
TaxRates []*string `form:"tax_rates"`
}

// CheckoutSessionPaymentIntentDataTransferDataParams is the set of parameters allowed for the
Expand Down Expand Up @@ -187,6 +240,21 @@ type CheckoutSessionListParams struct {
Subscription *string `form:"subscription"`
}

// CheckoutSessionCustomerDetailsTaxIds represent customer's tax IDs at the
// time of checkout.
type CheckoutSessionCustomerDetailsTaxIds struct {
Type CheckoutSessionCustomerDetailsTaxIdsType `json:"type"`
Value string `json:"value"`
}

// CheckoutSessionCustomerDetails represent the customer details including
// the tax exempt status and the customer's tax IDs.
type CheckoutSessionCustomerDetails struct {
Email string `json:"email"`
TaxExempt CheckoutSessionCustomerDetailsTaxExempt `json:"tax_exempt"`
TaxIds *[]CheckoutSessionCustomerDetailsTaxIds `json:"tax_ids"`
richardm-stripe marked this conversation as resolved.
Show resolved Hide resolved
}

// CheckoutSessionShippingAddressCollection is the set of parameters allowed for the
// shipping address collection.
type CheckoutSessionShippingAddressCollection struct {
Expand Down Expand Up @@ -224,6 +292,7 @@ type CheckoutSession struct {
APIResource
AllowPromotionCodes bool `json:"allow_promotion_codes"`
CancelURL string `json:"cancel_url"`
CustomerDetails *CheckoutSessionCustomerDetails `json:"customer_details"`
AmountSubtotal int64 `json:"amount_subtotal"`
AmountTotal int64 `json:"amount_total"`
ClientReferenceID string `json:"client_reference_id"`
Expand Down
19 changes: 15 additions & 4 deletions issuing_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ const (
IssuingTransactionPurchaseDetailsFuelUnitUSGallon IssuingTransactionPurchaseDetailsFuelUnit = "us_gallon"
)

// IssuingTransactionListType is the possible values for type when
// listing issuing transactions.
type IssuingTransactionListType string

// List of values that IssuingTransactionListType can take.
const (
IssuingTransactionListTypeCapture IssuingTransactionListType = "capture"
IssuingTransactionListTypeRefund IssuingTransactionListType = "refund"
)

// IssuingTransactionParams is the set of parameters that can be used when creating or updating an issuing transaction.
type IssuingTransactionParams struct {
Params `form:"*"`
Expand All @@ -40,10 +50,11 @@ type IssuingTransactionParams struct {
// 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"`
Card *string `form:"card"`
Cardholder *string `form:"cardholder"`
Created *int64 `form:"created"`
CreatedRange *RangeQueryParams `form:"created"`
Type *IssuingTransactionListType `form:"type"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use enums in params, this should be *string instead and we don't need the type. Also if we used the type we would use IssuingTransactionType instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woot! Great to know.

}

// IssuingTransactionAmountDetails is the resource representing the breakdown of the amount.
Expand Down
4 changes: 4 additions & 0 deletions taxrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import "encoding/json"
type TaxRateParams struct {
Params `form:"*"`
Active *bool `form:"active"`
Country *string `form:"country"`
Description *string `form:"description"`
DisplayName *string `form:"display_name"`
Inclusive *bool `form:"inclusive"`
Jurisdiction *string `form:"jurisdiction"`
Percentage *float64 `form:"percentage"`
State *string `form:"state"`
}

// TaxRateListParams is the set of parameters that can be used when listing tax rates.
Expand All @@ -29,6 +31,7 @@ type TaxRateListParams struct {
type TaxRate struct {
APIResource
Active bool `json:"active"`
Country string `json:"country"`
Created int64 `json:"created"`
Description string `json:"description"`
DisplayName string `json:"display_name"`
Expand All @@ -39,6 +42,7 @@ type TaxRate struct {
Metadata map[string]string `json:"metadata"`
Object string `json:"object"`
Percentage float64 `json:"percentage"`
State string `json:"state"`
}

// TaxRateList is a list of tax rates as retrieved from a list endpoint.
Expand Down