Bug 1477113 - Dispatch paymentmethodchange event from the front-end. r=MattN

Differential Revision: https://phabricator.services.mozilla.com/D13740
This commit is contained in:
Jared Wein
2018-12-13 18:48:54 +00:00
parent 3153b6c546
commit 31ab1285a6
14 changed files with 231 additions and 77 deletions

View File

@@ -641,6 +641,27 @@ var paymentDialogWrapper = {
}
},
async onChangePaymentMethod({
selectedPaymentCardBillingAddressGUID: billingAddressGUID,
}) {
const methodName = "basic-card";
let methodDetails;
try {
let billingAddress = await this._convertProfileAddressToPaymentAddress(billingAddressGUID);
const basicCardChangeDetails = Cc["@mozilla.org/dom/payments/basiccard-change-details;1"]
.createInstance(Ci.nsIBasicCardChangeDetails);
basicCardChangeDetails.initData(billingAddress);
methodDetails = basicCardChangeDetails.QueryInterface(Ci.nsIMethodChangeDetails);
} catch (ex) {
// TODO (Bug 1498403): Some kind of "credit card storage error" here, perhaps asking user
// to re-enter credit card # from management UI.
Cu.reportError(ex);
return;
}
paymentSrv.changePaymentMethod(this.request.requestId, methodName, methodDetails);
},
async onChangeShippingAddress({shippingAddressGUID}) {
if (shippingAddressGUID) {
// If a shipping address was de-selected e.g. the selected address was deleted, we'll
@@ -751,6 +772,10 @@ var paymentDialogWrapper = {
this.onChangePayerAddress(data);
break;
}
case "changePaymentMethod": {
this.onChangePaymentMethod(data);
break;
}
case "changeShippingAddress": {
this.onChangeShippingAddress(data);
break;