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

Remove PaymentDetailsUpdate dictionary #8678

Merged
merged 2 commits into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions files/en-us/_redirects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8233,6 +8233,9 @@
/en-US/docs/Web/API/Path2D.addPath /en-US/docs/Web/API/Path2D/addPath
/en-US/docs/Web/API/PaymentAddress/PaymentAddress.country /en-US/docs/Web/API/PaymentAddress/country
/en-US/docs/Web/API/PaymentAddress/regionCode /en-US/docs/Web/API/PaymentAddress
/en-US/docs/Web/API/PaymentDetailsUpdate /en-US/docs/Web/API/PaymentRequestUpdateEvent/updateWith
/en-US/docs/Web/API/PaymentDetailsUpdate/error /en-US/docs/Web/API/PaymentRequestUpdateEvent/updateWith
/en-US/docs/Web/API/PaymentDetailsUpdate/shippingAddressErrors /en-US/docs/Web/API/PaymentRequestUpdateEvent/updateWith
/en-US/docs/Web/API/PaymentRequest/PaymentRequest.onmerchantvalidation /en-US/docs/Web/API/PaymentRequest/onmerchantvalidation
/en-US/docs/Web/API/PaymentRequest/shippingaddresschange /en-US/docs/Web/API/PaymentRequest/shippingaddresschange_event
/en-US/docs/Web/API/PaymentRequestEvent/topLevelOrigin /en-US/docs/Web/API/PaymentRequestEvent/topOrigin
Expand Down
19 changes: 0 additions & 19 deletions files/en-us/_wikihistory.json
Original file line number Diff line number Diff line change
Expand Up @@ -66979,25 +66979,6 @@
"Sheppy"
]
},
"Web/API/PaymentDetailsUpdate": {
"modified": "2020-10-15T22:05:59.557Z",
"contributors": [
"sideshowbarker",
"Sheppy"
]
},
"Web/API/PaymentDetailsUpdate/error": {
"modified": "2020-10-15T22:11:38.526Z",
"contributors": [
"Sheppy"
]
},
"Web/API/PaymentDetailsUpdate/shippingAddressErrors": {
"modified": "2020-10-15T22:08:58.821Z",
"contributors": [
"Sheppy"
]
},
"Web/API/PaymentItem": {
"modified": "2020-10-15T22:12:04.568Z",
"contributors": [
Expand Down
6 changes: 3 additions & 3 deletions files/en-us/web/api/addresserrors/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<p>The <strong><code>AddressErrors</code></strong> dictionary is used by the <a href="/en-US/docs/Web/API/Payment_Request_API">Payment Request API</a> to report validation errors in a physical address (typically a billing address or a shipping address). Any members which are present indicate that a validation error occurred for the member of the same name in an address described using {{domxref("PaymentAddress")}}.</p>

<p><code>AddressErrors</code> is the type of the object returned by {{domxref("PaymentDetailsUpdate.shippingAddressErrors", "shippingAddressErrors")}} in the {{domxref("PaymentDetailsUpdate")}} passed into {{domxref("PaymentRequestUpdateEvent.updateWith()")}} by the {{event("shippingaddresschange")}} event handler if a change to the address resulted in a validation error occurring.</p>
<p><code>AddressErrors</code> is the type of the object returned by <code>shippingAddressErrors</code> in the object passed into {{domxref("PaymentRequestUpdateEvent.updateWith()")}} by the {{event("shippingaddresschange")}} event handler if a change to the address resulted in a validation error occurring.</p>

<p>See the {{anch("Examples", "examples below")}} to see how this works.</p>

Expand Down Expand Up @@ -102,7 +102,7 @@ <h4 id="JavaScript">JavaScript</h4>

<h5 id="Payment_Request_data">Payment Request data</h5>

<p>First, we declare the variables <code>supportedHandlers</code>, which is compatible with {{domxref("PaymentMethodData")}}, and <code>defaultPaymentDetails</code>, which is a {{domxref("PaymentDetailsUpdate")}} object.</p>
<p>First, we declare the variables <code>supportedHandlers</code>, which is compatible with {{domxref("PaymentMethodData")}}, and <code>defaultPaymentDetails</code>, which is an object containing the properties described in {{domxref("PaymentRequestUpdateEvent.updateWith")}}.</p>

<pre class="brush: js">let supportedHandlers = [
{
Expand Down Expand Up @@ -199,7 +199,7 @@ <h5 id="Handling_address_changes">Handling address changes</h5>

<p>That's done by removing all shipping options currently set on the request, then set up an object named <code>shippingAddressErrors</code> which contains a <code>country</code> property which is an error message describing why the stated country isn't being permitted as a value.</p>

<p>Then a {{domxref("PaymentDetailsUpdate")}} object is created with its {{domxref("PaymentDetailsUpdate.error", "error")}} set to a generic message about address errors and with the reset of the object's values taken from <code>shippingAddressErrors</code>, and, using "<code>...defaultPaymentDetails</code>" as the final entry in the object, the remeainder of the properties' values are taken from <code>defaultPaymentDetails</code>.</p>
<p>Then an object is created with its <code>error</code> set to a generic message about address errors and with the reset of the object's values taken from <code>shippingAddressErrors</code>, and, using "<code>...defaultPaymentDetails</code>" as the final entry in the object, the remeainder of the properties' values are taken from <code>defaultPaymentDetails</code>.</p>

<p>The final step is to call the event's {{domxref("PaymentRequestUpdateEvent.updateWith", "updateWith()")}} method, passing along the <code>updateDetails</code> object. This lets the Payment Request API know to present the specified error or errors but to allow the user to keep trying to edit the address.</p>

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/payment_request_api/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ <h2 id="Dictionaries">Dictionaries</h2>
<dd>A dictionary containing strings providing descriptive explanations of any errors in any {{domxref("PaymentAddress")}} entries which have errors.</dd>
<dt>{{domxref("PayerErrors")}}</dt>
<dd>A dictionary containing strings providing descriptive explanations of any errors in related to {{domxref("PaymentResponse")}}'s email, phone, and name attributes.</dd>
<dt>{{domxref("PaymentDetailsUpdate")}}</dt>
<dt>{{domxref("PaymentRequestUpdateEvent.updateWith#parameters", "PaymentDetailsUpdate")}}</dt>
<dd>An object describing changes that need to be made to the payment details in the event that the server needs to update information following the instantiation of the payment interface but before the user begins to interact with it.</dd>
</dl>

Expand Down
5 changes: 2 additions & 3 deletions files/en-us/web/api/paymentaddress/country/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ <h2 id="Usage_notes">Usage notes</h2>
<p>If the payment handler validates the address and determines that the value of
<code>country</code> is invalid, a call to
{{domxref("PaymentRequestUpdateEvent.updateWith()")}} will be made with a
<code>details</code> object containing a
{{domxref("PaymentDetailsUpdate.shippingAddressErrors", "shippingAddressErrors")}}
<code>details</code> object containing a <code>shippingAddressErrors</code>
field. That field contains an {{domxref("AddressErrors")}}-compliant object whose
{{domxref("AddressErrors.country", "country")}} property is a string indicating the
validation error that occurred and, if possible, suggests how to fix it.</p>
Expand All @@ -58,7 +57,7 @@ <h2 id="See_also">See also</h2>
<li><a
href="/en-US/docs/Web/API/Payment_Request_API/Using_the_Payment_Request_API">Using
the Payment Request API</a></li>
<li>{{domxref("PaymentDetailsUpdate.shippingAddressErrors")}}</li>
<li>{{domxref("PaymentRequestUpdateEvent.updateWith")}}</li>
<li>{{domxref("AddressErrors.country")}}</li>
</ul>
</div>
51 changes: 0 additions & 51 deletions files/en-us/web/api/paymentdetailsupdate/error/index.html

This file was deleted.

45 changes: 0 additions & 45 deletions files/en-us/web/api/paymentdetailsupdate/index.html

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h2 id="Examples">Examples</h2>

<p>Let's take a look at an example. This code creates a new {{domxref("PaymentRequest")}}, adds a handler for the <code>paymentmethodchange</code> event by calling the request's {{domxref("EventTarget.addEventListener", "addEventListener()")}}, then calls {{domxref("PaymentRequest.show", "show()")}} to present the payment interface to the user.</p>

<p>The code assumes the existence of a method <code>detailsForShipping()</code>, which returns a {{domxref("PaymentDetailsUpdate")}} object containing the shipping options for the <code>ground</code> shipping method, in the form found in the {{domxref("PaymentShippingOption")}} dictionary. By doing so, the payment form defaults to the ground shipping method.</p>
<p>The code assumes the existence of a method <code>detailsForShipping()</code>, which returns an object containing the shipping options for the <code>ground</code> shipping method, in the form found in the {{domxref("PaymentShippingOption")}} dictionary. By doing so, the payment form defaults to the ground shipping method.</p>

<pre class="brush: js">const options = {
requestShipping: true
Expand Down Expand Up @@ -72,7 +72,7 @@ <h2 id="Examples">Examples</h2>
}, false);
</pre>

<p>This begins by looking at the event's {{domxref("PaymentMethodChangeEvent.methodName", "methodName")}} property; if that indicates that the user is trying to use Apple Pay, we pass the {{domxref("PaymentMethodChangeEvent.methodDetails", "methodDetails")}} into a function called <code>calculateServiceFee()</code>, which we might create to take the information about the transaction, such as the underlying credit card being used to service the Apple Pay request, and compute and return an {{domxref("PaymentDetailsUpdate")}} object that specifies changes to be applied to the {{domxref("PaymentRequest")}} in order to add any service fees that the payment method might require.</p>
<p>This begins by looking at the event's {{domxref("PaymentMethodChangeEvent.methodName", "methodName")}} property; if that indicates that the user is trying to use Apple Pay, we pass the {{domxref("PaymentMethodChangeEvent.methodDetails", "methodDetails")}} into a function called <code>calculateServiceFee()</code>, which we might create to take the information about the transaction, such as the underlying credit card being used to service the Apple Pay request, and compute and return an object that specifies changes to be applied to the {{domxref("PaymentRequest")}} in order to add any service fees that the payment method might require.</p>

<p>Before the event handler returns, it calls the event's {{domxref("PaymentMethodChangeEvent.updateWith()")}} method to integrate the changes into the request.</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ <h2 id="Example">Example</h2>
const checkAddress = theAddress =&gt; {
let detailsUpdate = {};

// Check the address, return a PaymentDetailsUpdate object
// with any changes or errors.
// Check the address, return an object with any changes or errors.

return detailsUpdate;
};
Expand Down
20 changes: 17 additions & 3 deletions files/en-us/web/api/paymentrequest/show/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,22 @@ <h3 id="Parameters">Parameters</h3>
<dd>An optional {{jsxref("Promise")}} that you can provide if your architecture requires
that the payment request's details need to be updated between instantiating the
payment interface and the user beginning to interact with it. The promise should
resolve with a {{domxref("PaymentDetailsUpdate")}} object containing the updated
information.</dd>
resolve with an object containing the updated information:
<dl>
<dt><code>displayItems</code> {{optional_inline}}</dt>
<dd>An array of {{domxref("PaymentItem")}} objects, each describing one line item for the payment request. These represent the line items on a receipt or invoice.</dd>
<dt><code>error</code> {{optional_inline}}{{deprecated_inline}}</dt>
<dd>A {{domxref("DOMString")}} specifying an error message to present to the user<em>.</em> When calling {{domxref("PaymentRequestUpdateEvent.updateWith", "updateWith()")}}, including <code>error</code> in the updated data causes the {{Glossary("user agent")}} to display the text as a general error message. For address field specific errors, use <code>shippingAddressErrors</code>.</dd>
<dt><code>modifiers</code> {{optional_inline}}</dt>
<dd>An array of {{domxref("PaymentDetailsModifier")}} objects, each describing a modifier for particular payment method identifiers. For example, you can use one to adjust the total payment amount based on the selected payment method ("5% cash discount!").</dd>
<dt><code>shippingAddressErrors</code> {{optional_inline}}{{deprecated_inline}}</dt>
<dd>An {{domxref("AddressErrors")}} object which includes an error message for each property of the shipping address that could not be validated.</dd>
<dt><code>shippingOptions</code> {{optional_inline}}</dt>
<dd>An array of {{domxref("PaymentShippingOption")}} objects, each describing one available shipping option from which the user may choose.</dd>
<dt><code>total</code> {{optional_inline}}</dt>
<dd>A {{domxref("PaymentItem")}} providing an updated total for the payment. Make sure this equals the sum of all of the items in <code>displayItems</code>. <em>This is not calculated automatically</em>. You must update this value yourself anytime the total amount due changes. This lets you have flexibility for how to handle things like tax, discounts, and other adjustments to the total price charged.</dd>
</dl>
</dd>
</dl>

<h3 id="Return_value">Return value</h3>
Expand Down Expand Up @@ -135,7 +149,7 @@ <h3 id="asyncawait_syntax">async/await syntax</h3>

<p>In this code, the methods <code>checkAddress()</code> and <code>checkShipping()</code>,
respectively, check the shipping address and the shipping option changes and supply in
response either a {{domxref("PaymentDetailsUpdate")}} object or a promise to return one;
response either an object or a promise to return one;
this object contains the fields in the {{domxref("PaymentResponse")}} which have been or
need to be changed.</p>

Expand Down
Loading