PTHMINT-125: Cloud POS tip and amount_details support#62
Open
zulquer wants to merge 1 commit into
Open
Conversation
Add models and wiring to support tip information in order requests for POS/Cloud POS. Introduces Tip and AmountDetails components, exposes them in components.__init__, and adds amount_details field and add_amount_details method to OrderRequest. Includes example script and README documentation showing tip serialization (amounts in smallest currency unit), and updates/adds unit and integration tests to cover serialization and behavior. Tip.add_amount accepts either an Amount value object or an int.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #62 +/- ##
==========================================
+ Coverage 92.83% 92.89% +0.06%
==========================================
Files 164 166 +2
Lines 2889 2914 +25
==========================================
+ Hits 2682 2707 +25
Misses 207 207 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds amount_details support to order creation payloads to represent POS/Cloud POS tip information, by introducing new request components (Tip, AmountDetails) and wiring them into OrderRequest plus docs/examples/tests.
Changes:
- Introduces
TipandAmountDetailsrequest component models and exports them from the components package. - Extends
OrderRequestwithamount_detailsand anadd_amount_details()fluent setter. - Adds/updates unit + integration tests and documentation/example code demonstrating tip serialization.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
src/multisafepay/api/paths/orders/request/order_request.py |
Adds amount_details field + add_amount_details() method; updates docstring. |
src/multisafepay/api/paths/orders/request/components/tip.py |
New Tip component with add_amount() supporting int or Amount. |
src/multisafepay/api/paths/orders/request/components/amount_details.py |
New AmountDetails component that can include a Tip. |
src/multisafepay/api/paths/orders/request/components/__init__.py |
Exposes AmountDetails and Tip via __all__. |
tests/multisafepay/unit/api/path/orders/request/test_unit_order_request.py |
Unit coverage for amount_details initialization, setter, and serialization. |
tests/multisafepay/unit/api/path/orders/request/components/test_unit_tip.py |
New unit tests for Tip behavior. |
tests/multisafepay/unit/api/path/orders/request/components/test_unit_amount_details.py |
New unit tests for AmountDetails behavior and serialization. |
tests/multisafepay/integration/api/path/orders/request/test_integration_order_request.py |
Integration coverage ensuring amount_details is included in to_dict(). |
tests/multisafepay/integration/api/path/orders/manager/test_integration_order_manager_create.py |
Integration coverage ensuring request body includes serialized amount_details. |
README.md |
Documents Cloud POS tip usage and expected serialization shape. |
examples/order_manager/cloud_pos_order_with_tip.py |
New runnable example demonstrating creating an order with a tip. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1
to
+5
| """Tip model for order request amount details.""" | ||
|
|
||
| from typing import Optional, Union | ||
|
|
||
| from multisafepay.model.request_model import RequestModel |
Comment on lines
+1
to
+5
| """Amount details model for order request amount breakdowns.""" | ||
|
|
||
| from typing import Optional | ||
|
|
||
| from multisafepay.api.paths.orders.request.components.tip import Tip |
| @@ -67,6 +70,7 @@ class OrderRequest(RequestModel): | |||
| order_id (Optional[str]): The order ID. | |||
| currency (Optional[str]): The currency of the order. | |||
| amount (Optional[str]): The amount of the order. | |||
Comment on lines
+1
to
+3
| """Test module for unit testing.""" | ||
|
|
||
| from multisafepay.api.paths.orders.request.components.tip import Tip |
Comment on lines
+1
to
+3
| """Test module for unit testing.""" | ||
|
|
||
| from multisafepay.api.paths.orders.request.components.amount_details import ( |
Comment on lines
+1
to
+8
| """Create a Cloud POS order with tip information.""" | ||
|
|
||
| import os | ||
| import time | ||
|
|
||
| from dotenv import load_dotenv | ||
|
|
||
| from multisafepay import Sdk |
Comment on lines
+127
to
+133
| This serializes to: | ||
|
|
||
| ```json | ||
| { | ||
| "amount_details": { | ||
| "tip": { | ||
| "amount": 20 |
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.
Add models and wiring to support tip information in order requests for POS/Cloud POS. Introduces Tip and AmountDetails components, exposes them in components.init, and adds amount_details field and add_amount_details method to OrderRequest. Includes example script and README documentation showing tip serialization (amounts in smallest currency unit), and updates/adds unit and integration tests to cover serialization and behavior. Tip.add_amount accepts either an Amount value object or an int.