Skip to content

Commit

Permalink
API Updates (#1328)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcr-stripe committed Aug 19, 2021
1 parent bfd5bb2 commit 6a809e5
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 143 deletions.
9 changes: 9 additions & 0 deletions address.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,12 @@ type ShippingDetailsParams struct {
Phone *string `form:"phone"`
TrackingNumber *string `form:"tracking_number"`
}

// ShippingDetails is the structure containing shipping information.
type ShippingDetails struct {
Address *Address `json:"address"`
Carrier string `json:"carrier"`
Name string `json:"name"`
Phone string `json:"phone"`
TrackingNumber string `json:"tracking_number"`
}
126 changes: 63 additions & 63 deletions charge.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,8 @@ type ChargePaymentMethodDetailsCard struct {
Funding CardFunding `json:"funding"`
Installments *ChargePaymentMethodDetailsCardInstallments `json:"installments"`
Last4 string `json:"last4"`
Network PaymentMethodCardNetwork `json:"network"`
MOTO bool `json:"moto"`
Network PaymentMethodCardNetwork `json:"network"`
ThreeDSecure *ChargePaymentMethodDetailsCardThreeDSecure `json:"three_d_secure"`
Wallet *ChargePaymentMethodDetailsCardWallet `json:"wallet"`

Expand Down Expand Up @@ -512,6 +512,11 @@ type ChargePaymentMethodDetailsP24 struct {
Reference string `json:"reference"`
VerifiedName string `json:"verified_name"`
}
type ChargePaymentMethodDetailsSepaCreditTransfer struct {
BankName string `json:"bank_name"`
Bic string `json:"bic"`
Iban string `json:"iban"`
}

// ChargePaymentMethodDetailsSepaDebit represents details about the Sepa Debit PaymentMethod.
type ChargePaymentMethodDetailsSepaDebit struct {
Expand Down Expand Up @@ -551,32 +556,34 @@ type ChargePaymentMethodDetailsWechatPay struct {
// ChargePaymentMethodDetails represents the details about the PaymentMethod associated with the
// charge.
type ChargePaymentMethodDetails struct {
AchCreditTransfer *ChargePaymentMethodDetailsAchCreditTransfer `json:"ach_credit_transfer"`
AchDebit *ChargePaymentMethodDetailsAchDebit `json:"ach_debit"`
AcssDebit *ChargePaymentMethodDetailsAcssDebit `json:"acss_debit"`
AfterpayClearpay *ChargePaymentMethodDetailsAfterpayClearpay `json:"afterpay_clearpay"`
Alipay *ChargePaymentMethodDetailsAlipay `json:"alipay"`
AUBECSDebit *ChargePaymentMethodDetailsAUBECSDebit `json:"au_becs_debit"`
BACSDebit *ChargePaymentMethodDetailsBACSDebit `json:"bacs_debit"`
Bancontact *ChargePaymentMethodDetailsBancontact `json:"bancontact"`
Boleto *ChargePaymentMethodDetailsBoleto `json:"boleto"`
Card *ChargePaymentMethodDetailsCard `json:"card"`
CardPresent *ChargePaymentMethodDetailsCardPresent `json:"card_present"`
Eps *ChargePaymentMethodDetailsEps `json:"eps"`
FPX *ChargePaymentMethodDetailsFPX `json:"fpx"`
Giropay *ChargePaymentMethodDetailsGiropay `json:"giropay"`
Grabpay *ChargePaymentMethodDetailsGrabpay `json:"grabpay"`
Ideal *ChargePaymentMethodDetailsIdeal `json:"ideal"`
Klarna *ChargePaymentMethodDetailsKlarna `json:"klarna"`
Multibanco *ChargePaymentMethodDetailsMultibanco `json:"multibanco"`
OXXO *ChargePaymentMethodDetailsOXXO `json:"oxxo"`
P24 *ChargePaymentMethodDetailsP24 `json:"p24"`
SepaDebit *ChargePaymentMethodDetailsSepaDebit `json:"sepa_debit"`
Sofort *ChargePaymentMethodDetailsSofort `json:"sofort"`
StripeAccount *ChargePaymentMethodDetailsStripeAccount `json:"stripe_account"`
Type ChargePaymentMethodDetailsType `json:"type"`
Wechat *ChargePaymentMethodDetailsWechat `json:"wechat"`
WechatPay *ChargePaymentMethodDetailsWechatPay `json:"wechat_pay"`
AchCreditTransfer *ChargePaymentMethodDetailsAchCreditTransfer `json:"ach_credit_transfer"`
AchDebit *ChargePaymentMethodDetailsAchDebit `json:"ach_debit"`
AcssDebit *ChargePaymentMethodDetailsAcssDebit `json:"acss_debit"`
AfterpayClearpay *ChargePaymentMethodDetailsAfterpayClearpay `json:"afterpay_clearpay"`
Alipay *ChargePaymentMethodDetailsAlipay `json:"alipay"`
AUBECSDebit *ChargePaymentMethodDetailsAUBECSDebit `json:"au_becs_debit"`
BACSDebit *ChargePaymentMethodDetailsBACSDebit `json:"bacs_debit"`
Bancontact *ChargePaymentMethodDetailsBancontact `json:"bancontact"`
Boleto *ChargePaymentMethodDetailsBoleto `json:"boleto"`
Card *ChargePaymentMethodDetailsCard `json:"card"`
CardPresent *ChargePaymentMethodDetailsCardPresent `json:"card_present"`
Eps *ChargePaymentMethodDetailsEps `json:"eps"`
FPX *ChargePaymentMethodDetailsFPX `json:"fpx"`
Giropay *ChargePaymentMethodDetailsGiropay `json:"giropay"`
Grabpay *ChargePaymentMethodDetailsGrabpay `json:"grabpay"`
Ideal *ChargePaymentMethodDetailsIdeal `json:"ideal"`
InteracPresent *ChargePaymentMethodDetailsInteracPresent `json:"interac_present"`
Klarna *ChargePaymentMethodDetailsKlarna `json:"klarna"`
Multibanco *ChargePaymentMethodDetailsMultibanco `json:"multibanco"`
OXXO *ChargePaymentMethodDetailsOXXO `json:"oxxo"`
P24 *ChargePaymentMethodDetailsP24 `json:"p24"`
SepaCreditTransfer *ChargePaymentMethodDetailsSepaCreditTransfer `json:"sepa_credit_transfer"`
SepaDebit *ChargePaymentMethodDetailsSepaDebit `json:"sepa_debit"`
Sofort *ChargePaymentMethodDetailsSofort `json:"sofort"`
StripeAccount *ChargePaymentMethodDetailsStripeAccount `json:"stripe_account"`
Type ChargePaymentMethodDetailsType `json:"type"`
Wechat *ChargePaymentMethodDetailsWechat `json:"wechat"`
WechatPay *ChargePaymentMethodDetailsWechatPay `json:"wechat_pay"`
}

// ChargeTransferData represents the information for the transfer_data associated with a charge.
Expand Down Expand Up @@ -615,7 +622,9 @@ type Charge struct {
Level3 ChargeLevel3 `json:"level3"`
Livemode bool `json:"livemode"`
Metadata map[string]string `json:"metadata"`
Object string `json:"object"`
OnBehalfOf *Account `json:"on_behalf_of"`
Order *Order `json:"order"`
Outcome *ChargeOutcome `json:"outcome"`
Paid bool `json:"paid"`
PaymentIntent *PaymentIntent `json:"payment_intent"`
Expand All @@ -638,36 +647,10 @@ type Charge struct {
TransferGroup string `json:"transfer_group"`
}

// UnmarshalJSON handles deserialization of a charge.
// This custom unmarshaling is needed because the resulting
// property may be an ID or the full struct if it was expanded.
func (c *Charge) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}

type charge Charge
var v charge
if err := json.Unmarshal(data, &v); err != nil {
return err
}

*c = Charge(v)
return nil
}

// ChargeList is a list of charges as retrieved from a list endpoint.
type ChargeList struct {
APIResource
ListMeta
Data []*Charge `json:"data"`
}

// FraudDetails is the structure detailing fraud status.
type FraudDetails struct {
UserReport ChargeFraudUserReport `json:"user_report"`
StripeReport ChargeFraudStripeReport `json:"stripe_report"`
UserReport ChargeFraudUserReport `json:"user_report"`
}

// ChargeOutcomeRule tells you the Radar rule that blocked the charge, if any.
Expand All @@ -689,15 +672,6 @@ type ChargeOutcome struct {
Type string `json:"type"`
}

// ShippingDetails is the structure containing shipping information.
type ShippingDetails struct {
Address *Address `json:"address"`
Carrier string `json:"carrier"`
Name string `json:"name"`
Phone string `json:"phone"`
TrackingNumber string `json:"tracking_number"`
}

// UnmarshalJSON handles deserialization of a ChargeOutcomeRule.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded.
Expand All @@ -716,3 +690,29 @@ func (c *ChargeOutcomeRule) UnmarshalJSON(data []byte) error {
*c = ChargeOutcomeRule(v)
return nil
}

// ChargeList is a list of charges as retrieved from a list endpoint.
type ChargeList struct {
APIResource
ListMeta
Data []*Charge `json:"data"`
}

// UnmarshalJSON handles deserialization of a Charge.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded.
func (c *Charge) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}

type charge Charge
var v charge
if err := json.Unmarshal(data, &v); err != nil {
return err
}

*c = Charge(v)
return nil
}
3 changes: 3 additions & 0 deletions checkout_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type CheckoutSessionCustomerDetailsTaxIDsType string
const (
CheckoutSessionCustomerDetailsTaxIDsTypeAETRN CheckoutSessionCustomerDetailsTaxIDsType = "ae_trn"
CheckoutSessionCustomerDetailsTaxIDsTypeAUABN CheckoutSessionCustomerDetailsTaxIDsType = "au_abn"
CheckoutSessionCustomerDetailsTaxIDsTypeAUARN CheckoutSessionCustomerDetailsTaxIDsType = "au_arn"
CheckoutSessionCustomerDetailsTaxIDsTypeBRCNPJ CheckoutSessionCustomerDetailsTaxIDsType = "br_cnpj"
CheckoutSessionCustomerDetailsTaxIDsTypeBRCPF CheckoutSessionCustomerDetailsTaxIDsType = "br_cpf"
CheckoutSessionCustomerDetailsTaxIDsTypeCABN CheckoutSessionCustomerDetailsTaxIDsType = "ca_bn"
Expand Down Expand Up @@ -183,6 +184,8 @@ type CheckoutSessionLineItemPriceDataParams struct {
UnitAmount *int64 `form:"unit_amount"`
UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"`
}

// Settings for automatic tax lookup for this session and resulting payments, invoices, and subscriptions.
type CheckoutSessionAutomaticTaxParams struct {
Enabled *bool `form:"enabled"`
}
Expand Down
1 change: 0 additions & 1 deletion client/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import (
issuingcardholder "github.com/stripe/stripe-go/v72/issuing/cardholder"
issuingdispute "github.com/stripe/stripe-go/v72/issuing/dispute"
issuingtransaction "github.com/stripe/stripe-go/v72/issuing/transaction"
"github.com/stripe/stripe-go/v72/lineitem"
"github.com/stripe/stripe-go/v72/loginlink"
"github.com/stripe/stripe-go/v72/mandate"
"github.com/stripe/stripe-go/v72/oauth"
Expand Down
2 changes: 1 addition & 1 deletion quote.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ type QuoteListLineItemsParams struct {
Quote *string `form:"-"` // Included in URL
}

// When retrieving a quote, there is an includable upfront.line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of upfront line items.
// When retrieving a quote, there is an includable [computed.upfront.line_items](https://stripe.com/docs/api/quotes/object#quote_object-computed-upfront-line_items) property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of upfront line items.
type QuoteListComputedUpfrontLineItemsParams struct {
ListParams `form:"*"`
Quote *string `form:"-"` // Included in URL
Expand Down
55 changes: 30 additions & 25 deletions radar/earlyfraudwarning/client.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// Package earlyfraudwarning provides API functions related to early fraud
// warnings.
//
// For more details, see: https://stripe.com/docs/api/early_fraud_warnings?lang=go
//
// File generated from our OpenAPI spec
//
//

// Package earlyfraudwarning provides the /radar/early_fraud_warnings APIs
package earlyfraudwarning

import (
Expand All @@ -11,58 +14,60 @@ import (
"github.com/stripe/stripe-go/v72/form"
)

// Client is used to interact with the /radar/early_fraud_warnings API.
// Client is used to invoke /radar/early_fraud_warnings APIs.
type Client struct {
B stripe.Backend
Key string
}

// Get returns the details of an early fraud warning.
// Get returns the details of a radar early fraud warning.
func Get(id string, params *stripe.RadarEarlyFraudWarningParams) (*stripe.RadarEarlyFraudWarning, error) {
return getC().Get(id, params)
}

// Get returns the details of an early fraud warning.
// Get returns the details of a radar early fraud warning.
func (c Client) Get(id string, params *stripe.RadarEarlyFraudWarningParams) (*stripe.RadarEarlyFraudWarning, error) {
path := stripe.FormatURLPath("/v1/radar/early_fraud_warnings/%s", id)
ifr := &stripe.RadarEarlyFraudWarning{}
err := c.B.Call(http.MethodGet, path, c.Key, params, ifr)
return ifr, err
earlyfraudwarning := &stripe.RadarEarlyFraudWarning{}
err := c.B.Call(http.MethodGet, path, c.Key, params, earlyfraudwarning)
return earlyfraudwarning, err
}

// List returns a list of early fraud warnings.
// List returns a list of radar early fraud warnings.
func List(params *stripe.RadarEarlyFraudWarningListParams) *Iter {
return getC().List(params)
}

// List returns a list of early fraud warnings.
// List returns a list of radar early fraud warnings.
func (c Client) List(listParams *stripe.RadarEarlyFraudWarningListParams) *Iter {
return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) {
list := &stripe.RadarEarlyFraudWarningList{}
err := c.B.CallRaw(http.MethodGet, "/v1/radar/early_fraud_warnings", c.Key, b, p, list)
return &Iter{
Iter: stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListContainer, error) {
list := &stripe.RadarEarlyFraudWarningList{}
err := c.B.CallRaw(http.MethodGet, "/v1/radar/early_fraud_warnings", c.Key, b, p, list)

ret := make([]interface{}, len(list.Values))
for i, v := range list.Values {
ret[i] = v
}
ret := make([]interface{}, len(list.Values))
for i, v := range list.Values {
ret[i] = v
}

return ret, list, err
})}
return ret, list, err
}),
}
}

// Iter is an iterator for early fraud warnings.
// Iter is an iterator for radar early fraud warnings.
type Iter struct {
*stripe.Iter
}

// RadarEarlyFraudWarning returns the early fraud warning which the iterator is currently pointing to.
// RadarEarlyFraudWarning returns the radar early fraud warning which the iterator is currently pointing to.
func (i *Iter) RadarEarlyFraudWarning() *stripe.RadarEarlyFraudWarning {
return i.Current().(*stripe.RadarEarlyFraudWarning)
}

// RadarEarlyFraudWarningList returns the current list object which the
// iterator is currently using. List objects will change as new API calls are
// made to continue pagination.
// RadarEarlyFraudWarningList returns the current list object which the iterator is
// currently using. List objects will change as new API calls are made to
// continue pagination.
func (i *Iter) RadarEarlyFraudWarningList() *stripe.RadarEarlyFraudWarningList {
return i.List().(*stripe.RadarEarlyFraudWarningList)
}
Expand Down

0 comments on commit 6a809e5

Please sign in to comment.