diff --git a/docs/how_tos/feedback.rst b/docs/how_tos/feedback.rst index 5e0b41d32..7a73c4446 100644 --- a/docs/how_tos/feedback.rst +++ b/docs/how_tos/feedback.rst @@ -374,6 +374,7 @@ pre-built APIs that do not follow the format of the feedback module in the: * `feedback/data/sagas.js`_ * ``basket-changed-error-message`` + * ``dynamic-payment-methods-country-not-compatible`` * ``transaction-declined-message`` * ``error_message`` in URL parameters diff --git a/src/payment/PaymentPage.jsx b/src/payment/PaymentPage.jsx index b2555cfe8..801f5e517 100644 --- a/src/payment/PaymentPage.jsx +++ b/src/payment/PaymentPage.jsx @@ -14,7 +14,7 @@ import { AppContext } from '@edx/frontend-platform/react'; import { sendPageEvent } from '@edx/frontend-platform/analytics'; import messages from './PaymentPage.messages'; -import { handleApiError } from './data/handleRequestError'; +import handleRequestError from './data/handleRequestError'; // Actions import { fetchBasket } from './data/actions'; @@ -80,13 +80,18 @@ class PaymentPage extends React.Component { // Get Payment Intent to retrieve the payment status and order number associated with this DPM payment. // If this is not a Stripe dynamic payment methods (BNPL), URL will not contain any params // and should not retrieve the Payment Intent. + // TODO: depending on if we'll use this MFE in the future, refactor to follow the redux pattern with actions + // and reducers for getting the Payment Intent is more appropriate. const searchParams = new URLSearchParams(global.location.search); const clientSecretId = searchParams.get('payment_intent_client_secret'); if (clientSecretId) { - const { paymentIntent, error } = await this.state.stripe.retrievePaymentIntent(clientSecretId); - if (error) { handleApiError(error); } - this.setState({ orderNumber: paymentIntent.description }); - this.setState({ paymentStatus: paymentIntent.status }); + try { + const { paymentIntent } = await this.state.stripe.retrievePaymentIntent(clientSecretId); + this.setState({ orderNumber: paymentIntent?.description }); + this.setState({ paymentStatus: paymentIntent?.status }); + } catch (error) { + handleRequestError(error); + } } }; diff --git a/src/payment/checkout/Checkout.jsx b/src/payment/checkout/Checkout.jsx index 03c3ceec6..1972dc58d 100644 --- a/src/payment/checkout/Checkout.jsx +++ b/src/payment/checkout/Checkout.jsx @@ -312,7 +312,7 @@ Checkout.propTypes = { paymentMethod: PropTypes.oneOf(['paypal', 'apple-pay', 'cybersource', 'stripe']), orderType: PropTypes.oneOf(Object.values(ORDER_TYPES)), enableStripePaymentProcessor: PropTypes.bool, - stripe: PropTypes.func, + stripe: PropTypes.object, // eslint-disable-line react/forbid-prop-types clientSecretId: PropTypes.string, };