Documentation
¶
Index ¶
- type ActionRequiredError
- type CheckoutIssue
- type CheckoutPreview
- type Client
- type DelioClient
- type FinalizeGuard
- type FinalizeOptions
- type FinalizeResult
- type FinalizeStatus
- type FriscoClient
- type GuardMismatchError
- type MalformedResponseError
- type Money
- type OrderReadback
- type PaymentAction
- type PaymentActionKind
- type PaymentSelection
- type PreviewOptions
- type ReservationWindow
- type UnsupportedProviderError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionRequiredError ¶
type ActionRequiredError struct {
Action *PaymentAction
Result *FinalizeResult
}
ActionRequiredError reports a guarded stop when payment needs redirect/3DS.
func (*ActionRequiredError) Error ¶
func (e *ActionRequiredError) Error() string
type CheckoutIssue ¶
type CheckoutIssue struct {
Code string `json:"code,omitempty"`
Message string `json:"message,omitempty"`
}
CheckoutIssue is a normalized validation or business issue returned by checkout.
type CheckoutPreview ¶
type CheckoutPreview struct {
Provider string `json:"provider"`
UserID string `json:"user_id"`
CartID string `json:"cart_id,omitempty"`
ItemCount int `json:"item_count"`
Total *Money `json:"total,omitempty"`
Reservation *ReservationWindow `json:"reservation,omitempty"`
Payment *PaymentSelection `json:"payment,omitempty"`
ReadyToFinalize bool `json:"ready_to_finalize"`
Issues []CheckoutIssue `json:"issues,omitempty"`
Raw map[string]any `json:"raw,omitempty"`
}
CheckoutPreview is the normalized Frisco express-checkout cart snapshot.
type Client ¶
type Client interface {
Preview(s *session.Session, opts PreviewOptions) (*CheckoutPreview, error)
Finalize(s *session.Session, opts FinalizeOptions) (*FinalizeResult, error)
}
Client is the provider-aware checkout interface shared by Frisco and Delio.
type DelioClient ¶
type DelioClient struct{}
DelioClient implements the Delio checkout core using internal/delio helpers.
func NewDelioClient ¶
func NewDelioClient() *DelioClient
NewDelioClient returns a checkout client backed by internal/delio helpers.
func (*DelioClient) Finalize ¶
func (c *DelioClient) Finalize(s *session.Session, opts FinalizeOptions) (*FinalizeResult, error)
Finalize safely attempts the Delio payment step and only reports placed when the provider response clearly proves the order was placed.
func (*DelioClient) Preview ¶
func (c *DelioClient) Preview(s *session.Session, opts PreviewOptions) (*CheckoutPreview, error)
Preview fetches and normalizes the current Delio checkout state.
type FinalizeGuard ¶
type FinalizeGuard struct {
ExpectedCartID string `json:"expected_cart_id,omitempty"`
ExpectedItemCount *int `json:"expected_item_count,omitempty"`
ExpectedTotal *float64 `json:"expected_total,omitempty"`
}
FinalizeGuard allows callers to verify the preview state before placing an order.
type FinalizeOptions ¶
type FinalizeOptions struct {
Provider string `json:"provider,omitempty"`
UserID string `json:"user_id,omitempty"`
Guard *FinalizeGuard `json:"guard,omitempty"`
AllowActionRequired bool `json:"allow_action_required,omitempty"`
}
FinalizeOptions controls Frisco order finalization.
type FinalizeResult ¶
type FinalizeResult struct {
Provider string `json:"provider"`
UserID string `json:"user_id"`
Status FinalizeStatus `json:"status"`
OrderID string `json:"order_id,omitempty"`
Preview *CheckoutPreview `json:"preview,omitempty"`
Action *PaymentAction `json:"action,omitempty"`
Readback *OrderReadback `json:"readback,omitempty"`
APIResponse map[string]any `json:"api_response,omitempty"`
}
FinalizeResult captures the POST /order response plus optional readback.
type FinalizeStatus ¶
type FinalizeStatus string
FinalizeStatus is the normalized high-level outcome of a finalize attempt.
const ( FinalizeStatusPlaced FinalizeStatus = "placed" FinalizeStatusRequiresAction FinalizeStatus = "requires_action" FinalizeStatusPending FinalizeStatus = "pending" FinalizeStatusUnknown FinalizeStatus = "unknown" )
type FriscoClient ¶
type FriscoClient struct {
// contains filtered or unexported fields
}
FriscoClient implements the Frisco-only express-checkout core flow.
func NewFriscoClient ¶
func NewFriscoClient() *FriscoClient
NewFriscoClient returns a checkout client backed by internal/httpclient.
func NewFriscoClientForTests ¶
func NewFriscoClientForTests(httpClient *http.Client) *FriscoClient
NewFriscoClientForTests allows tests to inject a custom HTTP client.
func (*FriscoClient) Finalize ¶
func (c *FriscoClient) Finalize(s *session.Session, opts FinalizeOptions) (*FinalizeResult, error)
Finalize places the Frisco express-checkout order, reads the order back when possible, and blocks redirect/3DS flows behind a structured ActionRequiredError by default.
func (*FriscoClient) Preview ¶
func (c *FriscoClient) Preview(s *session.Session, opts PreviewOptions) (*CheckoutPreview, error)
Preview fetches and normalizes Frisco express-checkout cart data.
type GuardMismatchError ¶
GuardMismatchError reports that finalize guards did not match the fresh preview.
func (*GuardMismatchError) Error ¶
func (e *GuardMismatchError) Error() string
type MalformedResponseError ¶
MalformedResponseError reports that the provider returned an unexpected shape.
func (*MalformedResponseError) Error ¶
func (e *MalformedResponseError) Error() string
type OrderReadback ¶
type OrderReadback struct {
OrderID string `json:"order_id,omitempty"`
Order map[string]any `json:"order,omitempty"`
Payments []map[string]any `json:"payments,omitempty"`
}
OrderReadback contains post-finalize GET responses when an order ID is known.
type PaymentAction ¶
type PaymentAction struct {
Kind PaymentActionKind `json:"kind"`
URL string `json:"url,omitempty"`
Method string `json:"method,omitempty"`
Message string `json:"message,omitempty"`
Payload map[string]any `json:"payload,omitempty"`
}
PaymentAction captures required post-finalize interaction such as redirect/3DS.
func (*PaymentAction) IsRedirect ¶
func (a *PaymentAction) IsRedirect() bool
IsRedirect reports whether the action URL is an absolute web URL.
type PaymentActionKind ¶
type PaymentActionKind string
PaymentActionKind describes what kind of user/browser step is still required.
const ( PaymentActionKindRedirect PaymentActionKind = "redirect" PaymentActionKind3DS PaymentActionKind = "3ds" )
type PaymentSelection ¶
type PaymentSelection struct {
Method string `json:"method,omitempty"`
Channel string `json:"channel,omitempty"`
Status string `json:"status,omitempty"`
}
PaymentSelection describes the currently selected payment option in checkout.
type PreviewOptions ¶
type PreviewOptions struct {
Provider string `json:"provider,omitempty"`
UserID string `json:"user_id,omitempty"`
}
PreviewOptions controls checkout preview fetching.
type ReservationWindow ¶
type ReservationWindow struct {
StartsAt string `json:"starts_at,omitempty"`
EndsAt string `json:"ends_at,omitempty"`
DeliveryMethod string `json:"delivery_method,omitempty"`
Warehouse string `json:"warehouse,omitempty"`
}
ReservationWindow summarizes the reserved delivery window used for checkout.
type UnsupportedProviderError ¶
UnsupportedProviderError reports that the selected provider is not supported by the requested checkout flow.
func (*UnsupportedProviderError) Error ¶
func (e *UnsupportedProviderError) Error() string