feat(billing): let accounts switch billing currency with a confirmation note
This commit is contained in:
@@ -19,6 +19,7 @@ const state = {
|
||||
isUpdating: false,
|
||||
isCheckoutInProcess: false,
|
||||
isFetchingLimits: false,
|
||||
isSwitchingCurrency: false,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -142,6 +143,20 @@ export const actions = {
|
||||
}
|
||||
},
|
||||
|
||||
switchBillingCurrency: async ({ commit, dispatch }, { currency }) => {
|
||||
commit(types.default.SET_ACCOUNT_UI_FLAG, { isSwitchingCurrency: true });
|
||||
try {
|
||||
await EnterpriseAccountAPI.switchCurrency(currency);
|
||||
// Refresh the account so custom_attributes.billing_currency and the
|
||||
// subscription details reflect the new currency.
|
||||
await dispatch('get', { silent: true });
|
||||
} catch (error) {
|
||||
throwErrorMessage(error);
|
||||
} finally {
|
||||
commit(types.default.SET_ACCOUNT_UI_FLAG, { isSwitchingCurrency: false });
|
||||
}
|
||||
},
|
||||
|
||||
limits: async ({ commit }) => {
|
||||
commit(types.default.SET_ACCOUNT_UI_FLAG, { isFetchingLimits: true });
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user