- From: Danyao Wang <notifications@github.com>
- Date: Thu, 05 Sep 2019 08:28:29 -0700
- To: w3c/payment-request <payment-request@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/payment-request/issues/879/528424637@github.com>
I agree with @adrianhopebailie that Payment Request API should not be directly involved in translating SKUs to prices. SKU is a payment-method specific concept. I think we should keep Payment Request API generic. I like the `getTotalFromSku()` direction. But here's a missing piece: the merchant still needs to figure out how to implement `getTotalFromSku()`, which involves a cross-origin communication to the payment app. Given that Payment Request API is meant to establish a communication pipe between the merchant and the payment app, can we expand it to support this use case? What about something like this: ``` const emptyDetails = {} // make 'total' optional, so it can be omitted here const request = new PaymentRequest([{supportedMethods:'https://play.google.com/store'}], emptyDetails); // New channel for merchant to query selected payment app. This returns a promise that // resolves to a payment-method defined blob. Merchant can turn that into a `PaymentDetails`: let detailsPromise = request.query( 'https://play.google.com/store', {querySkuRequest: { sku: '123456'}} ).then((response) => { return { total: { label: "total", amount: { currency: response.querySkuTotalResponse.currency, value: response.querySkuTotalResponse.amount, }, }, }; }); request.show(detailsPromise); ``` To make this work, Payment Handler API will expose a `QueryEvent`, which is triggered on the payment app's service worker when merchant calls `request.query()`. The obvious concern is that this may be too generic: we're allowing arbitrary exchange of data between merchants and payment apps. On the other hand, a payment app can choose to decline a query from an untrusted merchant, using the merchant validation mechanism. -- 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/879#issuecomment-528424637
Received on Thursday, 5 September 2019 15:28:52 UTC