Skip to content

Commit

Permalink
Update IDL for Payment Request and add a historical.html
Browse files Browse the repository at this point in the history
  • Loading branch information
zcorpan authored Mar 17, 2017
1 parent cccdbe1 commit ee94762
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 30 deletions.
27 changes: 27 additions & 0 deletions payment-request/historical.https.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!doctype html>
<meta charset=utf-8>
<title>Historical Payment Request APIs</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
[
// https://github.com/w3c/browser-payment-api/pull/419
["paymentRequestID", "PaymentRequest"],
["paymentRequestID", "PaymentResponse"],

// https://github.com/w3c/browser-payment-api/pull/258
["careOf", "PaymentAddress"],

// https://github.com/w3c/browser-payment-api/pull/219
["totalAmount", "PaymentResponse"],

// https://github.com/w3c/browser-payment-api/pull/426
["paymentRequestId", "PaymentRequest"],
["paymentRequestId", "PaymentResponse"],

].forEach(([member, interf]) => {
test(() => {
assert_false(member in window[interf].prototype);
}, member + ' in ' + interf);
});
</script>
74 changes: 44 additions & 30 deletions payment-request/interfaces.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,56 +12,70 @@
interface EventTarget {};
</script>
<script type=text/plain>
[Constructor(sequence<PaymentMethodData> methodData, PaymentDetails details, optional PaymentOptions options), SecureContext]
[Constructor(sequence<PaymentMethodData> methodData, PaymentDetailsInit details, optional PaymentOptions options),
SecureContext]
interface PaymentRequest : EventTarget {
Promise<PaymentResponse> show();
Promise<void> abort();
Promise<boolean> canMakePayment();

readonly attribute PaymentAddress? shippingAddress;
readonly attribute DOMString? shippingOption;
readonly attribute DOMString id;
readonly attribute PaymentAddress? shippingAddress;
readonly attribute DOMString? shippingOption;
readonly attribute PaymentShippingType? shippingType;

// Supports "shippingaddresschange" event
attribute EventHandler onshippingaddresschange;
attribute EventHandler onshippingaddresschange;

// Supports "shippingoptionchange" event
attribute EventHandler onshippingoptionchange;
attribute EventHandler onshippingoptionchange;
};

dictionary PaymentMethodData {
required sequence<DOMString> supportedMethods;
object data;
};

dictionary PaymentCurrencyAmount {
required DOMString currency;
required DOMString value;
DOMString currencySystem = "urn:iso:std:iso:4217";
};

dictionary PaymentDetails {
PaymentItem total;
dictionary PaymentDetailsBase {
sequence<PaymentItem> displayItems;
sequence<PaymentShippingOption> shippingOptions;
sequence<PaymentDetailsModifier> modifiers;
};

dictionary PaymentDetailsInit : PaymentDetailsBase {
DOMString id;
required PaymentItem total;
};
dictionary PaymentDetailsUpdate : PaymentDetailsBase {
DOMString error;
PaymentItem total;
};
dictionary PaymentDetailsModifier {
required sequence<DOMString> supportedMethods;
PaymentItem total;
sequence<PaymentItem> additionalDisplayItems;
object data;
};
enum PaymentShippingType {
"shipping",
"delivery",
"pickup"
};

dictionary PaymentOptions {
boolean requestPayerEmail = false;
boolean requestPayerPhone = false;
boolean requestShipping = false;
boolean requestPayerName = false;
boolean requestPayerEmail = false;
boolean requestPayerPhone = false;
boolean requestShipping = false;
PaymentShippingType shippingType = "shipping";
};

dictionary PaymentItem {
required DOMString label;
required PaymentCurrencyAmount amount;
boolean pending = false;
};

[SecureContext]
interface PaymentAddress {
serializer = {attribute};
readonly attribute DOMString country;
readonly attribute FrozenArray<DOMString> addressLine;
readonly attribute DOMString region;
Expand All @@ -72,39 +86,39 @@
readonly attribute DOMString languageCode;
readonly attribute DOMString organization;
readonly attribute DOMString recipient;
readonly attribute DOMString careOf;
readonly attribute DOMString phone;
};

dictionary PaymentShippingOption {
required DOMString id;
required DOMString label;
required PaymentCurrencyAmount amount;
boolean selected = false;
};

enum PaymentComplete {
"success",
"fail",
""
"success",
"unknown"
};

[SecureContext]
interface PaymentResponse {
serializer = {attribute};

readonly attribute DOMString requestId;
readonly attribute DOMString methodName;
readonly attribute object details;
readonly attribute PaymentAddress? shippingAddress;
readonly attribute DOMString? shippingOption;
readonly attribute DOMString? payerName;
readonly attribute DOMString? payerEmail;
readonly attribute DOMString? payerPhone;

Promise<void> complete(optional PaymentComplete result = "");
Promise<void> complete(optional PaymentComplete result = "unknown");
};

[Constructor(DOMString type, optional PaymentRequestUpdateEventInit eventInitDict)]
[Constructor(DOMString type, optional PaymentRequestUpdateEventInit eventInitDict),
SecureContext]
interface PaymentRequestUpdateEvent : Event {
void updateWith(Promise<PaymentDetails> d);
void updateWith(Promise<PaymentDetailsUpdate> detailsPromise);
};

dictionary PaymentRequestUpdateEventInit : EventInit {
};
</script>
Expand Down

0 comments on commit ee94762

Please sign in to comment.