acp

package module
v0.0.0-...-98ac828 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

README

Go SDK for the Agentic Commerce Protocol

Go Reference CI Status License

Go SDK for the Agentic Commerce Protocol (ACP). github.com/sumup/acr supports Agentic Checkout, Delegated Payment, and Product Feeds.

Examples

Checkout Sample
go run ./examples/checkout

Once the server is up, try exercising the flow with curl:

# Create a checkout session with two SKUs
curl -sS -X POST http://localhost:8080/checkout_sessions \
  -H 'Content-Type: application/json' \
  -d '{
        "line_items": [
          {"id": "latte"},
          {"id": "mug"}
        ],
        "currency": "USD",
        "buyer": {
          "first_name": "Ava",
          "last_name": "Agent",
          "email": "ava.agent@example.com"
        }
      }'

# Complete the session once you have the id from the response above
curl -sS -X POST http://localhost:8080/checkout_sessions/<session_id>/complete \
  -H 'Content-Type: application/json' \
  -d '{
        "payment_data": {
          "provider": "sumup",
          "token": "pm_sample_token"
        }
      }'

Feel free to copy this sample into your own project and swap the in-memory store for your real product catalog, fulfillment rules, and payment hooks.

To see webhook delivery end-to-end, export the environment variables below before starting the sample server. The handler will POST an order_created event every time a checkout session completes.

export ACP_WEBHOOK_ENDPOINT="https://webhook.site/your-endpoint"
export ACP_WEBHOOK_HEADER="Merchant_Name-Signature"
export ACP_WEBHOOK_SECRET="super-secret"
go run ./examples/checkout
Delegated Payment Sample
go run ./examples/delegated_payment

Then call it with:

curl -sS -X POST http://localhost:8080/agentic_commerce/delegate_payment \
  -H 'Content-Type: application/json' \
  -d '{
        "payment_method": {
          "type": "card",
          "card_number_type": "fpan",
          "number": "4242424242424242",
          "exp_month": "11",
          "exp_year": "2026",
          "display_last4": "4242",
          "display_card_funding_type": "credit",
          "metadata": {"issuer": "demo-bank"}
        },
        "allowance": {
          "reason": "one_time",
          "max_amount": 2000,
          "currency": "usd",
          "checkout_session_id": "cs_000001",
          "merchant_id": "demo-merchant",
          "expires_at": "2025-12-31T23:59:59Z"
        },
        "risk_signals": [
          {"type": "card_testing", "action": "manual_review", "score": 10}
        ],
        "metadata": {"source": "sample"}
      }'
Product Feed Sample
go run ./examples/feed

This writes compressed feed exports to examples/feed/output/product_feed.jsonl.gz and examples/feed/output/product_feed.csv.gz.

License

Apache 2.0

Documentation

Overview

Package acp documents the Go SDK for the Agentic Commerce Protocol (ACP). It aggregates the checkout and delegated payment packages under a single module so merchants and PSPs can share common helpers, models, and documentation.

Checkout

Use NewCheckoutHandler with your CheckoutProvider implementation to expose the ACP checkout contract over `net/http`. Handler options such as WithSignatureVerifier and WithRequireSignedRequests enforce the canonical JSON signatures and timestamp skew requirements spelled out in the spec.

Delegated Payment

Payment service providers can call NewDelegatedPaymentHandler with their own DelegatedPaymentProvider to accept delegate payment payloads, validate them, and emit vault tokens scoped to a checkout session. Optional helpers such as WithAuthenticator and [DelegatedPaymentWithSignatureVerifier] keep API keys and signed requests in sync with ACP's security requirements.

How it works

  • Buyers check out using their preferred payment method and save it in ChatGPT.
  • The delegated payment payload is sent to the merchant’s PSP or vault directly. The delegated payment is single-use and set with allowances.
  • The PSP or vault returns a payment token scoped to the delegated payment outside of PCI scope.
  • OpenAI forwards the token during the complete-checkout call to enable the merchant to complete the transaction.

Index

Constants

View Source
const APIVersion = "2026-01-30"

APIVersion matches the published Agentic Commerce Protocol API. Emitted via the API-Version header on all HTTP responses returned by the handlers.

Variables

This section is empty.

Functions

func WithInternal

func WithInternal(err error) errorOption

WithInternal sets an internal error that can be retrieved from Error for telemetry purposes.

func WithOffendingParam

func WithOffendingParam(jsonPath string) errorOption

WithOffendingParam sets the JSON path for the field that triggered the error.

func WithRetryAfter

func WithRetryAfter(d time.Duration) errorOption

WithRetryAfter specifies how long clients should wait before retrying.

func WithStatusCode

func WithStatusCode(status int) errorOption

WithStatusCode overrides the HTTP status code returned to the client.

func WithSupportedVersions

func WithSupportedVersions(versions []string) errorOption

WithSupportedVersions sets the supported protocol versions returned to clients.

Types

type Address

type Address struct {
	Name       string  `json:"name"`
	LineOne    string  `json:"line_one"`
	LineTwo    *string `json:"line_two,omitempty"`
	PostalCode string  `json:"postal_code"`
	City       string  `json:"city"`
	State      string  `json:"state"`
	Country    string  `json:"country"`
}

Address defines model for Address.

type Adjustment

type Adjustment struct {
	// ID is the adjustment identifier.
	ID string `json:"id"`
	// Type classifies the adjustment.
	Type AdjustmentType `json:"type"`
	// OccurredAt is the RFC3339 timestamp for the adjustment event.
	OccurredAt time.Time `json:"occurred_at"`
	// Status is the adjustment processing status.
	Status AdjustmentStatus `json:"status"`
	// LineItems lists affected line items and quantities.
	LineItems []LineItemReference `json:"line_items,omitempty"`
	// Amount is the credited amount in minor units, inclusive of tax.
	Amount *int `json:"amount,omitempty"`
	// Currency is the ISO 4217 currency code for Amount.
	Currency *string `json:"currency,omitempty"`
	// Description is an optional human-readable explanation.
	Description *string `json:"description,omitempty"`
	// Reason is an optional structured reason code.
	Reason *string `json:"reason,omitempty"`
}

Adjustment is a post-order financial/logistical change (refund, return, dispute, etc.).

type AdjustmentStatus

type AdjustmentStatus string

AdjustmentStatus is the processing state of an order adjustment.

const (
	// AdjustmentStatusPending means processing has not finished yet.
	AdjustmentStatusPending AdjustmentStatus = "pending"
	// AdjustmentStatusCompleted means the adjustment was applied.
	AdjustmentStatusCompleted AdjustmentStatus = "completed"
	// AdjustmentStatusFailed means the adjustment failed.
	AdjustmentStatusFailed AdjustmentStatus = "failed"
)

Defines values for AdjustmentStatus.

type AdjustmentType

type AdjustmentType string

AdjustmentType classifies a post-order change such as refunds or disputes.

const (
	// AdjustmentTypeRefund is a full refund.
	AdjustmentTypeRefund AdjustmentType = "refund"
	// AdjustmentTypePartialRefund is a partial refund.
	AdjustmentTypePartialRefund AdjustmentType = "partial_refund"
	// AdjustmentTypeStoreCredit grants store credit.
	AdjustmentTypeStoreCredit AdjustmentType = "store_credit"
	// AdjustmentTypeReturn records returned goods.
	AdjustmentTypeReturn AdjustmentType = "return"
	// AdjustmentTypeExchange records an item exchange.
	AdjustmentTypeExchange AdjustmentType = "exchange"
	// AdjustmentTypeCancellation records a cancellation adjustment.
	AdjustmentTypeCancellation AdjustmentType = "cancellation"
	// AdjustmentTypeDispute records a dispute.
	AdjustmentTypeDispute AdjustmentType = "dispute"
	// AdjustmentTypeChargeback records a chargeback.
	AdjustmentTypeChargeback AdjustmentType = "chargeback"
)

Defines values for AdjustmentType.

type AffiliateAttribution

type AffiliateAttribution struct {
	// Provider is the attribution provider / affiliate network namespace (for example "impact.com").
	Provider string `json:"provider"`
	// Token is an opaque provider-issued token for fraud-resistant validation.
	Token *string `json:"token,omitempty"`
	// PublisherID is the provider-scoped affiliate/publisher identifier.
	PublisherID *string                      `json:"publisher_id,omitempty"`
	CampaignID  *string                      `json:"campaign_id,omitempty"`
	CreativeID  *string                      `json:"creative_id,omitempty"`
	SubID       *string                      `json:"sub_id,omitempty"`
	Source      *AffiliateAttributionSource  `json:"source,omitempty"`
	IssuedAt    *time.Time                   `json:"issued_at,omitempty"`
	ExpiresAt   *time.Time                   `json:"expires_at,omitempty"`
	Metadata    AffiliateAttributionMetadata `json:"metadata,omitempty"`
	// Touchpoint is the attribution touchpoint type ("first" or "last").
	Touchpoint *string `json:"touchpoint,omitempty"`
}

AffiliateAttribution defines model for AffiliateAttribution.

type AffiliateAttributionMetadata

type AffiliateAttributionMetadata map[string]any

AffiliateAttributionMetadata defines model for AffiliateAttribution.Metadata.

type AffiliateAttributionSource

type AffiliateAttributionSource struct {
	Type string  `json:"type"`
	URL  *string `json:"url,omitempty"`
}

AffiliateAttributionSource defines model for AffiliateAttribution.Source.

type Allowance

type Allowance struct {
	// Current possible values: "one_time".
	Reason AllowanceReason `json:"reason" validate:"required,eq=one_time"`
	// Max amount the payment method can be charged for.
	MaxAmount int `json:"max_amount" validate:"required,gt=0"`
	// Currency.
	Currency string `json:"currency" validate:"required,currency"`
	// Reference to checkout_session_id.
	CheckoutSessionID string `json:"checkout_session_id" validate:"required"`
	// Merchant identifying descriptor.
	MerchantID string `json:"merchant_id" validate:"required"`
	// Time formatted as an RFC 3339 string.
	ExpiresAt time.Time `json:"expires_at" validate:"required"`
}

Allowance scopes token use per the spec.

type AllowanceReason

type AllowanceReason string
const (
	AllowanceReasonOneTime AllowanceReason = "one_time"
)

type AuthenticationAcquirerDetails

type AuthenticationAcquirerDetails struct {
	// AcquirerBin is the acquirer BIN (directory-server specific).
	AcquirerBin string `json:"acquirer_bin"`
	// AcquirerCountry is the ISO 3166-1 alpha-2 country code.
	AcquirerCountry string `json:"acquirer_country"`
	// AcquirerMerchantId is the merchant ID assigned by the acquirer.
	AcquirerMerchantId string `json:"acquirer_merchant_id"`
	// MerchantName is the merchant name assigned by the acquirer.
	MerchantName string `json:"merchant_name"`
	// RequestorId is the requestor ID when required by the directory server.
	RequestorId *string `json:"requestor_id,omitempty"`
}

AuthenticationAcquirerDetails describes the acquirer details used for this 3DS Authentication.

type AuthenticationChallengePreference

type AuthenticationChallengePreference struct {
	// Type is the challenge subtype preference.
	Type AuthenticationChallengePreferenceType `json:"type"`
}

AuthenticationChallengePreference captures details about a requested challenge flow.

type AuthenticationChallengePreferenceType

type AuthenticationChallengePreferenceType string

AuthenticationChallengePreferenceType defines challenge preference type.

const (
	AuthenticationChallengePreferenceTypeMandated  AuthenticationChallengePreferenceType = "mandated"
	AuthenticationChallengePreferenceTypePreferred AuthenticationChallengePreferenceType = "preferred"
)

Defines values for AuthenticationChallengePreferenceType.

type AuthenticationDirectoryServer

type AuthenticationDirectoryServer string

AuthenticationDirectoryServer defines supported 3DS directory servers.

const (
	AuthenticationDirectoryServerAmericanExpress AuthenticationDirectoryServer = "american_express"
	AuthenticationDirectoryServerMastercard      AuthenticationDirectoryServer = "mastercard"
	AuthenticationDirectoryServerVisa            AuthenticationDirectoryServer = "visa"
)

Defines values for AuthenticationDirectoryServer.

type AuthenticationECI

type AuthenticationECI string

AuthenticationECI defines accepted ECI values.

const (
	AuthenticationECI01 AuthenticationECI = "01"
	AuthenticationECI02 AuthenticationECI = "02"
	AuthenticationECI05 AuthenticationECI = "05"
	AuthenticationECI06 AuthenticationECI = "06"
	AuthenticationECI07 AuthenticationECI = "07"
)

Defines values for AuthenticationECI.

type AuthenticationFlowPreference

type AuthenticationFlowPreference struct {
	// Type is the preferred flow type: "challenge" or "frictionless".
	Type AuthenticationFlowPreferenceType `json:"type"`
	// Challenge captures details about a requested challenge flow.
	Challenge *AuthenticationChallengePreference `json:"challenge,omitempty"`
	// Frictionless captures details about a requested frictionless flow.
	Frictionless *AuthenticationFrictionlessPreference `json:"frictionless,omitempty"`
}

AuthenticationFlowPreference captures seller preferences for the 3DS authentication flow.

type AuthenticationFlowPreferenceType

type AuthenticationFlowPreferenceType string

AuthenticationFlowPreferenceType defines flow preference type.

const (
	AuthenticationFlowPreferenceTypeChallenge    AuthenticationFlowPreferenceType = "challenge"
	AuthenticationFlowPreferenceTypeFrictionless AuthenticationFlowPreferenceType = "frictionless"
)

Defines values for AuthenticationFlowPreferenceType.

type AuthenticationFrictionlessPreference

type AuthenticationFrictionlessPreference struct{}

AuthenticationFrictionlessPreference captures details about a requested frictionless flow.

type AuthenticationMetadata

type AuthenticationMetadata struct {
	// AcquirerDetails are details about the acquirer used for this 3DS Authentication.
	AcquirerDetails AuthenticationAcquirerDetails `json:"acquirer_details"`
	// DirectoryServer is the 3DS directory server used for this Authentication.
	DirectoryServer AuthenticationDirectoryServer `json:"directory_server"`
	// FlowPreference captures seller's preferred 3DS authentication flow, if any.
	FlowPreference *AuthenticationFlowPreference `json:"flow_preference,omitempty"`
}

AuthenticationMetadata captures seller-provided authentication metadata for 3DS flows.

type AuthenticationOutcome

type AuthenticationOutcome string

AuthenticationOutcome defines 3DS authentication outcomes.

const (
	AuthenticationOutcomeAbandoned           AuthenticationOutcome = "abandoned"
	AuthenticationOutcomeAttemptAcknowledged AuthenticationOutcome = "attempt_acknowledged"
	AuthenticationOutcomeAuthenticated       AuthenticationOutcome = "authenticated"
	AuthenticationOutcomeCanceled            AuthenticationOutcome = "canceled"
	AuthenticationOutcomeDenied              AuthenticationOutcome = "denied"
	AuthenticationOutcomeInformational       AuthenticationOutcome = "informational"
	AuthenticationOutcomeInternalError       AuthenticationOutcome = "internal_error"
	AuthenticationOutcomeNotSupported        AuthenticationOutcome = "not_supported"
	AuthenticationOutcomeProcessingError     AuthenticationOutcome = "processing_error"
	AuthenticationOutcomeRejected            AuthenticationOutcome = "rejected"
)

Defines values for AuthenticationOutcome.

type AuthenticationOutcomeDetails

type AuthenticationOutcomeDetails struct {
	// ThreeDsCryptogram is the 3DS cryptogram (authentication value / AAV/CAVV/AEVV).
	// This value is 20 bytes, base64-encoded into a 28-character string.
	ThreeDsCryptogram string `json:"three_ds_cryptogram"`
	// ElectronicCommerceIndicator is the ECI returned by the 3DS provider.
	ElectronicCommerceIndicator AuthenticationECI `json:"electronic_commerce_indicator"`
	// TransactionId is the 3DS transaction identifier (XID for 3DS1, dsTransID for 3DS2).
	TransactionId string `json:"transaction_id"`
	// Version is the 3D Secure version used for this authentication (for example "1.0.2" or "2.2.0").
	Version string `json:"version"`
}

AuthenticationOutcomeDetails provides detailed 3DS authentication data.

type AuthenticationResult

type AuthenticationResult struct {
	// Outcome is the outcome of this 3DS Authentication.
	Outcome AuthenticationOutcome `json:"outcome"`
	// OutcomeDetails contains detailed authentication data.
	// Required when Outcome is authenticated, informational, or attempt_acknowledged.
	OutcomeDetails *AuthenticationOutcomeDetails `json:"outcome_details,omitempty"`
}

AuthenticationResult represents agent-provided 3DS authentication results.

type Authenticator

type Authenticator interface {
	Authenticate(ctx context.Context, apiKey string) error
}

Authenticator validates Authorization header API keys before the request reaches the provider.

type AuthenticatorFunc

type AuthenticatorFunc func(ctx context.Context, apiKey string) error

AuthenticatorFunc lifts bare functions into Authenticator.

func (AuthenticatorFunc) Authenticate

func (f AuthenticatorFunc) Authenticate(ctx context.Context, apiKey string) error

Authenticate validates the API key using the wrapped function.

type AvailabilityStatus

type AvailabilityStatus string

AvailabilityStatus defines model for LineItem.AvailabilityStatus.

const (
	AvailabilityStatusInStock    AvailabilityStatus = "in_stock"
	AvailabilityStatusLowStock   AvailabilityStatus = "low_stock"
	AvailabilityStatusOutOfStock AvailabilityStatus = "out_of_stock"
	AvailabilityStatusBackorder  AvailabilityStatus = "backorder"
	AvailabilityStatusPreOrder   AvailabilityStatus = "pre_order"
)

Defines values for AvailabilityStatus.

type AvailablePromotion

type AvailablePromotion struct {
	Code         string  `json:"code"`
	Description  string  `json:"description"`
	Requirements *string `json:"requirements,omitempty"`
}

AvailablePromotion defines model for AvailablePromotion.

type Buyer

type Buyer struct {
	Email                string                     `json:"email"`
	FirstName            *string                    `json:"first_name,omitempty"`
	LastName             *string                    `json:"last_name,omitempty"`
	FullName             *string                    `json:"full_name,omitempty"`
	PhoneNumber          *string                    `json:"phone_number,omitempty"`
	CustomerID           *string                    `json:"customer_id,omitempty"`
	AccountType          *BuyerAccountType          `json:"account_type,omitempty"`
	AuthenticationStatus *BuyerAuthenticationStatus `json:"authentication_status,omitempty"`
	Company              *CompanyInfo               `json:"company,omitempty"`
	Loyalty              *LoyaltyInfo               `json:"loyalty,omitempty"`
	TaxExemption         *TaxExemption              `json:"tax_exemption,omitempty"`
}

Buyer defines model for Buyer.

type BuyerAccountType

type BuyerAccountType string

BuyerAccountType defines model for Buyer.AccountType.

const (
	BuyerAccountTypeGuest      BuyerAccountType = "guest"
	BuyerAccountTypeRegistered BuyerAccountType = "registered"
	BuyerAccountTypeBusiness   BuyerAccountType = "business"
)

Defines values for BuyerAccountType.

type BuyerAuthenticationStatus

type BuyerAuthenticationStatus string

BuyerAuthenticationStatus defines model for Buyer.AuthenticationStatus.

const (
	BuyerAuthenticationStatusAuthenticated  BuyerAuthenticationStatus = "authenticated"
	BuyerAuthenticationStatusGuest          BuyerAuthenticationStatus = "guest"
	BuyerAuthenticationStatusRequiresSignIn BuyerAuthenticationStatus = "requires_signin"
)

Defines values for BuyerAuthenticationStatus.

type CancelSessionRequest

type CancelSessionRequest struct {
	IntentTrace *IntentTrace `json:"intent_trace,omitempty"`
}

CancelSessionRequest defines model for CancelSessionRequest.

func (CancelSessionRequest) Validate

func (r CancelSessionRequest) Validate() error

Validate ensures CancelSessionRequest conforms to the ACP schema.

type CardChecksPerformed

type CardChecksPerformed string
const (
	CardChecksPerformedAVS  CardChecksPerformed = "avs"
	CardChecksPerformedCVV  CardChecksPerformed = "cvv"
	CardChecksPerformedANI  CardChecksPerformed = "ani"
	CardChecksPerformedAUTH CardChecksPerformed = "auth0"
)

type CardFundingType

type CardFundingType string
const (
	CardFundingTypeCredit  CardFundingType = "credit"
	CardFundingTypeDebit   CardFundingType = "debit"
	CardFundingTypePrepaid CardFundingType = "prepaid"
)

type CardNumberType

type CardNumberType string
const (
	CardCardNumberTypeFPAN         CardNumberType = "fpan"
	CardCardNumberTypeNetworkToken CardNumberType = "network_token"
)

type CheckoutHandler

type CheckoutHandler struct {
	// contains filtered or unexported fields
}

CheckoutHandler wires ACP checkout routes to a CheckoutProvider.

func NewCheckoutHandler

func NewCheckoutHandler(service CheckoutProvider, opts ...Option) *CheckoutHandler

NewCheckoutHandler builds a CheckoutHandler backed by net/http's ServeMux.

func (*CheckoutHandler) GetWebhookSender

func (h *CheckoutHandler) GetWebhookSender(endpoint, merchantName string, secret []byte, opts ...WebhookOption) (WebhookSender, error)

GetWebhookSender returns a configued WebhookSender that allows your implementation to deliver webhooks back to the agent.

Parameters:

  • endpoint is the absolute URL provided by OpenAI for receiving webhook events.
  • merchantName controls the signature header name (the header name is Merchant_Name-Signature).
  • secret is the HMAC secret provided by OpenAI for signing webhook payloads.

func (*CheckoutHandler) ServeHTTP

func (h *CheckoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP satisfies http.Handler.

type CheckoutOrderStatus

type CheckoutOrderStatus string

CheckoutOrderStatus is the order-level lifecycle status returned in Order. It aligns with the webhook/order superset used for post-purchase tracking.

const (
	// CheckoutOrderStatusCreated indicates an order record has been created.
	CheckoutOrderStatusCreated CheckoutOrderStatus = "created"
	// CheckoutOrderStatusConfirmed indicates the order has been accepted/confirmed.
	CheckoutOrderStatusConfirmed CheckoutOrderStatus = "confirmed"
	// CheckoutOrderStatusManualReview indicates the order is waiting for manual review.
	CheckoutOrderStatusManualReview CheckoutOrderStatus = "manual_review"
	// CheckoutOrderStatusProcessing indicates fulfillment/processing has started.
	CheckoutOrderStatusProcessing CheckoutOrderStatus = "processing"
	// CheckoutOrderStatusShipped indicates at least one shipment has been handed off.
	CheckoutOrderStatusShipped CheckoutOrderStatus = "shipped"
	// CheckoutOrderStatusDelivered indicates fulfillment is complete and delivered.
	CheckoutOrderStatusDelivered CheckoutOrderStatus = "delivered"
	// CheckoutOrderStatusCanceled indicates the order has been canceled.
	CheckoutOrderStatusCanceled CheckoutOrderStatus = "canceled"
)

Defines values for CheckoutOrderStatus.

type CheckoutProvider

type CheckoutProvider interface {
	CreateSession(ctx context.Context, req CheckoutSessionCreateRequest) (*CheckoutSession, error)
	UpdateSession(ctx context.Context, id string, req CheckoutSessionUpdateRequest) (*CheckoutSession, error)
	GetSession(ctx context.Context, id string) (*CheckoutSession, error)
	CompleteSession(ctx context.Context, id string, req CheckoutSessionCompleteRequest) (*SessionWithOrder, error)
	CancelSession(ctx context.Context, id string, req *CancelSessionRequest) (*CheckoutSession, error)
}

CheckoutProvider is implemented by business logic that owns checkout sessions.

type CheckoutSession

type CheckoutSession struct {
	ID              string           `json:"id"`
	Protocol        *ProtocolVersion `json:"protocol,omitempty"`
	Buyer           *Buyer           `json:"buyer,omitempty"`
	PaymentProvider *PaymentProvider `json:"payment_provider,omitempty"`
	// Payment contains payment provider response data (if available).
	Payment  *PaymentResponse      `json:"payment,omitempty"`
	Status   CheckoutSessionStatus `json:"status"`
	Currency string                `json:"currency"`
	// PresentmentCurrency is the currency used for buyer-facing pricing.
	PresentmentCurrency *string `json:"presentment_currency,omitempty"`
	// ExchangeRate is the conversion rate from Currency to PresentmentCurrency.
	ExchangeRate *float64 `json:"exchange_rate,omitempty"`
	// ExchangeRateTimestamp is the time the exchange rate was captured.
	ExchangeRateTimestamp *time.Time          `json:"exchange_rate_timestamp,omitempty"`
	Locale                *string             `json:"locale,omitempty"`
	Timezone              *string             `json:"timezone,omitempty"`
	LineItems             []LineItem          `json:"line_items"`
	FulfillmentDetails    *FulfillmentDetails `json:"fulfillment_details,omitempty"`
	FulfillmentOptions    []FulfillmentOption `json:"fulfillment_options"`
	// SelectedFulfillmentOptions lists fulfillment choices by item group.
	SelectedFulfillmentOptions []SelectedFulfillmentOptions `json:"selected_fulfillment_options,omitempty"`
	// FulfillmentGroups allow splitting items across multiple destinations.
	FulfillmentGroups []FulfillmentGroup `json:"fulfillment_groups,omitempty"`
	Totals            []Total            `json:"totals"`
	Messages          []Message          `json:"messages"`
	Links             []Link             `json:"links"`
	// AuthenticationMetadata is seller-provided authentication metadata for 3DS flows.
	AuthenticationMetadata *AuthenticationMetadata `json:"authentication_metadata,omitempty"`
	// AvailablePromotions lists promotions applicable to the current cart.
	AvailablePromotions []AvailablePromotion `json:"available_promotions,omitempty"`
	CreatedAt           *time.Time           `json:"created_at,omitempty"`
	UpdatedAt           *time.Time           `json:"updated_at,omitempty"`
	ExpiresAt           *time.Time           `json:"expires_at,omitempty"`
	ContinueURL         *string              `json:"continue_url,omitempty"`
	Metadata            map[string]any       `json:"metadata,omitempty"`
	QuoteID             *string              `json:"quote_id,omitempty"`
	QuoteExpiresAt      *time.Time           `json:"quote_expires_at,omitempty"`
}

CheckoutSession defines model for CheckoutSession.

type CheckoutSessionCompleteRequest

type CheckoutSessionCompleteRequest struct {
	Buyer       *Buyer      `json:"buyer,omitempty"`
	PaymentData PaymentData `json:"payment_data"`
	// AuthenticationResult is agent-provided 3DS authentication results for card payments.
	AuthenticationResult *AuthenticationResult `json:"authentication_result,omitempty"`
	// AffiliateAttribution contains optional attribution data for crediting third-party publishers.
	AffiliateAttribution *AffiliateAttribution `json:"affiliate_attribution,omitempty"`
	// RiskSignals captures client-provided signals for fraud analysis.
	RiskSignals *RiskSignals `json:"risk_signals,omitempty"`
}

CheckoutSessionCompleteRequest defines model for CheckoutSessionCompleteRequest.

func (CheckoutSessionCompleteRequest) Validate

Validate ensures CheckoutSessionCompleteRequest satisfies payment requirements.

type CheckoutSessionCreateRequest

type CheckoutSessionCreateRequest struct {
	Buyer *Buyer `json:"buyer,omitempty"`
	// LineItems is the list of requested items for the checkout session.
	LineItems []Item `json:"line_items"`
	// Currency is the ISO 4217 currency code for this checkout.
	Currency           string              `json:"currency"`
	FulfillmentDetails *FulfillmentDetails `json:"fulfillment_details,omitempty"`
	FulfillmentGroups  []FulfillmentGroup  `json:"fulfillment_groups,omitempty"`
	// AffiliateAttribution contains optional attribution data for crediting third-party publishers.
	AffiliateAttribution *AffiliateAttribution `json:"affiliate_attribution,omitempty"`
	Coupons              []string              `json:"coupons,omitempty"`
	Locale               *string               `json:"locale,omitempty"`
	Timezone             *string               `json:"timezone,omitempty"`
	QuoteID              *string               `json:"quote_id,omitempty"`
	Metadata             map[string]any        `json:"metadata,omitempty"`
}

CheckoutSessionCreateRequest defines model for CheckoutSessionCreateRequest.

func (CheckoutSessionCreateRequest) Validate

func (r CheckoutSessionCreateRequest) Validate() error

Validate ensures CheckoutSessionCreateRequest satisfies required schema constraints.

type CheckoutSessionStatus

type CheckoutSessionStatus string

CheckoutSessionStatus defines model for CheckoutSessionBase.Status.

const (
	CheckoutSessionStatusIncomplete             CheckoutSessionStatus = "incomplete"
	CheckoutSessionStatusCanceled               CheckoutSessionStatus = "canceled"
	CheckoutSessionStatusCompleted              CheckoutSessionStatus = "completed"
	CheckoutSessionStatusCompleteInProgress     CheckoutSessionStatus = "complete_in_progress"
	CheckoutSessionStatusInProgress             CheckoutSessionStatus = "in_progress"
	CheckoutSessionStatusNotReadyForPayment     CheckoutSessionStatus = "not_ready_for_payment"
	CheckoutSessionStatusRequiresEscalation     CheckoutSessionStatus = "requires_escalation"
	CheckoutSessionStatusAuthenticationRequired CheckoutSessionStatus = "authentication_required"
	CheckoutSessionStatusReadyForPayment        CheckoutSessionStatus = "ready_for_payment"
	CheckoutSessionStatusPendingApproval        CheckoutSessionStatus = "pending_approval"
	CheckoutSessionStatusExpired                CheckoutSessionStatus = "expired"
)

Defines values for CheckoutSessionBaseStatus.

type CheckoutSessionUpdateRequest

type CheckoutSessionUpdateRequest struct {
	Buyer                      *Buyer                       `json:"buyer,omitempty"`
	LineItems                  *[]Item                      `json:"line_items,omitempty"`
	FulfillmentDetails         *FulfillmentDetails          `json:"fulfillment_details,omitempty"`
	FulfillmentGroups          []FulfillmentGroup           `json:"fulfillment_groups,omitempty"`
	SelectedFulfillmentOptions []SelectedFulfillmentOptions `json:"selected_fulfillment_options,omitempty"`
	Coupons                    []string                     `json:"coupons,omitempty"`
}

CheckoutSessionUpdateRequest defines model for CheckoutSessionUpdateRequest.

func (CheckoutSessionUpdateRequest) Validate

func (r CheckoutSessionUpdateRequest) Validate() error

Validate ensures CheckoutSessionUpdateRequest maintains schema constraints.

type CompanyInfo

type CompanyInfo struct {
	Name       string  `json:"name"`
	TaxID      *string `json:"tax_id,omitempty"`
	Department *string `json:"department,omitempty"`
	CostCenter *string `json:"cost_center,omitempty"`
}

CompanyInfo defines model for Buyer.Company.

type CustomAttribute

type CustomAttribute struct {
	DisplayName string `json:"display_name"`
	Value       string `json:"value"`
}

CustomAttribute defines model for CustomAttribute.

type DelegatedPaymentHandler

type DelegatedPaymentHandler struct {
	// contains filtered or unexported fields
}

DelegatedPaymentHandler exposes the ACP delegate payment API over net/http.

func NewDelegatedPaymentHandler

func NewDelegatedPaymentHandler(service DelegatedPaymentProvider, opts ...Option) *DelegatedPaymentHandler

NewDelegatedPaymentHandler wires the delegate payment routes to the provided DelegatedPaymentProvider.

func (*DelegatedPaymentHandler) ServeHTTP

ServeHTTP satisfies http.Handler.

type DelegatedPaymentProvider

type DelegatedPaymentProvider interface {
	DelegatePayment(ctx context.Context, req PaymentRequest) (*VaultToken, error)
}

DelegatedPaymentProvider owns the delegated payment tokenization lifecycle. To integrate your Payments Service Provider with the Delegate Payment Spec implement this interface.

type DimensionsInfo

type DimensionsInfo struct {
	Length float64        `json:"length"`
	Width  float64        `json:"width"`
	Height float64        `json:"height"`
	Unit   DimensionsUnit `json:"unit"`
}

DimensionsInfo defines model for DimensionsInfo.

type DimensionsUnit

type DimensionsUnit string

DimensionsUnit defines model for DimensionsInfo.Unit.

const (
	DimensionsUnitCentimeters DimensionsUnit = "cm"
	DimensionsUnitInches      DimensionsUnit = "in"
)

Defines values for DimensionsUnit.

type Disclosure

type Disclosure struct {
	Type        DisclosureType        `json:"type"`
	ContentType DisclosureContentType `json:"content_type"`
	Content     string                `json:"content"`
}

Disclosure defines model for Disclosure.

type DisclosureContentType

type DisclosureContentType string

DisclosureContentType defines model for Disclosure.ContentType.

const (
	DisclosureContentTypeMarkdown DisclosureContentType = "markdown"
	DisclosureContentTypePlain    DisclosureContentType = "plain"
)

Defines values for DisclosureContentType.

type DisclosureType

type DisclosureType string

DisclosureType defines model for Disclosure.Type.

const (
	DisclosureTypeDisclaimer DisclosureType = "disclaimer"
)

Defines values for DisclosureType.

type DiscountDetail

type DiscountDetail struct {
	Code        *string               `json:"code,omitempty"`
	Type        DiscountDetailType    `json:"type"`
	Amount      int                   `json:"amount"`
	Description *string               `json:"description,omitempty"`
	Source      *DiscountDetailSource `json:"source,omitempty"`
}

DiscountDetail defines model for DiscountDetail.

type DiscountDetailSource

type DiscountDetailSource string

DiscountDetailSource defines model for DiscountDetail.Source.

const (
	DiscountDetailSourceCoupon    DiscountDetailSource = "coupon"
	DiscountDetailSourceAutomatic DiscountDetailSource = "automatic"
	DiscountDetailSourceLoyalty   DiscountDetailSource = "loyalty"
)

Defines values for DiscountDetailSource.

type DiscountDetailType

type DiscountDetailType string

DiscountDetailType defines model for DiscountDetail.Type.

const (
	DiscountDetailTypePercentage DiscountDetailType = "percentage"
	DiscountDetailTypeFixed      DiscountDetailType = "fixed"
	DiscountDetailTypeBogo       DiscountDetailType = "bogo"
	DiscountDetailTypeVolume     DiscountDetailType = "volume"
)

Defines values for DiscountDetailType.

type Error

type Error struct {
	Type              ErrorType `json:"type"`
	Code              ErrorCode `json:"code"`
	Message           string    `json:"message"`
	Param             *string   `json:"param,omitempty"`
	SupportedVersions []string  `json:"supported_versions,omitempty"`

	Internal error `json:"-"`
	// contains filtered or unexported fields
}

Error represents a structured ACP error payload.

func NewHTTPError

func NewHTTPError(status int, typ ErrorType, code ErrorCode, message string, opts ...errorOption) *Error

NewHTTPError allows callers to control the status code explicitly.

func NewInvalidRequestError

func NewInvalidRequestError(message string, opts ...errorOption) *Error

NewInvalidRequestError builds a Bad Request ACP error payload.

func NewProcessingError

func NewProcessingError(message string, opts ...errorOption) *Error

NewProcessingError builds an Internal Server Error ACP error payload.

func NewRateLimitExceededError

func NewRateLimitExceededError(message string, opts ...errorOption) *Error

NewRateLimitExceededError builds a Too Many Requests ACP error payload.

func NewServiceUnavailableError

func NewServiceUnavailableError(message string, opts ...errorOption) *Error

NewServiceUnavailableError builds a Service Unavailable ACP error payload.

func (*Error) Error

func (e *Error) Error() string

Error makes *Error satisfy the stdlib error interface.

func (*Error) RetryAfter

func (e *Error) RetryAfter() time.Duration

RetryAfter returns the duration clients should wait before retrying.

type ErrorCode

type ErrorCode string

ErrorCode is a machine-readable identifier for the specific failure.

const (
	DuplicateRequest       ErrorCode = "duplicate_request"        // Safe duplicate with the same idempotency key.
	IdempotencyConflict    ErrorCode = "idempotency_conflict"     // Same idempotency key but different parameters.
	IdempotencyKeyRequired ErrorCode = "idempotency_key_required" // Idempotency-Key header is missing.
	IdempotencyInFlight    ErrorCode = "idempotency_in_flight"    // Request with same idempotency key is still processing.
	InvalidCard            ErrorCode = "invalid_card"             // Credential failed basic validation (such as length or expiry).
	InvalidSignature       ErrorCode = "invalid_signature"        // Signature is missing or does not match the payload.
	SignatureRequired      ErrorCode = "signature_required"       // Signed requests are required but headers were missing.
	StaleTimestamp         ErrorCode = "stale_timestamp"          // Timestamp skew exceeded the allowed window.
	MissingAuthorization   ErrorCode = "missing_authorization"    // Authorization header missing.
	InvalidAuthorization   ErrorCode = "invalid_authorization"    // Authorization header malformed or API key invalid.
	RequestNotIdempotent   ErrorCode = "request_not_idempotent"
)

type ErrorType

type ErrorType string

ErrorType mirrors the ACP error.type field.

const (
	InvalidRequest ErrorType = "invalid_request" // Missing or malformed field.
	// Deprecated: use invalid_request + code idempotency_conflict/idempotency_key_required/idempotency_in_flight.
	RequestNotIdempotentType ErrorType = "request_not_idempotent" // Idempotency violation.
	ProcessingError          ErrorType = "processing_error"       // Downstream gateway or network failure.
	RateLimitExceeded        ErrorType = "rate_limit_exceeded"    // Too many requests.
	ServiceUnavailable       ErrorType = "service_unavailable"    // Temporary outage or maintenance.
)

type EstimatedDelivery

type EstimatedDelivery struct {
	Earliest time.Time `json:"earliest"`
	Latest   time.Time `json:"latest"`
}

EstimatedDelivery defines model for EstimatedDelivery.

type EventData

type EventData interface {
	// contains filtered or unexported methods
}

EventData is implemented by webhook payloads.

type EventDataType

type EventDataType string

EventDataType labels the payload for a webhook event.

const (
	// EventDataTypeOrder indicates the webhook data payload is an order object.
	EventDataTypeOrder EventDataType = "order"
)

type Fulfillment

type Fulfillment struct {
	// ID is the fulfillment identifier.
	ID string `json:"id"`
	// Type selects shipping, pickup, or digital delivery.
	Type FulfillmentType `json:"type"`
	// Status is the current fulfillment state.
	Status *FulfillmentStatus `json:"status,omitempty"`
	// LineItems lists included line items and quantities.
	LineItems []LineItemReference `json:"line_items,omitempty"`
	// Carrier is the shipping carrier name for shipping fulfillments.
	Carrier *string `json:"carrier,omitempty"`
	// TrackingNumber is the carrier tracking number for shipping fulfillments.
	TrackingNumber *string `json:"tracking_number,omitempty"`
	// TrackingURL is the external tracking URL for shipping fulfillments.
	TrackingURL *string `json:"tracking_url,omitempty"`
	// Destination is the destination address when applicable.
	Destination *Address `json:"destination,omitempty"`
	// EstimatedDelivery is the expected delivery window.
	EstimatedDelivery *EstimatedDelivery `json:"estimated_delivery,omitempty"`
	// DigitalDelivery contains digital access credentials/links.
	DigitalDelivery *FulfillmentDigitalDelivery `json:"digital_delivery,omitempty"`
	// Description is optional human-readable fulfillment context.
	Description *string `json:"description,omitempty"`
	// Events is an append-only progress log.
	Events []FulfillmentEvent `json:"events,omitempty"`
}

Fulfillment describes how some order items are delivered (shipping, pickup, digital).

type FulfillmentDeliveryWindow

type FulfillmentDeliveryWindow struct {
	Start time.Time `json:"start"`
	End   time.Time `json:"end"`
}

FulfillmentDeliveryWindow defines model for FulfillmentOptionLocalDelivery.DeliveryWindow.

type FulfillmentDetails

type FulfillmentDetails struct {
	Name        *string  `json:"name,omitempty"`
	PhoneNumber *string  `json:"phone_number,omitempty"`
	Email       *string  `json:"email,omitempty"`
	Address     *Address `json:"address,omitempty"`
}

FulfillmentDetails defines model for FulfillmentDetails.

type FulfillmentDigitalDelivery

type FulfillmentDigitalDelivery struct {
	// AccessURL is the URL where the buyer can access the digital content.
	AccessURL *string `json:"access_url,omitempty"`
	// LicenseKey is an activation/license key when applicable.
	LicenseKey *string `json:"license_key,omitempty"`
	// ExpiresAt is the RFC3339 timestamp after which access expires.
	ExpiresAt *time.Time `json:"expires_at,omitempty"`
}

FulfillmentDigitalDelivery holds digital access details for digital fulfillments.

type FulfillmentEvent

type FulfillmentEvent struct {
	// ID is the event identifier.
	ID string `json:"id"`
	// Type is the event type.
	Type FulfillmentEventType `json:"type"`
	// OccurredAt is the RFC3339 timestamp when the event occurred.
	OccurredAt time.Time `json:"occurred_at"`
	// Description is optional human-readable event detail.
	Description *string `json:"description,omitempty"`
	// Location is the optional location of the event.
	Location *string `json:"location,omitempty"`
}

FulfillmentEvent is an immutable event entry describing fulfillment progress.

type FulfillmentEventType

type FulfillmentEventType string

FulfillmentEventType is a point-in-time event in a fulfillment timeline.

const (
	// FulfillmentEventTypeProcessing indicates processing activity.
	FulfillmentEventTypeProcessing FulfillmentEventType = "processing"
	// FulfillmentEventTypeShipped indicates carrier handoff.
	FulfillmentEventTypeShipped FulfillmentEventType = "shipped"
	// FulfillmentEventTypeInTransit indicates carrier network transit.
	FulfillmentEventTypeInTransit FulfillmentEventType = "in_transit"
	// FulfillmentEventTypeOutForDelivery indicates final-mile dispatch.
	FulfillmentEventTypeOutForDelivery FulfillmentEventType = "out_for_delivery"
	// FulfillmentEventTypeReadyForPickup indicates pickup availability.
	FulfillmentEventTypeReadyForPickup FulfillmentEventType = "ready_for_pickup"
	// FulfillmentEventTypeDelivered indicates successful delivery.
	FulfillmentEventTypeDelivered FulfillmentEventType = "delivered"
	// FulfillmentEventTypeFailedAttempt indicates an unsuccessful delivery attempt.
	FulfillmentEventTypeFailedAttempt FulfillmentEventType = "failed_attempt"
	// FulfillmentEventTypeReturned indicates returned/return-to-sender flow.
	FulfillmentEventTypeReturned FulfillmentEventType = "returned"
)

Defines values for FulfillmentEventType.

type FulfillmentGroup

type FulfillmentGroup struct {
	ID                 string                `json:"id"`
	ItemIDs            []string              `json:"item_ids"`
	DestinationType    FulfillmentOptionType `json:"destination_type"`
	FulfillmentDetails *FulfillmentDetails   `json:"fulfillment_details,omitempty"`
	LocationID         *string               `json:"location_id,omitempty"`
	Instructions       *string               `json:"instructions,omitempty"`
}

FulfillmentGroup defines model for FulfillmentGroup.

type FulfillmentOption

type FulfillmentOption struct {
	// contains filtered or unexported fields
}

FulfillmentOption defines model for CheckoutSessionBase.fulfillment_options.Item.

func (FulfillmentOption) AsFulfillmentOptionDigital

func (t FulfillmentOption) AsFulfillmentOptionDigital() (FulfillmentOptionDigital, error)

AsFulfillmentOptionDigital returns the union data inside the CheckoutSessionBase_FulfillmentOptions_Item as a FulfillmentOptionDigital

func (FulfillmentOption) AsFulfillmentOptionLocalDelivery

func (t FulfillmentOption) AsFulfillmentOptionLocalDelivery() (FulfillmentOptionLocalDelivery, error)

AsFulfillmentOptionLocalDelivery returns the union data inside the CheckoutSessionBase_FulfillmentOptions_Item as a FulfillmentOptionLocalDelivery

func (FulfillmentOption) AsFulfillmentOptionPickup

func (t FulfillmentOption) AsFulfillmentOptionPickup() (FulfillmentOptionPickup, error)

AsFulfillmentOptionPickup returns the union data inside the CheckoutSessionBase_FulfillmentOptions_Item as a FulfillmentOptionPickup

func (FulfillmentOption) AsFulfillmentOptionShipping

func (t FulfillmentOption) AsFulfillmentOptionShipping() (FulfillmentOptionShipping, error)

AsFulfillmentOptionShipping returns the union data inside the CheckoutSessionBase_FulfillmentOptions_Item as a FulfillmentOptionShipping

func (*FulfillmentOption) FromFulfillmentOptionDigital

func (t *FulfillmentOption) FromFulfillmentOptionDigital(v FulfillmentOptionDigital) error

FromFulfillmentOptionDigital overwrites any union data inside the CheckoutSessionBase_FulfillmentOptions_Item as the provided FulfillmentOptionDigital

func (*FulfillmentOption) FromFulfillmentOptionLocalDelivery

func (t *FulfillmentOption) FromFulfillmentOptionLocalDelivery(v FulfillmentOptionLocalDelivery) error

FromFulfillmentOptionLocalDelivery overwrites any union data inside the CheckoutSessionBase_FulfillmentOptions_Item as the provided FulfillmentOptionLocalDelivery

func (*FulfillmentOption) FromFulfillmentOptionPickup

func (t *FulfillmentOption) FromFulfillmentOptionPickup(v FulfillmentOptionPickup) error

FromFulfillmentOptionPickup overwrites any union data inside the CheckoutSessionBase_FulfillmentOptions_Item as the provided FulfillmentOptionPickup

func (*FulfillmentOption) FromFulfillmentOptionShipping

func (t *FulfillmentOption) FromFulfillmentOptionShipping(v FulfillmentOptionShipping) error

FromFulfillmentOptionShipping overwrites any union data inside the CheckoutSessionBase_FulfillmentOptions_Item as the provided FulfillmentOptionShipping

func (FulfillmentOption) MarshalJSON

func (t FulfillmentOption) MarshalJSON() ([]byte, error)

MarshalJSON serializes the underlying union for CheckoutSessionBase_FulfillmentOptions_Item.

func (*FulfillmentOption) MergeFulfillmentOptionDigital

func (t *FulfillmentOption) MergeFulfillmentOptionDigital(v FulfillmentOptionDigital) error

MergeFulfillmentOptionDigital performs a merge with any union data inside the CheckoutSessionBase_FulfillmentOptions_Item, using the provided FulfillmentOptionDigital

func (*FulfillmentOption) MergeFulfillmentOptionLocalDelivery

func (t *FulfillmentOption) MergeFulfillmentOptionLocalDelivery(v FulfillmentOptionLocalDelivery) error

MergeFulfillmentOptionLocalDelivery performs a merge with any union data inside the CheckoutSessionBase_FulfillmentOptions_Item, using the provided FulfillmentOptionLocalDelivery

func (*FulfillmentOption) MergeFulfillmentOptionPickup

func (t *FulfillmentOption) MergeFulfillmentOptionPickup(v FulfillmentOptionPickup) error

MergeFulfillmentOptionPickup performs a merge with any union data inside the CheckoutSessionBase_FulfillmentOptions_Item, using the provided FulfillmentOptionPickup

func (*FulfillmentOption) MergeFulfillmentOptionShipping

func (t *FulfillmentOption) MergeFulfillmentOptionShipping(v FulfillmentOptionShipping) error

MergeFulfillmentOptionShipping performs a merge with any union data inside the CheckoutSessionBase_FulfillmentOptions_Item, using the provided FulfillmentOptionShipping

func (*FulfillmentOption) UnmarshalJSON

func (t *FulfillmentOption) UnmarshalJSON(b []byte) error

UnmarshalJSON loads union data for CheckoutSessionBase_FulfillmentOptions_Item.

type FulfillmentOptionDigital

type FulfillmentOptionDigital struct {
	ID          string  `json:"id"`
	Title       string  `json:"title"`
	Description *string `json:"description,omitempty"`
	Totals      []Total `json:"totals"`
	Type        string  `json:"type"`
}

FulfillmentOptionDigital defines model for FulfillmentOptionDigital.

type FulfillmentOptionLocalDelivery

type FulfillmentOptionLocalDelivery struct {
	Type           string                     `json:"type"`
	ID             string                     `json:"id"`
	Title          string                     `json:"title"`
	Description    *string                    `json:"description,omitempty"`
	DeliveryWindow *FulfillmentDeliveryWindow `json:"delivery_window,omitempty"`
	ServiceArea    *FulfillmentServiceArea    `json:"service_area,omitempty"`
	Totals         []Total                    `json:"totals"`
}

FulfillmentOptionLocalDelivery defines model for FulfillmentOptionLocalDelivery.

type FulfillmentOptionPickup

type FulfillmentOptionPickup struct {
	Type        string                    `json:"type"`
	ID          string                    `json:"id"`
	Title       string                    `json:"title"`
	Description *string                   `json:"description,omitempty"`
	Location    FulfillmentPickupLocation `json:"location"`
	PickupType  *FulfillmentPickupType    `json:"pickup_type,omitempty"`
	ReadyBy     *time.Time                `json:"ready_by,omitempty"`
	PickupBy    *time.Time                `json:"pickup_by,omitempty"`
	Totals      []Total                   `json:"totals"`
}

FulfillmentOptionPickup defines model for FulfillmentOptionPickup.

type FulfillmentOptionShipping

type FulfillmentOptionShipping struct {
	ID                   string     `json:"id"`
	Title                string     `json:"title"`
	Description          *string    `json:"description,omitempty"`
	Carrier              *string    `json:"carrier,omitempty"`
	EarliestDeliveryTime *time.Time `json:"earliest_delivery_time,omitempty"`
	LatestDeliveryTime   *time.Time `json:"latest_delivery_time,omitempty"`
	Totals               []Total    `json:"totals"`
	Type                 string     `json:"type"`
}

FulfillmentOptionShipping defines model for FulfillmentOptionShipping.

type FulfillmentOptionType

type FulfillmentOptionType string

FulfillmentOptionType defines model for SelectedFulfillmentOptions.Type.

const (
	FulfillmentOptionTypeShipping      FulfillmentOptionType = "shipping"
	FulfillmentOptionTypeDigital       FulfillmentOptionType = "digital"
	FulfillmentOptionTypePickup        FulfillmentOptionType = "pickup"
	FulfillmentOptionTypeLocalDelivery FulfillmentOptionType = "local_delivery"
)

Defines values for FulfillmentOptionType.

type FulfillmentPickupLocation

type FulfillmentPickupLocation struct {
	Name         string  `json:"name"`
	Address      Address `json:"address"`
	Phone        *string `json:"phone,omitempty"`
	Instructions *string `json:"instructions,omitempty"`
}

FulfillmentPickupLocation describes pickup location metadata.

type FulfillmentPickupType

type FulfillmentPickupType string

FulfillmentPickupType defines model for FulfillmentOptionPickup.PickupType.

const (
	FulfillmentPickupTypeInStore  FulfillmentPickupType = "in_store"
	FulfillmentPickupTypeCurbside FulfillmentPickupType = "curbside"
	FulfillmentPickupTypeLocker   FulfillmentPickupType = "locker"
)

Defines values for FulfillmentPickupType.

type FulfillmentServiceArea

type FulfillmentServiceArea struct {
	RadiusMiles      *float64 `json:"radius_miles,omitempty"`
	CenterPostalCode *string  `json:"center_postal_code,omitempty"`
}

FulfillmentServiceArea defines model for FulfillmentOptionLocalDelivery.ServiceArea.

type FulfillmentStatus

type FulfillmentStatus string

FulfillmentStatus is the current state of a fulfillment. Not every state applies to every fulfillment type.

const (
	// FulfillmentStatusPending means fulfillment is queued but not started.
	FulfillmentStatusPending FulfillmentStatus = "pending"
	// FulfillmentStatusProcessing means fulfillment is in progress.
	FulfillmentStatusProcessing FulfillmentStatus = "processing"
	// FulfillmentStatusShipped means shipment was handed to a carrier.
	FulfillmentStatusShipped FulfillmentStatus = "shipped"
	// FulfillmentStatusInTransit means shipment is moving through carrier network.
	FulfillmentStatusInTransit FulfillmentStatus = "in_transit"
	// FulfillmentStatusOutForDelivery means final-mile delivery is in progress.
	FulfillmentStatusOutForDelivery FulfillmentStatus = "out_for_delivery"
	// FulfillmentStatusReadyForPickup means buyer can collect the order.
	FulfillmentStatusReadyForPickup FulfillmentStatus = "ready_for_pickup"
	// FulfillmentStatusDelivered means fulfillment completed successfully.
	FulfillmentStatusDelivered FulfillmentStatus = "delivered"
	// FulfillmentStatusFailed means fulfillment could not be completed.
	FulfillmentStatusFailed FulfillmentStatus = "failed"
	// FulfillmentStatusCanceled means fulfillment was canceled.
	FulfillmentStatusCanceled FulfillmentStatus = "canceled"
)

Defines values for FulfillmentStatus.

type FulfillmentType

type FulfillmentType string

FulfillmentType identifies the delivery method for a fulfillment.

const (
	// FulfillmentTypeShipping is carrier shipment.
	FulfillmentTypeShipping FulfillmentType = "shipping"
	// FulfillmentTypePickup is in-store or curbside pickup.
	FulfillmentTypePickup FulfillmentType = "pickup"
	// FulfillmentTypeDigital is non-physical digital delivery.
	FulfillmentTypeDigital FulfillmentType = "digital"
)

Defines values for FulfillmentType.

type GiftWrap

type GiftWrap struct {
	Enabled bool    `json:"enabled"`
	Style   *string `json:"style,omitempty"`
	Charge  *int    `json:"charge,omitempty"`
}

GiftWrap defines model for GiftWrap.

type IntentTrace

type IntentTrace struct {
	ReasonCode   IntentTraceReasonCode `json:"reason_code"`
	TraceSummary *string               `json:"trace_summary,omitempty"`
	Metadata     map[string]any        `json:"metadata,omitempty"`
}

IntentTrace defines model for IntentTrace.

type IntentTraceReasonCode

type IntentTraceReasonCode string

IntentTraceReasonCode defines model for IntentTrace.ReasonCode.

const (
	IntentTraceReasonCodePriceSensitivity IntentTraceReasonCode = "price_sensitivity"
	IntentTraceReasonCodeShippingCost     IntentTraceReasonCode = "shipping_cost"
	IntentTraceReasonCodeShippingSpeed    IntentTraceReasonCode = "shipping_speed"
	IntentTraceReasonCodeProductFit       IntentTraceReasonCode = "product_fit"
	IntentTraceReasonCodeTrustSecurity    IntentTraceReasonCode = "trust_security"
	IntentTraceReasonCodeReturnsPolicy    IntentTraceReasonCode = "returns_policy"
	IntentTraceReasonCodePaymentOptions   IntentTraceReasonCode = "payment_options"
	IntentTraceReasonCodeComparison       IntentTraceReasonCode = "comparison"
	IntentTraceReasonCodeTimingDeferred   IntentTraceReasonCode = "timing_deferred"
	IntentTraceReasonCodeOther            IntentTraceReasonCode = "other"
)

Defines values for IntentTraceReasonCode.

type Item

type Item struct {
	ID         string  `json:"id"`
	Name       *string `json:"name,omitempty"`
	UnitAmount *int    `json:"unit_amount,omitempty"`
}

Item defines model for Item.

type LineItem

type LineItem struct {
	ID                       string                    `json:"id"`
	Item                     Item                      `json:"item"`
	Quantity                 int                       `json:"quantity"`
	Name                     *string                   `json:"name,omitempty"`
	Description              *string                   `json:"description,omitempty"`
	Images                   []string                  `json:"images,omitempty"`
	UnitAmount               *int                      `json:"unit_amount,omitempty"`
	Disclosures              []Disclosure              `json:"disclosures,omitempty"`
	CustomAttributes         []CustomAttribute         `json:"custom_attributes,omitempty"`
	MarketplaceSellerDetails *MarketplaceSellerDetails `json:"marketplace_seller_details,omitempty"`
	ProductID                *string                   `json:"product_id,omitempty"`
	SKU                      *string                   `json:"sku,omitempty"`
	VariantID                *string                   `json:"variant_id,omitempty"`
	Category                 *string                   `json:"category,omitempty"`
	Tags                     []string                  `json:"tags,omitempty"`
	Weight                   *WeightInfo               `json:"weight,omitempty"`
	Dimensions               *DimensionsInfo           `json:"dimensions,omitempty"`
	AvailabilityStatus       *AvailabilityStatus       `json:"availability_status,omitempty"`
	AvailableQuantity        *int                      `json:"available_quantity,omitempty"`
	MaxQuantityPerOrder      *int                      `json:"max_quantity_per_order,omitempty"`
	FulfillableOn            *time.Time                `json:"fulfillable_on,omitempty"`
	VariantOptions           []VariantOption           `json:"variant_options,omitempty"`
	DiscountDetails          []DiscountDetail          `json:"discount_details,omitempty"`
	TaxExempt                *bool                     `json:"tax_exempt,omitempty"`
	TaxExemptionReason       *string                   `json:"tax_exemption_reason,omitempty"`
	ParentID                 *string                   `json:"parent_id,omitempty"`
	// Totals contains the line-item totals breakdown including base_amount, discount, subtotal, tax, and total.
	Totals []Total `json:"totals"`
}

LineItem defines model for LineItem.

type LineItemReference

type LineItemReference struct {
	// ID references an OrderLineItem.ID.
	ID string `json:"id"`
	// Quantity is the affected quantity for this reference.
	Quantity int `json:"quantity"`
}

LineItemReference points to a line item and quantity in fulfillments/adjustments.

type Link struct {
	Type  LinkType `json:"type"`
	Title *string  `json:"title,omitempty"`
	Url   string   `json:"url"`
}

Link defines model for Link.

type LinkType

type LinkType string

LinkType defines model for Link.Type.

const (
	PrivacyPolicy LinkType = "privacy_policy"
	ReturnPolicy  LinkType = "return_policy"
	// Deprecated: removed in ACP 2025-12-11; attach policies to line items in marketplace scenarios.
	SellerShopPolicies LinkType = "seller_shop_policies"
	ShippingPolicy     LinkType = "shipping_policy"
	ContactUs          LinkType = "contact_us"
	AboutUs            LinkType = "about_us"
	FAQ                LinkType = "faq"
	Support            LinkType = "support"
	TermsOfUse         LinkType = "terms_of_use"
)

Defines values for LinkType.

type LoyaltyInfo

type LoyaltyInfo struct {
	Tier          *string    `json:"tier,omitempty"`
	PointsBalance *int       `json:"points_balance,omitempty"`
	MemberSince   *time.Time `json:"member_since,omitempty"`
}

LoyaltyInfo defines model for Buyer.Loyalty.

type MarketplaceSellerDetails

type MarketplaceSellerDetails struct {
	Name string `json:"name"`
}

MarketplaceSellerDetails defines model for MarketplaceSellerDetails.

type Message

type Message struct {
	// contains filtered or unexported fields
}

Message defines model for CheckoutSessionBase.messages.Item.

func (Message) AsMessageError

func (t Message) AsMessageError() (MessageError, error)

AsMessageError returns the union data inside the CheckoutSessionBase_Messages_Item as a MessageError

func (Message) AsMessageInfo

func (t Message) AsMessageInfo() (MessageInfo, error)

AsMessageInfo returns the union data inside the CheckoutSessionBase_Messages_Item as a MessageInfo

func (Message) AsMessageWarning

func (t Message) AsMessageWarning() (MessageWarning, error)

AsMessageWarning returns the union data inside the CheckoutSessionBase_Messages_Item as a MessageWarning

func (*Message) FromMessageError

func (t *Message) FromMessageError(v MessageError) error

FromMessageError overwrites any union data inside the CheckoutSessionBase_Messages_Item as the provided MessageError

func (*Message) FromMessageInfo

func (t *Message) FromMessageInfo(v MessageInfo) error

FromMessageInfo overwrites any union data inside the CheckoutSessionBase_Messages_Item as the provided MessageInfo

func (*Message) FromMessageWarning

func (t *Message) FromMessageWarning(v MessageWarning) error

FromMessageWarning overwrites any union data inside the CheckoutSessionBase_Messages_Item as the provided MessageWarning

func (Message) MarshalJSON

func (t Message) MarshalJSON() ([]byte, error)

MarshalJSON serializes the underlying union for CheckoutSessionBase_Messages_Item.

func (*Message) MergeMessageError

func (t *Message) MergeMessageError(v MessageError) error

MergeMessageError performs a merge with any union data inside the CheckoutSessionBase_Messages_Item, using the provided MessageError

func (*Message) MergeMessageInfo

func (t *Message) MergeMessageInfo(v MessageInfo) error

MergeMessageInfo performs a merge with any union data inside the CheckoutSessionBase_Messages_Item, using the provided MessageInfo

func (*Message) MergeMessageWarning

func (t *Message) MergeMessageWarning(v MessageWarning) error

MergeMessageWarning performs a merge with any union data inside the CheckoutSessionBase_Messages_Item, using the provided MessageWarning

func (*Message) UnmarshalJSON

func (t *Message) UnmarshalJSON(b []byte) error

UnmarshalJSON loads union data for CheckoutSessionBase_Messages_Item.

type MessageError

type MessageError struct {
	Code        MessageErrorCode        `json:"code"`
	Content     string                  `json:"content"`
	ContentType MessageErrorContentType `json:"content_type"`
	Severity    *MessageSeverity        `json:"severity,omitempty"`
	Resolution  *MessageResolution      `json:"resolution,omitempty"`
	Param       *string                 `json:"param,omitempty"`
	Type        string                  `json:"type"`
}

MessageError defines model for MessageError.

type MessageErrorCode

type MessageErrorCode string

MessageErrorCode defines model for MessageError.Code.

const (
	Invalid                 MessageErrorCode = "invalid"
	Missing                 MessageErrorCode = "missing"
	OutOfStock              MessageErrorCode = "out_of_stock"
	PaymentDeclined         MessageErrorCode = "payment_declined"
	Requires3ds             MessageErrorCode = "requires_3ds"
	RequiresSignIn          MessageErrorCode = "requires_sign_in"
	LowStock                MessageErrorCode = "low_stock"
	QuantityExceeded        MessageErrorCode = "quantity_exceeded"
	CouponInvalid           MessageErrorCode = "coupon_invalid"
	CouponExpired           MessageErrorCode = "coupon_expired"
	MinimumNotMet           MessageErrorCode = "minimum_not_met"
	MaximumExceeded         MessageErrorCode = "maximum_exceeded"
	RegionRestricted        MessageErrorCode = "region_restricted"
	AgeVerificationRequired MessageErrorCode = "age_verification_required"
	ApprovalRequired        MessageErrorCode = "approval_required"
	Unsupported             MessageErrorCode = "unsupported"
	NotFound                MessageErrorCode = "not_found"
	Conflict                MessageErrorCode = "conflict"
	RateLimited             MessageErrorCode = "rate_limited"
	Expired                 MessageErrorCode = "expired"
	InterventionRequired    MessageErrorCode = "intervention_required"
)

Defines values for MessageErrorCode.

type MessageErrorContentType

type MessageErrorContentType string

MessageErrorContentType defines model for MessageError.ContentType.

const (
	MessageErrorContentTypeMarkdown MessageErrorContentType = "markdown"
	MessageErrorContentTypePlain    MessageErrorContentType = "plain"
)

Defines values for MessageErrorContentType.

type MessageInfo

type MessageInfo struct {
	Content     string                 `json:"content"`
	ContentType MessageInfoContentType `json:"content_type"`
	Severity    *MessageSeverity       `json:"severity,omitempty"`
	Resolution  *MessageResolution     `json:"resolution,omitempty"`

	// Param RFC 9535 JSONPath
	Param *string `json:"param,omitempty"`
	Type  string  `json:"type"`
}

MessageInfo defines model for MessageInfo.

type MessageInfoContentType

type MessageInfoContentType string

MessageInfoContentType defines model for MessageInfo.ContentType.

const (
	MessageInfoContentTypeMarkdown MessageInfoContentType = "markdown"
	MessageInfoContentTypePlain    MessageInfoContentType = "plain"
)

Defines values for MessageInfoContentType.

type MessageResolution

type MessageResolution string

MessageResolution defines who is responsible for resolving a message.

const (
	MessageResolutionRecoverable         MessageResolution = "recoverable"
	MessageResolutionRequiresBuyerInput  MessageResolution = "requires_buyer_input"
	MessageResolutionRequiresBuyerReview MessageResolution = "requires_buyer_review"
)

Defines values for MessageResolution.

type MessageSeverity

type MessageSeverity string

MessageSeverity defines model for MessageInfo/MessageWarning/MessageError.Severity.

const (
	MessageSeverityInfo     MessageSeverity = "info"
	MessageSeverityLow      MessageSeverity = "low"
	MessageSeverityMedium   MessageSeverity = "medium"
	MessageSeverityHigh     MessageSeverity = "high"
	MessageSeverityCritical MessageSeverity = "critical"
)

Defines values for MessageSeverity.

type MessageWarning

type MessageWarning struct {
	Code        MessageWarningCode     `json:"code"`
	Content     string                 `json:"content"`
	ContentType MessageInfoContentType `json:"content_type"`
	Severity    *MessageSeverity       `json:"severity,omitempty"`
	Resolution  *MessageResolution     `json:"resolution,omitempty"`
	// Param RFC 9535 JSONPath
	Param *string `json:"param,omitempty"`
	Type  string  `json:"type"`
}

MessageWarning defines model for MessageWarning.

type MessageWarningCode

type MessageWarningCode string

MessageWarningCode defines model for MessageWarning.Code.

const (
	MessageWarningLowStock            MessageWarningCode = "low_stock"
	MessageWarningHighDemand          MessageWarningCode = "high_demand"
	MessageWarningShippingDelay       MessageWarningCode = "shipping_delay"
	MessageWarningPriceChange         MessageWarningCode = "price_change"
	MessageWarningExpiringPromotion   MessageWarningCode = "expiring_promotion"
	MessageWarningLimitedAvailability MessageWarningCode = "limited_availability"
)

Defines values for MessageWarningCode.

type Middleware

type Middleware func(http.HandlerFunc) http.HandlerFunc

Middleware is an HTTP middleware applied to the ACP handlers.

type Option

type Option func(*config)

Option customizes the handler behavior.

func WithAuthenticator

func WithAuthenticator(auth Authenticator) Option

WithAuthenticator enables Authorization header API key validation.

func WithMaxClockSkew

func WithMaxClockSkew(skew time.Duration) Option

WithMaxClockSkew sets the tolerated absolute difference between the Timestamp header and the server clock when verifying signed requests.

func WithMiddleware

func WithMiddleware(mw ...Middleware) Option

WithMiddleware appends custom middleware in the order provided.

func WithRequireSignedRequests

func WithRequireSignedRequests() Option

WithRequireSignedRequests enforces that every request carries Signature and Timestamp headers when a verifier is configured.

func WithSignatureVerifier

func WithSignatureVerifier(verifier signature.Verifier) Option

WithSignatureVerifier enables canonical JSON signature enforcement.

type Order

type Order struct {
	// Type is the discriminator for webhook payloads when present.
	Type *EventDataType `json:"type,omitempty"`
	// ID is the order identifier.
	ID string `json:"id"`
	// CheckoutSessionId identifies the checkout session used to create this order.
	CheckoutSessionId string `json:"checkout_session_id"`
	// OrderNumber is a human-readable order reference.
	OrderNumber *string `json:"order_number,omitempty"`
	// PermalinkUrl is the buyer-facing URL to view order details.
	PermalinkUrl string `json:"permalink_url"`
	// Status is the order-level lifecycle state.
	Status *CheckoutOrderStatus `json:"status,omitempty"`
	// EstimatedDelivery is the expected delivery window for this order.
	EstimatedDelivery *EstimatedDelivery `json:"estimated_delivery,omitempty"`
	// Confirmation contains confirmation metadata such as receipt URL.
	Confirmation *OrderConfirmation `json:"confirmation,omitempty"`
	// Support contains merchant support contact details for this order.
	Support *SupportInfo `json:"support,omitempty"`
	// LineItems tracks ordered items and fulfillment progress.
	LineItems []OrderLineItem `json:"line_items,omitempty"`
	// Fulfillments tracks shipping, pickup, and digital delivery.
	Fulfillments []Fulfillment `json:"fulfillments,omitempty"`
	// Adjustments tracks post-order changes like refunds/returns/disputes.
	Adjustments []Adjustment `json:"adjustments,omitempty"`
	// Totals captures order-level financial breakdown, including amount_refunded.
	Totals []Total `json:"totals,omitempty"`
}

Order defines model for Order.

type OrderConfirmation

type OrderConfirmation struct {
	ConfirmationNumber    *string `json:"confirmation_number,omitempty"`
	ConfirmationEmailSent *bool   `json:"confirmation_email_sent,omitempty"`
	ReceiptURL            *string `json:"receipt_url,omitempty"`
	InvoiceNumber         *string `json:"invoice_number,omitempty"`
}

OrderConfirmation defines model for OrderConfirmation.

type OrderCreate

type OrderCreate struct {
	// Type is the webhook payload discriminator and is always "order".
	Type EventDataType `json:"type"`
	// ID is the order identifier.
	ID *string `json:"id,omitempty"`
	// CheckoutSessionID identifies the checkout session that produced this order.
	CheckoutSessionID string `json:"checkout_session_id"`
	// OrderNumber is a human-readable order reference.
	OrderNumber *string `json:"order_number,omitempty"`
	// PermalinkURL is the buyer-facing order URL.
	PermalinkURL string `json:"permalink_url"`
	// Status is the order lifecycle state at event emission time.
	Status OrderStatus `json:"status"`
	// EstimatedDelivery is the expected delivery window.
	EstimatedDelivery *EstimatedDelivery `json:"estimated_delivery,omitempty"`
	// Confirmation contains receipt and confirmation metadata.
	Confirmation *OrderConfirmation `json:"confirmation,omitempty"`
	// Support contains merchant support contact details.
	Support *SupportInfo `json:"support,omitempty"`
	// LineItems describes ordered items and item-level fulfillment progress.
	LineItems []OrderLineItem `json:"line_items,omitempty"`
	// Fulfillments describes shipping/pickup/digital delivery state.
	Fulfillments []Fulfillment `json:"fulfillments,omitempty"`
	// Adjustments describes refunds, credits, returns, and disputes.
	Adjustments []Adjustment `json:"adjustments,omitempty"`
	// Totals is an order-level totals breakdown.
	Totals []Total `json:"totals,omitempty"`
}

OrderCreate emits order data after the order is created.

type OrderLineItem

type OrderLineItem struct {
	// ID is the line item identifier for references in fulfillments/adjustments.
	ID string `json:"id"`
	// Title is the product name.
	Title string `json:"title"`
	// ProductID is the merchant catalog product identifier.
	ProductID *string `json:"product_id,omitempty"`
	// Description is the product description.
	Description *string `json:"description,omitempty"`
	// ImageURL is the product image URL.
	ImageURL *string `json:"image_url,omitempty"`
	// URL is the product page URL.
	URL *string `json:"url,omitempty"`
	// Quantity tracks ordered vs shipped units.
	Quantity OrderLineItemQuantity `json:"quantity"`
	// UnitPrice is the price per unit in minor currency units.
	UnitPrice *int `json:"unit_price,omitempty"`
	// Subtotal is quantity.ordered * unit_price in minor currency units.
	Subtotal *int `json:"subtotal,omitempty"`
	// Totals is the optional line-item totals breakdown.
	Totals []Total `json:"totals,omitempty"`
	// Status is the current fulfillment state for this line item.
	Status *OrderLineItemStatus `json:"status,omitempty"`
}

OrderLineItem is a post-purchase line item with optional fulfillment and price details.

type OrderLineItemQuantity

type OrderLineItemQuantity struct {
	// Ordered is the quantity originally purchased.
	Ordered int `json:"ordered"`
	// Shipped is the quantity handed to carrier/fulfilled so far.
	Shipped *int `json:"shipped,omitempty"`
}

OrderLineItemQuantity captures ordered vs shipped quantity for a line item. Shipped is optional and defaults to zero when omitted.

type OrderLineItemStatus

type OrderLineItemStatus string

OrderLineItemStatus represents per-line fulfillment progress in an order.

const (
	// OrderLineItemStatusProcessing means no units have shipped yet.
	OrderLineItemStatusProcessing OrderLineItemStatus = "processing"
	// OrderLineItemStatusPartial means some but not all units have shipped.
	OrderLineItemStatusPartial OrderLineItemStatus = "partial"
	// OrderLineItemStatusShipped means all ordered units have shipped.
	OrderLineItemStatusShipped OrderLineItemStatus = "shipped"
	// OrderLineItemStatusDelivered means the item has been delivered.
	OrderLineItemStatusDelivered OrderLineItemStatus = "delivered"
	// OrderLineItemStatusCanceled means fulfillment for this item was canceled.
	OrderLineItemStatusCanceled OrderLineItemStatus = "canceled"
)

Defines values for OrderLineItemStatus.

type OrderStatus

type OrderStatus = CheckoutOrderStatus

OrderStatus defines model for webhook data status.

const (
	// OrderStatusCreated indicates a newly created order.
	OrderStatusCreated OrderStatus = CheckoutOrderStatusCreated
	// OrderStatusConfirmed indicates order acceptance/confirmation.
	OrderStatusConfirmed OrderStatus = CheckoutOrderStatusConfirmed
	// OrderStatusManualReview indicates manual review is required.
	OrderStatusManualReview OrderStatus = CheckoutOrderStatusManualReview
	// OrderStatusProcessing indicates post-checkout processing has started.
	OrderStatusProcessing OrderStatus = CheckoutOrderStatusProcessing
	// OrderStatusShipped indicates the order has been shipped.
	OrderStatusShipped OrderStatus = CheckoutOrderStatusShipped
	// OrderStatusDelivered indicates fulfillment has completed.
	OrderStatusDelivered OrderStatus = CheckoutOrderStatusDelivered
	// OrderStatusCanceled indicates the order was canceled.
	OrderStatusCanceled OrderStatus = CheckoutOrderStatusCanceled
)

type OrderUpdated

type OrderUpdated struct {
	// Type is the webhook payload discriminator and is always "order".
	Type EventDataType `json:"type"`
	// ID is the order identifier.
	ID *string `json:"id,omitempty"`
	// CheckoutSessionID identifies the checkout session that produced this order.
	CheckoutSessionID string `json:"checkout_session_id"`
	// OrderNumber is a human-readable order reference.
	OrderNumber *string `json:"order_number,omitempty"`
	// PermalinkURL is the buyer-facing order URL.
	PermalinkURL string `json:"permalink_url"`
	// Status is the order lifecycle state at event emission time.
	Status OrderStatus `json:"status"`
	// EstimatedDelivery is the expected delivery window.
	EstimatedDelivery *EstimatedDelivery `json:"estimated_delivery,omitempty"`
	// Confirmation contains receipt and confirmation metadata.
	Confirmation *OrderConfirmation `json:"confirmation,omitempty"`
	// Support contains merchant support contact details.
	Support *SupportInfo `json:"support,omitempty"`
	// LineItems describes ordered items and item-level fulfillment progress.
	LineItems []OrderLineItem `json:"line_items,omitempty"`
	// Fulfillments describes shipping/pickup/digital delivery state.
	Fulfillments []Fulfillment `json:"fulfillments,omitempty"`
	// Adjustments describes refunds, credits, returns, and disputes.
	Adjustments []Adjustment `json:"adjustments,omitempty"`
	// Totals is an order-level totals breakdown.
	Totals []Total `json:"totals,omitempty"`
}

OrderUpdated emits order data whenever the order status changes.

type PaymentCardNetwork

type PaymentCardNetwork string

PaymentCardNetwork defines model for PaymentMethod.SupportedCardNetworks items.

const (
	PaymentCardNetworkAmex       PaymentCardNetwork = "amex"
	PaymentCardNetworkDiscover   PaymentCardNetwork = "discover"
	PaymentCardNetworkMastercard PaymentCardNetwork = "mastercard"
	PaymentCardNetworkVisa       PaymentCardNetwork = "visa"
)

Defines values for PaymentCardNetwork.

type PaymentCredential

type PaymentCredential struct {
	// Type is the credential type (for example "spt" or "wallet_token").
	Type string `json:"type"`
	// Token is the opaque credential/token value.
	Token string `json:"token"`
}

PaymentCredential holds a credential token used by a payment instrument.

type PaymentData

type PaymentData struct {
	// HandlerID identifies which advertised payment handler to use.
	HandlerID *string `json:"handler_id,omitempty"`
	// Instrument carries handler-specific payment instrument details.
	Instrument *PaymentInstrument `json:"instrument,omitempty"`
	// Deprecated: prefer handler_id + instrument for ACP payment handlers.
	// Token is a provider-issued payment token (required with Provider).
	Token *string `json:"token,omitempty"`
	// Deprecated: prefer handler_id + instrument for ACP payment handlers.
	// Provider identifies the payment provider that issued Token.
	Provider       *PaymentDataProvider `json:"provider,omitempty"`
	BillingAddress *Address             `json:"billing_address,omitempty"`
	// PurchaseOrderNumber enables non-tokenized payment flows (B2B).
	PurchaseOrderNumber *string `json:"purchase_order_number,omitempty"`
	// PaymentTerms specify invoice payment terms (for example "net_30").
	PaymentTerms *PaymentTerms `json:"payment_terms,omitempty"`
	// DueDate is the payment due date for invoice flows.
	DueDate *time.Time `json:"due_date,omitempty"`
	// ApprovalRequired signals whether buyer approval is required before payment capture.
	ApprovalRequired *bool `json:"approval_required,omitempty"`
}

PaymentData defines model for PaymentData.

type PaymentDataProvider

type PaymentDataProvider string

PaymentDataProvider defines model for PaymentData.Provider.

type PaymentInstrument

type PaymentInstrument struct {
	// Type is the instrument type (for example "card" or "wallet_token").
	Type string `json:"type"`
	// Credential carries the credential required by the selected handler.
	Credential PaymentCredential `json:"credential"`
}

PaymentInstrument describes the selected payment instrument.

type PaymentMethod

type PaymentMethod struct {
	SupportedCardNetworks []PaymentCardNetwork `json:"supported_card_networks,omitempty"`
	Type                  PaymentMethodType    `json:"type"`
}

PaymentMethod defines model for PaymentProvider.SupportedPaymentMethods items.

type PaymentMethodCard

type PaymentMethodCard struct {
	// The type of payment method used. Currently only card.
	Type PaymentMethodCardType `json:"type" validate:"required,eq=card"`
	// The type of card number. Network tokens are preferred with fallback to FPAN. See [PCI Scope] for more details.
	//
	// [PCI Scope]: https://developers.openai.com/commerce/guides/production#security-and-compliance
	CardNumberType CardNumberType `json:"card_number_type" validate:"required,oneof=fpan network_token"`
	// Card number.
	Number secret.Secret[string] `json:"number" validate:"required"`
	// Expiry month.
	ExpMonth *string `json:"exp_month,omitempty" validate:"omitempty,len=2,numeric"`
	// Expiry year.
	ExpYear *string `json:"exp_year,omitempty" validate:"omitempty,len=4,numeric"`
	// Cardholder name.
	Name *string `json:"name,omitempty"`
	// Card CVC number.
	CVC *string `json:"cvc,omitempty" validate:"omitempty,numeric"`
	// In case of non-PAN, this is the original last 4 digits of the card for customer display.
	DisplayLast4 *string `json:"display_last4,omitempty" validate:"omitempty,len=4"`
	// Funding type of the card to display.
	DisplayCardFundingType CardFundingType `json:"display_card_funding_type" validate:"required,oneof=credit debit prepaid"`
	// Brand of the card to display.
	//
	// Exapmple: "Visa", "amex", "discover"
	DisplayBrand *string `json:"display_brand,omitempty"`
	// If the card came via a digital wallet, what type of wallet.
	DisplayWalletType *string `json:"display_wallet_type,omitempty"`
	// Institution Identification Number (aka BIN). The first 6-8 digits on a card identifying the issuer.
	IIN *string `json:"iin,omitempty" validate:"omitempty,max=8"`
	// Cryptogram provided with network tokens.
	Cryptogram *string `json:"cryptogram,omitempty"`
	// Electronic Commerce Indicator / Security Level Indicator provided with network tokens.
	ECIValue *string `json:"eci_value,omitempty"`
	// Checks already performed on the card.
	ChecksPerformed []CardChecksPerformed `json:"checks_performed,omitempty" validate:"omitempty,dive,required"`
	// Arbitrary key/value pairs.
	Metadata map[string]string `json:"metadata" validate:"required,map_present"`
}

PaymentMethodCard captures the delegated card credential.

type PaymentMethodCardType

type PaymentMethodCardType string
const (
	PaymentMethodCardTypeCard PaymentMethodCardType = "card"
)

type PaymentMethodType

type PaymentMethodType string

PaymentMethodType defines model for PaymentMethod.Type.

const (
	PaymentMethodTypeCard PaymentMethodType = "card"
)

Defines values for PaymentMethodType.

type PaymentProvider

type PaymentProvider struct {
	Provider                PaymentProviderProvider `json:"provider"`
	SupportedPaymentMethods []PaymentMethod         `json:"supported_payment_methods"`
}

PaymentProvider defines model for PaymentProvider.

type PaymentProviderProvider

type PaymentProviderProvider string

PaymentProviderProvider defines model for PaymentProvider.Provider.

type PaymentRequest

type PaymentRequest struct {
	// Type of credential. The only accepted value is "CARD".
	PaymentMethod PaymentMethodCard `json:"payment_method" validate:"required"`
	// Use cases that the stored credential can be applied to.
	Allowance Allowance `json:"allowance" validate:"required"`
	// Address associated with the payment method.
	BillingAddress *Address `json:"billing_address,omitempty" validate:"omitempty"`
	// Arbitrary key/value pairs.
	Metadata map[string]string `json:"metadata" validate:"required,map_present"`
	// List of risk signals.
	RiskSignals []RiskSignal `json:"risk_signals" validate:"required,min=1,dive"`
}

PaymentRequest mirrors the ACP DelegatePaymentRequest payload described in the spec: https://developers.openai.com/commerce/specs/payment.

func (PaymentRequest) Validate

func (r PaymentRequest) Validate() error

Validate ensures the request complies with the ACP Delegate Payment spec by running go-playground/validator rules plus custom constraints.

type PaymentResponse

type PaymentResponse struct {
	Provider    *string          `json:"provider,omitempty"`
	Instruments []map[string]any `json:"instruments,omitempty"`
	Handlers    []map[string]any `json:"handlers,omitempty"`
}

PaymentResponse defines model for PaymentResponse.

type PaymentTerms

type PaymentTerms string

PaymentTerms defines model for PaymentData.PaymentTerms.

const (
	PaymentTermsImmediate PaymentTerms = "immediate"
	PaymentTermsNet15     PaymentTerms = "net_15"
	PaymentTermsNet30     PaymentTerms = "net_30"
	PaymentTermsNet60     PaymentTerms = "net_60"
	PaymentTermsNet90     PaymentTerms = "net_90"
)

Defines values for PaymentTerms.

type ProtocolVersion

type ProtocolVersion struct {
	Version      string   `json:"version"`
	Capabilities []string `json:"capabilities,omitempty"`
}

ProtocolVersion defines model for ProtocolVersion.

type RequestContext

type RequestContext struct {
	// API Key used to make requests
	//
	// Example: Bearer api_key_123
	Authorization string
	// The preferred locale for content like messages and errors
	//
	// Example: en-US
	AcceptLanguage string
	// Information about the client making this request
	//
	// Example: ChatGPT/2.0 (Mac OS X 15.0.1; arm64; build 0)
	UserAgent string
	// Key used to ensure requests are idempotent
	//
	// Example: idempotency_key_123
	IdempotencyKey string
	// Unique key for each request for tracing purposes
	//
	// Example: request_id_123
	RequestID string
	// Base64 encoded signature of the request body
	//
	// Example: eyJtZX...
	Signature string
	// Formatted as an RFC 3339 string.
	//
	// Example: 2025-09-25T10:30:00Z
	Timestamp string
	// API version
	//
	// Example: 2026-01-30
	APIVersion string
}

func RequestContextFromContext

func RequestContextFromContext(ctx context.Context) *RequestContext

RequestContextFromContext extracts the HTTP request metadata previously stored in the context.

type RiskSignal

type RiskSignal struct {
	// The type of risk signal.
	Type RiskSignalType `json:"type" validate:"required,oneof=card_testing"`
	// Action taken.
	Action RiskSignalAction `json:"action" validate:"required,oneof=manual_review authorized blocked"`
	// Details of the risk signal.
	Score int `json:"score" validate:"gte=0"`
}

RiskSignal provides PSPs with fraud intelligence references.

type RiskSignalAction

type RiskSignalAction string
const (
	RiskSignalActionManualReview RiskSignalAction = "manual_review"
	RiskSignalActionAuthorized   RiskSignalAction = "authorized"
	RiskSignalActionBlocked      RiskSignalAction = "blocked"
)

type RiskSignalType

type RiskSignalType string
const (
	RiskSignalTypeCardTesting RiskSignalType = "card_testing"
)

type RiskSignals

type RiskSignals struct {
	IPAddress         *string `json:"ip_address,omitempty"`
	UserAgent         *string `json:"user_agent,omitempty"`
	AcceptLanguage    *string `json:"accept_language,omitempty"`
	SessionID         *string `json:"session_id,omitempty"`
	DeviceFingerprint *string `json:"device_fingerprint,omitempty"`
}

RiskSignals defines model for RiskSignals.

type SelectedFulfillmentOptions

type SelectedFulfillmentOptions struct {
	Type     FulfillmentOptionType `json:"type"`
	OptionID string                `json:"option_id"`
	ItemIDs  []string              `json:"item_ids"`
}

SelectedFulfillmentOptions defines model for SelectedFulfillmentOptions.

type SessionWithOrder

type SessionWithOrder struct {
	CheckoutSession
	Order Order `json:"order"`
}

SessionWithOrder defines model for SessionWithOrder.

type SplitPayment

type SplitPayment struct {
	Amount int `json:"amount"`
}

SplitPayment defines model for SplitPayment.

type SupportInfo

type SupportInfo struct {
	Email         *string `json:"email,omitempty"`
	Phone         *string `json:"phone,omitempty"`
	Hours         *string `json:"hours,omitempty"`
	HelpCenterURL *string `json:"help_center_url,omitempty"`
}

SupportInfo defines model for SupportInfo.

type TaxBreakdownItem

type TaxBreakdownItem struct {
	Jurisdiction string  `json:"jurisdiction"`
	Rate         float64 `json:"rate"`
	Amount       int     `json:"amount"`
}

TaxBreakdownItem defines model for TaxBreakdownItem.

type TaxExemption

type TaxExemption struct {
	CertificateID   string     `json:"certificate_id"`
	CertificateType string     `json:"certificate_type"`
	ExemptRegions   []string   `json:"exempt_regions,omitempty"`
	ExpiresAt       *time.Time `json:"expires_at,omitempty"`
}

TaxExemption defines model for Buyer.TaxExemption.

type Total

type Total struct {
	Amount            int                `json:"amount"`
	PresentmentAmount *int               `json:"presentment_amount,omitempty"`
	Description       *string            `json:"description,omitempty"`
	DisplayText       string             `json:"display_text"`
	Type              TotalType          `json:"type"`
	Breakdown         []TaxBreakdownItem `json:"breakdown,omitempty"`
}

Total defines model for Total.

type TotalType

type TotalType string

TotalType identifies a monetary component in a totals breakdown.

const (
	TotalTypeDiscount        TotalType = "discount"
	TotalTypeFee             TotalType = "fee"
	TotalTypeFulfillment     TotalType = "fulfillment"
	TotalTypeGiftWrap        TotalType = "gift_wrap"
	TotalTypeItemsBaseAmount TotalType = "items_base_amount"
	TotalTypeItemsDiscount   TotalType = "items_discount"
	TotalTypeStoreCredit     TotalType = "store_credit"
	TotalTypeSubtotal        TotalType = "subtotal"
	TotalTypeTax             TotalType = "tax"
	TotalTypeTip             TotalType = "tip"
	TotalTypeTotal           TotalType = "total"
	// TotalTypeAmountRefunded tracks cumulative refunded amount post-purchase.
	TotalTypeAmountRefunded TotalType = "amount_refunded"
)

Defines values for TotalType.

type VariantOption

type VariantOption struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

VariantOption defines model for VariantOption.

type VaultToken

type VaultToken struct {
	// Unique vault token identifier vt_….
	ID string `json:"id" validate:"required"`
	// Time formatted as an RFC 3339 string.
	Created time.Time `json:"created" validate:"required"`
	// Arbitrary key/value pairs for correlation (e.g., source, merchant_id, idempotency_key).
	Metadata map[string]string `json:"metadata" validate:"omitempty"`
}

VaultToken is emitted by PSPs after tokenizing the delegated payment payload.

type WebhookEventType

type WebhookEventType string

WebhookEventType enumerates the supported checkout webhook events.

const (
	// WebhookEventTypeOrderCreated is emitted when an order is first created.
	WebhookEventTypeOrderCreated WebhookEventType = "order_create"
	// WebhookEventTypeOrderUpdated is emitted when an existing order changes.
	WebhookEventTypeOrderUpdated WebhookEventType = "order_update"
)

type WebhookOption

type WebhookOption func(*webhookSender)

func WebhookWithClient

func WebhookWithClient(client *http.Client) WebhookOption

WebhookWithClient allows overriding the HTTP client used for delivering webhook events.

type WebhookSender

type WebhookSender interface {
	// Send sends webhook to the configured webhook endpoint.
	Send(context.Context, EventData) error
}

WebhookSender is an interface of a webhook delivery implementation.

type WeightInfo

type WeightInfo struct {
	Value float64    `json:"value"`
	Unit  WeightUnit `json:"unit"`
}

WeightInfo defines model for WeightInfo.

type WeightUnit

type WeightUnit string

WeightUnit defines model for WeightInfo.Unit.

const (
	WeightUnitGrams     WeightUnit = "g"
	WeightUnitKilograms WeightUnit = "kg"
	WeightUnitOunces    WeightUnit = "oz"
	WeightUnitPounds    WeightUnit = "lb"
)

Defines values for WeightUnit.

Directories

Path Synopsis
examples
checkout command
feed command
Package feed provides types and helpers for exporting [ACP product feeds].
Package feed provides types and helpers for exporting [ACP product feeds].

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL