Skip to content

Commit 8534b85

Browse files
committed
restore store's contract-404 handling for custom billing, keeping the page's own error texts
1 parent 4497467 commit 8534b85

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

assets/js/hubsubscription.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,15 @@ class HubSubscription {
269269
this.onLoadCustomBillingSucceeded(data);
270270
continueHandler();
271271
}).fail(xhr => {
272-
this.onLoadCustomBillingFailed('Loading custom billing options failed.');
272+
this.onLoadCustomBillingFailed(xhr.status, 'Loading custom billing options failed.');
273+
// store's documented answer for "this hub has no custom billing" is a 404 with a JSON error body
274+
if (xhr.status == 404 && xhr.responseJSON?.status == 'error') {
275+
continueHandler();
276+
}
273277
});
274278
}
275279

276280
onLoadCustomBillingSucceeded(data) {
277-
// custom_billing is null when the hub has no custom billing
278281
this._subscriptionData.customBilling = data.custom_billing || null;
279282
if (this._subscriptionData.customBilling) {
280283
this._subscriptionData.quantity = this._subscriptionData.customBilling.quantity || this._subscriptionData.quantity;
@@ -284,8 +287,13 @@ class HubSubscription {
284287
this._subscriptionData.inProgress = false;
285288
}
286289

287-
onLoadCustomBillingFailed(error) {
288-
this._subscriptionData.errorMessage = error;
290+
onLoadCustomBillingFailed(status, error) {
291+
if (status == 404) {
292+
this._subscriptionData.customBilling = null;
293+
this._subscriptionData.errorMessage = '';
294+
} else {
295+
this._subscriptionData.errorMessage = error;
296+
}
289297
this._subscriptionData.inProgress = false;
290298
}
291299

0 commit comments

Comments
 (0)