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
Test update for w3c/payment-request#419
  • Loading branch information
zcorpan committed Mar 10, 2017
1 parent 16bd452 commit a809a76
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 28 deletions.
23 changes: 23 additions & 0 deletions payment-request/historical.https.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!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"],

].forEach(([member, interf]) => {
test(() => {
assert_false(member in window[interf].prototype);
}, member + ' in ' + interf);
});
</script>
64 changes: 36 additions & 28 deletions payment-request/interfaces.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,56 +12,64 @@
interface EventTarget {};
</script>
<script type=text/plain>
[Constructor(sequence<PaymentMethodData> methodData, PaymentDetails details, optional PaymentOptions options), SecureContext]
[Constructor(sequence<PaymentMethodData> methodData, PaymentDetails 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? paymentRequestId;
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;
sequence<PaymentItem> displayItems;
sequence<PaymentShippingOption> shippingOptions;
sequence<PaymentDetailsModifier> modifiers;
DOMString error;
};

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 +80,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 paymentRequestId;
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<PaymentDetails> detailsPromise);
};

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

0 comments on commit a809a76

Please sign in to comment.