- From: Marcos Cáceres <notifications@github.com>
- Date: Fri, 25 Aug 2017 20:04:19 -0700
- To: w3c/payment-request <payment-request@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/payment-request/pull/591/c325078077@github.com>
@zkoch, tldr: 1. Don't block the payment sheet if the developer doesn't call `.updateWith()`. 1. Don't allow developers to keep recycling the event (e.g., keep a reference to a shipping change event, and then use it to update the the payment sheet when an option change event happens - see code below). === Note to self, add this test: ``` var methods = [{ supportedMethods: ["basic-card"] }]; var details = { total: { label: "", amount: { currency: "USD", value: "1" } }, }; var shippingOptions = [ { id: "standard", label: "🚛 Ground Shipping (2 days)", amount: { currency: "USD", value: "5.00" }, selected: true, }, { id: "drone", label: "🚀 Drone Express (2 hours)", amount: { currency: "USD", value: "25.00" }, }, ]; details.shippingOptions = shippingOptions; var r = new PaymentRequest(methods, details, { requestShipping: true }); r.addEventListener( "shippingaddresschange", e => { ev = e; ev.updateWith(details); var listener = ev2 => { var newDetails = { ...details }; newDetails.total.label = "FAIL" + Math.random(); ev.updateWith(newDetails); }; r.addEventListener("shippingoptionchange", listener); r.addEventListener("shippingaddresschange", listener); }, { once: true } ); r.show(); ``` -- 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/pull/591#issuecomment-325078077
Received on Saturday, 26 August 2017 03:05:04 UTC