Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for all checkout creation options #18

Merged

Conversation

PaulSonOfLars
Copy link
Contributor

This implements the changes mentioned in #16.

Since this required drastically changing the layout of CheckoutCreateParams and breaking backwards compatibility, I opted to commit to those breaking changes, and update the signature of the checkout.Create call to reflect the mandatory fields involved.

I notice that there are some other types which could use the same changes; namely discounts, subscriptions, and webhooks. Happy to make those changes too if this PR makes it in.

checkout.go Outdated
StoreID string `json:"store_id"`
VariantID string `json:"variant_id"`
// Quantities represents variant quantities when creating checkout
type Quantities struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the same structure of variable names so this struct will be

CheckoutCreateDataVariantQuantity instead of Quantities

@AchoArnold
Copy link
Member

Thanks for the PR @PaulSonOfLars

Copy link

codecov bot commented Jan 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (632bedf) 81.32% compared to head (1327a52) 81.18%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #18      +/-   ##
==========================================
- Coverage   81.32%   81.18%   -0.15%     
==========================================
  Files          22       22              
  Lines         573      558      -15     
==========================================
- Hits          466      453      -13     
+ Misses         55       54       -1     
+ Partials       52       51       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

checkoutData["discount_code"] = params.DiscountCode
}

func (service *CheckoutsService) Create(ctx context.Context, variantId int, storeId int, attributes *CheckoutCreateAttributes) (*CheckoutApiResponse, *Response, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you used int for variantId and storeId instead of string I like the idea of int but this will make the library inconsistent, if only one endpoint requires int and the others require string I'll propose either keep as string or refactor all the other endpoints to use int

Another thing is the order of endpoints, usually i use the order of (parent, child, grandchild) so since variant is a property of the storeId it should come after store in the list of parameters.

func (service *CheckoutsService) Create(ctx context.Context, storeID, variantID int, attributes *CheckoutCreateAttributes) (*CheckoutApiResponse, *Response, error) {
}

@PaulSonOfLars
Copy link
Contributor Author

Hi @AchoArnold, thanks for the review! I've gone ahead and made the changes you requested - let me know how those look to you :)
Also - I've been trying out the checkout changes i made locally and they've been working well so far.

@PaulSonOfLars
Copy link
Contributor Author

By the way - I noticed your CI isn't running the E2E test; unsure if thats intentional or not. Thought you might want to know if not!

@AchoArnold
Copy link
Member

Yep @PaulSonOfLars I usually run the e2e tests locally because It uses an my real account on lemonsqueezy I don't want to corrupt it too much with automated tests.

@AchoArnold AchoArnold merged commit a4fd5be into NdoleStudio:main Jan 16, 2024
6 checks passed
@PaulSonOfLars PaulSonOfLars deleted the paul/add-checkout-create-options branch January 16, 2024 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants