Re: Checkout API spec published

Hi Manu,

I've looked over the Checkout spec. It's a great start. There's one issue
to resolve.

The browser can signal the merchant only by resolving the promise that
calls finishCheckout() in your examples. In the course of a checkout, it's
conceivable that the user selects shipping option 1, then shipping option
2, then shipping option 1 again. Your examples show recalculations of the
line items with a call to checkout.send('paymentItem',
checkoutDetails.items) when this happens. The checkout.send() function is
synchronous. After calling it, the code steps down to the line that
requests the payment. However, the user has not finished selection their
payment options yet.

I can see 2 ways to resolve this issue from the top of my head:

   1. checkoutDetails should have a "finished" boolean field. This is set
   to false when user changes shipping options. It is set to true when the
   user clicks "Buy". The merchant has to check this field.

   if (!checkoutDetails.finished)

   2. Fire events instead of resolving a promise when the user selects a
   shipping option. Usage of your API would change slightly.

   var checkout = new Checkout();
       .onEvent('shippingOptionChange', recalculateLineItems)

   // Returns line items with updated price/tax/etc based on the options
   that the user has selected in checkoutDetails.
   function recalculateLineItems(checkoutDetails) {

   // Requests the payment from the browser.
   function finishCheckout(checkoutDetails) {

I prefer option 2, because it's harder for the merchant to accidently
charge you before you've finished selecting your payment and shipping
options. What do you think?


On Tue, Feb 9, 2016 at 1:02 PM Ian Jacobs <> wrote:

> > On Feb 9, 2016, at 12:34 PM, Dave Longley <>
> wrote:
> >
> > On 02/09/2016 12:11 PM, Ian Jacobs wrote:
> >> [snip]
> >>
> >> My suggestion is that @context be explicit in the data that is passed
> >> to the API (and thus HTTP info not necessary).
> >>
> >> I am hearing you say you have use cases where the @context cannot be
> >> stated explicitly. Can you say more about those use cases?
> [snipping your reply]
> Dave,
> Thanks for the productive phone call today. It helped me understand the
> landscape and I think we ended up on the same page. I look forward to the
> next proposal!
> Ian
> --
> Ian Jacobs <>
> Tel:                       +1 718 260 9447

Received on Wednesday, 10 February 2016 19:40:32 UTC