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

API Updates #1374

Merged
merged 1 commit into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 13 additions & 0 deletions checkout/session/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ func (c Client) Get(id string, params *stripe.CheckoutSessionParams) (*stripe.Ch
return session, err
}

// Expire is the method for the `POST /v1/checkout/sessions/{session}/expire` API.
func Expire(id string, params *stripe.CheckoutSessionExpireParams) (*stripe.CheckoutSession, error) {
return getC().Expire(id, params)
}

// Expire is the method for the `POST /v1/checkout/sessions/{session}/expire` API.
func (c Client) Expire(id string, params *stripe.CheckoutSessionExpireParams) (*stripe.CheckoutSession, error) {
path := stripe.FormatURLPath("/v1/checkout/sessions/%s/expire", id)
session := &stripe.CheckoutSession{}
err := c.B.Call(http.MethodPost, path, c.Key, params, session)
return session, err
}

// List returns a list of checkout sessions.
func List(params *stripe.CheckoutSessionListParams) *Iter {
return getC().List(params)
Expand Down
18 changes: 18 additions & 0 deletions checkout_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ const (
CheckoutSessionPaymentStatusUnpaid CheckoutSessionPaymentStatus = "unpaid"
)

// The status of the Checkout Session, one of `open`, `complete`, or `expired`.
type CheckoutSessionStatus string

// List of values that CheckoutSessionStatus can take
const (
CheckoutSessionStatusComplete CheckoutSessionStatus = "complete"
CheckoutSessionStatusExpired CheckoutSessionStatus = "expired"
CheckoutSessionStatusOpen CheckoutSessionStatus = "open"
)

// CheckoutSessionSubmitType is the list of allowed values for the submit type on a Session.
type CheckoutSessionSubmitType string

Expand Down Expand Up @@ -420,6 +430,13 @@ type CheckoutSessionParams struct {
TaxIDCollection *CheckoutSessionTaxIDCollectionParams `form:"tax_id_collection"`
}

// A Session can be expired when it is in one of these statuses: open
//
// After it expires, a customer can't complete a Session and customers loading the Session see a message saying the Session is expired.
type CheckoutSessionExpireParams struct {
Params `form:"*"`
}

// CheckoutSessionListLineItemsParams is the set of parameters that can be
// used when listing line items on a session.
type CheckoutSessionListLineItemsParams struct {
Expand Down Expand Up @@ -587,6 +604,7 @@ type CheckoutSession struct {
SetupIntent *SetupIntent `json:"setup_intent"`
Shipping *ShippingDetails `json:"shipping"`
ShippingAddressCollection *CheckoutSessionShippingAddressCollection `json:"shipping_address_collection"`
Status CheckoutSessionStatus `json:"status"`
SubmitType CheckoutSessionSubmitType `json:"submit_type"`
Subscription *Subscription `json:"subscription"`
SuccessURL string `json:"success_url"`
Expand Down
6 changes: 6 additions & 0 deletions example/generated_examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1492,3 +1492,9 @@ func TestCustomerListPaymentMethods(t *testing.T) {
result := customer.ListPaymentMethods(params)
assert.NotNil(t, result)
}

func TestCheckoutSessionExpire(t *testing.T) {
params := &stripe.CheckoutSessionExpireParams{}
result, _ := checkout_session.Expire("sess_xyz", params)
assert.NotNil(t, result)
}