@@ -87,14 +87,58 @@ type CheckoutApiResponse = ApiResponse[CheckoutAttributes, ApiResponseRelationsh
8787// CheckoutsApiResponse is the api response for a list of checkout.
8888type CheckoutsApiResponse = ApiResponseList [CheckoutAttributes , ApiResponseRelationshipsDiscount ]
8989
90- // CheckoutCreateParams are parameters for creating a checkout
91- type CheckoutCreateParams struct {
92- CustomPrice int `json:"custom_price"`
93- EnabledVariants []int `json:"enabled_variants"`
94- ButtonColor string `json:"button_color"`
95- DiscountCode * string `json:"discount_code"`
96- CustomData map [string ]string `json:"custom_data"`
97- ExpiresAt time.Time `json:"expires_at"`
98- StoreID string `json:"store_id"`
99- VariantID string `json:"variant_id"`
90+ // CheckoutCreateDataQuantity represents variant quantities when creating checkout
91+ type CheckoutCreateDataQuantity struct {
92+ VariantId int `json:"variant_id"`
93+ Quantity int `json:"quantity"`
94+ }
95+
96+ // CheckoutCreateData represents the data options for creating a checkout.
97+ type CheckoutCreateData struct {
98+ Email string `json:"email,omitempty"`
99+ Name string `json:"name,omitempty"`
100+ BillingAddressCountry string `json:"billing_address.country,omitempty"`
101+ BillingAddressZip string `json:"billing_address.zip,omitempty"`
102+ TaxNumber string `json:"tax_number,omitempty"`
103+ DiscountCode string `json:"discount_code,omitempty"`
104+ Custom map [string ]any `json:"custom,omitempty"`
105+ VariantQuantities []CheckoutCreateDataQuantity `json:"variant_quantities,omitempty"`
106+ }
107+
108+ // CheckoutCreateOptions represents the checkout options for creating a checkout.
109+ //
110+ // Note: We use pointers for the boolean fields as otherwise, setting them to "false" would omit them, which would
111+ // break some of the boolean checks in the API. See: https://docs.lemonsqueezy.com/api/checkouts#create-a-checkout
112+ type CheckoutCreateOptions struct {
113+ Embed * bool `json:"embed,omitempty"`
114+ Media * bool `json:"media,omitempty"`
115+ Logo * bool `json:"logo,omitempty"`
116+ Desc * bool `json:"desc,omitempty"`
117+ Discount * bool `json:"discount,omitempty"`
118+ Dark * bool `json:"dark,omitempty"`
119+ SubscriptionPreview * bool `json:"subscription_preview,omitempty"`
120+ ButtonColor string `json:"button_color,omitempty"`
121+ }
122+
123+ // CheckoutCreateProductOptions represents product options for creating a checkout.
124+ type CheckoutCreateProductOptions struct {
125+ Name string `json:"name,omitempty"`
126+ Description string `json:"description,omitempty"`
127+ Media []string `json:"media,omitempty"`
128+ RedirectUrl string `json:"redirect_url,omitempty"`
129+ ReceiptButtonText string `json:"receipt_button_text,omitempty"`
130+ ReceiptLinkUrl string `json:"receipt_link_url,omitempty"`
131+ ReceiptThankYouNote string `json:"receipt_thank_you_note,omitempty"`
132+ EnabledVariants []int `json:"enabled_variants,omitempty"`
133+ }
134+
135+ // CheckoutCreateAttributes represents individual parameters for creating a checkout.
136+ type CheckoutCreateAttributes struct {
137+ CustomPrice * int `json:"custom_price,omitempty"`
138+ ProductOptions CheckoutCreateProductOptions `json:"product_options,omitempty"`
139+ CheckoutOptions CheckoutCreateOptions `json:"checkout_options,omitempty"`
140+ CheckoutData CheckoutCreateData `json:"checkout_data,omitempty"`
141+ Preview * bool `json:"preview,omitempty"`
142+ TestMode * bool `json:"test_mode,omitempty"`
143+ ExpiresAt * time.Time `json:"expires_at,omitempty"`
100144}
0 commit comments