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

Checkout API to Cart API migration #1000

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft

Checkout API to Cart API migration #1000

wants to merge 16 commits into from

Conversation

kdaviduik
Copy link
Contributor

@kdaviduik kdaviduik commented Jan 16, 2025

Public SDK deprecation notice

WHY are these changes introduced?

The main goal of this (final) version of the SDK is to extend the longevity of its .checkout interface by replacing it with an equivalent interface based on the Cart API

WHAT is this pull request doing?

Replaces the Checkout API dependency from all .checkout interface methods such as fetch, addLines, removeLines etc. All existing checkout methods now use Cart API equivalents under the hood.

HOW to test your changes?

  • Check our Slack post

Checklist

  • Added tests
  • [] Added or updated documentation
  • Validated buy-button-js operation with this SDK

@kdaviduik kdaviduik marked this pull request as draft January 16, 2025 01:08
kdaviduik and others added 3 commits January 15, 2025 20:09
Co-authored-by: Juan P. Prieto <[email protected]>
Before these tests weren't actually testing anything useful  -
the API response was mocked, and then the test ensured that the
mock returned the return value we mocked.

Now these tests execute actual storefront API calls, and are
now useful integration tests that we can trust.
kdaviduik and others added 3 commits January 20, 2025 13:18
The goal of this commit is to isolate the non-test, non-doc code changes
to be reviewed.

This commit contains:
- Changes to the GQL operations used in the checkout resource
- Input and payload mapping to match the previous inputs/payloads
as closely as possible

This commit does NOT contain:
- Unit tests
- Integration tests
- Migration guide
- Docs updates

Co-authored-by: Juan P. Prieto <[email protected]>
In cart-payload-mapper-test, these are just unit tests.

All of the other tests make actual SF API calls and verify that the response
returned from the SDK is what we expect. Our goal here is to ensure
that when a given checkout method is called with SDK v3, the response
is the same as what previous versions of the SDK returned (aside from
known/documented discrepancies between the cart/checkout APIs).

In the tests, the "expected" values are all values that we got when
we ran these operations with the previous SDK version. The "actual"
values are what v3 of the SDK returns for the same operation.

Co-authored-by: Juan P. Prieto <[email protected]>
Co-authored-by: Juan P. Prieto <[email protected]>
This property is added on by the GraphQL JS client. `hasPreviousPage`
was coming out as true and `hasNextPage` was coming out as false,
but since we fetch all pages and give them back as a single array,
those values are misleading, so now we're hard-coding them both to
false.
As a sanity check during the development phase, we were throwing
an error if we were aware of a discount code but it wasn't appearing
in the output of our discount mapping. Upon investigating further, we
determined that this is expected behaviour for any discount codes that
are applied but have `applicable: false`. Therefore, we are updating
our sanity check to only throw an error if the discount code IS applied
but somehow didn't get mapped.

These sanity checks that throw errors will be removed before release.
The assertions were slightly off, since the item is $70 rather than $73.5.
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