diff --git a/toolkit/components/payments/content/paymentDialogWrapper.js b/toolkit/components/payments/content/paymentDialogWrapper.js
index c007ac83cc14..97ffb7793cb9 100644
--- a/toolkit/components/payments/content/paymentDialogWrapper.js
+++ b/toolkit/components/payments/content/paymentDialogWrapper.js
@@ -108,6 +108,9 @@ var paymentDialogWrapper = {
if (!requestId || typeof(requestId) != "string") {
throw new Error("Invalid PaymentRequest ID");
}
+
+ // The Request object returned by the Payment Service is live and
+ // will automatically get updated if event.updateWith is used.
this.request = paymentSrv.getPaymentRequestById(requestId);
if (!this.request) {
@@ -250,6 +253,19 @@ var paymentDialogWrapper = {
});
},
+ updateRequest() {
+ // There is no need to update this.request since the object is live
+ // and will automatically get updated if event.updateWith is used.
+ let requestSerialized = this._serializeRequest(this.request);
+
+ this.mm.sendAsyncMessage("paymentChromeToContent", {
+ messageType: "updateState",
+ data: {
+ request: requestSerialized,
+ },
+ });
+ },
+
/**
* Recursively convert and filter input to the subset of data types supported by JSON
*
diff --git a/toolkit/components/payments/paymentUIService.js b/toolkit/components/payments/paymentUIService.js
index ae64cbc92589..e9d57d1f99cb 100644
--- a/toolkit/components/payments/paymentUIService.js
+++ b/toolkit/components/payments/paymentUIService.js
@@ -80,7 +80,13 @@ PaymentUIService.prototype = {
},
updatePayment(requestId) {
+ let dialog = this.findDialog(requestId);
this.log.debug("updatePayment:", requestId);
+ if (!dialog) {
+ this.log.error("updatePayment: no dialog found");
+ return;
+ }
+ dialog.paymentDialogWrapper.updateRequest();
},
// other helper methods
@@ -90,17 +96,25 @@ PaymentUIService.prototype = {
* @returns {boolean} whether the specified dialog was closed.
*/
closeDialog(requestId) {
+ let win = this.findDialog(requestId);
+ if (!win) {
+ return false;
+ }
+ this.log.debug(`closing: ${win.name}`);
+ win.close();
+ return true;
+ },
+
+ findDialog(requestId) {
let enu = Services.wm.getEnumerator(null);
let win;
while ((win = enu.getNext())) {
if (win.name == `${this.REQUEST_ID_PREFIX}${requestId}`) {
- this.log.debug(`closing: ${win.name}`);
- win.close();
- return true;
+ return win;
}
}
- return false;
+ return null;
},
requestIdForWindow(window) {
diff --git a/toolkit/components/payments/res/containers/payment-dialog.js b/toolkit/components/payments/res/containers/payment-dialog.js
index 5caf5f3005be..2f82ac513ce2 100644
--- a/toolkit/components/payments/res/containers/payment-dialog.js
+++ b/toolkit/components/payments/res/containers/payment-dialog.js
@@ -32,6 +32,7 @@ class PaymentDialog extends PaymentStateSubscriberMixin(HTMLElement) {
this._orderDetailsOverlay = contents.querySelector("#order-details-overlay");
this._shippingRequestedEls = contents.querySelectorAll(".shippingRequested");
+ this._errorText = contents.querySelector("#error-text");
this._disabledOverlay = contents.getElementById("disabled-overlay");
@@ -178,14 +179,16 @@ class PaymentDialog extends PaymentStateSubscriberMixin(HTMLElement) {
render(state) {
let request = state.request;
+ let paymentDetails = request.paymentDetails;
this._hostNameEl.textContent = request.topLevelPrincipal.URI.displayHost;
- let totalItem = request.paymentDetails.totalItem;
+ let totalItem = paymentDetails.totalItem;
let totalAmountEl = this.querySelector("#total > currency-amount");
totalAmountEl.value = totalItem.amount.value;
totalAmountEl.currency = totalItem.amount.currency;
this._orderDetailsOverlay.hidden = !state.orderDetailsShowing;
+ this._errorText.textContent = paymentDetails.error;
for (let element of this._shippingRequestedEls) {
element.hidden = !request.paymentOptions.requestShipping;
}
diff --git a/toolkit/components/payments/res/paymentRequest.xhtml b/toolkit/components/payments/res/paymentRequest.xhtml
index bf2c3fc67e23..07e727384b4d 100644
--- a/toolkit/components/payments/res/paymentRequest.xhtml
+++ b/toolkit/components/payments/res/paymentRequest.xhtml
@@ -71,6 +71,7 @@
+