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

feat: (PON-326) updated localize date for billing #764

Merged
merged 8 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ STRIPE_RESPONSE_URL=null
STRIPE_DEFERRED_INTENT_BETA_FLAG=elements_enable_deferred_intent_beta_1
SUBSCRIPTIONS_BASE_URL=null
ENABLE_B2C_SUBSCRIPTIONS=false
SUBSCRIPTIONS_LEARNER_HELP_CENTER_URL=null
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ STRIPE_RESPONSE_URL=http://localhost:18130/payment/stripe/checkout/
STRIPE_DEFERRED_INTENT_BETA_FLAG=elements_enable_deferred_intent_beta_1
SUBSCRIPTIONS_BASE_URL='http://localhost:18750'
ENABLE_B2C_SUBSCRIPTIONS=true
SUBSCRIPTIONS_LEARNER_HELP_CENTER_URL=https://support.edx.org/hc/articles/12975352138007
1 change: 1 addition & 0 deletions .env.development-stage
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ STRIPE_RESPONSE_URL=http://localhost:18130/payment/stripe/checkout/
STRIPE_DEFERRED_INTENT_BETA_FLAG=elements_enable_deferred_intent_beta_1
SUBSCRIPTIONS_BASE_URL='http://localhost:18750'
ENABLE_B2C_SUBSCRIPTIONS=false
SUBSCRIPTIONS_LEARNER_HELP_CENTER_URL=https://support.edx.org/hc/articles/12975352138007
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ STRIPE_RESPONSE_URL=http://localhost:18130/payment/stripe/checkout/
STRIPE_DEFERRED_INTENT_BETA_FLAG=elements_enable_deferred_intent_beta_1
SUBSCRIPTIONS_BASE_URL='http://localhost:18750'
ENABLE_B2C_SUBSCRIPTIONS=false
SUBSCRIPTIONS_LEARNER_HELP_CENTER_URL=https://support.edx.org/hc/articles/12975352138007
20 changes: 20 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"lodash.camelcase": "^4.3.0",
"lodash.snakecase": "^4.1.1",
"lodash.without": "^4.4.0",
"moment-timezone": "^0.5.43",
"prop-types": "^15.8.1",
"react": "^16.14.0",
"react-dom": "^16.14.0",
Expand Down
1 change: 1 addition & 0 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ mergeConfig({
STRIPE_DEFERRED_INTENT_BETA_FLAG: process.env.STRIPE_DEFERRED_INTENT_BETA_FLAG,
SUBSCRIPTIONS_BASE_URL: process.env.SUBSCRIPTIONS_BASE_URL,
ENABLE_B2C_SUBSCRIPTIONS: process.env.ENABLE_B2C_SUBSCRIPTIONS,
SUBSCRIPTIONS_LEARNER_HELP_CENTER_URL: process.env.SUBSCRIPTIONS_LEARNER_HELP_CENTER_URL,
});

subscribe(APP_READY, () => {
Expand Down
1 change: 1 addition & 0 deletions src/payment/__factories__/userAccount.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Factory.define('userAccount')
name: null,
country: null,
socialLinks: null,
timeZone: 'America/Los_Angeles',
profileImage: {
imageUrlMedium: 'http://localhost/image_medium.jpg',
imageUrlLarge: 'http://localhost/image_large.jpg',
Expand Down
2 changes: 0 additions & 2 deletions src/subscription/SubscriptionPage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ describe('<SubscriptionPage />', () => {
expect(screen.getAllByText('Verified Certificate')).toHaveLength(2);
// verify that Checkout Form fields are present in the DOM
expect(screen.queryAllByText('Last Name (required)')).toHaveLength(1);
// verify that MonthlySubscriptionNotification is present in the DOM
expect(screen.queryAllByText('You will be charged $55 USD on April 21, 2025, then monthly until you cancel your subscription.')).toHaveLength(1);
});

it('should not render the Subscription details when error_code is present', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/subscription/__factories__/subscription.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Factory.define('subscription')
total_price: 0,
currency: 'USD',
paymentMethod: 'stripe',
trial_end: 'April 21, 2025',
trial_end: '2023-06-29T13:05:04Z',
error_code: null,
})
.attr('products', ['numProducts', 'productType'], (numProducts, productType) => {
Expand Down
6 changes: 2 additions & 4 deletions src/subscription/checkout/SubscriptionCheckout.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ describe('<SubscriptionCheckout />', () => {

// verify that Checkout Form fields are present in the DOM
expect(screen.queryByText('Last Name (required)')).toBeDefined();
// verify that MonthlySubscriptionNotification is present in the DOM
expect(
screen.queryByText('You’ll be charged $55.00 USD on April 21, 2025 then every 31 days until you cancel your subscription.'),
).toBeDefined();
expect(screen.queryByLabelText('City')).toBeDefined();
expect(screen.queryByLabelText('Country')).toBeDefined();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ exports[`<SubscriptionCheckout /> should render the <SubscriptionCheckout/> with
class="d-flex justify-content-start pt-3 monthly-legal-notification"
>
<p>
You will be charged $55 USD on April 21, 2025, then monthly until you cancel your subscription.
You will be charged $55 USD on June 29, 2023 (PDT), then monthly until you cancel your subscription.
</p>
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
import React from 'react';
import React, { useContext } from 'react';
import { useSelector } from 'react-redux';
import { useIntl, defineMessages } from '@edx/frontend-platform/i18n';
import { detailsSelector } from '../../data/details/selectors';
import {
useIntl,
getLocale,
} from '@edx/frontend-platform/i18n';

import moment from 'moment-timezone';

import { AppContext } from '@edx/frontend-platform/react';
import { getPropsToRemoveFractionZeroDigits } from '../../../payment/data/utils';
import { detailsSelector } from '../../data/details/selectors';

const messages = defineMessages({
'subscription.checkout.billing.notification': {
id: 'subscription.checkout.billing.notification',
defaultMessage: 'You will be charged {price} {currency} {trialEnd} then monthly until you cancel your subscription.',
description: 'Subscription monthly billing notification for Users that they will be charged every 31 days for this subscription.',
},
'subscription.checkout.billing.trial.date': {
id: 'subscription.checkout.billing.trial.date',
defaultMessage: 'on {date},',
description: 'Subscription legal trialing helping text.',
},
'subscription.checkout.billing.resubscribe.date': {
id: 'subscription.checkout.billing.resubscribe.date',
defaultMessage: 'today,',
description: 'Subscription legal resubscribe helping text.',
},
});
import messages from './messages';

const MonthlyBillingNotification = () => {
const {
price, currency, trialEnd, isTrialEligible,
} = useSelector(detailsSelector);
const intl = useIntl();
const trialDateHelpingText = intl.formatMessage(messages['subscription.checkout.billing.trial.date'], { date: trialEnd });
const { authenticatedUser } = useContext(AppContext);

const userTimezone = (
authenticatedUser.timeZone || moment.tz.guess() || 'UTC'
);
const date = moment(trialEnd);
const localizeDate = date.tz(userTimezone);

// Format the date as "June 28, 2022 (PKT)"
const formattedDate = localizeDate.locale(getLocale()).format('MMMM D, YYYY (z)');

const trialDateHelpingText = intl.formatMessage(messages['subscription.checkout.billing.trial.date'], { date: formattedDate });
const resubscribeDateHelpingText = intl.formatMessage(messages['subscription.checkout.billing.resubscribe.date'], {});

return (
Expand Down
21 changes: 21 additions & 0 deletions src/subscription/checkout/monthly-billing-notification/messages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { defineMessages } from '@edx/frontend-platform/i18n';

const messages = defineMessages({
'subscription.checkout.billing.notification': {
id: 'subscription.checkout.billing.notification',
defaultMessage: 'You will be charged {price} {currency} {trialEnd} then monthly until you cancel your subscription.',
description: 'Subscription monthly billing notification for Users that they will be charged every 31 days for this subscription.',
},
'subscription.checkout.billing.trial.date': {
id: 'subscription.checkout.billing.trial.date',
defaultMessage: 'on {date},',
description: 'Subscription legal trialing helping text.',
},
'subscription.checkout.billing.resubscribe.date': {
id: 'subscription.checkout.billing.resubscribe.date',
defaultMessage: 'today,',
description: 'Subscription legal resubscribe helping text.',
},
});

export default messages;
4 changes: 3 additions & 1 deletion src/subscription/details/legal/SubscriptionLegal.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Hyperlink } from '@edx/paragon';
import { getConfig } from '@edx/frontend-platform';
import { useIntl } from '@edx/frontend-platform/i18n';

import messages from './messages';
import { getPropsToRemoveFractionZeroDigits } from '../../../payment/data/utils';

Expand All @@ -13,7 +15,7 @@ const SubscriptionLegal = ({
const intl = useIntl();
const supportLink = (
<Hyperlink
destination="https://support.edx.org/hc/en-us/articles/12975352138007"
destination={getConfig().SUBSCRIPTIONS_LEARNER_HELP_CENTER_URL}
>
{intl.formatMessage(messages['subscription.details.order.legal.link'])}
</Hyperlink>
Expand Down