From 2972fbb86df49ef7a4f4b9bdfc8b5e3c1c1aee31 Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Mon, 29 May 2017 18:19:34 +1000 Subject: [PATCH] Use first matching PaymentDetailsModifier (closes #309) --- index.html | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/index.html b/index.html index 1394616a..6556af72 100644 --- a/index.html +++ b/index.html @@ -1364,6 +1364,75 @@

modify the PaymentDetailsBase based on a payment method identifier. It contains the following members:

+

+ When presenting a payment request to an end-user, if there are multiple + PaymentDetailsModifier dictionaries in a sequence for the same + payment method identifier, then the user agent MUST use the + first entry to match a payment method identifier as its + modifier. +

+
+

+ In the following example, the developer has included multiple + PaymentDetailsModifier for the same payment method identifier + ("basic-card"). In such a case, the user agent chooses the first + matching modifier. However, the second modifier would be still be + used for by the payment handler for "https://example.com/bobpay". +

+
+          const modifiers = [
+            // This one will be used a for "basic-card" payment, when paying
+            // with a "Example Card" credit card...
+            {
+              supportedMethods: ["basic-card"],
+              total: {
+                currency: "USD",
+                value: "80.00",
+              },
+              additionalDisplayItems: [
+                {
+                  label: "ExampleCard loyalty discount, 20% off!",
+                  amount: {
+                    currency: "USD",
+                    value: "-20.00",
+                  },
+                },
+              ],
+              data: {
+                supportedTypes: ["credit"],
+                supportedNetworks: ["example-card"],
+              },
+            },
+            // In the following, "basic-card" is ignored because only
+            // the first "basic-card" above will match. However,
+            // users of the "example.com/bobpay" payment handler
+            // wishing to pay with an "Example Card" credit card
+            // will receive the 30% discount.
+            {
+              supportedMethods: ["basic-card", "https://example.com/bobpay"],
+              total: {
+                currency: "USD",
+                value: "70.00",
+              },
+              additionalDisplayItems: [
+                {
+                  label: "ExampleCard loyalty discount, 30% off!",
+                  amount: {
+                    currency: "USD",
+                    value: "-30.00",
+                  },
+                },
+              ],
+              data: {
+                supportedTypes: ["credit"],
+                supportedNetworks: ["example-card"],
+              },
+            },
+          ];
+          const options = { modifiers };
+          const request = new PaymentRequest(methods, details, options);
+        
+
supportedMethods