Skip to content

Conversation

@ajeety4
Copy link
Contributor

@ajeety4 ajeety4 commented Dec 2, 2025

Product Description

Adds a new column Status Confirmed On in payments report. This column displays when the status of payment was last fetched from the provider.

image

Technical Summary

Ticket.

Feature Flag

MTN_MOBILE_WORKER_VERIFICATION

Safety Assurance

Safety story

A minor change for adding a new column. Changes behind an unused FF.

Automated test coverage

Test cases are updated.

QA Plan

None

Rollback instructions

  • This PR can be reverted after deploy with no further considerations

Labels & Review

  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@ajeety4 ajeety4 added the product/feature-flag Change will only affect users who have a specific feature flag enabled label Dec 2, 2025
@ajeety4 ajeety4 marked this pull request as ready for review December 2, 2025 07:21
@ajeety4 ajeety4 requested review from kaapstorm and mkangia December 2, 2025 07:22
Comment on lines 394 to 400

status_update = {
PaymentProperties.PAYMENT_STATUS: status,
PaymentProperties.PAYMENT_STATUS_CONFIRMED_ON: datetime.utcnow().isoformat(),
}

if error_code is not None:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The _handle_payment_status_retry() function omits the new PAYMENT_STATUS_CONFIRMED_ON field in the dictionary it returns during intermediate retries after a request error.
Severity: HIGH | Confidence: High

🔍 Detailed Analysis

When a PaymentRequestError occurs during a payment status check, the _handle_payment_status_retry() function is called. If the retry count has not been exceeded, the function returns a dictionary that only includes the PAYMENT_STATUS_ATTEMPT_COUNT. This return value is missing the newly introduced PAYMENT_STATUS_CONFIRMED_ON field. As a result, when bulk_update_cases() processes this incomplete data, the case property for the confirmation timestamp is not updated. This leaves the timestamp stale, which contradicts the feature's goal of showing when the status was last fetched.

💡 Suggested Fix

Update _handle_payment_status_retry() to include the PAYMENT_STATUS_CONFIRMED_ON field with the current UTC timestamp in the dictionary it returns during intermediate retries. This will ensure consistency with other status update paths.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: corehq/apps/integration/payments/services.py#L394-L400

Potential issue: When a `PaymentRequestError` occurs during a payment status check, the
`_handle_payment_status_retry()` function is called. If the retry count has not been
exceeded, the function returns a dictionary that only includes the
`PAYMENT_STATUS_ATTEMPT_COUNT`. This return value is missing the newly introduced
`PAYMENT_STATUS_CONFIRMED_ON` field. As a result, when `bulk_update_cases()` processes
this incomplete data, the case property for the confirmation timestamp is not updated.
This leaves the timestamp stale, which contradicts the feature's goal of showing when
the status was last fetched.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 8082363

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional, as the payment status is still pending confirmation from the provider due to a request error. Once the maximum retry count is exceeded, we update PAYMENT_STATUS_CONFIRMED_ON with the timestamp of the last retry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product/feature-flag Change will only affect users who have a specific feature flag enabled

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants