mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #4292 from overleaf/tm-handle-recurly-pricing-errors
Handle Recurly pricing API errors and add coupon code error display GitOrigin-RevId: b86a42a059984a7efa596db85bbcedb93c0e7376
This commit is contained in:
parent
4b9aa97ea1
commit
41471ec60f
2 changed files with 44 additions and 2 deletions
|
@ -98,6 +98,9 @@ block content
|
|||
.alert.alert-warning.small(ng-show="genericError")
|
||||
strong {{genericError}}
|
||||
|
||||
.alert.alert-warning.small(ng-show="couponError")
|
||||
strong {{couponError}}
|
||||
|
||||
div(ng-show="paymentMethod.value === 'credit_card'")
|
||||
.row
|
||||
.col-xs-6
|
||||
|
|
|
@ -119,7 +119,16 @@ export default App.controller(
|
|||
) {
|
||||
$scope.currencyCode = 'USD'
|
||||
setupPricing()
|
||||
} else if (err.name === 'api-error' && err.code === 'not-found') {
|
||||
// not-found here should refer to the coupon code, plan_code should be valid
|
||||
$scope.$applyAsync(() => {
|
||||
$scope.couponError = 'Coupon code is not valid for selected plan'
|
||||
})
|
||||
} else {
|
||||
// Bail out on other errors, form state will not be correct
|
||||
$scope.$applyAsync(() => {
|
||||
$scope.recurlyLoadError = true
|
||||
})
|
||||
throw err
|
||||
}
|
||||
})
|
||||
|
@ -175,7 +184,25 @@ export default App.controller(
|
|||
$scope.$apply()
|
||||
})
|
||||
|
||||
$scope.applyCoupon = () => pricing.coupon($scope.data.coupon).done()
|
||||
$scope.applyCoupon = () => {
|
||||
$scope.couponError = ''
|
||||
pricing
|
||||
.coupon($scope.data.coupon)
|
||||
.catch(err => {
|
||||
if (err.name === 'api-error' && err.code === 'not-found') {
|
||||
$scope.$applyAsync(() => {
|
||||
$scope.couponError = 'Coupon code is not valid for selected plan'
|
||||
})
|
||||
} else {
|
||||
$scope.$applyAsync(() => {
|
||||
$scope.couponError =
|
||||
'An error occured when verifying the coupon code'
|
||||
})
|
||||
throw err
|
||||
}
|
||||
})
|
||||
.done()
|
||||
}
|
||||
|
||||
$scope.applyVatNumber = () =>
|
||||
pricing
|
||||
|
@ -184,7 +211,19 @@ export default App.controller(
|
|||
|
||||
$scope.changeCurrency = function (newCurrency) {
|
||||
$scope.currencyCode = newCurrency
|
||||
return pricing.currency(newCurrency).done()
|
||||
return pricing
|
||||
.currency(newCurrency)
|
||||
.catch(function (err) {
|
||||
if (
|
||||
$scope.currencyCode !== 'USD' &&
|
||||
err.name === 'invalid-currency'
|
||||
) {
|
||||
$scope.changeCurrency('USD')
|
||||
} else {
|
||||
throw err
|
||||
}
|
||||
})
|
||||
.done()
|
||||
}
|
||||
|
||||
$scope.inputHasError = function (formItem) {
|
||||
|
|
Loading…
Reference in a new issue