Comments (4)
Hi @michaeljaszczuk. Thanks for creating this issue. All the classes have the default/implicit default constructor. What kind of init
methods are you looking for? Parameterized init
methods with all the class attributes and their initialization?
from checkout-sdk-python.
Exactly,
For example implementation of:
payment_request.amount = 123
payment_request.payment_type = PaymentType.REGULAR
payment_request.capture = auto_capture
source = RequestSource(type_p=PaymentSourceType.ID)
source.card = card_id
payment_request.source = source
three_ds = ThreeDsRequest()
three_ds.enabled = True
payment_request.three_ds = three_ds
# Metadata (Tags):
if adhoc_tag:
payment_request.metadata = {'udf1': tag}
Could be done in that way:
payment_request = PaymentRequest(
amount=123,
payment_type=PaymentType.REGULAR,
capture=True,
source=RequestSource(type_p=PaymentSourceType.ID, card_id=card_id)
three_ds=ThreeDsRequest(
enabled=True
)
)
Also i believe very useful would be add PaymentStatus Enum to common/enums.py
If you don't mind i could create PR for that but i believe i have no access to do it
from checkout-sdk-python.
Ok. I've just noticed in your code snippets RequestSource(type_p=PaymentSourceType.ID)
. This can be replaced with RequestIdSource()
. There are different implementations for RequestSource
(which is not meant to be used directly):
- RequestCardSource
- RequestCustomerSource
- RequestDLocalSource
- RequestIdSource
- RequestNetworkTokenSource
- RequestTokenSource
You can find the code source for them in these 2 files (depending on your keys):
Same with RequestDestination
for Payouts, or any other class in this SDK that has declared inheritance.
Going back to the original question, the reason why we decided not to implement init
methods for each class is maintainability. Some classes have a bigger number of attributes, there are hundreds on classes and we want to keep the codebase clean and easier to maintain as possible. I see the utility of these constructors in certain situations but we cannot affort to add them and maintain all that code or simply to add some of them which will create inconsistencies in the code (some classes have them, others don't, why?). Some programming languages have this feature ootb, others have libraries that generate this code automatically. Unfortunately we don't know any similar solution for Python. Anything you can recommend?
This is not a hard no... We'd be happy you can help us with it but if you do it please try to implement that solution consistently across all project classes, or just a module to start (payments for example). Just a reminder that we're building v3 beta and if we really want to make these commitment then we will have to keep them :)
from checkout-sdk-python.
Right, understand 🤔 Thanks for clarification, in that case we can close the ticket :)
from checkout-sdk-python.
Related Issues (20)
- CheckoutApiException class should have error_type from the response also. HOT 3
- Master Card - Unprocessible entity HOT 2
- Incorrectly typed exception HOT 2
- Payout request destination specifies required account holder HOT 2
- Integrate with Risk.js HOT 2
- Add serializer to response wrapper HOT 4
- Documentation around making a payment is incorrect HOT 2
- Error handling in the readme HOT 3
- Your API Key is invalid HOT 1
- CVV issue HOT 1
- Feature request: initialize InstrumentsClient with API
- 3D Secure flow is not supported by the SDK HOT 2
- Add Dynamic Descriptor to payment requests HOT 1
- Contributions HOT 2
- Request: custom response classes HOT 2
- Credentials HOT 10
- Add support for create payment token API call HOT 1
- How to get All reports HOT 3
- Add error codes and error messages to API and Business validation declines HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from checkout-sdk-python.