Uh oh!
There was an error while loading. Please reload this page.
PTHMINT-125: Cloud POS tip and amount_details support - #62
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.61% 92.66% +0.05%
==========================================
Files 180 182 +2 Lines 3331 3356 +25 ==========================================
+ Hits 3085 3110 +25
Misses 246 246 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
| """Tip model for order request amount details.""" | ||
| from typing import Optional, Union | ||
| from multisafepay.model.request_model import RequestModel |
| """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. | |||
| """Test module for unit testing.""" | ||
| from multisafepay.api.paths.orders.request.components.tip import Tip |
| """Test module for unit testing.""" | ||
| from multisafepay.api.paths.orders.request.components.amount_details import ( |
| """Create a Cloud POS order with tip information.""" | ||
| import os | ||
| import time | ||
| from dotenv import load_dotenv | ||
| from multisafepay import Sdk |
| This serializes to: | ||
| ```json | ||
| { | ||
| "amount_details": { | ||
| "tip": { | ||
| "amount": 20 |
Add copyright, license and disclaimer headers to example, component and test files; clarify README text for amount_details serialization; and change OrderRequest.amount type from Optional[str] to Optional[int] to reflect numeric amounts. Tests were updated with headers only.
Uh oh!
There was an error while loading. Please reload this page.
This pull request introduces support for specifying tip amounts in Cloud POS and POS order creation requests. It adds new models for handling tip and amount details, updates the order request structure, and provides documentation, examples, and comprehensive tests to ensure correct serialization and integration.
Cloud POS Tip Support:
AmountDetailsandTipto represent order amount breakdowns, allowing tip information to be included in order requests. [1][2]OrderRequestto support an optionalamount_detailsfield and added anadd_amount_detailsmethod for builder-style usage. [1][2][3]AmountDetailsandTip. [1][2]Documentation and Examples:
README.mdwith usage instructions and an example for sending tip information in Cloud POS orders.examples/order_manager/cloud_pos_order_with_tip.pydemonstrating how to create a Cloud POS order with a tip.Testing:
amount_detailsandtipfields, ensuring correct initialization, builder usage, and serialization. [1][2][3][4][5][6][7][8][9][10][11][12][13]