Re: [w3c/payment-request] Need short example of serializing response (#576)

The above beautifully distills down to:

```JS
async function doPaymentRequest() {
  const payResponse = await new PaymentRequest(methods, details).show();
  let result = "unknown";
  try {
    const httpResponse = await fetch("/buy", {
      method: "POST",
      headers: new Headers({ "Content-Type": "application/json" }),
      body: payResponse.toJSON(),
    });
    result = httpResponse.ok ? "success" : "fail";
  } catch (err) {
    console.error(err);
  } finally {
    payResponse.complete(result);
  }
}
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/payment-request/issues/576#issuecomment-322369608

Received on Tuesday, 15 August 2017 03:42:17 UTC