Giter VIP home page Giter VIP logo

Comments (4)

rsaestrela avatar rsaestrela commented on August 18, 2024

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.

michaeljaszczuk avatar michaeljaszczuk commented on August 18, 2024

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.

rsaestrela avatar rsaestrela commented on August 18, 2024

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.

michaeljaszczuk avatar michaeljaszczuk commented on August 18, 2024

Right, understand 🤔 Thanks for clarification, in that case we can close the ticket :)

from checkout-sdk-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.