-
Notifications
You must be signed in to change notification settings - Fork 91
ISS-971955 feat: Add DeviceActivity support for POS Gateway integration #309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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')
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't make sense, auth already contains the public key, should directly use from there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
| if not activity_id: | ||
| raise BadRequestError("Activity ID must be provided") | ||
|
|
||
| device_mode = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be extracted as separate method
- 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
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.