Fix the issue where the certificate cannot be downloaded when the order status is "processing".
This pull request addresses an issue where, after completing an order, the status might be marked as "processing". In this state, the "Finalizing order" interface cannot be called again, resulting in a 403 status code and preventing the certificate from being downloaded.
Problem
This pull request addresses an issue where, after completing an order, the status might be marked as "processing". In this state, the "Finalizing order" interface cannot be called again, resulting in a 403 status code and preventing the certificate from being downloaded.
Solution
To resolve this issue, the script has been modified to:
-
Check for non-empty
CERTIFICATE_URL
: Instead of waiting for the status to change to "valid", the script now checks if theCERTIFICATE_URL
is not empty. If theCERTIFICATE_URL
is available, the script breaks out of the loop and proceeds to download the certificate. -
Use
getorder
API: To ensure that the latest status and certificate URL are retrieved, thegetorder
API endpoint is used to fetch the updated information.
Changes Made
-
Loop logic modification: The loop now checks if the
CERTIFICATE_URL
is not empty instead of checking for a specific status. -
Error handling: After the loop, an error message is displayed if the
CERTIFICATE_URL
remains empty, indicating that the certificate is still not available. -
API call update: The
getorder
API endpoint is called to ensure that the most up-to-date status and certificate URL are retrieved.
Steps to Reproduce
- Create a new order: Trigger the creation of a new order through the script.
- Observe the status: Observe the status returned by the API after the order is marked as "valid".
- Run the modified script: Execute the modified script to observe the behavior.
-
Verify certificate retrieval: Ensure that the script successfully retrieves the certificate once the
CERTIFICATE_URL
is available, even if the order status is "processing".
Testing
- Manual testing: I manually tested the modified script by creating orders and observing the behavior.
- Automated testing: Automated tests may be required to ensure the robustness of the change.
Conclusion
This fix ensures that the script can reliably retrieve the certificate as soon as it is available, regardless of the order status being "processing" or "valid". It improves the reliability and efficiency of the script when dealing with completed orders.