PaypalProvider: allow to make also get requests#439
Open
PetrDlouhy wants to merge 4 commits intojazzband:mainfrom
Open
PaypalProvider: allow to make also get requests#439PetrDlouhy wants to merge 4 commits intojazzband:mainfrom
PetrDlouhy wants to merge 4 commits intojazzband:mainfrom
Conversation
d04277b to
457d850
Compare
WhyNotHugo
approved these changes
Mar 4, 2025
Member
WhyNotHugo
left a comment
There was a problem hiding this comment.
LGTM, only one minor detail.
| def post(self, payment, *args, **kwargs): | ||
| return self.http_request(payment, *args, http_method=requests.post, **kwargs) | ||
|
|
||
| def get(self, payment, *args, **kwargs): |
Member
There was a problem hiding this comment.
Please add a short docstring for this, so folks can find it and use it.
457d850 to
7c60f04
Compare
Member
|
CI is now green, so rebasing. |
Add get() method to complement the existing post() method, and refactor to support making API requests that are not tied to a specific payment instance. Changes: - Add http_request() helper method that accepts http_method parameter - Refactor post() to use http_request() with requests.post - Add new get() method that uses http_request() with requests.get - Update http_request() to handle payment=None by skipping payment-specific operations (set_error_data, change_status, set_response_data) - Update get_access_token() to handle payment=None for token caching - Add comprehensive docstrings to both get() and post() methods This enables making GET requests to PayPal API and allows use cases where API calls are not associated with a payment (e.g., fetching account info, checking subscription status).
Add comprehensive test to verify that get() method works correctly when called with payment=None, which is needed for API calls not tied to a specific payment instance. The test verifies: - OAuth token acquisition happens correctly - GET request is made with proper headers - Response data is returned correctly
2149cc6 to
b12b64b
Compare
Fix critical bug where @authorize decorator would crash on 401 errors when payment=None, preventing proper token refresh for API calls not tied to a payment instance. Changes: - Add payment=None check in @authorize decorator before accessing payment attrs - Extract expires_in variable to fix line length linting error (line 198) - Add test for 401 error handling with payment=None This enables reliable use of get()/post() with payment=None for operations like subscription management that don't have an associated Payment instance.
9cca3b7 to
fefb798
Compare
for more information, see https://pre-commit.ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PaypalProvider: Add also
get()method to be able to use the provider to create also GET request to PayPal API.