ISS-971955 feat: Add DeviceActivity support for POS Gateway integration#309
Merged
PayManiRazor merged 4 commits intomasterfrom Aug 27, 2025
Merged
ISS-971955 feat: Add DeviceActivity support for POS Gateway integration#309PayManiRazor merged 4 commits intomasterfrom
PayManiRazor merged 4 commits intomasterfrom
Conversation
- Add DeviceActivity resource with create() and get_status() methods
- Support PUBLIC authentication for DeviceActivity APIs
- Add X-Razorpay-Device-Mode header injection for wired/wireless modes
- Add DeviceMode constants (WIRED, WIRELESS)
- Enhance Client to support public_auth parameter
- Add comprehensive test coverage and mock responses
- Fix test_multiple_client URL mismatch
- Maintain backward compatibility with existing APIs
Endpoints:
- POST /v1/devices/activity (create device activity)
- GET /v1/devices/activity/{id} (get activity status)
Usage:
client = razorpay.Client(auth=(...), public_auth=(...))
client.device_activity.create(data, mode='wired')
client.device_activity.get_status('act_123', mode='wireless')
sunnyagg
reviewed
Aug 26, 2025
sunnyagg
reviewed
Aug 26, 2025
razorpay/client.py
Outdated
| } | ||
|
|
||
| def __init__(self, session=None, auth=None, **options): | ||
| def __init__(self, session=None, auth=None, public_auth=None, **options): |
There was a problem hiding this comment.
this doesn't make sense, auth already contains the public key, should directly use from there
Contributor
Author
There was a problem hiding this comment.
At first, I thought the integration team would create only one client, so I added a field to separate the auth. Removed this now, integration team will create two different client (one for public auth for activity related API and other for private auth for Order related APIs)
sunnyagg
reviewed
Aug 26, 2025
| if not activity_id: | ||
| raise BadRequestError("Activity ID must be provided") | ||
|
|
||
| device_mode = None |
- Remove public_auth complexity from Client class - Use standard HTTP Basic Auth for all APIs instead of dual auth system - Refactor DeviceActivity to use single authentication approach - Extract device mode validation into reusable private method - Update tests to use simplified client initialization - Maintain backward compatibility while reducing authentication complexity
- Modified client.py to use use_public_auth parameter for authentication type selection - When use_public_auth=True, only key_id is used for authentication (empty key_secret) - Device APIs in device_activity.py now automatically pass use_public_auth=True - Regular APIs continue using full authentication (use_public_auth=False by default) - Single client can handle both device APIs and regular APIs seamlessly - Updated tests to reflect new authentication approach - No breaking changes to existing API usage
sunnyagg
approved these changes
Aug 26, 2025
sunnyagg
approved these changes
Aug 27, 2025
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.
Endpoints:
Usage:
client = razorpay.Client(auth=(...), public_auth=(...)) client.device_activity.create(data, mode='wired')
client.device_activity.get_status('act_123', mode='wireless')
Note :- Please follow the below points while attaching test cases document link below:
- If label
Testedis added then test cases document URL is mandatory.- Link added should be a valid URL and accessible throughout the org.
- If the branch name contains hotfix / revert by default the BVT workflow check will pass.