From 3aa0fcf464bc9df84599e4bf6f1fc83805e67600 Mon Sep 17 00:00:00 2001 From: Tim Down <158919+timdown@users.noreply.github.com> Date: Mon, 24 Jul 2023 11:21:44 +0100 Subject: [PATCH] Merge pull request #13934 from overleaf/tm-block-subscriptions-restricted-countries Block web sales to restricted countries GitOrigin-RevId: 47c0ac1d5dc387369bbadb67f5822d7fc6637d98 --- .../Subscription/SubscriptionController.js | 7 +++++++ .../subscriptions/restricted-country.pug | 11 ++++++++++ .../features/subscription/data/countries.ts | 12 +++++------ services/web/locales/en.json | 1 + .../SubscriptionControllerTests.js | 21 +++++++++++++++++++ 5 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 services/web/app/views/subscriptions/restricted-country.pug diff --git a/services/web/app/src/Features/Subscription/SubscriptionController.js b/services/web/app/src/Features/Subscription/SubscriptionController.js index 644c0b1fb8..c5e013397a 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionController.js +++ b/services/web/app/src/Features/Subscription/SubscriptionController.js @@ -213,6 +213,13 @@ async function paymentPage(req, res) { currency = recommendedCurrency } + // Block web sales to restricted countries + if (['CU', 'IR', 'KP', 'RU', 'SY', 'VE'].includes(countryCode)) { + return res.render('subscriptions/restricted-country', { + title: 'restricted', + }) + } + res.render('subscriptions/new-react', { title: 'subscribe', currency, diff --git a/services/web/app/views/subscriptions/restricted-country.pug b/services/web/app/views/subscriptions/restricted-country.pug new file mode 100644 index 0000000000..70bdac23cc --- /dev/null +++ b/services/web/app/views/subscriptions/restricted-country.pug @@ -0,0 +1,11 @@ +extends ../layout-marketing + +block content + main.content.content-alt#main-content + .container + .error-container + .error-details + p.error-status #{translate("restricted")} + p.error-description !{translate("sorry_detected_sales_restricted_region", {link: "/contact"})} + p.error-actions + a.error-btn(href="/") #{translate("home")} diff --git a/services/web/frontend/js/features/subscription/data/countries.ts b/services/web/frontend/js/features/subscription/data/countries.ts index ef77c0c6d9..e49064e81d 100644 --- a/services/web/frontend/js/features/subscription/data/countries.ts +++ b/services/web/frontend/js/features/subscription/data/countries.ts @@ -64,7 +64,7 @@ const countries = [ { code: 'CR', name: 'Costa Rica' }, { code: 'CI', name: 'Côte d’Ivoire' }, { code: 'HR', name: 'Croatia' }, - { code: 'CU', name: 'Cuba' }, + // { code: 'CU', name: 'Cuba' }, // blocked { code: 'CY', name: 'Cyprus' }, { code: 'CZ', name: 'Czech Republic' }, { code: 'DK', name: 'Denmark' }, @@ -115,7 +115,7 @@ const countries = [ { code: 'IS', name: 'Iceland' }, { code: 'IN', name: 'India' }, { code: 'ID', name: 'Indonesia' }, - { code: 'IR', name: 'Iran' }, + // { code: 'IR', name: 'Iran' }, // blocked { code: 'IQ', name: 'Iraq' }, { code: 'IE', name: 'Ireland' }, { code: 'IM', name: 'Isle of Man' }, @@ -180,7 +180,7 @@ const countries = [ { code: 'NG', name: 'Nigeria' }, { code: 'NU', name: 'Niue' }, { code: 'NF', name: 'Norfolk Island' }, - { code: 'KP', name: 'North Korea' }, + // { code: 'KP', name: 'North Korea' }, // blocked { code: 'VD', name: 'North Vietnam' }, { code: 'MP', name: 'Northern Mariana Islands' }, { code: 'NO', name: 'Norway' }, @@ -204,7 +204,7 @@ const countries = [ { code: 'QA', name: 'Qatar' }, { code: 'RE', name: 'Réunion' }, { code: 'RO', name: 'Romania' }, - { code: 'RU', name: 'Russia' }, + // { code: 'RU', name: 'Russia' }, // blocked { code: 'RW', name: 'Rwanda' }, { code: 'BL', name: 'Saint Barthélemy' }, { code: 'SH', name: 'Saint Helena' }, @@ -238,7 +238,7 @@ const countries = [ { code: 'SZ', name: 'Swaziland' }, { code: 'SE', name: 'Sweden' }, { code: 'CH', name: 'Switzerland' }, - { code: 'SY', name: 'Syria' }, + // { code: 'SY', name: 'Syria' }, // blocked { code: 'TW', name: 'Taiwan' }, { code: 'TJ', name: 'Tajikistan' }, { code: 'TZ', name: 'Tanzania' }, @@ -266,7 +266,7 @@ const countries = [ { code: 'UZ', name: 'Uzbekistan' }, { code: 'VU', name: 'Vanuatu' }, { code: 'VA', name: 'Vatican City' }, - { code: 'VE', name: 'Venezuela' }, + // { code: 'VE', name: 'Venezuela' }, // blocked { code: 'VN', name: 'Vietnam' }, { code: 'WK', name: 'Wake Island' }, { code: 'WF', name: 'Wallis and Futuna' }, diff --git a/services/web/locales/en.json b/services/web/locales/en.json index 3773515e07..99c9b8046c 100644 --- a/services/web/locales/en.json +++ b/services/web/locales/en.json @@ -1544,6 +1544,7 @@ "something_went_wrong_rendering_pdf_expected": "There was an issue displaying this PDF. <0>Please recompile", "something_went_wrong_server": "Something went wrong. Please try again.", "somthing_went_wrong_compiling": "Sorry, something went wrong and your project could not be compiled. Please try again in a few moments.", + "sorry_detected_sales_restricted_region": "Sorry, we’ve detected that you are in a region from which we cannot presently accept payments. If you think you’ve received this message in error, please contact us with details of your location, and we will look into this for you. We apologize for the inconvenience.", "sorry_something_went_wrong_opening_the_document_please_try_again": "Sorry, an unexpected error occurred when trying to open this content on Overleaf. Please try again.", "sorry_your_token_expired": "Sorry, your token expired", "sort_by": "Sort by", diff --git a/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js b/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js index 88db5404b9..27c8d259d1 100644 --- a/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js +++ b/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js @@ -393,6 +393,27 @@ describe('SubscriptionController', function () { this.SubscriptionController.paymentPage(this.req, this.res) }) }) + + describe('with a user from a restricted country', function () { + beforeEach(function () { + this.LimitationsManager.promises.userHasV1OrV2Subscription.resolves( + false + ) + this.PlansLocator.findLocalPlanInSettings.returns({}) + this.GeoIpLookup.promises.getCurrencyCode.resolves({ + currencyCode: this.stubbedCurrencyCode, + countryCode: 'KP', + }) + }) + + it('should render the restricted country page', function (done) { + this.res.render = (page, opts) => { + page.should.equal('subscriptions/restricted-country') + done() + } + this.SubscriptionController.paymentPage(this.req, this.res, done) + }) + }) }) describe('successfulSubscription', function () {