Skip to content

Commit

Permalink
fix(payment): catch cleeng invalid coupon for offer
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristiaanScheermeijer committed Apr 10, 2024
1 parent 1011dd2 commit 00e455a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
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

0 comments on commit 00e455a

Please sign in to comment.