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

Modify interface to allow client to choose which service to connect to #9

Merged
merged 1 commit into from
May 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions explainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ Sites using the proposed API would still need to be configured to work with each
Usage of the API would begin with a call to `Window.getDigitalGoodsService()`, which returns a promise yielding null if there is no DigitalGoodsService:

```js
const itemService = await getDigitalGoodsService();
if (itemService === null ||
itemService.paymentMethod !== "https://example.com/billing") {
// Not using our preferred item service.
const itemService = await getDigitalGoodsService("https://example.com/billing");
if (itemService === null) {
// Our preferred item service is not available.
// Use a normal web-based payment flow.
return;
}
Expand Down Expand Up @@ -91,16 +90,12 @@ itemService.acknowledge(purchaseToken);

```webidl
partial interface Window {
// Resolves the promise with null if the website is not running in an environment
// where a product service is available.
Promise<DigitalGoodsService?> getDigitalGoodsService();
// Resolves the promise with null if the product service associated with the
// given payment method is unavailable.
Promise<DigitalGoodsService?> getDigitalGoodsService(DOMString paymentMethod);
};

interface DigitalGoodsService {
// The payment method identifier to use for purchases in conjunction with this
// service.
DOMString paymentMethod;

Promise<sequence<ItemDetails>> getDetails(sequence<ItemId> itemIds);

Promise<void> acknowledge(PurchaseToken purchaseToken,
Expand Down