@edx/frontend-app-subscription-manage 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/UpdatePaymentMethodModal/UpdatePaymentMethodModal.js +13 -5
- package/dist/components/UpdatePaymentMethodModal/UpdatePaymentMethodModal.js.map +1 -1
- package/dist/components/messages.d.ts +5 -0
- package/dist/components/messages.js +5 -0
- package/dist/components/messages.js.map +1 -1
- package/dist/data/hooks/useManageQueries.d.ts +2 -0
- package/dist/data/hooks/useManageQueries.js +12 -0
- package/dist/data/hooks/useManageQueries.js.map +1 -1
- package/dist/data/services/subscription/validateCartPaymentMethod.d.ts +15 -0
- package/dist/data/services/subscription/validateCartPaymentMethod.js +43 -0
- package/dist/data/services/subscription/validateCartPaymentMethod.js.map +1 -0
- package/dist/utils/edxSession.js +2 -2
- package/dist/utils/edxSession.js.map +1 -1
- package/dist/utils/queries.d.ts +5 -0
- package/dist/utils/queries.js +13 -0
- package/dist/utils/queries.js.map +1 -1
- package/package.json +1 -1
|
@@ -15,7 +15,8 @@ import { CreditCard } from '@openedx/paragon/icons';
|
|
|
15
15
|
import { Elements, CardNumberElement, CardCvcElement, CardExpiryElement, useElements, useStripe, } from '@stripe/react-stripe-js';
|
|
16
16
|
import { loadStripe } from '@stripe/stripe-js';
|
|
17
17
|
import { appId } from '../../constants';
|
|
18
|
-
import {
|
|
18
|
+
import { PaymentMethodValidationError } from '../../data/services/subscription/validateCartPaymentMethod';
|
|
19
|
+
import { useUpdatePaymentMethodMutation, useValidateCartPaymentMethodMutation, useViaxClient, } from '../../data/hooks/useManageQueries';
|
|
19
20
|
import messages from '../messages';
|
|
20
21
|
const ELEMENT_STYLE = {
|
|
21
22
|
base: {
|
|
@@ -38,6 +39,7 @@ const PaymentForm = ({ subscriptionBiId, onClose, onSuccess, }) => {
|
|
|
38
39
|
const stripe = useStripe();
|
|
39
40
|
const elements = useElements();
|
|
40
41
|
const client = useViaxClient();
|
|
42
|
+
const validateMutation = useValidateCartPaymentMethodMutation(client);
|
|
41
43
|
const updateMutation = useUpdatePaymentMethodMutation(client);
|
|
42
44
|
const [postalCode, setPostalCode] = useState('');
|
|
43
45
|
const [cardError, setCardError] = useState(null);
|
|
@@ -72,13 +74,19 @@ const PaymentForm = ({ subscriptionBiId, onClose, onSuccess, }) => {
|
|
|
72
74
|
setCardError((error === null || error === void 0 ? void 0 : error.message) || formatMessage(messages['manage.updatePayment.error']));
|
|
73
75
|
return;
|
|
74
76
|
}
|
|
75
|
-
|
|
77
|
+
const mutationArgs = {
|
|
76
78
|
biId: subscriptionBiId,
|
|
77
79
|
tStripePaymentMethodId: paymentMethod.id,
|
|
78
|
-
}
|
|
80
|
+
};
|
|
81
|
+
yield validateMutation.mutateAsync(mutationArgs);
|
|
82
|
+
yield updateMutation.mutateAsync(mutationArgs);
|
|
79
83
|
onSuccess();
|
|
80
84
|
}
|
|
81
85
|
catch (err) {
|
|
86
|
+
if (err instanceof PaymentMethodValidationError) {
|
|
87
|
+
setCardError(formatMessage(messages['manage.updatePayment.invalidCard']));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
82
90
|
const message = err instanceof Error && err.message
|
|
83
91
|
? err.message
|
|
84
92
|
: formatMessage(messages['manage.updatePayment.error']);
|
|
@@ -88,11 +96,11 @@ const PaymentForm = ({ subscriptionBiId, onClose, onSuccess, }) => {
|
|
|
88
96
|
setIsSubmitting(false);
|
|
89
97
|
}
|
|
90
98
|
});
|
|
91
|
-
return (_jsxs("form", { className: "manage-update-payment", onSubmit: handleSubmit, children: [_jsx("p", { className: "manage-update-payment__intro text-primary-500 mb-4", children: formatMessage(messages['manage.updatePayment.intro']) }), _jsx("h3", { className: "manage-update-payment__section font-weight-bold text-primary-500 mb-3", children: formatMessage(messages['manage.updatePayment.sectionTitle']) }), _jsxs("div", { className: "manage-update-payment__row manage-update-payment__row--card mb-0", children: [_jsxs(Form.Group, { className: "manage-update-payment__field manage-update-payment__field--card-number mb-3", children: [_jsx(Form.Label, { className: "manage-update-payment__label d-block text-primary-500 mb-1", children: formatMessage(messages['manage.updatePayment.cardNumber']) }), _jsx("div", { className: "manage-update-payment__element bg-white d-flex align-items-center", children: _jsx(CardNumberElement, { options: {
|
|
99
|
+
return (_jsxs("form", { className: "manage-update-payment", onSubmit: handleSubmit, children: [_jsx("p", { className: "manage-update-payment__intro text-primary-500 mb-4", children: formatMessage(messages['manage.updatePayment.intro']) }), cardError && (_jsx(Alert, { variant: "danger", className: "mb-4", children: cardError })), _jsx("h3", { className: "manage-update-payment__section font-weight-bold text-primary-500 mb-3", children: formatMessage(messages['manage.updatePayment.sectionTitle']) }), _jsxs("div", { className: "manage-update-payment__row manage-update-payment__row--card mb-0", children: [_jsxs(Form.Group, { className: "manage-update-payment__field manage-update-payment__field--card-number mb-3", children: [_jsx(Form.Label, { className: "manage-update-payment__label d-block text-primary-500 mb-1", children: formatMessage(messages['manage.updatePayment.cardNumber']) }), _jsx("div", { className: "manage-update-payment__element bg-white d-flex align-items-center", children: _jsx(CardNumberElement, { options: {
|
|
92
100
|
style: ELEMENT_STYLE,
|
|
93
101
|
showIcon: true,
|
|
94
102
|
placeholder: '1234 1234 1234 1234',
|
|
95
|
-
} }) })] }), _jsxs(Form.Group, { className: "manage-update-payment__field manage-update-payment__field--cvc mb-3", children: [_jsx(Form.Label, { className: "manage-update-payment__label d-block text-primary-500 mb-1", children: formatMessage(messages['manage.updatePayment.cvc']) }), _jsxs("div", { className: "manage-update-payment__element manage-update-payment__element--cvc bg-white d-flex align-items-center", children: [_jsx(CardCvcElement, { options: { style: ELEMENT_STYLE, placeholder: 'CVC' } }), _jsx(Icon, { src: CreditCard, className: "manage-update-payment__cvc-icon", "aria-hidden": true })] })] }), _jsxs(Form.Group, { className: "manage-update-payment__field manage-update-payment__field--expiry mb-3", children: [_jsx(Form.Label, { className: "manage-update-payment__label d-block text-primary-500 mb-1", children: formatMessage(messages['manage.updatePayment.expiry']) }), _jsx("div", { className: "manage-update-payment__element bg-white d-flex align-items-center", children: _jsx(CardExpiryElement, { options: { style: ELEMENT_STYLE, placeholder: 'MM / YY' } }) })] })] }), _jsx("div", { className: "manage-update-payment__row manage-update-payment__row--postal mb-0", children: _jsxs(Form.Group, { className: "manage-update-payment__field manage-update-payment__field--postal mb-3", children: [_jsx(Form.Label, { className: "manage-update-payment__label d-block text-primary-500 mb-1", children: formatMessage(messages['manage.updatePayment.postal']) }), _jsx("div", { className: "manage-update-payment__element bg-white d-flex align-items-center", children: _jsx("input", { className: "manage-update-payment__control w-100 m-0 p-0 bg-transparent border-0", type: "text", name: "postal-code", value: postalCode, onChange: (e) => setPostalCode(e.target.value), autoComplete: "postal-code", required: true }) })] }) }),
|
|
103
|
+
} }) })] }), _jsxs(Form.Group, { className: "manage-update-payment__field manage-update-payment__field--cvc mb-3", children: [_jsx(Form.Label, { className: "manage-update-payment__label d-block text-primary-500 mb-1", children: formatMessage(messages['manage.updatePayment.cvc']) }), _jsxs("div", { className: "manage-update-payment__element manage-update-payment__element--cvc bg-white d-flex align-items-center", children: [_jsx(CardCvcElement, { options: { style: ELEMENT_STYLE, placeholder: 'CVC' } }), _jsx(Icon, { src: CreditCard, className: "manage-update-payment__cvc-icon", "aria-hidden": true })] })] }), _jsxs(Form.Group, { className: "manage-update-payment__field manage-update-payment__field--expiry mb-3", children: [_jsx(Form.Label, { className: "manage-update-payment__label d-block text-primary-500 mb-1", children: formatMessage(messages['manage.updatePayment.expiry']) }), _jsx("div", { className: "manage-update-payment__element bg-white d-flex align-items-center", children: _jsx(CardExpiryElement, { options: { style: ELEMENT_STYLE, placeholder: 'MM / YY' } }) })] })] }), _jsx("div", { className: "manage-update-payment__row manage-update-payment__row--postal mb-0", children: _jsxs(Form.Group, { className: "manage-update-payment__field manage-update-payment__field--postal mb-3", children: [_jsx(Form.Label, { className: "manage-update-payment__label d-block text-primary-500 mb-1", children: formatMessage(messages['manage.updatePayment.postal']) }), _jsx("div", { className: "manage-update-payment__element bg-white d-flex align-items-center", children: _jsx("input", { className: "manage-update-payment__control w-100 m-0 p-0 bg-transparent border-0", type: "text", name: "postal-code", value: postalCode, onChange: (e) => setPostalCode(e.target.value), autoComplete: "postal-code", required: true }) })] }) }), _jsxs(ActionRow, { className: "manage-update-payment__actions mt-4 w-100 justify-content-end flex-wrap flex-column-reverse flex-sm-row align-items-stretch align-items-sm-center", children: [_jsx(Button, { type: "button", variant: "tertiary", className: "w-100 w-sm-auto", onClick: onClose, disabled: isSubmitting, children: formatMessage(messages['manage.updatePayment.close']) }), _jsx(Button, { type: "submit", variant: "primary", className: "manage-btn manage-btn--dark w-100 w-sm-auto", disabled: !stripe || isSubmitting, children: isSubmitting
|
|
96
104
|
? formatMessage(messages['manage.updatePayment.submitting'])
|
|
97
105
|
: formatMessage(messages['manage.updatePayment.submit']) })] })] }));
|
|
98
106
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdatePaymentMethodModal.js","sourceRoot":"","sources":["../../../src/components/UpdatePaymentMethodModal/UpdatePaymentMethodModal.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAc,EACZ,WAAW,EACX,SAAS,EACT,OAAO,EACP,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EACL,KAAK,EACL,IAAI,EACJ,WAAW,EACX,MAAM,EACN,SAAS,EACT,IAAI,GACL,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EACL,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,SAAS,GACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAe,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EACL,8BAA8B,EAC9B,aAAa,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MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,YACvD,KAAC,WAAW,IACV,gBAAgB,EAAE,gBAAiB,EACnC,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,GACnC,GACO,CACZ,GACgB,IACP,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,wBAAwB,CAAC","sourcesContent":["import React, {\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport {\n Alert,\n Form,\n ModalDialog,\n Button,\n ActionRow,\n Icon,\n} from '@openedx/paragon';\nimport { getAppConfig, useIntl } from '@openedx/frontend-base';\nimport { CreditCard } from '@openedx/paragon/icons';\nimport {\n Elements,\n CardNumberElement,\n CardCvcElement,\n CardExpiryElement,\n useElements,\n useStripe,\n} from '@stripe/react-stripe-js';\nimport { loadStripe, type Stripe } from '@stripe/stripe-js';\n\nimport { appId } from '../../constants';\nimport {\n useUpdatePaymentMethodMutation,\n useViaxClient,\n} from '../../data/hooks/useManageQueries';\nimport messages from '../messages';\n\nconst ELEMENT_STYLE = {\n base: {\n color: '#00262b',\n fontSize: '16px',\n lineHeight: '24px',\n fontFamily: '\"Open Sans\", \"Helvetica Neue\", Arial, sans-serif',\n fontSmoothing: 'antialiased',\n '::placeholder': {\n color: '#707070',\n },\n },\n invalid: {\n color: '#b91c1c',\n iconColor: '#b91c1c',\n },\n};\n\ninterface UpdatePaymentMethodModalProps {\n isOpen: boolean,\n onClose: () => void,\n subscriptionBiId: string | null | undefined,\n nextBillingDate: string | null,\n}\n\ninterface PaymentFormProps {\n subscriptionBiId: string,\n onClose: () => void,\n onSuccess: () => void,\n}\n\nconst PaymentForm: React.FC<PaymentFormProps> = ({\n subscriptionBiId,\n onClose,\n onSuccess,\n}) => {\n const { formatMessage } = useIntl();\n const stripe = useStripe();\n const elements = useElements();\n const client = useViaxClient();\n const updateMutation = useUpdatePaymentMethodMutation(client);\n\n const [postalCode, setPostalCode] = useState('');\n const [cardError, setCardError] = useState<string | null>(null);\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const handleSubmit = async (event: React.FormEvent) => {\n event.preventDefault();\n setCardError(null);\n\n if (!stripe || !elements) {\n return;\n }\n\n const cardNumber = elements.getElement(CardNumberElement);\n if (!cardNumber) {\n return;\n }\n\n const trimmedPostal = postalCode.trim();\n if (!trimmedPostal) {\n setCardError(formatMessage(messages['manage.updatePayment.postalRequired']));\n return;\n }\n\n setIsSubmitting(true);\n try {\n const { error, paymentMethod } = await stripe.createPaymentMethod({\n type: 'card',\n card: cardNumber,\n billing_details: {\n address: {\n postal_code: trimmedPostal,\n },\n },\n });\n\n if (error || !paymentMethod?.id) {\n setCardError(error?.message || formatMessage(messages['manage.updatePayment.error']));\n return;\n }\n\n await updateMutation.mutateAsync({\n biId: subscriptionBiId,\n tStripePaymentMethodId: paymentMethod.id,\n });\n onSuccess();\n } catch (err) {\n const message = err instanceof Error && err.message\n ? err.message\n : formatMessage(messages['manage.updatePayment.error']);\n setCardError(message);\n } finally {\n setIsSubmitting(false);\n }\n };\n\n return (\n <form className=\"manage-update-payment\" onSubmit={handleSubmit}>\n <p className=\"manage-update-payment__intro text-primary-500 mb-4\">\n {formatMessage(messages['manage.updatePayment.intro'])}\n </p>\n\n <h3 className=\"manage-update-payment__section font-weight-bold text-primary-500 mb-3\">\n {formatMessage(messages['manage.updatePayment.sectionTitle'])}\n </h3>\n\n <div className=\"manage-update-payment__row manage-update-payment__row--card mb-0\">\n <Form.Group className=\"manage-update-payment__field manage-update-payment__field--card-number mb-3\">\n <Form.Label className=\"manage-update-payment__label d-block text-primary-500 mb-1\">\n {formatMessage(messages['manage.updatePayment.cardNumber'])}\n </Form.Label>\n <div className=\"manage-update-payment__element bg-white d-flex align-items-center\">\n <CardNumberElement\n options={{\n style: ELEMENT_STYLE,\n showIcon: true,\n placeholder: '1234 1234 1234 1234',\n }}\n />\n </div>\n </Form.Group>\n\n <Form.Group className=\"manage-update-payment__field manage-update-payment__field--cvc mb-3\">\n <Form.Label className=\"manage-update-payment__label d-block text-primary-500 mb-1\">\n {formatMessage(messages['manage.updatePayment.cvc'])}\n </Form.Label>\n <div className=\"manage-update-payment__element manage-update-payment__element--cvc bg-white d-flex align-items-center\">\n <CardCvcElement options={{ style: ELEMENT_STYLE, placeholder: 'CVC' }} />\n <Icon\n src={CreditCard}\n className=\"manage-update-payment__cvc-icon\"\n aria-hidden\n />\n </div>\n </Form.Group>\n\n <Form.Group className=\"manage-update-payment__field manage-update-payment__field--expiry mb-3\">\n <Form.Label className=\"manage-update-payment__label d-block text-primary-500 mb-1\">\n {formatMessage(messages['manage.updatePayment.expiry'])}\n </Form.Label>\n <div className=\"manage-update-payment__element bg-white d-flex align-items-center\">\n <CardExpiryElement options={{ style: ELEMENT_STYLE, placeholder: 'MM / YY' }} />\n </div>\n </Form.Group>\n </div>\n\n <div className=\"manage-update-payment__row manage-update-payment__row--postal mb-0\">\n <Form.Group className=\"manage-update-payment__field manage-update-payment__field--postal mb-3\">\n <Form.Label className=\"manage-update-payment__label d-block text-primary-500 mb-1\">\n {formatMessage(messages['manage.updatePayment.postal'])}\n </Form.Label>\n <div className=\"manage-update-payment__element bg-white d-flex align-items-center\">\n <input\n className=\"manage-update-payment__control w-100 m-0 p-0 bg-transparent border-0\"\n type=\"text\"\n name=\"postal-code\"\n value={postalCode}\n onChange={(e) => setPostalCode(e.target.value)}\n autoComplete=\"postal-code\"\n required\n />\n </div>\n </Form.Group>\n </div>\n\n {cardError && (\n <Alert variant=\"danger\" className=\"mt-3 mb-0\">\n {cardError}\n </Alert>\n )}\n\n <ActionRow className=\"manage-update-payment__actions mt-4 w-100 justify-content-end flex-wrap flex-column-reverse flex-sm-row align-items-stretch align-items-sm-center\">\n <Button\n type=\"button\"\n variant=\"tertiary\"\n className=\"w-100 w-sm-auto\"\n onClick={onClose}\n disabled={isSubmitting}\n >\n {formatMessage(messages['manage.updatePayment.close'])}\n </Button>\n <Button\n type=\"submit\"\n variant=\"primary\"\n className=\"manage-btn manage-btn--dark w-100 w-sm-auto\"\n disabled={!stripe || isSubmitting}\n >\n {isSubmitting\n ? formatMessage(messages['manage.updatePayment.submitting'])\n : formatMessage(messages['manage.updatePayment.submit'])}\n </Button>\n </ActionRow>\n </form>\n );\n};\n\nconst UpdatePaymentMethodModal: React.FC<UpdatePaymentMethodModalProps> = ({\n isOpen,\n onClose,\n subscriptionBiId,\n nextBillingDate,\n}) => {\n const { formatMessage } = useIntl();\n const config = getAppConfig(appId);\n const publishableKey = (config.STRIPE_PUBLIC_KEY as string | undefined) || '';\n const [stripePromise, setStripePromise] = useState<Promise<Stripe | null> | null>(null);\n const [step, setStep] = useState<'form' | 'success'>('form');\n\n useEffect(() => {\n if (!publishableKey) {\n setStripePromise(null);\n return;\n }\n setStripePromise(loadStripe(publishableKey));\n }, [publishableKey]);\n\n useEffect(() => {\n if (isOpen) {\n setStep('form');\n }\n }, [isOpen]);\n\n const handleClose = useCallback(() => {\n setStep('form');\n onClose();\n }, [onClose]);\n\n const title = step === 'success'\n ? formatMessage(messages['manage.updatePayment.successTitle'])\n : formatMessage(messages['manage.updatePayment.title']);\n\n const canShowForm = Boolean(publishableKey && subscriptionBiId && stripePromise);\n\n const elementsOptions = useMemo(() => ({\n fonts: [{ cssSrc: 'https://fonts.googleapis.com/css?family=Open+Sans' }],\n }), []);\n\n return (\n <ModalDialog\n title={title}\n isOpen={isOpen}\n onClose={handleClose}\n size=\"lg\"\n hasCloseButton\n isOverflowVisible={false}\n isFullscreenOnMobile\n className=\"manage-update-payment-modal\"\n >\n <ModalDialog.Header>\n <ModalDialog.Title>{title}</ModalDialog.Title>\n </ModalDialog.Header>\n\n <ModalDialog.Body>\n {step === 'success' ? (\n <div className=\"manage-update-payment manage-update-payment--success\">\n <p className=\"manage-update-payment__intro text-primary-500 mb-0\">\n {nextBillingDate\n ? formatMessage(messages['manage.updatePayment.successBody'], {\n date: nextBillingDate,\n })\n : formatMessage(messages['manage.updatePayment.successBodyNoDate'])}\n </p>\n <ActionRow className=\"manage-update-payment__actions mt-4 w-100 justify-content-end flex-wrap\">\n <Button\n variant=\"primary\"\n className=\"manage-btn manage-btn--dark\"\n onClick={handleClose}\n >\n {formatMessage(messages['manage.updatePayment.close'])}\n </Button>\n </ActionRow>\n </div>\n ) : !canShowForm ? (\n <Alert variant=\"warning\">\n {formatMessage(messages['manage.updatePayment.stripeMissing'])}\n </Alert>\n ) : (\n <Elements stripe={stripePromise} options={elementsOptions}>\n <PaymentForm\n subscriptionBiId={subscriptionBiId!}\n onClose={handleClose}\n onSuccess={() => setStep('success')}\n />\n </Elements>\n )}\n </ModalDialog.Body>\n </ModalDialog>\n );\n};\n\nexport default UpdatePaymentMethodModal;\n"]}
|
|
1
|
+
{"version":3,"file":"UpdatePaymentMethodModal.js","sourceRoot":"","sources":["../../../src/components/UpdatePaymentMethodModal/UpdatePaymentMethodModal.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAc,EACZ,WAAW,EACX,SAAS,EACT,OAAO,EACP,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EACL,KAAK,EACL,IAAI,EACJ,WAAW,EACX,MAAM,EACN,SAAS,EACT,IAAI,GACL,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EACL,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,SAAS,GACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAe,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,4BAA4B,EAAE,MAAM,4DAA4D,CAAC;AAC1G,OAAO,EACL,8BAA8B,EAC9B,oCAAoC,EACpC,aAAa,GACd,MAAM,mCAAmC,CAAC;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,YAEnB,aAAa,CAAC,QAAQ,CAAC,4BAA4B,CAAC,CAAC,GAC/C,GACC,IACR,CACP,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CACjB,KAAC,KAAK,IAAC,OAAO,EAAC,SAAS,YACrB,aAAa,CAAC,QAAQ,CAAC,oCAAoC,CAAC,CAAC,GACxD,CACT,CAAC,CAAC,CAAC,CACF,KAAC,QAAQ,IAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,YACvD,KAAC,WAAW,IACV,gBAAgB,EAAE,gBAAiB,EACnC,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,GACnC,GACO,CACZ,GACgB,IACP,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,wBAAwB,CAAC","sourcesContent":["import React, {\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport {\n Alert,\n Form,\n ModalDialog,\n Button,\n ActionRow,\n Icon,\n} from '@openedx/paragon';\nimport { getAppConfig, useIntl } from '@openedx/frontend-base';\nimport { CreditCard } from '@openedx/paragon/icons';\nimport {\n Elements,\n CardNumberElement,\n CardCvcElement,\n CardExpiryElement,\n useElements,\n useStripe,\n} from '@stripe/react-stripe-js';\nimport { loadStripe, type Stripe } from '@stripe/stripe-js';\n\nimport { appId } from '../../constants';\nimport { PaymentMethodValidationError } from '../../data/services/subscription/validateCartPaymentMethod';\nimport {\n useUpdatePaymentMethodMutation,\n useValidateCartPaymentMethodMutation,\n useViaxClient,\n} from '../../data/hooks/useManageQueries';\nimport messages from '../messages';\n\nconst ELEMENT_STYLE = {\n base: {\n color: '#00262b',\n fontSize: '16px',\n lineHeight: '24px',\n fontFamily: '\"Open Sans\", \"Helvetica Neue\", Arial, sans-serif',\n fontSmoothing: 'antialiased',\n '::placeholder': {\n color: '#707070',\n },\n },\n invalid: {\n color: '#b91c1c',\n iconColor: '#b91c1c',\n },\n};\n\ninterface UpdatePaymentMethodModalProps {\n isOpen: boolean,\n onClose: () => void,\n subscriptionBiId: string | null | undefined,\n nextBillingDate: string | null,\n}\n\ninterface PaymentFormProps {\n subscriptionBiId: string,\n onClose: () => void,\n onSuccess: () => void,\n}\n\nconst PaymentForm: React.FC<PaymentFormProps> = ({\n subscriptionBiId,\n onClose,\n onSuccess,\n}) => {\n const { formatMessage } = useIntl();\n const stripe = useStripe();\n const elements = useElements();\n const client = useViaxClient();\n const validateMutation = useValidateCartPaymentMethodMutation(client);\n const updateMutation = useUpdatePaymentMethodMutation(client);\n\n const [postalCode, setPostalCode] = useState('');\n const [cardError, setCardError] = useState<string | null>(null);\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const handleSubmit = async (event: React.FormEvent) => {\n event.preventDefault();\n setCardError(null);\n\n if (!stripe || !elements) {\n return;\n }\n\n const cardNumber = elements.getElement(CardNumberElement);\n if (!cardNumber) {\n return;\n }\n\n const trimmedPostal = postalCode.trim();\n if (!trimmedPostal) {\n setCardError(formatMessage(messages['manage.updatePayment.postalRequired']));\n return;\n }\n\n setIsSubmitting(true);\n try {\n const { error, paymentMethod } = await stripe.createPaymentMethod({\n type: 'card',\n card: cardNumber,\n billing_details: {\n address: {\n postal_code: trimmedPostal,\n },\n },\n });\n\n if (error || !paymentMethod?.id) {\n setCardError(error?.message || formatMessage(messages['manage.updatePayment.error']));\n return;\n }\n\n const mutationArgs = {\n biId: subscriptionBiId,\n tStripePaymentMethodId: paymentMethod.id,\n };\n\n await validateMutation.mutateAsync(mutationArgs);\n await updateMutation.mutateAsync(mutationArgs);\n onSuccess();\n } catch (err) {\n if (err instanceof PaymentMethodValidationError) {\n setCardError(formatMessage(messages['manage.updatePayment.invalidCard']));\n return;\n }\n const message = err instanceof Error && err.message\n ? err.message\n : formatMessage(messages['manage.updatePayment.error']);\n setCardError(message);\n } finally {\n setIsSubmitting(false);\n }\n };\n\n return (\n <form className=\"manage-update-payment\" onSubmit={handleSubmit}>\n <p className=\"manage-update-payment__intro text-primary-500 mb-4\">\n {formatMessage(messages['manage.updatePayment.intro'])}\n </p>\n\n {cardError && (\n <Alert variant=\"danger\" className=\"mb-4\">\n {cardError}\n </Alert>\n )}\n\n <h3 className=\"manage-update-payment__section font-weight-bold text-primary-500 mb-3\">\n {formatMessage(messages['manage.updatePayment.sectionTitle'])}\n </h3>\n\n <div className=\"manage-update-payment__row manage-update-payment__row--card mb-0\">\n <Form.Group className=\"manage-update-payment__field manage-update-payment__field--card-number mb-3\">\n <Form.Label className=\"manage-update-payment__label d-block text-primary-500 mb-1\">\n {formatMessage(messages['manage.updatePayment.cardNumber'])}\n </Form.Label>\n <div className=\"manage-update-payment__element bg-white d-flex align-items-center\">\n <CardNumberElement\n options={{\n style: ELEMENT_STYLE,\n showIcon: true,\n placeholder: '1234 1234 1234 1234',\n }}\n />\n </div>\n </Form.Group>\n\n <Form.Group className=\"manage-update-payment__field manage-update-payment__field--cvc mb-3\">\n <Form.Label className=\"manage-update-payment__label d-block text-primary-500 mb-1\">\n {formatMessage(messages['manage.updatePayment.cvc'])}\n </Form.Label>\n <div className=\"manage-update-payment__element manage-update-payment__element--cvc bg-white d-flex align-items-center\">\n <CardCvcElement options={{ style: ELEMENT_STYLE, placeholder: 'CVC' }} />\n <Icon\n src={CreditCard}\n className=\"manage-update-payment__cvc-icon\"\n aria-hidden\n />\n </div>\n </Form.Group>\n\n <Form.Group className=\"manage-update-payment__field manage-update-payment__field--expiry mb-3\">\n <Form.Label className=\"manage-update-payment__label d-block text-primary-500 mb-1\">\n {formatMessage(messages['manage.updatePayment.expiry'])}\n </Form.Label>\n <div className=\"manage-update-payment__element bg-white d-flex align-items-center\">\n <CardExpiryElement options={{ style: ELEMENT_STYLE, placeholder: 'MM / YY' }} />\n </div>\n </Form.Group>\n </div>\n\n <div className=\"manage-update-payment__row manage-update-payment__row--postal mb-0\">\n <Form.Group className=\"manage-update-payment__field manage-update-payment__field--postal mb-3\">\n <Form.Label className=\"manage-update-payment__label d-block text-primary-500 mb-1\">\n {formatMessage(messages['manage.updatePayment.postal'])}\n </Form.Label>\n <div className=\"manage-update-payment__element bg-white d-flex align-items-center\">\n <input\n className=\"manage-update-payment__control w-100 m-0 p-0 bg-transparent border-0\"\n type=\"text\"\n name=\"postal-code\"\n value={postalCode}\n onChange={(e) => setPostalCode(e.target.value)}\n autoComplete=\"postal-code\"\n required\n />\n </div>\n </Form.Group>\n </div>\n\n <ActionRow className=\"manage-update-payment__actions mt-4 w-100 justify-content-end flex-wrap flex-column-reverse flex-sm-row align-items-stretch align-items-sm-center\">\n <Button\n type=\"button\"\n variant=\"tertiary\"\n className=\"w-100 w-sm-auto\"\n onClick={onClose}\n disabled={isSubmitting}\n >\n {formatMessage(messages['manage.updatePayment.close'])}\n </Button>\n <Button\n type=\"submit\"\n variant=\"primary\"\n className=\"manage-btn manage-btn--dark w-100 w-sm-auto\"\n disabled={!stripe || isSubmitting}\n >\n {isSubmitting\n ? formatMessage(messages['manage.updatePayment.submitting'])\n : formatMessage(messages['manage.updatePayment.submit'])}\n </Button>\n </ActionRow>\n </form>\n );\n};\n\nconst UpdatePaymentMethodModal: React.FC<UpdatePaymentMethodModalProps> = ({\n isOpen,\n onClose,\n subscriptionBiId,\n nextBillingDate,\n}) => {\n const { formatMessage } = useIntl();\n const config = getAppConfig(appId);\n const publishableKey = (config.STRIPE_PUBLIC_KEY as string | undefined) || '';\n const [stripePromise, setStripePromise] = useState<Promise<Stripe | null> | null>(null);\n const [step, setStep] = useState<'form' | 'success'>('form');\n\n useEffect(() => {\n if (!publishableKey) {\n setStripePromise(null);\n return;\n }\n setStripePromise(loadStripe(publishableKey));\n }, [publishableKey]);\n\n useEffect(() => {\n if (isOpen) {\n setStep('form');\n }\n }, [isOpen]);\n\n const handleClose = useCallback(() => {\n setStep('form');\n onClose();\n }, [onClose]);\n\n const title = step === 'success'\n ? formatMessage(messages['manage.updatePayment.successTitle'])\n : formatMessage(messages['manage.updatePayment.title']);\n\n const canShowForm = Boolean(publishableKey && subscriptionBiId && stripePromise);\n\n const elementsOptions = useMemo(() => ({\n fonts: [{ cssSrc: 'https://fonts.googleapis.com/css?family=Open+Sans' }],\n }), []);\n\n return (\n <ModalDialog\n title={title}\n isOpen={isOpen}\n onClose={handleClose}\n size=\"lg\"\n hasCloseButton\n isOverflowVisible={false}\n isFullscreenOnMobile\n className=\"manage-update-payment-modal\"\n >\n <ModalDialog.Header>\n <ModalDialog.Title>{title}</ModalDialog.Title>\n </ModalDialog.Header>\n\n <ModalDialog.Body>\n {step === 'success' ? (\n <div className=\"manage-update-payment manage-update-payment--success\">\n <p className=\"manage-update-payment__intro text-primary-500 mb-0\">\n {nextBillingDate\n ? formatMessage(messages['manage.updatePayment.successBody'], {\n date: nextBillingDate,\n })\n : formatMessage(messages['manage.updatePayment.successBodyNoDate'])}\n </p>\n <ActionRow className=\"manage-update-payment__actions mt-4 w-100 justify-content-end flex-wrap\">\n <Button\n variant=\"primary\"\n className=\"manage-btn manage-btn--dark\"\n onClick={handleClose}\n >\n {formatMessage(messages['manage.updatePayment.close'])}\n </Button>\n </ActionRow>\n </div>\n ) : !canShowForm ? (\n <Alert variant=\"warning\">\n {formatMessage(messages['manage.updatePayment.stripeMissing'])}\n </Alert>\n ) : (\n <Elements stripe={stripePromise} options={elementsOptions}>\n <PaymentForm\n subscriptionBiId={subscriptionBiId!}\n onClose={handleClose}\n onSuccess={() => setStep('success')}\n />\n </Elements>\n )}\n </ModalDialog.Body>\n </ModalDialog>\n );\n};\n\nexport default UpdatePaymentMethodModal;\n"]}
|
|
@@ -259,6 +259,11 @@ declare const messages: {
|
|
|
259
259
|
defaultMessage: string;
|
|
260
260
|
description: string;
|
|
261
261
|
};
|
|
262
|
+
'manage.updatePayment.invalidCard': {
|
|
263
|
+
id: string;
|
|
264
|
+
defaultMessage: string;
|
|
265
|
+
description: string;
|
|
266
|
+
};
|
|
262
267
|
'manage.updatePayment.stripeMissing': {
|
|
263
268
|
id: string;
|
|
264
269
|
defaultMessage: string;
|
|
@@ -262,6 +262,11 @@ const messages = defineMessages({
|
|
|
262
262
|
defaultMessage: 'We could not update your payment method. Please try again.',
|
|
263
263
|
description: 'Generic error when payment method update fails',
|
|
264
264
|
},
|
|
265
|
+
'manage.updatePayment.invalidCard': {
|
|
266
|
+
id: 'manage.updatePayment.invalidCard',
|
|
267
|
+
defaultMessage: 'This card is not valid. Please try a different card.',
|
|
268
|
+
description: 'Shown when the backend rejects the card during validation',
|
|
269
|
+
},
|
|
265
270
|
'manage.updatePayment.stripeMissing': {
|
|
266
271
|
id: 'manage.updatePayment.stripeMissing',
|
|
267
272
|
defaultMessage: 'Payment updates are temporarily unavailable. Please try again later.',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/components/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,QAAQ,GAAG,cAAc,CAAC;IAC9B,mBAAmB,EAAE;QACnB,EAAE,EAAE,mBAAmB;QACvB,cAAc,EAAE,4BAA4B;QAC5C,WAAW,EAAE,iDAAiD;KAC/D;IACD,gBAAgB,EAAE;QAChB,EAAE,EAAE,gBAAgB;QACpB,cAAc,EAAE,uBAAuB;QACvC,WAAW,EAAE,gDAAgD;KAC9D;IACD,cAAc,EAAE;QACd,EAAE,EAAE,cAAc;QAClB,cAAc,EAAE,8DAA8D;QAC9E,WAAW,EAAE,2CAA2C;KACzD;IACD,qBAAqB,EAAE;QACrB,EAAE,EAAE,qBAAqB;QACzB,cAAc,EAAE,eAAe;QAC/B,WAAW,EAAE,sDAAsD;KACpE;IACD,wBAAwB,EAAE;QACxB,EAAE,EAAE,wBAAwB;QAC5B,cAAc,EAAE,uDAAuD;QACvE,WAAW,EAAE,mCAAmC;KACjD;IACD,yBAAyB,EAAE;QACzB,EAAE,EAAE,yBAAyB;QAC7B,cAAc,EAAE,cAAc;QAC9B,WAAW,EAAE,wBAAwB;KACtC;IACD,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AAc,EAAE,0BAA0B;QAC1C,WAAW,EAAE,wCAAwC;KACtD;IACD,0BAA0B,EAAE;QAC1B,EAAE,EAAE,0BAA0B;QAC9B,cAAc,EAAE,aAAa;QAC7B,WAAW,EAAE,mDAAmD;KACjE;IACD,qBAAqB,EAAE;QACrB,EAAE,EAAE,qBAAqB;QACzB,cAAc,EAAE,0DAA0D;QAC1E,WAAW,EAAE,kCAAkC;KAChD;IACD,+BAA+B,EAAE;QAC/B,EAAE,EAAE,+BAA+B;QACnC,cAAc,EAAE,kBAAkB;QAClC,WAAW,EAAE,gDAAgD;KAC9D;IAED,iBAAiB;IACjB,4BAA4B,EAAE;QAC5B,EAAE,EAAE,4BAA4B;QAChC,cAAc,EAAE,wEAAwE;QACxF,WAAW,EAAE,2BAA2B;KACzC;IACD,2BAA2B,EAAE;QAC3B,EAAE,EAAE,2BAA2B;QAC/B,cAAc,EAAE,8IAA8I;QAC9J,WAAW,EAAE,oDAAoD;KAClE;IACD,iCAAiC,EAAE;QACjC,EAAE,EAAE,iCAAiC;QACrC,cAAc,EAAE,iIAAiI;QACjJ,WAAW,EAAE,kCAAkC;KAChD;IACD,6BAA6B,EAAE;QAC7B,EAAE,EAAE,6BAA6B;QACjC,cAAc,EAAE,qBAAqB;QACrC,WAAW,EAAE,8CAA8C;KAC5D;CACF,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC","sourcesContent":["import { defineMessages } from '@openedx/frontend-base';\n\nconst messages = defineMessages({\n 'manage.page.title': {\n id: 'manage.page.title',\n defaultMessage: 'Order History | {siteName}',\n description: 'Document title for the manage subscription page',\n },\n 'manage.loading': {\n id: 'manage.loading',\n defaultMessage: 'Loading subscription…',\n description: 'Loading state for the manage subscription page',\n },\n 'manage.error': {\n id: 'manage.error',\n defaultMessage: 'We could not load your subscription. Please try again later.',\n description: 'Error alert when subscription fetch fails',\n },\n 'manage.header.title': {\n id: 'manage.header.title',\n defaultMessage: 'Order History',\n description: 'Page heading for order history / manage subscription',\n },\n 'manage.header.subtitle': {\n id: 'manage.header.subtitle',\n defaultMessage: 'View previous purchases and manage your subscription.',\n description: 'Page subtitle under Order History',\n },\n 'manage.tab.subscription': {\n id: 'manage.tab.subscription',\n defaultMessage: 'Subscription',\n description: 'Subscription tab label',\n },\n 'manage.tab.paymentHistory': {\n id: 'manage.tab.paymentHistory',\n defaultMessage: 'Payment history',\n description: 'Payment history tab label',\n },\n 'manage.paymentHistory.heading': {\n id: 'manage.paymentHistory.heading',\n defaultMessage: 'Payment history',\n description: 'Heading for the payment history panel',\n },\n 'manage.paymentHistory.nextPayment': {\n id: 'manage.paymentHistory.nextPayment',\n defaultMessage: 'Next payment scheduled for {date}.',\n description: 'Next payment line above the invoice list',\n },\n 'manage.paymentHistory.empty': {\n id: 'manage.paymentHistory.empty',\n defaultMessage: 'No payments yet.',\n description: 'Empty state when the learner has no invoices',\n },\n 'manage.paymentHistory.error': {\n id: 'manage.paymentHistory.error',\n defaultMessage: 'We could not load your payment history. Please try again later.',\n description: 'Error alert when invoice fetch fails',\n },\n 'manage.paymentHistory.noSubscription': {\n id: 'manage.paymentHistory.noSubscription',\n defaultMessage: 'Payment history is available after you subscribe.',\n description: 'Shown when there is no subscriptionBiId to query invoices',\n },\n 'manage.paymentHistory.tileTitle': {\n id: 'manage.paymentHistory.tileTitle',\n defaultMessage: 'edX Plus Subscription',\n description: 'Title on each payment history invoice tile',\n },\n 'manage.paymentHistory.startOfService': {\n id: 'manage.paymentHistory.startOfService',\n defaultMessage: 'Start of service:',\n description: 'Label for invoice period start on payment history tile',\n },\n 'manage.paymentHistory.totalCost': {\n id: 'manage.paymentHistory.totalCost',\n defaultMessage: 'Total cost:',\n description: 'Label for invoice total on payment history tile',\n },\n 'manage.paymentHistory.orderNumber': {\n id: 'manage.paymentHistory.orderNumber',\n defaultMessage: 'Order number:',\n description: 'Label for order number on payment history tile',\n },\n 'manage.paymentHistory.desc.trial': {\n id: 'manage.paymentHistory.desc.trial',\n defaultMessage: 'edX Plus Subscription — free trial',\n description: 'Description for a $0 trial invoice',\n },\n 'manage.paymentHistory.desc.paid': {\n id: 'manage.paymentHistory.desc.paid',\n defaultMessage: 'edX Plus Subscription',\n description: 'Description for a paid subscription invoice',\n },\n 'manage.paymentHistory.status.paid': {\n id: 'manage.paymentHistory.status.paid',\n defaultMessage: 'Paid',\n description: 'Invoice status label: PAID',\n },\n 'manage.paymentHistory.status.open': {\n id: 'manage.paymentHistory.status.open',\n defaultMessage: 'Open',\n description: 'Invoice status label: OPEN',\n },\n 'manage.paymentHistory.status.draft': {\n id: 'manage.paymentHistory.status.draft',\n defaultMessage: 'Draft',\n description: 'Invoice status label: DRAFT',\n },\n 'manage.help.prefix': {\n id: 'manage.help.prefix',\n defaultMessage: 'Need more help? Visit the',\n description: 'Prefix before Learner Help Center link',\n },\n 'manage.help.link': {\n id: 'manage.help.link',\n defaultMessage: 'Learner Help Center',\n description: 'Learner Help Center link text',\n },\n\n // Become a subscriber\n 'manage.none.heading': {\n id: 'manage.none.heading',\n defaultMessage: 'Become a subscriber',\n description: 'Section heading when user has no subscription',\n },\n 'manage.none.subheading': {\n id: 'manage.none.subheading',\n defaultMessage: 'You will manage your subscription here.',\n description: 'Section subheading when user has no subscription',\n },\n 'manage.none.cardTitle': {\n id: 'manage.none.cardTitle',\n defaultMessage: 'Try edX Subscription for free',\n description: 'Upsell card title for non-subscribers',\n },\n 'manage.none.cardBody': {\n id: 'manage.none.cardBody',\n defaultMessage: 'Get access to hundreds of courses for ${price}/month {currency}',\n description: 'Upsell card body including monthly price',\n },\n 'manage.none.cardBodyNoPrice': {\n id: 'manage.none.cardBodyNoPrice',\n defaultMessage: 'Get access to hundreds of courses with edX subscription',\n description: 'Upsell card body when price is unavailable',\n },\n 'manage.none.subscribe': {\n id: 'manage.none.subscribe',\n defaultMessage: 'Subscribe',\n description: 'Primary subscribe CTA',\n },\n 'manage.none.learnMore': {\n id: 'manage.none.learnMore',\n defaultMessage: 'Learn about edX Subscription',\n description: 'Secondary learn-more link on upsell card',\n },\n\n // Active\n 'manage.active.heading': {\n id: 'manage.active.heading',\n defaultMessage: 'Manage your subscription',\n description: 'Section heading for active subscribers',\n },\n 'manage.active.since': {\n id: 'manage.active.since',\n defaultMessage: 'Subscriber since {date}.',\n description: 'Subscriber since date line',\n },\n 'manage.active.statusMonthly': {\n id: 'manage.active.statusMonthly',\n defaultMessage: 'Active, Monthly Plan',\n description: 'Active monthly plan status label',\n },\n 'manage.active.statusAnnual': {\n id: 'manage.active.statusAnnual',\n defaultMessage: 'Active, Annual Plan',\n description: 'Active annual plan status label',\n },\n 'manage.active.nextPayment': {\n id: 'manage.active.nextPayment',\n defaultMessage: 'Your next payment is {date}.',\n description: 'Next payment date line for active subscribers',\n },\n 'manage.active.changeAnnual': {\n id: 'manage.active.changeAnnual',\n defaultMessage: 'Change to annual and save',\n description: 'CTA to switch to annual billing',\n },\n 'manage.active.updatePayment': {\n id: 'manage.active.updatePayment',\n defaultMessage: 'Update payment method',\n description: 'CTA to update payment method',\n },\n 'manage.updatePayment.title': {\n id: 'manage.updatePayment.title',\n defaultMessage: 'Update payment method.',\n description: 'Update payment method modal title',\n },\n 'manage.updatePayment.intro': {\n id: 'manage.updatePayment.intro',\n defaultMessage: 'By providing your card information, you allow edX to charge your card for future payments.',\n description: 'Update payment method modal intro copy',\n },\n 'manage.updatePayment.sectionTitle': {\n id: 'manage.updatePayment.sectionTitle',\n defaultMessage: 'Add new payment method',\n description: 'Heading above Stripe card fields',\n },\n 'manage.updatePayment.cardNumber': {\n id: 'manage.updatePayment.cardNumber',\n defaultMessage: 'Card number',\n description: 'Label for Stripe card number field',\n },\n 'manage.updatePayment.cvc': {\n id: 'manage.updatePayment.cvc',\n defaultMessage: 'Security code',\n description: 'Label for Stripe CVC field',\n },\n 'manage.updatePayment.expiry': {\n id: 'manage.updatePayment.expiry',\n defaultMessage: 'Expiration date',\n description: 'Label for Stripe expiry field',\n },\n 'manage.updatePayment.postal': {\n id: 'manage.updatePayment.postal',\n defaultMessage: 'Zip/Postal code',\n description: 'Label for postal code field',\n },\n 'manage.updatePayment.submit': {\n id: 'manage.updatePayment.submit',\n defaultMessage: 'Update card',\n description: 'Primary CTA to submit new payment method',\n },\n 'manage.updatePayment.submitting': {\n id: 'manage.updatePayment.submitting',\n defaultMessage: 'Updating…',\n description: 'Submit button label while update is in progress',\n },\n 'manage.updatePayment.close': {\n id: 'manage.updatePayment.close',\n defaultMessage: 'Close',\n description: 'Close button on update payment method modal',\n },\n 'manage.updatePayment.successTitle': {\n id: 'manage.updatePayment.successTitle',\n defaultMessage: 'Payment method updated.',\n description: 'Success modal title after payment method update',\n },\n 'manage.updatePayment.successBody': {\n id: 'manage.updatePayment.successBody',\n defaultMessage: 'Your new payment method will be applied on your next billing date, {date}.',\n description: 'Success modal body with next billing date',\n },\n 'manage.updatePayment.successBodyNoDate': {\n id: 'manage.updatePayment.successBodyNoDate',\n defaultMessage: 'Your new payment method will be applied on your next billing date.',\n description: 'Success modal body when next billing date is unknown',\n },\n 'manage.updatePayment.postalRequired': {\n id: 'manage.updatePayment.postalRequired',\n defaultMessage: 'Enter a zip/postal code.',\n description: 'Validation error when postal code is empty',\n },\n 'manage.updatePayment.error': {\n id: 'manage.updatePayment.error',\n defaultMessage: 'We could not update your payment method. Please try again.',\n description: 'Generic error when payment method update fails',\n },\n 'manage.updatePayment.stripeMissing': {\n id: 'manage.updatePayment.stripeMissing',\n defaultMessage: 'Payment updates are temporarily unavailable. Please try again later.',\n description: 'Shown when Stripe publishable key is not configured',\n },\n 'manage.active.cancelPrompt': {\n id: 'manage.active.cancelPrompt',\n defaultMessage: 'Need a break?',\n description: 'Prompt before cancel subscription link',\n },\n 'manage.active.cancelLink': {\n id: 'manage.active.cancelLink',\n defaultMessage: 'Cancel subscription',\n description: 'Cancel subscription link text',\n },\n\n // Canceled with access / renew banner\n 'manage.canceled.bannerTitle': {\n id: 'manage.canceled.bannerTitle',\n defaultMessage: 'Renew your subscription before it expires.',\n description: 'Expiring subscription banner title',\n },\n 'manage.canceled.bannerBody': {\n id: 'manage.canceled.bannerBody',\n defaultMessage: 'Your subscription is set to expire on {date} and you will have limited access to edX. Renew your subscription to keep your learning flexible.',\n description: 'Expiring subscription banner body',\n },\n 'manage.canceled.statusMonthly': {\n id: 'manage.canceled.statusMonthly',\n defaultMessage: 'Cancelled, Monthly plan',\n description: 'Cancelled monthly plan status label',\n },\n 'manage.canceled.statusAnnual': {\n id: 'manage.canceled.statusAnnual',\n defaultMessage: 'Cancelled, Annual plan',\n description: 'Cancelled annual plan status label',\n },\n 'manage.canceled.noPayments': {\n id: 'manage.canceled.noPayments',\n defaultMessage: 'You have no upcoming payments. You cancelled your subscription on {date}.',\n description: 'Cancelled status card body with cancel date',\n },\n 'manage.canceled.noPaymentsNoDate': {\n id: 'manage.canceled.noPaymentsNoDate',\n defaultMessage: 'You have no upcoming payments. You cancelled your subscription.',\n description: 'Cancelled status card body without cancel date',\n },\n 'manage.canceled.renew': {\n id: 'manage.canceled.renew',\n defaultMessage: 'Renew subscription',\n description: 'Renew subscription CTA',\n },\n 'manage.canceled.renewing': {\n id: 'manage.canceled.renewing',\n defaultMessage: 'Renewing…',\n description: 'Renew button label while reactivation mutation is in progress',\n },\n 'manage.canceled.renewError': {\n id: 'manage.canceled.renewError',\n defaultMessage: 'We could not renew your subscription. Please try again.',\n description: 'Error when reactivate mutation fails',\n },\n\n // Renew confirmation modal\n 'manage.renewModal.title': {\n id: 'manage.renewModal.title',\n defaultMessage: 'Renew your edX Plus subscription for ${price}/{frequency}',\n description: 'Renew modal title with price',\n },\n 'manage.renewModal.titleNoPrice': {\n id: 'manage.renewModal.titleNoPrice',\n defaultMessage: 'Renew your edX Plus subscription',\n description: 'Renew modal title when price is unavailable',\n },\n 'manage.renewModal.body': {\n id: 'manage.renewModal.body',\n defaultMessage: 'Your subscription will renew on {date} for ${price}/{frequency} {currency} (inclusive of applicable taxes). Cancel your subscription anytime from your dashboard. By clicking “Confirm subscription” you agree to our {termsLink}, and {refundLink}.',\n description: 'Renew modal body with terms links',\n },\n 'manage.renewModal.termsOfUse': {\n id: 'manage.renewModal.termsOfUse',\n defaultMessage: 'Terms of Use',\n description: 'Terms of Use link text in renew modal',\n },\n 'manage.renewModal.refundPolicy': {\n id: 'manage.renewModal.refundPolicy',\n defaultMessage: 'Refund Policy',\n description: 'Refund Policy link text in renew modal',\n },\n 'manage.renewModal.paymentMethod': {\n id: 'manage.renewModal.paymentMethod',\n defaultMessage: 'Payment Method',\n description: 'Payment method section heading in renew modal',\n },\n 'manage.renewModal.card': {\n id: 'manage.renewModal.card',\n defaultMessage: 'Card',\n description: 'Card payment method label in renew modal',\n },\n 'manage.renewModal.updatePayment': {\n id: 'manage.renewModal.updatePayment',\n defaultMessage: 'Update payment method',\n description: 'Update payment method button in renew modal',\n },\n 'manage.renewModal.recurringConfirm': {\n id: 'manage.renewModal.recurringConfirm',\n defaultMessage: 'I agree to enroll in a recurring {cycle} subscription for ${price}/{frequency} {currency}.',\n description: 'Recurring subscription consent checkbox',\n },\n 'manage.renewModal.ukCaConfirm': {\n id: 'manage.renewModal.ukCaConfirm',\n defaultMessage: 'Second checkbox only for UK and CA residents',\n description: 'Extra consent checkbox for UK and CA residents',\n },\n 'manage.renewModal.confirm': {\n id: 'manage.renewModal.confirm',\n defaultMessage: 'Confirm subscription',\n description: 'Confirm renew / reactivate button',\n },\n\n // Canceled expired / resubscribe\n 'manage.expired.heading': {\n id: 'manage.expired.heading',\n defaultMessage: 'Pick up where you left off',\n description: 'Section heading for expired / canceled without access (placeholder until final copy lands)',\n },\n 'manage.expired.subheading': {\n id: 'manage.expired.subheading',\n defaultMessage: 'You will manage your subscription here.',\n description: 'Section subheading for expired subscription state',\n },\n 'manage.expired.resubscribeTitle': {\n id: 'manage.expired.resubscribeTitle',\n defaultMessage: 'Resubscribe for ${price}/month {currency}',\n description: 'Resubscribe card title with price',\n },\n 'manage.expired.resubscribeTitleNoPrice': {\n id: 'manage.expired.resubscribeTitleNoPrice',\n defaultMessage: 'Resubscribe to edX Subscription',\n description: 'Resubscribe card title when price is unavailable',\n },\n 'manage.expired.canceledOn': {\n id: 'manage.expired.canceledOn',\n defaultMessage: 'You cancelled your subscription on {date}.',\n description: 'Resubscribe card cancelled-on line',\n },\n 'manage.expired.canceledOnNoDate': {\n id: 'manage.expired.canceledOnNoDate',\n defaultMessage: 'You cancelled your subscription.',\n description: 'Resubscribe card when cancel date is unknown',\n },\n\n // Cancel confirmation\n 'manage.cancel.title': {\n id: 'manage.cancel.title',\n defaultMessage: 'Are you sure you want to cancel?',\n description: 'Cancel confirmation page title',\n },\n 'manage.cancel.body': {\n id: 'manage.cancel.body',\n defaultMessage: 'If you cancel, you will lose access to all graded course content when your subscription expires on {date}. Your course progress will be saved if you re-subscribe within the calendar year.',\n description: 'Cancel confirmation body with period end date',\n },\n 'manage.cancel.bodyNoDate': {\n id: 'manage.cancel.bodyNoDate',\n defaultMessage: 'If you cancel, you will lose access to all graded course content when your subscription expires. Your course progress will be saved if you re-subscribe within the calendar year.',\n description: 'Cancel confirmation body without period end date',\n },\n 'manage.cancel.coursesHeading': {\n id: 'manage.cancel.coursesHeading',\n defaultMessage: 'Courses you are enrolled in ({count})',\n description: 'Heading for enrolled courses list on cancel confirmation',\n },\n 'manage.cancel.keep': {\n id: 'manage.cancel.keep',\n defaultMessage: 'No, keep my subscription',\n description: 'Secondary button to abort cancellation',\n },\n 'manage.cancel.confirm': {\n id: 'manage.cancel.confirm',\n defaultMessage: 'Yes, cancel subscription',\n description: 'Primary button to confirm cancellation',\n },\n 'manage.cancel.confirming': {\n id: 'manage.cancel.confirming',\n defaultMessage: 'Cancelling…',\n description: 'Cancel button label while mutation is in progress',\n },\n 'manage.cancel.error': {\n id: 'manage.cancel.error',\n defaultMessage: 'We could not cancel your subscription. Please try again.',\n description: 'Error when cancel mutation fails',\n },\n 'manage.cancel.viewCertificate': {\n id: 'manage.cancel.viewCertificate',\n defaultMessage: 'View certificate',\n description: 'View certificate button on enrolled course row',\n },\n\n // Cancel success\n 'manage.cancelSuccess.title': {\n id: 'manage.cancelSuccess.title',\n defaultMessage: 'Thank you for learning with us on edX. Your subscription is cancelled.',\n description: 'Cancel success page title',\n },\n 'manage.cancelSuccess.body': {\n id: 'manage.cancelSuccess.body',\n defaultMessage: 'Your edX Plus subscription has been cancelled and you will no longer be charged after {date}. You will receive a confirmation email shortly.',\n description: 'Cancel success body with last charge / access date',\n },\n 'manage.cancelSuccess.bodyNoDate': {\n id: 'manage.cancelSuccess.bodyNoDate',\n defaultMessage: 'Your edX Plus subscription has been cancelled and you will no longer be charged. You will receive a confirmation email shortly.',\n description: 'Cancel success body without date',\n },\n 'manage.cancelSuccess.return': {\n id: 'manage.cancelSuccess.return',\n defaultMessage: 'Return to Dashboard',\n description: 'Return to dashboard CTA after cancel success',\n },\n});\n\nexport default messages;\n"]}
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/components/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,QAAQ,GAAG,cAAc,CAAC;IAC9B,mBAAmB,EAAE;QACnB,EAAE,EAAE,mBAAmB;QACvB,cAAc,EAAE,4BAA4B;QAC5C,WAAW,EAAE,iDAAiD;KAC/D;IACD,gBAAgB,EAAE;QAChB,EAAE,EAAE,gBAAgB;QACpB,cAAc,EAAE,uBAAuB;QACvC,WAAW,EAAE,gDAAgD;KAC9D;IACD,cAAc,EAAE;QACd,EAAE,EAAE,cAAc;QAClB,cAAc,EAAE,8DAA8D;QAC9E,WAAW,EAAE,2CAA2C;KACzD;IACD,qBAAqB,EAAE;QACrB,EAAE,EAAE,qBAAqB;QACzB,cAAc,EAAE,eAAe;QAC/B,WAAW,EAAE,sDAAsD;KACpE;IACD,wBAAwB,EAAE;QACxB,EAAE,EAAE,wBAAwB;QAC5B,cAAc,EAAE,uDAAuD;QACvE,WAAW,EAAE,mCAAmC;KACjD;IACD,yBAAyB,EAAE;QACzB,EAAE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AW,EAAE,0DAA0D;KACxE;IACD,oBAAoB,EAAE;QACpB,EAAE,EAAE,oBAAoB;QACxB,cAAc,EAAE,0BAA0B;QAC1C,WAAW,EAAE,wCAAwC;KACtD;IACD,uBAAuB,EAAE;QACvB,EAAE,EAAE,uBAAuB;QAC3B,cAAc,EAAE,0BAA0B;QAC1C,WAAW,EAAE,wCAAwC;KACtD;IACD,0BAA0B,EAAE;QAC1B,EAAE,EAAE,0BAA0B;QAC9B,cAAc,EAAE,aAAa;QAC7B,WAAW,EAAE,mDAAmD;KACjE;IACD,qBAAqB,EAAE;QACrB,EAAE,EAAE,qBAAqB;QACzB,cAAc,EAAE,0DAA0D;QAC1E,WAAW,EAAE,kCAAkC;KAChD;IACD,+BAA+B,EAAE;QAC/B,EAAE,EAAE,+BAA+B;QACnC,cAAc,EAAE,kBAAkB;QAClC,WAAW,EAAE,gDAAgD;KAC9D;IAED,iBAAiB;IACjB,4BAA4B,EAAE;QAC5B,EAAE,EAAE,4BAA4B;QAChC,cAAc,EAAE,wEAAwE;QACxF,WAAW,EAAE,2BAA2B;KACzC;IACD,2BAA2B,EAAE;QAC3B,EAAE,EAAE,2BAA2B;QAC/B,cAAc,EAAE,8IAA8I;QAC9J,WAAW,EAAE,oDAAoD;KAClE;IACD,iCAAiC,EAAE;QACjC,EAAE,EAAE,iCAAiC;QACrC,cAAc,EAAE,iIAAiI;QACjJ,WAAW,EAAE,kCAAkC;KAChD;IACD,6BAA6B,EAAE;QAC7B,EAAE,EAAE,6BAA6B;QACjC,cAAc,EAAE,qBAAqB;QACrC,WAAW,EAAE,8CAA8C;KAC5D;CACF,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC","sourcesContent":["import { defineMessages } from '@openedx/frontend-base';\n\nconst messages = defineMessages({\n 'manage.page.title': {\n id: 'manage.page.title',\n defaultMessage: 'Order History | {siteName}',\n description: 'Document title for the manage subscription page',\n },\n 'manage.loading': {\n id: 'manage.loading',\n defaultMessage: 'Loading subscription…',\n description: 'Loading state for the manage subscription page',\n },\n 'manage.error': {\n id: 'manage.error',\n defaultMessage: 'We could not load your subscription. Please try again later.',\n description: 'Error alert when subscription fetch fails',\n },\n 'manage.header.title': {\n id: 'manage.header.title',\n defaultMessage: 'Order History',\n description: 'Page heading for order history / manage subscription',\n },\n 'manage.header.subtitle': {\n id: 'manage.header.subtitle',\n defaultMessage: 'View previous purchases and manage your subscription.',\n description: 'Page subtitle under Order History',\n },\n 'manage.tab.subscription': {\n id: 'manage.tab.subscription',\n defaultMessage: 'Subscription',\n description: 'Subscription tab label',\n },\n 'manage.tab.paymentHistory': {\n id: 'manage.tab.paymentHistory',\n defaultMessage: 'Payment history',\n description: 'Payment history tab label',\n },\n 'manage.paymentHistory.heading': {\n id: 'manage.paymentHistory.heading',\n defaultMessage: 'Payment history',\n description: 'Heading for the payment history panel',\n },\n 'manage.paymentHistory.nextPayment': {\n id: 'manage.paymentHistory.nextPayment',\n defaultMessage: 'Next payment scheduled for {date}.',\n description: 'Next payment line above the invoice list',\n },\n 'manage.paymentHistory.empty': {\n id: 'manage.paymentHistory.empty',\n defaultMessage: 'No payments yet.',\n description: 'Empty state when the learner has no invoices',\n },\n 'manage.paymentHistory.error': {\n id: 'manage.paymentHistory.error',\n defaultMessage: 'We could not load your payment history. Please try again later.',\n description: 'Error alert when invoice fetch fails',\n },\n 'manage.paymentHistory.noSubscription': {\n id: 'manage.paymentHistory.noSubscription',\n defaultMessage: 'Payment history is available after you subscribe.',\n description: 'Shown when there is no subscriptionBiId to query invoices',\n },\n 'manage.paymentHistory.tileTitle': {\n id: 'manage.paymentHistory.tileTitle',\n defaultMessage: 'edX Plus Subscription',\n description: 'Title on each payment history invoice tile',\n },\n 'manage.paymentHistory.startOfService': {\n id: 'manage.paymentHistory.startOfService',\n defaultMessage: 'Start of service:',\n description: 'Label for invoice period start on payment history tile',\n },\n 'manage.paymentHistory.totalCost': {\n id: 'manage.paymentHistory.totalCost',\n defaultMessage: 'Total cost:',\n description: 'Label for invoice total on payment history tile',\n },\n 'manage.paymentHistory.orderNumber': {\n id: 'manage.paymentHistory.orderNumber',\n defaultMessage: 'Order number:',\n description: 'Label for order number on payment history tile',\n },\n 'manage.paymentHistory.desc.trial': {\n id: 'manage.paymentHistory.desc.trial',\n defaultMessage: 'edX Plus Subscription — free trial',\n description: 'Description for a $0 trial invoice',\n },\n 'manage.paymentHistory.desc.paid': {\n id: 'manage.paymentHistory.desc.paid',\n defaultMessage: 'edX Plus Subscription',\n description: 'Description for a paid subscription invoice',\n },\n 'manage.paymentHistory.status.paid': {\n id: 'manage.paymentHistory.status.paid',\n defaultMessage: 'Paid',\n description: 'Invoice status label: PAID',\n },\n 'manage.paymentHistory.status.open': {\n id: 'manage.paymentHistory.status.open',\n defaultMessage: 'Open',\n description: 'Invoice status label: OPEN',\n },\n 'manage.paymentHistory.status.draft': {\n id: 'manage.paymentHistory.status.draft',\n defaultMessage: 'Draft',\n description: 'Invoice status label: DRAFT',\n },\n 'manage.help.prefix': {\n id: 'manage.help.prefix',\n defaultMessage: 'Need more help? Visit the',\n description: 'Prefix before Learner Help Center link',\n },\n 'manage.help.link': {\n id: 'manage.help.link',\n defaultMessage: 'Learner Help Center',\n description: 'Learner Help Center link text',\n },\n\n // Become a subscriber\n 'manage.none.heading': {\n id: 'manage.none.heading',\n defaultMessage: 'Become a subscriber',\n description: 'Section heading when user has no subscription',\n },\n 'manage.none.subheading': {\n id: 'manage.none.subheading',\n defaultMessage: 'You will manage your subscription here.',\n description: 'Section subheading when user has no subscription',\n },\n 'manage.none.cardTitle': {\n id: 'manage.none.cardTitle',\n defaultMessage: 'Try edX Subscription for free',\n description: 'Upsell card title for non-subscribers',\n },\n 'manage.none.cardBody': {\n id: 'manage.none.cardBody',\n defaultMessage: 'Get access to hundreds of courses for ${price}/month {currency}',\n description: 'Upsell card body including monthly price',\n },\n 'manage.none.cardBodyNoPrice': {\n id: 'manage.none.cardBodyNoPrice',\n defaultMessage: 'Get access to hundreds of courses with edX subscription',\n description: 'Upsell card body when price is unavailable',\n },\n 'manage.none.subscribe': {\n id: 'manage.none.subscribe',\n defaultMessage: 'Subscribe',\n description: 'Primary subscribe CTA',\n },\n 'manage.none.learnMore': {\n id: 'manage.none.learnMore',\n defaultMessage: 'Learn about edX Subscription',\n description: 'Secondary learn-more link on upsell card',\n },\n\n // Active\n 'manage.active.heading': {\n id: 'manage.active.heading',\n defaultMessage: 'Manage your subscription',\n description: 'Section heading for active subscribers',\n },\n 'manage.active.since': {\n id: 'manage.active.since',\n defaultMessage: 'Subscriber since {date}.',\n description: 'Subscriber since date line',\n },\n 'manage.active.statusMonthly': {\n id: 'manage.active.statusMonthly',\n defaultMessage: 'Active, Monthly Plan',\n description: 'Active monthly plan status label',\n },\n 'manage.active.statusAnnual': {\n id: 'manage.active.statusAnnual',\n defaultMessage: 'Active, Annual Plan',\n description: 'Active annual plan status label',\n },\n 'manage.active.nextPayment': {\n id: 'manage.active.nextPayment',\n defaultMessage: 'Your next payment is {date}.',\n description: 'Next payment date line for active subscribers',\n },\n 'manage.active.changeAnnual': {\n id: 'manage.active.changeAnnual',\n defaultMessage: 'Change to annual and save',\n description: 'CTA to switch to annual billing',\n },\n 'manage.active.updatePayment': {\n id: 'manage.active.updatePayment',\n defaultMessage: 'Update payment method',\n description: 'CTA to update payment method',\n },\n 'manage.updatePayment.title': {\n id: 'manage.updatePayment.title',\n defaultMessage: 'Update payment method.',\n description: 'Update payment method modal title',\n },\n 'manage.updatePayment.intro': {\n id: 'manage.updatePayment.intro',\n defaultMessage: 'By providing your card information, you allow edX to charge your card for future payments.',\n description: 'Update payment method modal intro copy',\n },\n 'manage.updatePayment.sectionTitle': {\n id: 'manage.updatePayment.sectionTitle',\n defaultMessage: 'Add new payment method',\n description: 'Heading above Stripe card fields',\n },\n 'manage.updatePayment.cardNumber': {\n id: 'manage.updatePayment.cardNumber',\n defaultMessage: 'Card number',\n description: 'Label for Stripe card number field',\n },\n 'manage.updatePayment.cvc': {\n id: 'manage.updatePayment.cvc',\n defaultMessage: 'Security code',\n description: 'Label for Stripe CVC field',\n },\n 'manage.updatePayment.expiry': {\n id: 'manage.updatePayment.expiry',\n defaultMessage: 'Expiration date',\n description: 'Label for Stripe expiry field',\n },\n 'manage.updatePayment.postal': {\n id: 'manage.updatePayment.postal',\n defaultMessage: 'Zip/Postal code',\n description: 'Label for postal code field',\n },\n 'manage.updatePayment.submit': {\n id: 'manage.updatePayment.submit',\n defaultMessage: 'Update card',\n description: 'Primary CTA to submit new payment method',\n },\n 'manage.updatePayment.submitting': {\n id: 'manage.updatePayment.submitting',\n defaultMessage: 'Updating…',\n description: 'Submit button label while update is in progress',\n },\n 'manage.updatePayment.close': {\n id: 'manage.updatePayment.close',\n defaultMessage: 'Close',\n description: 'Close button on update payment method modal',\n },\n 'manage.updatePayment.successTitle': {\n id: 'manage.updatePayment.successTitle',\n defaultMessage: 'Payment method updated.',\n description: 'Success modal title after payment method update',\n },\n 'manage.updatePayment.successBody': {\n id: 'manage.updatePayment.successBody',\n defaultMessage: 'Your new payment method will be applied on your next billing date, {date}.',\n description: 'Success modal body with next billing date',\n },\n 'manage.updatePayment.successBodyNoDate': {\n id: 'manage.updatePayment.successBodyNoDate',\n defaultMessage: 'Your new payment method will be applied on your next billing date.',\n description: 'Success modal body when next billing date is unknown',\n },\n 'manage.updatePayment.postalRequired': {\n id: 'manage.updatePayment.postalRequired',\n defaultMessage: 'Enter a zip/postal code.',\n description: 'Validation error when postal code is empty',\n },\n 'manage.updatePayment.error': {\n id: 'manage.updatePayment.error',\n defaultMessage: 'We could not update your payment method. Please try again.',\n description: 'Generic error when payment method update fails',\n },\n 'manage.updatePayment.invalidCard': {\n id: 'manage.updatePayment.invalidCard',\n defaultMessage: 'This card is not valid. Please try a different card.',\n description: 'Shown when the backend rejects the card during validation',\n },\n 'manage.updatePayment.stripeMissing': {\n id: 'manage.updatePayment.stripeMissing',\n defaultMessage: 'Payment updates are temporarily unavailable. Please try again later.',\n description: 'Shown when Stripe publishable key is not configured',\n },\n 'manage.active.cancelPrompt': {\n id: 'manage.active.cancelPrompt',\n defaultMessage: 'Need a break?',\n description: 'Prompt before cancel subscription link',\n },\n 'manage.active.cancelLink': {\n id: 'manage.active.cancelLink',\n defaultMessage: 'Cancel subscription',\n description: 'Cancel subscription link text',\n },\n\n // Canceled with access / renew banner\n 'manage.canceled.bannerTitle': {\n id: 'manage.canceled.bannerTitle',\n defaultMessage: 'Renew your subscription before it expires.',\n description: 'Expiring subscription banner title',\n },\n 'manage.canceled.bannerBody': {\n id: 'manage.canceled.bannerBody',\n defaultMessage: 'Your subscription is set to expire on {date} and you will have limited access to edX. Renew your subscription to keep your learning flexible.',\n description: 'Expiring subscription banner body',\n },\n 'manage.canceled.statusMonthly': {\n id: 'manage.canceled.statusMonthly',\n defaultMessage: 'Cancelled, Monthly plan',\n description: 'Cancelled monthly plan status label',\n },\n 'manage.canceled.statusAnnual': {\n id: 'manage.canceled.statusAnnual',\n defaultMessage: 'Cancelled, Annual plan',\n description: 'Cancelled annual plan status label',\n },\n 'manage.canceled.noPayments': {\n id: 'manage.canceled.noPayments',\n defaultMessage: 'You have no upcoming payments. You cancelled your subscription on {date}.',\n description: 'Cancelled status card body with cancel date',\n },\n 'manage.canceled.noPaymentsNoDate': {\n id: 'manage.canceled.noPaymentsNoDate',\n defaultMessage: 'You have no upcoming payments. You cancelled your subscription.',\n description: 'Cancelled status card body without cancel date',\n },\n 'manage.canceled.renew': {\n id: 'manage.canceled.renew',\n defaultMessage: 'Renew subscription',\n description: 'Renew subscription CTA',\n },\n 'manage.canceled.renewing': {\n id: 'manage.canceled.renewing',\n defaultMessage: 'Renewing…',\n description: 'Renew button label while reactivation mutation is in progress',\n },\n 'manage.canceled.renewError': {\n id: 'manage.canceled.renewError',\n defaultMessage: 'We could not renew your subscription. Please try again.',\n description: 'Error when reactivate mutation fails',\n },\n\n // Renew confirmation modal\n 'manage.renewModal.title': {\n id: 'manage.renewModal.title',\n defaultMessage: 'Renew your edX Plus subscription for ${price}/{frequency}',\n description: 'Renew modal title with price',\n },\n 'manage.renewModal.titleNoPrice': {\n id: 'manage.renewModal.titleNoPrice',\n defaultMessage: 'Renew your edX Plus subscription',\n description: 'Renew modal title when price is unavailable',\n },\n 'manage.renewModal.body': {\n id: 'manage.renewModal.body',\n defaultMessage: 'Your subscription will renew on {date} for ${price}/{frequency} {currency} (inclusive of applicable taxes). Cancel your subscription anytime from your dashboard. By clicking “Confirm subscription” you agree to our {termsLink}, and {refundLink}.',\n description: 'Renew modal body with terms links',\n },\n 'manage.renewModal.termsOfUse': {\n id: 'manage.renewModal.termsOfUse',\n defaultMessage: 'Terms of Use',\n description: 'Terms of Use link text in renew modal',\n },\n 'manage.renewModal.refundPolicy': {\n id: 'manage.renewModal.refundPolicy',\n defaultMessage: 'Refund Policy',\n description: 'Refund Policy link text in renew modal',\n },\n 'manage.renewModal.paymentMethod': {\n id: 'manage.renewModal.paymentMethod',\n defaultMessage: 'Payment Method',\n description: 'Payment method section heading in renew modal',\n },\n 'manage.renewModal.card': {\n id: 'manage.renewModal.card',\n defaultMessage: 'Card',\n description: 'Card payment method label in renew modal',\n },\n 'manage.renewModal.updatePayment': {\n id: 'manage.renewModal.updatePayment',\n defaultMessage: 'Update payment method',\n description: 'Update payment method button in renew modal',\n },\n 'manage.renewModal.recurringConfirm': {\n id: 'manage.renewModal.recurringConfirm',\n defaultMessage: 'I agree to enroll in a recurring {cycle} subscription for ${price}/{frequency} {currency}.',\n description: 'Recurring subscription consent checkbox',\n },\n 'manage.renewModal.ukCaConfirm': {\n id: 'manage.renewModal.ukCaConfirm',\n defaultMessage: 'Second checkbox only for UK and CA residents',\n description: 'Extra consent checkbox for UK and CA residents',\n },\n 'manage.renewModal.confirm': {\n id: 'manage.renewModal.confirm',\n defaultMessage: 'Confirm subscription',\n description: 'Confirm renew / reactivate button',\n },\n\n // Canceled expired / resubscribe\n 'manage.expired.heading': {\n id: 'manage.expired.heading',\n defaultMessage: 'Pick up where you left off',\n description: 'Section heading for expired / canceled without access (placeholder until final copy lands)',\n },\n 'manage.expired.subheading': {\n id: 'manage.expired.subheading',\n defaultMessage: 'You will manage your subscription here.',\n description: 'Section subheading for expired subscription state',\n },\n 'manage.expired.resubscribeTitle': {\n id: 'manage.expired.resubscribeTitle',\n defaultMessage: 'Resubscribe for ${price}/month {currency}',\n description: 'Resubscribe card title with price',\n },\n 'manage.expired.resubscribeTitleNoPrice': {\n id: 'manage.expired.resubscribeTitleNoPrice',\n defaultMessage: 'Resubscribe to edX Subscription',\n description: 'Resubscribe card title when price is unavailable',\n },\n 'manage.expired.canceledOn': {\n id: 'manage.expired.canceledOn',\n defaultMessage: 'You cancelled your subscription on {date}.',\n description: 'Resubscribe card cancelled-on line',\n },\n 'manage.expired.canceledOnNoDate': {\n id: 'manage.expired.canceledOnNoDate',\n defaultMessage: 'You cancelled your subscription.',\n description: 'Resubscribe card when cancel date is unknown',\n },\n\n // Cancel confirmation\n 'manage.cancel.title': {\n id: 'manage.cancel.title',\n defaultMessage: 'Are you sure you want to cancel?',\n description: 'Cancel confirmation page title',\n },\n 'manage.cancel.body': {\n id: 'manage.cancel.body',\n defaultMessage: 'If you cancel, you will lose access to all graded course content when your subscription expires on {date}. Your course progress will be saved if you re-subscribe within the calendar year.',\n description: 'Cancel confirmation body with period end date',\n },\n 'manage.cancel.bodyNoDate': {\n id: 'manage.cancel.bodyNoDate',\n defaultMessage: 'If you cancel, you will lose access to all graded course content when your subscription expires. Your course progress will be saved if you re-subscribe within the calendar year.',\n description: 'Cancel confirmation body without period end date',\n },\n 'manage.cancel.coursesHeading': {\n id: 'manage.cancel.coursesHeading',\n defaultMessage: 'Courses you are enrolled in ({count})',\n description: 'Heading for enrolled courses list on cancel confirmation',\n },\n 'manage.cancel.keep': {\n id: 'manage.cancel.keep',\n defaultMessage: 'No, keep my subscription',\n description: 'Secondary button to abort cancellation',\n },\n 'manage.cancel.confirm': {\n id: 'manage.cancel.confirm',\n defaultMessage: 'Yes, cancel subscription',\n description: 'Primary button to confirm cancellation',\n },\n 'manage.cancel.confirming': {\n id: 'manage.cancel.confirming',\n defaultMessage: 'Cancelling…',\n description: 'Cancel button label while mutation is in progress',\n },\n 'manage.cancel.error': {\n id: 'manage.cancel.error',\n defaultMessage: 'We could not cancel your subscription. Please try again.',\n description: 'Error when cancel mutation fails',\n },\n 'manage.cancel.viewCertificate': {\n id: 'manage.cancel.viewCertificate',\n defaultMessage: 'View certificate',\n description: 'View certificate button on enrolled course row',\n },\n\n // Cancel success\n 'manage.cancelSuccess.title': {\n id: 'manage.cancelSuccess.title',\n defaultMessage: 'Thank you for learning with us on edX. Your subscription is cancelled.',\n description: 'Cancel success page title',\n },\n 'manage.cancelSuccess.body': {\n id: 'manage.cancelSuccess.body',\n defaultMessage: 'Your edX Plus subscription has been cancelled and you will no longer be charged after {date}. You will receive a confirmation email shortly.',\n description: 'Cancel success body with last charge / access date',\n },\n 'manage.cancelSuccess.bodyNoDate': {\n id: 'manage.cancelSuccess.bodyNoDate',\n defaultMessage: 'Your edX Plus subscription has been cancelled and you will no longer be charged. You will receive a confirmation email shortly.',\n description: 'Cancel success body without date',\n },\n 'manage.cancelSuccess.return': {\n id: 'manage.cancelSuccess.return',\n defaultMessage: 'Return to Dashboard',\n description: 'Return to dashboard CTA after cancel success',\n },\n});\n\nexport default messages;\n"]}
|
|
@@ -33,5 +33,7 @@ export declare function useSubscriptionPaymentMethodQuery(client: ViaxGqlClient
|
|
|
33
33
|
export declare function useCancelSubscriptionMutation(client: ViaxGqlClient | null): UseMutationResult<Record<string, unknown> | null, Error, string>;
|
|
34
34
|
/** Undo pending cancellation before period end; refreshes subscriber view on success. */
|
|
35
35
|
export declare function useReactivateSubscriptionMutation(client: ViaxGqlClient | null): UseMutationResult<Record<string, unknown> | null, Error, string>;
|
|
36
|
+
/** Pre-check for a tokenized card; call before the update mutation attaches it. */
|
|
37
|
+
export declare function useValidateCartPaymentMethodMutation(client: ViaxGqlClient | null): UseMutationResult<Record<string, unknown> | null, Error, UpdatePaymentMethodArgs>;
|
|
36
38
|
/** Update default Stripe payment method on the subscription. */
|
|
37
39
|
export declare function useUpdatePaymentMethodMutation(client: ViaxGqlClient | null): UseMutationResult<Record<string, unknown> | null, Error, UpdatePaymentMethodArgs>;
|
|
@@ -24,6 +24,7 @@ import { getSubscriptionEnrollments } from '../services/subscription/getSubscrip
|
|
|
24
24
|
import { getSubscriptionPaymentMethod, } from '../services/subscription/getSubscriptionPaymentMethod';
|
|
25
25
|
import { reactivateSubscription } from '../services/subscription/reactivateSubscription';
|
|
26
26
|
import { updateSubscriptionPaymentMethod, } from '../services/subscription/updateSubscriptionPaymentMethod';
|
|
27
|
+
import { validateCartPaymentMethod } from '../services/subscription/validateCartPaymentMethod';
|
|
27
28
|
import { manageKeys } from './keys';
|
|
28
29
|
/** Shared Viax GraphQL client for the manage MFE (singleton per API URL). */
|
|
29
30
|
let cachedClient = null;
|
|
@@ -185,6 +186,17 @@ export function useReactivateSubscriptionMutation(client) {
|
|
|
185
186
|
}),
|
|
186
187
|
});
|
|
187
188
|
}
|
|
189
|
+
/** Pre-check for a tokenized card; call before the update mutation attaches it. */
|
|
190
|
+
export function useValidateCartPaymentMethodMutation(client) {
|
|
191
|
+
return useMutation({
|
|
192
|
+
mutationFn: (args) => {
|
|
193
|
+
if (!client) {
|
|
194
|
+
throw new Error('Viax client is not configured.');
|
|
195
|
+
}
|
|
196
|
+
return validateCartPaymentMethod(client.gql, args);
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
}
|
|
188
200
|
/** Update default Stripe payment method on the subscription. */
|
|
189
201
|
export function useUpdatePaymentMethodMutation(client) {
|
|
190
202
|
const queryClient = useQueryClient();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useManageQueries.js","sourceRoot":"","sources":["../../../src/data/hooks/useManageQueries.ts"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;AAEH,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC3C,O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,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;YACpD,CAAC;YACD,OAAO,+BAA+B,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC3D,CAAC;QACD,SAAS,EAAE,GAAG,EAAE;YACd,WAAW,CAAC,iBAAiB,CAAC,EAAE,QAAQ,EAAE,UAAU,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;YACvE,WAAW,CAAC,iBAAiB,CAAC;gBAC5B,QAAQ,EAAE,CAAC,GAAG,UAAU,CAAC,GAAG,EAAE,eAAe,CAAC;aAC/C,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Hooks for Viax session, subscriber status, enrollments, and cancel mutation.\n */\n\nimport { useEffect, useMemo } from 'react';\nimport {\n useMutation,\n useQuery,\n useQueryClient,\n type UseMutationResult,\n type UseQueryResult,\n} from '@tanstack/react-query';\nimport { getAppConfig, getSiteConfig } from '@openedx/frontend-base';\n\nimport { appId } from '../../constants';\nimport type {\n CurrentUserSubscriberResult,\n PaymentHistoryItem,\n SubscriptionEnrollment,\n BillingPlansResult,\n} from '../../types';\nimport { createGqlClient, type ViaxGqlClient } from '../../utils/graphqlClient';\nimport { fetchEdxSession, getEdxSessionUrl } from '../../utils/edxSession';\nimport { cancelSubscription } from '../services/subscription/cancelSubscription';\nimport { getBillingPlans } from '../services/subscription/getBillingPlans';\nimport { getIsCurrentUserSubscriber } from '../services/subscription/getIsCurrentUserSubscriber';\nimport { getPaymentHistory } from '../services/subscription/getPaymentHistory';\nimport { getSubscriptionEnrollments } from '../services/subscription/getSubscriptionEnrollments';\nimport {\n getSubscriptionPaymentMethod,\n type SubscriptionPaymentMethod,\n} from '../services/subscription/getSubscriptionPaymentMethod';\nimport { reactivateSubscription } from '../services/subscription/reactivateSubscription';\nimport {\n updateSubscriptionPaymentMethod,\n type UpdatePaymentMethodArgs,\n} from '../services/subscription/updateSubscriptionPaymentMethod';\nimport { manageKeys } from './keys';\n\n/** Shared Viax GraphQL client for the manage MFE (singleton per API URL). */\nlet cachedClient: ViaxGqlClient | null = null;\nlet cachedApiUrl: string | undefined;\n\nexport function useViaxClient(): ViaxGqlClient | null {\n const config = getAppConfig(appId);\n const apiUrl = config.VIAX_API_URL as string | undefined;\n\n return useMemo(() => {\n if (!apiUrl) {\n return null;\n }\n if (cachedClient && cachedApiUrl === apiUrl) {\n return cachedClient;\n }\n cachedClient = createGqlClient({ apiUrl });\n cachedApiUrl = apiUrl;\n return cachedClient;\n }, [apiUrl]);\n}\n\n/** Exchange edX session cookies for a Viax token. */\nexport function useViaxSessionQuery(): UseQueryResult<Awaited<ReturnType<typeof fetchEdxSession>>> {\n const sessionUrl = getSiteConfig().lmsBaseUrl\n ? getEdxSessionUrl()\n : null;\n\n return useQuery({\n queryKey: manageKeys.viaxSession(),\n enabled: !!sessionUrl,\n queryFn: () => fetchEdxSession(sessionUrl!),\n staleTime: 5 * 60 * 1000,\n retry: 1,\n });\n}\n\n/**\n * Applies the Viax token from the session query onto the GraphQL client.\n */\nexport function useViaxSession(client: ViaxGqlClient | null) {\n const sessionQuery = useViaxSessionQuery();\n\n useEffect(() => {\n if (client && sessionQuery.data?.viaxToken) {\n client.setToken(sessionQuery.data.viaxToken);\n }\n }, [client, sessionQuery.data?.viaxToken]);\n\n return {\n sessionReady: Boolean(client && sessionQuery.isSuccess && sessionQuery.data?.viaxToken),\n isSessionLoading: sessionQuery.isPending,\n isSessionError: sessionQuery.isError,\n sessionError: sessionQuery.error,\n };\n}\n\n/** Current user's subscription context. */\nexport function useIsSubscriberQuery(\n client: ViaxGqlClient | null,\n sessionReady: boolean,\n): UseQueryResult<CurrentUserSubscriberResult | null> {\n return useQuery({\n queryKey: manageKeys.isSubscriber(),\n enabled: !!client && sessionReady,\n queryFn: () => getIsCurrentUserSubscriber(client!.gql),\n staleTime: 2 * 60 * 1000,\n retry: 1,\n });\n}\n\n/** Available monthly / annual billing plans for price display. */\nexport function useBillingPlansQuery(\n client: ViaxGqlClient | null,\n sessionReady: boolean,\n): UseQueryResult<BillingPlansResult> {\n return useQuery({\n queryKey: manageKeys.billingPlans(),\n enabled: !!client && sessionReady,\n queryFn: () => getBillingPlans(client!.gql),\n staleTime: 10 * 60 * 1000,\n retry: 1,\n });\n}\n\n/** Enrollments for cancel confirmation. */\nexport function useSubscriptionEnrollmentsQuery(\n client: ViaxGqlClient | null,\n sessionReady: boolean,\n subscriptionBiIds: string | string[] | null | undefined,\n): UseQueryResult<SubscriptionEnrollment[]> {\n const ids = (Array.isArray(subscriptionBiIds)\n ? subscriptionBiIds\n : [subscriptionBiIds ?? ''])\n .map((id) => (id ?? '').trim())\n .filter(Boolean);\n const key = ids.join(',') || 'none';\n\n return useQuery({\n queryKey: manageKeys.enrollments(key),\n enabled: !!client && sessionReady && ids.length > 0,\n queryFn: () => getSubscriptionEnrollments(client!.gql, ids),\n staleTime: 60 * 1000,\n retry: 1,\n });\n}\n\n/** Invoices for the Payment history tab. */\nexport function usePaymentHistoryQuery(\n client: ViaxGqlClient | null,\n sessionReady: boolean,\n subscriptionBiId: string | null | undefined,\n): UseQueryResult<PaymentHistoryItem[]> {\n const sub = subscriptionBiId?.trim() || '';\n\n return useQuery({\n queryKey: manageKeys.paymentHistory(sub || 'none'),\n enabled: !!client && sessionReady && !!sub,\n queryFn: () => getPaymentHistory(client!.gql, sub),\n staleTime: 60 * 1000,\n retry: 1,\n });\n}\n\n/** Stripe payment method on file for renew / manage display. */\nexport function useSubscriptionPaymentMethodQuery(\n client: ViaxGqlClient | null,\n sessionReady: boolean,\n subscriptionBiId: string | null | undefined,\n enabled = true,\n): UseQueryResult<SubscriptionPaymentMethod | null> {\n const sub = subscriptionBiId?.trim() || '';\n\n return useQuery({\n queryKey: manageKeys.paymentMethod(sub || 'none'),\n enabled: !!client && sessionReady && !!sub && enabled,\n queryFn: () => getSubscriptionPaymentMethod(client!.gql, sub),\n staleTime: 60 * 1000,\n retry: 1,\n });\n}\n\n/** Cancel subscription mutation; invalidates subscriber query on success. */\nexport function useCancelSubscriptionMutation(\n client: ViaxGqlClient | null,\n): UseMutationResult<Record<string, unknown> | null, Error, string> {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (subscriptionBiId: string) => {\n if (!client) {\n throw new Error('Viax client is not configured.');\n }\n return cancelSubscription(client.gql, subscriptionBiId);\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: manageKeys.isSubscriber() });\n },\n });\n}\n\n/** Undo pending cancellation before period end; refreshes subscriber view on success. */\nexport function useReactivateSubscriptionMutation(\n client: ViaxGqlClient | null,\n): UseMutationResult<Record<string, unknown> | null, Error, string> {\n const queryClient = useQueryClient();\n\n const markActive = (\n prev: CurrentUserSubscriberResult | null | undefined,\n ): CurrentUserSubscriberResult | null => {\n if (!prev) {\n return prev ?? null;\n }\n return {\n ...prev,\n isSubscriber: true,\n canEnroll: true,\n status: 'ACTIVE',\n canceledAt: null,\n };\n };\n\n return useMutation({\n mutationFn: (subscriptionBiId: string) => {\n if (!client) {\n throw new Error('Viax client is not configured.');\n }\n return reactivateSubscription(client.gql, subscriptionBiId);\n },\n onSuccess: async () => {\n // Immediate UI flip to the active manage view.\n queryClient.setQueryData(manageKeys.isSubscriber(), markActive);\n\n await queryClient.refetchQueries({ queryKey: manageKeys.isSubscriber() });\n\n // If the read-after-write still shows a cancel status, keep the active view\n // (reactivate already succeeded).\n queryClient.setQueryData(\n manageKeys.isSubscriber(),\n (prev: CurrentUserSubscriberResult | null | undefined) => {\n if (!prev) {\n return prev ?? null;\n }\n const status = (prev.status ?? '').toUpperCase();\n const stillCanceled = (\n status.includes('CANCEL')\n );\n return stillCanceled ? markActive(prev) : {\n ...prev,\n canceledAt: null,\n };\n },\n );\n\n await queryClient.invalidateQueries({\n queryKey: [...manageKeys.all, 'paymentHistory'],\n });\n },\n });\n}\n\n/** Update default Stripe payment method on the subscription. */\nexport function useUpdatePaymentMethodMutation(\n client: ViaxGqlClient | null,\n): UseMutationResult<Record<string, unknown> | null, Error, UpdatePaymentMethodArgs> {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (args: UpdatePaymentMethodArgs) => {\n if (!client) {\n throw new Error('Viax client is not configured.');\n }\n return updateSubscriptionPaymentMethod(client.gql, args);\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: manageKeys.isSubscriber() });\n queryClient.invalidateQueries({\n queryKey: [...manageKeys.all, 'paymentMethod'],\n });\n },\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useManageQueries.js","sourceRoot":"","sources":["../../../src/data/hooks/useManageQueries.ts"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;;AAEH,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EACL,WAAW,EACX,QAAQ,EACR,cAAc,GAGf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAErE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAOxC,OAAO,EAAE,eAAe,EAAsB,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,qDAAqD,CAAC;AACjG,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAC/E,OAAO,EAAE,0BAA0B,EAAE,MAAM,qDAAqD,CAAC;AACjG,OAAO,EACL,4BAA4B,GAE7B,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,iDAAiD,CAAC;AACzF,OAAO,EACL,+BAA+B,GAEhC,MAAM,0DAA0D,CAAC;AAClE,OAAO,EAAE,yBAAy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AC/C,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Hooks for Viax session, subscriber status, enrollments, and cancel mutation.\n */\n\nimport { useEffect, useMemo } from 'react';\nimport {\n useMutation,\n useQuery,\n useQueryClient,\n type UseMutationResult,\n type UseQueryResult,\n} from '@tanstack/react-query';\nimport { getAppConfig, getSiteConfig } from '@openedx/frontend-base';\n\nimport { appId } from '../../constants';\nimport type {\n CurrentUserSubscriberResult,\n PaymentHistoryItem,\n SubscriptionEnrollment,\n BillingPlansResult,\n} from '../../types';\nimport { createGqlClient, type ViaxGqlClient } from '../../utils/graphqlClient';\nimport { fetchEdxSession, getEdxSessionUrl } from '../../utils/edxSession';\nimport { cancelSubscription } from '../services/subscription/cancelSubscription';\nimport { getBillingPlans } from '../services/subscription/getBillingPlans';\nimport { getIsCurrentUserSubscriber } from '../services/subscription/getIsCurrentUserSubscriber';\nimport { getPaymentHistory } from '../services/subscription/getPaymentHistory';\nimport { getSubscriptionEnrollments } from '../services/subscription/getSubscriptionEnrollments';\nimport {\n getSubscriptionPaymentMethod,\n type SubscriptionPaymentMethod,\n} from '../services/subscription/getSubscriptionPaymentMethod';\nimport { reactivateSubscription } from '../services/subscription/reactivateSubscription';\nimport {\n updateSubscriptionPaymentMethod,\n type UpdatePaymentMethodArgs,\n} from '../services/subscription/updateSubscriptionPaymentMethod';\nimport { validateCartPaymentMethod } from '../services/subscription/validateCartPaymentMethod';\nimport { manageKeys } from './keys';\n\n/** Shared Viax GraphQL client for the manage MFE (singleton per API URL). */\nlet cachedClient: ViaxGqlClient | null = null;\nlet cachedApiUrl: string | undefined;\n\nexport function useViaxClient(): ViaxGqlClient | null {\n const config = getAppConfig(appId);\n const apiUrl = config.VIAX_API_URL as string | undefined;\n\n return useMemo(() => {\n if (!apiUrl) {\n return null;\n }\n if (cachedClient && cachedApiUrl === apiUrl) {\n return cachedClient;\n }\n cachedClient = createGqlClient({ apiUrl });\n cachedApiUrl = apiUrl;\n return cachedClient;\n }, [apiUrl]);\n}\n\n/** Exchange edX session cookies for a Viax token. */\nexport function useViaxSessionQuery(): UseQueryResult<Awaited<ReturnType<typeof fetchEdxSession>>> {\n const sessionUrl = getSiteConfig().lmsBaseUrl\n ? getEdxSessionUrl()\n : null;\n\n return useQuery({\n queryKey: manageKeys.viaxSession(),\n enabled: !!sessionUrl,\n queryFn: () => fetchEdxSession(sessionUrl!),\n staleTime: 5 * 60 * 1000,\n retry: 1,\n });\n}\n\n/**\n * Applies the Viax token from the session query onto the GraphQL client.\n */\nexport function useViaxSession(client: ViaxGqlClient | null) {\n const sessionQuery = useViaxSessionQuery();\n\n useEffect(() => {\n if (client && sessionQuery.data?.viaxToken) {\n client.setToken(sessionQuery.data.viaxToken);\n }\n }, [client, sessionQuery.data?.viaxToken]);\n\n return {\n sessionReady: Boolean(client && sessionQuery.isSuccess && sessionQuery.data?.viaxToken),\n isSessionLoading: sessionQuery.isPending,\n isSessionError: sessionQuery.isError,\n sessionError: sessionQuery.error,\n };\n}\n\n/** Current user's subscription context. */\nexport function useIsSubscriberQuery(\n client: ViaxGqlClient | null,\n sessionReady: boolean,\n): UseQueryResult<CurrentUserSubscriberResult | null> {\n return useQuery({\n queryKey: manageKeys.isSubscriber(),\n enabled: !!client && sessionReady,\n queryFn: () => getIsCurrentUserSubscriber(client!.gql),\n staleTime: 2 * 60 * 1000,\n retry: 1,\n });\n}\n\n/** Available monthly / annual billing plans for price display. */\nexport function useBillingPlansQuery(\n client: ViaxGqlClient | null,\n sessionReady: boolean,\n): UseQueryResult<BillingPlansResult> {\n return useQuery({\n queryKey: manageKeys.billingPlans(),\n enabled: !!client && sessionReady,\n queryFn: () => getBillingPlans(client!.gql),\n staleTime: 10 * 60 * 1000,\n retry: 1,\n });\n}\n\n/** Enrollments for cancel confirmation. */\nexport function useSubscriptionEnrollmentsQuery(\n client: ViaxGqlClient | null,\n sessionReady: boolean,\n subscriptionBiIds: string | string[] | null | undefined,\n): UseQueryResult<SubscriptionEnrollment[]> {\n const ids = (Array.isArray(subscriptionBiIds)\n ? subscriptionBiIds\n : [subscriptionBiIds ?? ''])\n .map((id) => (id ?? '').trim())\n .filter(Boolean);\n const key = ids.join(',') || 'none';\n\n return useQuery({\n queryKey: manageKeys.enrollments(key),\n enabled: !!client && sessionReady && ids.length > 0,\n queryFn: () => getSubscriptionEnrollments(client!.gql, ids),\n staleTime: 60 * 1000,\n retry: 1,\n });\n}\n\n/** Invoices for the Payment history tab. */\nexport function usePaymentHistoryQuery(\n client: ViaxGqlClient | null,\n sessionReady: boolean,\n subscriptionBiId: string | null | undefined,\n): UseQueryResult<PaymentHistoryItem[]> {\n const sub = subscriptionBiId?.trim() || '';\n\n return useQuery({\n queryKey: manageKeys.paymentHistory(sub || 'none'),\n enabled: !!client && sessionReady && !!sub,\n queryFn: () => getPaymentHistory(client!.gql, sub),\n staleTime: 60 * 1000,\n retry: 1,\n });\n}\n\n/** Stripe payment method on file for renew / manage display. */\nexport function useSubscriptionPaymentMethodQuery(\n client: ViaxGqlClient | null,\n sessionReady: boolean,\n subscriptionBiId: string | null | undefined,\n enabled = true,\n): UseQueryResult<SubscriptionPaymentMethod | null> {\n const sub = subscriptionBiId?.trim() || '';\n\n return useQuery({\n queryKey: manageKeys.paymentMethod(sub || 'none'),\n enabled: !!client && sessionReady && !!sub && enabled,\n queryFn: () => getSubscriptionPaymentMethod(client!.gql, sub),\n staleTime: 60 * 1000,\n retry: 1,\n });\n}\n\n/** Cancel subscription mutation; invalidates subscriber query on success. */\nexport function useCancelSubscriptionMutation(\n client: ViaxGqlClient | null,\n): UseMutationResult<Record<string, unknown> | null, Error, string> {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (subscriptionBiId: string) => {\n if (!client) {\n throw new Error('Viax client is not configured.');\n }\n return cancelSubscription(client.gql, subscriptionBiId);\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: manageKeys.isSubscriber() });\n },\n });\n}\n\n/** Undo pending cancellation before period end; refreshes subscriber view on success. */\nexport function useReactivateSubscriptionMutation(\n client: ViaxGqlClient | null,\n): UseMutationResult<Record<string, unknown> | null, Error, string> {\n const queryClient = useQueryClient();\n\n const markActive = (\n prev: CurrentUserSubscriberResult | null | undefined,\n ): CurrentUserSubscriberResult | null => {\n if (!prev) {\n return prev ?? null;\n }\n return {\n ...prev,\n isSubscriber: true,\n canEnroll: true,\n status: 'ACTIVE',\n canceledAt: null,\n };\n };\n\n return useMutation({\n mutationFn: (subscriptionBiId: string) => {\n if (!client) {\n throw new Error('Viax client is not configured.');\n }\n return reactivateSubscription(client.gql, subscriptionBiId);\n },\n onSuccess: async () => {\n // Immediate UI flip to the active manage view.\n queryClient.setQueryData(manageKeys.isSubscriber(), markActive);\n\n await queryClient.refetchQueries({ queryKey: manageKeys.isSubscriber() });\n\n // If the read-after-write still shows a cancel status, keep the active view\n // (reactivate already succeeded).\n queryClient.setQueryData(\n manageKeys.isSubscriber(),\n (prev: CurrentUserSubscriberResult | null | undefined) => {\n if (!prev) {\n return prev ?? null;\n }\n const status = (prev.status ?? '').toUpperCase();\n const stillCanceled = (\n status.includes('CANCEL')\n );\n return stillCanceled ? markActive(prev) : {\n ...prev,\n canceledAt: null,\n };\n },\n );\n\n await queryClient.invalidateQueries({\n queryKey: [...manageKeys.all, 'paymentHistory'],\n });\n },\n });\n}\n\n/** Pre-check for a tokenized card; call before the update mutation attaches it. */\nexport function useValidateCartPaymentMethodMutation(\n client: ViaxGqlClient | null,\n): UseMutationResult<Record<string, unknown> | null, Error, UpdatePaymentMethodArgs> {\n return useMutation({\n mutationFn: (args: UpdatePaymentMethodArgs) => {\n if (!client) {\n throw new Error('Viax client is not configured.');\n }\n return validateCartPaymentMethod(client.gql, args);\n },\n });\n}\n\n/** Update default Stripe payment method on the subscription. */\nexport function useUpdatePaymentMethodMutation(\n client: ViaxGqlClient | null,\n): UseMutationResult<Record<string, unknown> | null, Error, UpdatePaymentMethodArgs> {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (args: UpdatePaymentMethodArgs) => {\n if (!client) {\n throw new Error('Viax client is not configured.');\n }\n return updateSubscriptionPaymentMethod(client.gql, args);\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: manageKeys.isSubscriber() });\n queryClient.invalidateQueries({\n queryKey: [...manageKeys.all, 'paymentMethod'],\n });\n },\n });\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { GqlRunner } from '../../../types';
|
|
2
|
+
import type { UpdatePaymentMethodArgs } from './updateSubscriptionPaymentMethod';
|
|
3
|
+
/**
|
|
4
|
+
* Thrown when Viax rejects the card (`success: false`). `reason` holds the raw
|
|
5
|
+
* backend text, which is diagnostic and not safe to show to a learner.
|
|
6
|
+
*/
|
|
7
|
+
export declare class PaymentMethodValidationError extends Error {
|
|
8
|
+
reason: string | null;
|
|
9
|
+
constructor(reason: string | null);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Validate a tokenized card before it is attached (`tValidateCartPaymentMethod`).
|
|
13
|
+
* Same arguments as the update mutation; throws when the card is rejected.
|
|
14
|
+
*/
|
|
15
|
+
export declare function validateCartPaymentMethod(gql: GqlRunner, { biId, tStripePaymentMethodId }: UpdatePaymentMethodArgs): Promise<Record<string, unknown> | null>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { VALIDATE_CART_PAYMENT_METHOD } from '../../../utils/queries';
|
|
11
|
+
/**
|
|
12
|
+
* Thrown when Viax rejects the card (`success: false`). `reason` holds the raw
|
|
13
|
+
* backend text, which is diagnostic and not safe to show to a learner.
|
|
14
|
+
*/
|
|
15
|
+
export class PaymentMethodValidationError extends Error {
|
|
16
|
+
constructor(reason) {
|
|
17
|
+
super(reason !== null && reason !== void 0 ? reason : 'Payment method validation failed.');
|
|
18
|
+
this.name = 'PaymentMethodValidationError';
|
|
19
|
+
this.reason = reason;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Validate a tokenized card before it is attached (`tValidateCartPaymentMethod`).
|
|
24
|
+
* Same arguments as the update mutation; throws when the card is rejected.
|
|
25
|
+
*/
|
|
26
|
+
export function validateCartPaymentMethod(gql_1, _a) {
|
|
27
|
+
return __awaiter(this, arguments, void 0, function* (gql, { biId, tStripePaymentMethodId }) {
|
|
28
|
+
const data = yield gql(VALIDATE_CART_PAYMENT_METHOD, {
|
|
29
|
+
biId,
|
|
30
|
+
tStripePaymentMethodId,
|
|
31
|
+
});
|
|
32
|
+
const result = data === null || data === void 0 ? void 0 : data.tValidateCartPaymentMethod;
|
|
33
|
+
if (result && typeof result === 'object') {
|
|
34
|
+
const payload = result;
|
|
35
|
+
if (payload.success === false) {
|
|
36
|
+
throw new PaymentMethodValidationError(payload.error ? String(payload.error) : null);
|
|
37
|
+
}
|
|
38
|
+
return payload;
|
|
39
|
+
}
|
|
40
|
+
return result ? { result } : null;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=validateCartPaymentMethod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateCartPaymentMethod.js","sourceRoot":"","sources":["../../../../src/data/services/subscription/validateCartPaymentMethod.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAGtE;;;GAGG;AACH,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IAGrD,YAAY,MAAqB;QAC/B,KAAK,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,mCAAmC,CAAC,CAAC;QACrD,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;QAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAgB,yBAAyB;yDAC7C,GAAc,EACd,EAAE,IAAI,EAAE,sBAAsB,EAA2B;QAEzD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,4BAA4B,EAAE;YACnD,IAAI;YACJ,sBAAsB;SACvB,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,0BAA0B,CAAC;QAEhD,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YACzC,MAAM,OAAO,GAAG,MAAiC,CAAC;YAClD,IAAI,OAAO,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;gBAC9B,MAAM,IAAI,4BAA4B,CACpC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAC7C,CAAC;YACJ,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,OAAO,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACpC,CAAC;CAAA","sourcesContent":["import type { GqlRunner } from '../../../types';\nimport { VALIDATE_CART_PAYMENT_METHOD } from '../../../utils/queries';\nimport type { UpdatePaymentMethodArgs } from './updateSubscriptionPaymentMethod';\n\n/**\n * Thrown when Viax rejects the card (`success: false`). `reason` holds the raw\n * backend text, which is diagnostic and not safe to show to a learner.\n */\nexport class PaymentMethodValidationError extends Error {\n reason: string | null;\n\n constructor(reason: string | null) {\n super(reason ?? 'Payment method validation failed.');\n this.name = 'PaymentMethodValidationError';\n this.reason = reason;\n }\n}\n\n/**\n * Validate a tokenized card before it is attached (`tValidateCartPaymentMethod`).\n * Same arguments as the update mutation; throws when the card is rejected.\n */\nexport async function validateCartPaymentMethod(\n gql: GqlRunner,\n { biId, tStripePaymentMethodId }: UpdatePaymentMethodArgs,\n): Promise<Record<string, unknown> | null> {\n const data = await gql(VALIDATE_CART_PAYMENT_METHOD, {\n biId,\n tStripePaymentMethodId,\n });\n const result = data?.tValidateCartPaymentMethod;\n\n if (result && typeof result === 'object') {\n const payload = result as Record<string, unknown>;\n if (payload.success === false) {\n throw new PaymentMethodValidationError(\n payload.error ? String(payload.error) : null,\n );\n }\n return payload;\n }\n\n return result ? { result } : null;\n}\n"]}
|
package/dist/utils/edxSession.js
CHANGED
|
@@ -16,8 +16,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
16
16
|
import { EnvironmentTypes, getSiteConfig } from '@openedx/frontend-base';
|
|
17
17
|
/** Hardcoded edX JWT used only for local/dev against Viax (same pattern as enroll/checkout MFEs). */
|
|
18
18
|
const DEV_SESSION_BODY = {
|
|
19
|
-
payload: 'eyJhbGciOiJSUzUxMiIsImtpZCI6Imxtc3N0YWdlMDAyIiwidHlwIjoiSldUIn0.
|
|
20
|
-
signature: '
|
|
19
|
+
payload: 'eyJhbGciOiJSUzUxMiIsImtpZCI6Imxtc3N0YWdlMDAyIiwidHlwIjoiSldUIn0.eyJhdWQiOiJJbmtvY3VqTGlreXVjc0Vkd2lXYXRkZWJyRWFja21ldkxha0R1aWZLb29zaGtha1dvdyIsImV4cCI6MTc4OTA2NjY0OCwiZ3JhbnRfdHlwZSI6InBhc3N3b3JkIiwiaWF0IjoxNzg5MDYzMDQ4LCJpc3MiOiJodHRwczovL2NvdXJzZXMuc3RhZ2UuZWR4Lm9yZy9vYXV0aDIiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJBRF8yNjA4X1FGT0MiLCJzY29wZXMiOlsidXNlcl9pZCIsImVtYWlsIiwicHJvZmlsZSJdLCJ2ZXJzaW9uIjoiMS4yLjAiLCJzdWIiOiJkNjcwZjVkMTVjZDZhMjNlODhhZWU1ZmE4YmM1YjllNCIsImZpbHRlcnMiOlsidXNlcjptZSJdLCJpc19yZXN0cmljdGVkIjpmYWxzZSwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJ1c2VyX2lkIjo1Mjg1MTM2LCJlbWFpbCI6Im90Y2F6ZGlycXh3eWJvenJwekB2dG1wai5jb20iLCJuYW1lIjoiQWthc2ggRGV2Z2FuIiwiZmFtaWx5X25hbWUiOiIiLCJnaXZlbl9uYW1lIjoiIiwiYWRtaW5pc3RyYXRvciI6ZmFsc2UsInN1cGVydXNlciI6ZmFsc2V9',
|
|
20
|
+
signature: 'FljhOKGbMyrew2NOCGbL75crdYatXPfUtFTIX3JiDcszj6TP6zctqedvYT4mY0bkqSIzwAcZ5kAzqP9vfnDEhin_XcrR93yiQM4E7B5X8EJ8LbV7TJ4xbn39yZY2J1IunaYhUyjSawPHTPiUW7V1vTgsWgUUmodOrndTzSazcOfl5Sc_Ns_Th5HJ1_WeCzveAwLgtHGUCq0cu1TEr-aPPThNcNYWfn1pofa3Ai--OemzORb7V0S7GbI27TjYW0m0ngaifrxp-DeBr9iUFR7feLAMZ4fksp4s2cRHYhHC6fAqKtA8bOLSa7rDSpkMgYQzJetuTXGjM0SrwPrPd12d2w'
|
|
21
21
|
};
|
|
22
22
|
function parseSessionResponse(data) {
|
|
23
23
|
var _a, _b, _c, _d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edxSession.js","sourceRoot":"","sources":["../../src/utils/edxSession.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;;;;;;;;;AAEH,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAWzE,qGAAqG;AACrG,MAAM,gBAAgB,GAAG;IACvB,OAA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AC;AACtD,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAgB,eAAe,CAAC,UAAkB;;QACtD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,UAAU,EAAE;YAClC,MAAM,EAAE,MAAM;YACd,WAAW,EAAE,SAAS;YACtB,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;gBAC1B,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,SAAS;SACrE,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CACb,gCAAgC,GAAG,CAAC,MAAM,uCAAuC,CAClF,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAkD,CAAC;QAC9E,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACtC,CAAC;QAED,OAAO,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CAAA","sourcesContent":["/**\n * Exchange the learner's edX session for a Viax JWT.\n *\n * Dev uses POST with a hardcoded JWT payload (local LMS cookie exchange is\n * unavailable). Stage/prod use POST with browser session cookies.\n */\n\nimport { EnvironmentTypes, getSiteConfig } from '@openedx/frontend-base';\n\nexport interface EdxSessionResult {\n viaxToken: string,\n customerUid: string,\n partyUid?: string,\n edxUserId?: string,\n username?: string,\n email?: string,\n}\n\n/** Hardcoded edX JWT used only for local/dev against Viax (same pattern as enroll/checkout MFEs). */\nconst DEV_SESSION_BODY = {\n payload: 'eyJhbGciOiJSUzUxMiIsImtpZCI6Imxtc3N0YWdlMDAyIiwidHlwIjoiSldUIn0.eyJhdWQiOiJJbmtvY3VqTGlreXVjc0Vkd2lXYXRkZWJyRWFja21ldkxha0R1aWZLb29zaGtha1dvdyIsImV4cCI6MTc4OTA2NjY0OCwiZ3JhbnRfdHlwZSI6InBhc3N3b3JkIiwiaWF0IjoxNzg5MDYzMDQ4LCJpc3MiOiJodHRwczovL2NvdXJzZXMuc3RhZ2UuZWR4Lm9yZy9vYXV0aDIiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJBRF8yNjA4X1FGT0MiLCJzY29wZXMiOlsidXNlcl9pZCIsImVtYWlsIiwicHJvZmlsZSJdLCJ2ZXJzaW9uIjoiMS4yLjAiLCJzdWIiOiJkNjcwZjVkMTVjZDZhMjNlODhhZWU1ZmE4YmM1YjllNCIsImZpbHRlcnMiOlsidXNlcjptZSJdLCJpc19yZXN0cmljdGVkIjpmYWxzZSwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJ1c2VyX2lkIjo1Mjg1MTM2LCJlbWFpbCI6Im90Y2F6ZGlycXh3eWJvenJwekB2dG1wai5jb20iLCJuYW1lIjoiQWthc2ggRGV2Z2FuIiwiZmFtaWx5X25hbWUiOiIiLCJnaXZlbl9uYW1lIjoiIiwiYWRtaW5pc3RyYXRvciI6ZmFsc2UsInN1cGVydXNlciI6ZmFsc2V9',\n signature: 'FljhOKGbMyrew2NOCGbL75crdYatXPfUtFTIX3JiDcszj6TP6zctqedvYT4mY0bkqSIzwAcZ5kAzqP9vfnDEhin_XcrR93yiQM4E7B5X8EJ8LbV7TJ4xbn39yZY2J1IunaYhUyjSawPHTPiUW7V1vTgsWgUUmodOrndTzSazcOfl5Sc_Ns_Th5HJ1_WeCzveAwLgtHGUCq0cu1TEr-aPPThNcNYWfn1pofa3Ai--OemzORb7V0S7GbI27TjYW0m0ngaifrxp-DeBr9iUFR7feLAMZ4fksp4s2cRHYhHC6fAqKtA8bOLSa7rDSpkMgYQzJetuTXGjM0SrwPrPd12d2w'\n};\n\nfunction parseSessionResponse(data: Record<string, unknown>): EdxSessionResult {\n const viaxToken = (\n data.viaxToken ?? data.token ?? data.access_token ?? data.accessToken\n ) as string | undefined;\n const customerUid = (data.customerUid ?? data.customer_uid) as string | undefined;\n\n if (!viaxToken) {\n throw new Error('Session response missing viax token.');\n }\n if (!customerUid) {\n throw new Error('Session response missing customerUid.');\n }\n\n return {\n viaxToken,\n customerUid,\n partyUid: data.partyUid as string | undefined,\n edxUserId: data.edxUserId as string | undefined,\n username: data.username as string | undefined,\n email: data.email as string | undefined,\n };\n}\n\nfunction isDevelopment(): boolean {\n return getSiteConfig().environment === EnvironmentTypes.DEVELOPMENT;\n}\n\n/** LMS edx-session endpoint for the current site. */\nexport function getEdxSessionUrl(): string {\n return isDevelopment()\n ? 'https://courses.stage.edx.org/api/edx-session'\n : `${getSiteConfig().lmsBaseUrl}/api/edx-session`;\n}\n\n/** Exchange the learner's edX session for a Viax token. */\nexport async function fetchEdxSession(sessionUrl: string): Promise<EdxSessionResult> {\n const res = await fetch(sessionUrl, {\n method: 'POST',\n credentials: 'include',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: isDevelopment() ? JSON.stringify(DEV_SESSION_BODY) : undefined,\n });\n\n if (!res.ok) {\n throw new Error(\n `Failed to establish session (${res.status}). Please log into edX and try again.`,\n );\n }\n\n const data = await res.json() as Record<string, unknown> & { error?: string };\n if (data.error) {\n throw new Error(String(data.error));\n }\n\n return parseSessionResponse(data);\n}\n"]}
|
package/dist/utils/queries.d.ts
CHANGED
|
@@ -34,6 +34,11 @@ export declare const GET_SUBSCRIPTION_PAYMENT_METHOD = "query SubscriptionPaymen
|
|
|
34
34
|
* Same query as frontend-app-subscription-checkout.
|
|
35
35
|
*/
|
|
36
36
|
export declare const GET_BILLING_PLANS = "query GetBillingPlans {\n filterCustomerBillingPlan(_first: 10) {\n edges {\n node {\n uid\n tStripePriceId\n tStripeAmount {\n amount\n units { code }\n }\n bipIsTemplate\n bipOwnershipModel { uid omName }\n }\n }\n }\n}";
|
|
37
|
+
/**
|
|
38
|
+
* Validate a tokenized card (pm_…) before attaching it to the subscription.
|
|
39
|
+
* Runs after stripe.createPaymentMethod, before UPDATE_SUBSCRIPTION_PAYMENT_METHOD.
|
|
40
|
+
*/
|
|
41
|
+
export declare const VALIDATE_CART_PAYMENT_METHOD = "mutation ValidateCartPaymentMethod(\n $biId: String!\n $tStripePaymentMethodId: String!\n) {\n tValidateCartPaymentMethod(\n biId: $biId\n tStripePaymentMethodId: $tStripePaymentMethodId\n )\n}";
|
|
37
42
|
/**
|
|
38
43
|
* Attach a new Stripe payment method (pm_…) as the subscription default.
|
|
39
44
|
*/
|
package/dist/utils/queries.js
CHANGED
|
@@ -115,6 +115,19 @@ export const GET_BILLING_PLANS = `query GetBillingPlans {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
}`;
|
|
118
|
+
/**
|
|
119
|
+
* Validate a tokenized card (pm_…) before attaching it to the subscription.
|
|
120
|
+
* Runs after stripe.createPaymentMethod, before UPDATE_SUBSCRIPTION_PAYMENT_METHOD.
|
|
121
|
+
*/
|
|
122
|
+
export const VALIDATE_CART_PAYMENT_METHOD = `mutation ValidateCartPaymentMethod(
|
|
123
|
+
$biId: String!
|
|
124
|
+
$tStripePaymentMethodId: String!
|
|
125
|
+
) {
|
|
126
|
+
tValidateCartPaymentMethod(
|
|
127
|
+
biId: $biId
|
|
128
|
+
tStripePaymentMethodId: $tStripePaymentMethodId
|
|
129
|
+
)
|
|
130
|
+
}`;
|
|
118
131
|
/**
|
|
119
132
|
* Attach a new Stripe payment method (pm_…) as the subscription default.
|
|
120
133
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../src/utils/queries.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG;;EAE5C,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG;;;;;;;;;;;;;;;;;;;;;;;EAuB1C,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;EAkBjC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;EAEjC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;;EAErC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG;;;;;;;;;;;;;;;;;;;EAmB7C,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;EAe/B,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG;;;;;;;;EAQhD,CAAC","sourcesContent":["/**\n * GraphQL documents for the manage-subscription MFE.\n */\n\n/**\n * tIsCurrentUserSubscriber is a JSON scalar — returns the full object;\n * no subfield selection is allowed.\n */\nexport const GET_IS_CURRENT_USER_SUBSCRIBER = `query IsCurrentUserSubscriber {\n tIsCurrentUserSubscriber\n}`;\n\n/**\n * Enrollments for cancel confirmation.\n * Build `_filter` client-side, e.g. tSubscriptionBiId IN ('BI…', 'BI…').\n */\nexport const GET_SUBSCRIPTION_ENROLLMENTS = `query EnrollmentsForSubscriptions($filter: String!) {\n filterTwouEnrollment(_first: 200, _filter: $filter) {\n edges {\n node {\n biId\n tSubscriptionBiId\n bpStatus { code }\n tCourseRunKey\n tCertificateId\n tCertificateUrl\n tCourse {\n maId\n maName\n imageUrl\n tBrandText\n tSchools {\n tName\n tSortValue\n }\n }\n }\n }\n }\n}`;\n\n/**\n * Invoices for the learner's subscription (payment history).\n * Filter is inlined client-side: biRelatesTo.biId = '<subscriptionBiId>'.\n */\nexport const GET_PAYMENT_HISTORY = `query PaymentHistory($filter: String!, $first: Int!) {\n filterTwouInvoice(_first: $first, _filter: $filter) {\n edges {\n node {\n biId\n tStripeInvoiceId\n bpStatus { code name }\n billDate\n billBillingPeriod { start end }\n billFinancialCharges {\n fichAmount {\n amount\n units { code }\n }\n }\n }\n }\n }\n}`;\n\n/**\n * Cancel the learner's subscription (default: at period end).\n * Pass `immediate: true` to end access immediately.\n */\nexport const CANCEL_SUBSCRIPTION = `mutation CancelSubscription($biId: String!, $immediate: Boolean) {\n tCancelSubscription(biId: $biId, immediate: $immediate)\n}`;\n\n/**\n * Resume a cancelled subscription before the period end / cancellation date.\n */\nexport const REACTIVATE_SUBSCRIPTION = `mutation ReactivateSubscription($biId: String!) {\n tReactivateSubscription(biId: $biId)\n}`;\n\n/**\n * Payment method on an existing subscription (for renew / manage display).\n */\nexport const GET_SUBSCRIPTION_PAYMENT_METHOD = `query SubscriptionPaymentMethod($filter: String!) {\n filterTwouSubscription(_first: 1, _filter: $filter) {\n edges {\n node {\n biId\n hiConsistsOf {\n ... on TwouSubscriptionItem {\n paybPayment {\n ... on TwouStripePayment {\n tStripePaymentMethodId\n tPaymentMethodLast4\n tPaymentMethodBrand\n }\n }\n }\n }\n }\n }\n }\n}`;\n\n/**\n * Available customer billing plans (monthly / annual template prices).\n * Same query as frontend-app-subscription-checkout.\n */\nexport const GET_BILLING_PLANS = `query GetBillingPlans {\n filterCustomerBillingPlan(_first: 10) {\n edges {\n node {\n uid\n tStripePriceId\n tStripeAmount {\n amount\n units { code }\n }\n bipIsTemplate\n bipOwnershipModel { uid omName }\n }\n }\n }\n}`;\n\n/**\n * Attach a new Stripe payment method (pm_…) as the subscription default.\n */\nexport const UPDATE_SUBSCRIPTION_PAYMENT_METHOD = `mutation UpdateSubscriptionPaymentMethod(\n $biId: String!\n $tStripePaymentMethodId: String!\n) {\n tUpdateSubscriptionPaymentMethod(\n biId: $biId\n tStripePaymentMethodId: $tStripePaymentMethodId\n )\n}`;\n"]}
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../src/utils/queries.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG;;EAE5C,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG;;;;;;;;;;;;;;;;;;;;;;;EAuB1C,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;EAkBjC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;EAEjC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;;EAErC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG;;;;;;;;;;;;;;;;;;;EAmB7C,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;EAe/B,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG;;;;;;;;EAQ1C,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG;;;;;;;;EAQhD,CAAC","sourcesContent":["/**\n * GraphQL documents for the manage-subscription MFE.\n */\n\n/**\n * tIsCurrentUserSubscriber is a JSON scalar — returns the full object;\n * no subfield selection is allowed.\n */\nexport const GET_IS_CURRENT_USER_SUBSCRIBER = `query IsCurrentUserSubscriber {\n tIsCurrentUserSubscriber\n}`;\n\n/**\n * Enrollments for cancel confirmation.\n * Build `_filter` client-side, e.g. tSubscriptionBiId IN ('BI…', 'BI…').\n */\nexport const GET_SUBSCRIPTION_ENROLLMENTS = `query EnrollmentsForSubscriptions($filter: String!) {\n filterTwouEnrollment(_first: 200, _filter: $filter) {\n edges {\n node {\n biId\n tSubscriptionBiId\n bpStatus { code }\n tCourseRunKey\n tCertificateId\n tCertificateUrl\n tCourse {\n maId\n maName\n imageUrl\n tBrandText\n tSchools {\n tName\n tSortValue\n }\n }\n }\n }\n }\n}`;\n\n/**\n * Invoices for the learner's subscription (payment history).\n * Filter is inlined client-side: biRelatesTo.biId = '<subscriptionBiId>'.\n */\nexport const GET_PAYMENT_HISTORY = `query PaymentHistory($filter: String!, $first: Int!) {\n filterTwouInvoice(_first: $first, _filter: $filter) {\n edges {\n node {\n biId\n tStripeInvoiceId\n bpStatus { code name }\n billDate\n billBillingPeriod { start end }\n billFinancialCharges {\n fichAmount {\n amount\n units { code }\n }\n }\n }\n }\n }\n}`;\n\n/**\n * Cancel the learner's subscription (default: at period end).\n * Pass `immediate: true` to end access immediately.\n */\nexport const CANCEL_SUBSCRIPTION = `mutation CancelSubscription($biId: String!, $immediate: Boolean) {\n tCancelSubscription(biId: $biId, immediate: $immediate)\n}`;\n\n/**\n * Resume a cancelled subscription before the period end / cancellation date.\n */\nexport const REACTIVATE_SUBSCRIPTION = `mutation ReactivateSubscription($biId: String!) {\n tReactivateSubscription(biId: $biId)\n}`;\n\n/**\n * Payment method on an existing subscription (for renew / manage display).\n */\nexport const GET_SUBSCRIPTION_PAYMENT_METHOD = `query SubscriptionPaymentMethod($filter: String!) {\n filterTwouSubscription(_first: 1, _filter: $filter) {\n edges {\n node {\n biId\n hiConsistsOf {\n ... on TwouSubscriptionItem {\n paybPayment {\n ... on TwouStripePayment {\n tStripePaymentMethodId\n tPaymentMethodLast4\n tPaymentMethodBrand\n }\n }\n }\n }\n }\n }\n }\n}`;\n\n/**\n * Available customer billing plans (monthly / annual template prices).\n * Same query as frontend-app-subscription-checkout.\n */\nexport const GET_BILLING_PLANS = `query GetBillingPlans {\n filterCustomerBillingPlan(_first: 10) {\n edges {\n node {\n uid\n tStripePriceId\n tStripeAmount {\n amount\n units { code }\n }\n bipIsTemplate\n bipOwnershipModel { uid omName }\n }\n }\n }\n}`;\n\n/**\n * Validate a tokenized card (pm_…) before attaching it to the subscription.\n * Runs after stripe.createPaymentMethod, before UPDATE_SUBSCRIPTION_PAYMENT_METHOD.\n */\nexport const VALIDATE_CART_PAYMENT_METHOD = `mutation ValidateCartPaymentMethod(\n $biId: String!\n $tStripePaymentMethodId: String!\n) {\n tValidateCartPaymentMethod(\n biId: $biId\n tStripePaymentMethodId: $tStripePaymentMethodId\n )\n}`;\n\n/**\n * Attach a new Stripe payment method (pm_…) as the subscription default.\n */\nexport const UPDATE_SUBSCRIPTION_PAYMENT_METHOD = `mutation UpdateSubscriptionPaymentMethod(\n $biId: String!\n $tStripePaymentMethodId: String!\n) {\n tUpdateSubscriptionPaymentMethod(\n biId: $biId\n tStripePaymentMethodId: $tStripePaymentMethodId\n )\n}`;\n"]}
|