Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix / catch Cleeng invalid coupon for offer #489

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/common/src/controllers/CheckoutController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ export default class CheckoutController {
useCheckoutStore.getState().setOrder(null);
} else if (error.message === 'Invalid coupon code') {
throw new FormValidationError({ couponCode: [i18next.t('account:checkout.coupon_not_valid')] });
} else if (error.message === 'Invalid coupon code for this offer') {
throw new FormValidationError({ couponCode: [i18next.t('account:checkout.coupon_not_valid_for_offer')] });
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ export default class CleengCheckoutService extends CheckoutService {
if (response.errors[0].includes(`Coupon ${payload.couponCode} not found`)) {
throw new Error('Invalid coupon code');
}

if (response.errors[0].includes(`Coupon ${payload.couponCode} cannot be applied on this offer`)) {
throw new Error('Invalid coupon code for this offer');
}
}

return response;
Expand Down
1 change: 1 addition & 0 deletions platforms/web/public/locales/en/account.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"coupon_applied": "Your coupon code has been applied",
"coupon_discount": "Coupon discount",
"coupon_not_valid": "Coupon code is not valid",
"coupon_not_valid_for_offer": "Coupon code is not valid for this offer",
"credit_card": "Credit card",
"credit_card_name": "Credit card name",
"days_trial_one": "You will be charged tomorrow.",
Expand Down
1 change: 1 addition & 0 deletions platforms/web/public/locales/es/account.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"coupon_applied": "Se ha aplicado tu código de cupón",
"coupon_discount": "Descuento de cupón",
"coupon_not_valid": "El código de cupón no es válido",
"coupon_not_valid_for_offer": "El código de cupón no es válido para esta oferta",
"credit_card": "Tarjeta de crédito",
"credit_card_name": "Nombre de la tarjeta de crédito",
"days_trial_one": "Se te cobrará mañana.",
Expand Down
Loading