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

[Shop API] Separate Checkout API from the state machine states #11842

Open
dbalabka opened this issue Sep 14, 2020 · 3 comments
Open

[Shop API] Separate Checkout API from the state machine states #11842

dbalabka opened this issue Sep 14, 2020 · 3 comments

Comments

@dbalabka
Copy link
Contributor

dbalabka commented Sep 14, 2020

TL;DR;

I would like to propose to separate Checkout API from the state machine states:
https://docs.sylius.com/en/1.7/api/checkouts.html
I found that it might be useful to have a single endpoint to create an order or/and fill order partially.

Problem

The motivation to create such endpoints is to separate View and Backend logic. Such separation might be useful if we would like to AB test of possible flows of the checkout process (e.g., single-step checkout versus multiple steps checkout). Unfortunately, in the current implementation, it is not possible due to our backend logic strictly describes checkout steps by the state machine configured states.

Solution

Order API

In RESTful terms there should be two endpoints:

  1. with POST method to create order
  2. and PUT/PATCH method to modify the order.

Order finalization might be done during payment creation for a particular order. For example, the order will be marked as paid if payment has been created.

Currently, there no POST and PUT/PATCH methods for:

  1. https://docs.sylius.com/en/1.7/api/payments.html
  2. https://docs.sylius.com/en/1.7/api/orders.html

——
UPDATE

Eligible Shipping/Payment API

There should be another endpoint which returns a list of eligible shipping/payment methods based on partially filled order. If there not enough data then error (e.g., 400) should be returned.
Probably, there might be two options: when we provide all required information with request or take information from order otherwise.

@kayue
Copy link
Contributor

kayue commented Sep 14, 2020

What is your suggestion on retrieving eligible shipping method / payment method when we only use 1 API to complete checkout?

By this way your idea is what I implemented for my store.

@dbalabka
Copy link
Contributor Author

@kayue good catch. There should be another endpoint which returns a list of eligible shipping/payment methods based on partially filled order. If there not enough data then error (e.g., 400) should be returned.
Probably, there might be two options: when we provide all required information with request or take information from order otherwise.

@stale
Copy link

stale bot commented Dec 25, 2020

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in a week if no further activity occurs. Thank you for your contributions.

@stale stale bot added Stale Issues and PRs with no recent activity, about to be closed soon. and removed Stale Issues and PRs with no recent activity, about to be closed soon. labels Dec 25, 2020
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

No branches or pull requests

2 participants