Skip to content

Commit

Permalink
API Updates (#1446)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil-stripe authored Apr 8, 2022
1 parent 380bc04 commit 7a3134b
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 29 deletions.
16 changes: 8 additions & 8 deletions checkout_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ type CheckoutSessionTaxIDCollection struct {
Enabled bool `json:"enabled"`
}

// The aggregated line item discounts.
// The aggregated discounts.
type CheckoutSessionTotalDetailsBreakdownDiscount struct {
// The amount discounted.
Amount int64 `json:"amount"`
Expand All @@ -890,7 +890,7 @@ type CheckoutSessionTotalDetailsBreakdownDiscount struct {
Discount *Discount `json:"discount"`
}

// The aggregated line item tax amounts by rate.
// The aggregated tax amounts by rate.
type CheckoutSessionTotalDetailsBreakdownTax struct {
// Amount of tax applied for this rate.
Amount int64 `json:"amount"`
Expand All @@ -901,19 +901,19 @@ type CheckoutSessionTotalDetailsBreakdownTax struct {
TaxRate *TaxRate `json:"tax_rate"` // Do not use: use `Rate`
}
type CheckoutSessionTotalDetailsBreakdown struct {
// The aggregated line item discounts.
// The aggregated discounts.
Discounts []*CheckoutSessionTotalDetailsBreakdownDiscount `json:"discounts"`
// The aggregated line item tax amounts by rate.
// The aggregated tax amounts by rate.
Taxes []*CheckoutSessionTotalDetailsBreakdownTax `json:"taxes"`
}

// Tax and discount details for the computed total amount.
type CheckoutSessionTotalDetails struct {
// This is the sum of all the line item discounts.
// This is the sum of all the discounts.
AmountDiscount int64 `json:"amount_discount"`
// This is the sum of all the line item shipping amounts.
// This is the sum of all the shipping amounts.
AmountShipping int64 `json:"amount_shipping"`
// This is the sum of all the line item tax amounts.
// This is the sum of all the tax amounts.
AmountTax int64 `json:"amount_tax"`
Breakdown *CheckoutSessionTotalDetailsBreakdown `json:"breakdown"`
}
Expand Down Expand Up @@ -1031,7 +1031,7 @@ type CheckoutSession struct {
TaxIDCollection *CheckoutSessionTaxIDCollection `json:"tax_id_collection"`
// Tax and discount details for the computed total amount.
TotalDetails *CheckoutSessionTotalDetails `json:"total_details"`
// The URL to the Checkout Session.
// The URL to the Checkout Session. Redirect customers to this URL to take them to Checkout. If you're using [Custom Domains](https://stripe.com/docs/payments/checkout/custom-domains), the URL will use your subdomain. Otherwise, it'll use `checkout.stripe.com.`
URL string `json:"url"`
}

Expand Down
17 changes: 17 additions & 0 deletions paymentintent.go
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,23 @@ type PaymentIntentVerifyMicrodepositsParams struct {
DescriptorCode *string `form:"descriptor_code"`
}

// Manually reconcile the remaining amount for a customer_balance PaymentIntent.
//
// This can be used when the cash balance for [a customer in manual reconciliation mode](docs/payments/customer-balance/reconciliation#cash-manual-reconciliation) received funds.
type PaymentIntentApplyCustomerBalanceParams struct {
Params `form:"*"`
// Amount intended to be applied to this PaymentIntent from the customer's cash balance.
//
// A positive integer representing how much to charge in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency).
//
// The maximum amount is the amount of the PaymentIntent.
//
// When omitted, the amount defaults to the remaining amount requested on the PaymentIntent.
Amount *int64 `form:"amount"`
// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
Currency *string `form:"currency"`
}

// Settings to configure compatible payment methods from the [Stripe Dashboard](https://dashboard.stripe.com/settings/payment_methods)
type PaymentIntentAutomaticPaymentMethods struct {
// Automatically calculates compatible payment methods
Expand Down
16 changes: 16 additions & 0 deletions paymentintent/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,22 @@ func (c Client) Update(id string, params *stripe.PaymentIntentParams) (*stripe.P
return paymentintent, err
}

// ApplyCustomerBalance is the method for the `POST /v1/payment_intents/{intent}/apply_customer_balance` API.
func ApplyCustomerBalance(id string, params *stripe.PaymentIntentApplyCustomerBalanceParams) (*stripe.PaymentIntent, error) {
return getC().ApplyCustomerBalance(id, params)
}

// ApplyCustomerBalance is the method for the `POST /v1/payment_intents/{intent}/apply_customer_balance` API.
func (c Client) ApplyCustomerBalance(id string, params *stripe.PaymentIntentApplyCustomerBalanceParams) (*stripe.PaymentIntent, error) {
path := stripe.FormatURLPath(
"/v1/payment_intents/%s/apply_customer_balance",
id,
)
paymentintent := &stripe.PaymentIntent{}
err := c.B.Call(http.MethodPost, path, c.Key, params, paymentintent)
return paymentintent, err
}

// Cancel is the method for the `POST /v1/payment_intents/{intent}/cancel` API.
func Cancel(id string, params *stripe.PaymentIntentCancelParams) (*stripe.PaymentIntent, error) {
return getC().Cancel(id, params)
Expand Down
42 changes: 21 additions & 21 deletions quote.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ type QuoteAutomaticTax struct {
Status QuoteAutomaticTaxStatus `json:"status"`
}

// The aggregated line item discounts.
// The aggregated discounts.
type QuoteComputedRecurringTotalDetailsBreakdownDiscount struct {
// The amount discounted.
Amount int64 `json:"amount"`
Expand All @@ -248,7 +248,7 @@ type QuoteComputedRecurringTotalDetailsBreakdownDiscount struct {
Discount *Discount `json:"discount"`
}

// The aggregated line item tax amounts by rate.
// The aggregated tax amounts by rate.
type QuoteComputedRecurringTotalDetailsBreakdownTax struct {
// Amount of tax applied for this rate.
Amount int64 `json:"amount"`
Expand All @@ -258,17 +258,17 @@ type QuoteComputedRecurringTotalDetailsBreakdownTax struct {
Rate *TaxRate `json:"rate"`
}
type QuoteComputedRecurringTotalDetailsBreakdown struct {
// The aggregated line item discounts.
// The aggregated discounts.
Discounts []*QuoteComputedRecurringTotalDetailsBreakdownDiscount `json:"discounts"`
// The aggregated line item tax amounts by rate.
// The aggregated tax amounts by rate.
Taxes []*QuoteComputedRecurringTotalDetailsBreakdownTax `json:"taxes"`
}
type QuoteComputedRecurringTotalDetails struct {
// This is the sum of all the line item discounts.
// This is the sum of all the discounts.
AmountDiscount int64 `json:"amount_discount"`
// This is the sum of all the line item shipping amounts.
// This is the sum of all the shipping amounts.
AmountShipping int64 `json:"amount_shipping"`
// This is the sum of all the line item tax amounts.
// This is the sum of all the tax amounts.
AmountTax int64 `json:"amount_tax"`
Breakdown *QuoteComputedRecurringTotalDetailsBreakdown `json:"breakdown"`
}
Expand All @@ -286,7 +286,7 @@ type QuoteComputedRecurring struct {
TotalDetails *QuoteComputedRecurringTotalDetails `json:"total_details"`
}

// The aggregated line item discounts.
// The aggregated discounts.
type QuoteComputedUpfrontTotalDetailsBreakdownDiscount struct {
// The amount discounted.
Amount int64 `json:"amount"`
Expand All @@ -298,7 +298,7 @@ type QuoteComputedUpfrontTotalDetailsBreakdownDiscount struct {
Discount *Discount `json:"discount"`
}

// The aggregated line item tax amounts by rate.
// The aggregated tax amounts by rate.
type QuoteComputedUpfrontTotalDetailsBreakdownTax struct {
// Amount of tax applied for this rate.
Amount int64 `json:"amount"`
Expand All @@ -308,17 +308,17 @@ type QuoteComputedUpfrontTotalDetailsBreakdownTax struct {
Rate *TaxRate `json:"rate"`
}
type QuoteComputedUpfrontTotalDetailsBreakdown struct {
// The aggregated line item discounts.
// The aggregated discounts.
Discounts []*QuoteComputedUpfrontTotalDetailsBreakdownDiscount `json:"discounts"`
// The aggregated line item tax amounts by rate.
// The aggregated tax amounts by rate.
Taxes []*QuoteComputedUpfrontTotalDetailsBreakdownTax `json:"taxes"`
}
type QuoteComputedUpfrontTotalDetails struct {
// This is the sum of all the line item discounts.
// This is the sum of all the discounts.
AmountDiscount int64 `json:"amount_discount"`
// This is the sum of all the line item shipping amounts.
// This is the sum of all the shipping amounts.
AmountShipping int64 `json:"amount_shipping"`
// This is the sum of all the line item tax amounts.
// This is the sum of all the tax amounts.
AmountTax int64 `json:"amount_tax"`
Breakdown *QuoteComputedUpfrontTotalDetailsBreakdown `json:"breakdown"`
}
Expand Down Expand Up @@ -365,7 +365,7 @@ type QuoteSubscriptionData struct {
TrialPeriodDays int64 `json:"trial_period_days"`
}

// The aggregated line item discounts.
// The aggregated discounts.
type QuoteTotalDetailsBreakdownDiscount struct {
// The amount discounted.
Amount int64 `json:"amount"`
Expand All @@ -377,7 +377,7 @@ type QuoteTotalDetailsBreakdownDiscount struct {
Discount *Discount `json:"discount"`
}

// The aggregated line item tax amounts by rate.
// The aggregated tax amounts by rate.
type QuoteTotalDetailsBreakdownTax struct {
// Amount of tax applied for this rate.
Amount int64 `json:"amount"`
Expand All @@ -387,17 +387,17 @@ type QuoteTotalDetailsBreakdownTax struct {
Rate *TaxRate `json:"rate"`
}
type QuoteTotalDetailsBreakdown struct {
// The aggregated line item discounts.
// The aggregated discounts.
Discounts []*QuoteTotalDetailsBreakdownDiscount `json:"discounts"`
// The aggregated line item tax amounts by rate.
// The aggregated tax amounts by rate.
Taxes []*QuoteTotalDetailsBreakdownTax `json:"taxes"`
}
type QuoteTotalDetails struct {
// This is the sum of all the line item discounts.
// This is the sum of all the discounts.
AmountDiscount int64 `json:"amount_discount"`
// This is the sum of all the line item shipping amounts.
// This is the sum of all the shipping amounts.
AmountShipping int64 `json:"amount_shipping"`
// This is the sum of all the line item tax amounts.
// This is the sum of all the tax amounts.
AmountTax int64 `json:"amount_tax"`
Breakdown *QuoteTotalDetailsBreakdown `json:"breakdown"`
}
Expand Down

0 comments on commit 7a3134b

Please sign in to comment.