Package: paddle-billing-client
paddle-billing-clientPython wrapper around the new Paddle Billing APIPaddle Classic vs Paddle BillingPaddle Classic is the original Paddle API, which is still in use by many merchants. More info can be foundhereIf you are looking for the Paddle Classic API wrapper, please seepaddle-clientPaddle Billing is the new API, which is just launched at 2023, August. Paddle Billing is a complete rewrite of the Paddle Classic API, and is designed to be more flexible and easier to use. More info can be foundhereDjango IntegrationFor Paddle Classic, there is a Django integration available atdj-paddleanddjango-paddleFor Paddle Billing, there is a Work In Progress Django integration available atdjango-paddle-billing📦 FeaturesPydantic models for all API requests and responsesTests withpytestandVCR.pyfor mocking HTTP requestsWebsite stalkerGithub Action to monitor any API changesPagination support with generator to process pages one by oneHelper function for signature validation for webhooksTestsProductsPricesDiscountsCustomersCustomer Credit balancesAddressesBusinessesTransactionsSubscriptions (except activate)Subscription ResumeSubscription Activate TrialingAdjustmentsPricing PreviewsReportsEvent typesEventsNotification SettingsNotificationsNotification logsInstallationpipinstall-Upaddle-billing-clientor install withPoetrypoetryaddpaddle-billing-clientUsagefrompaddle_billing_client.clientimportPaddleApiClientfromapiclientimportHeaderAuthenticationclient=PaddleApiClient(base_url="https://sandbox-api.paddle.com",authentication_method=HeaderAuthentication(token="your-paddle-token"))# Create a productproduct=client.create_product(ProductRequest(name="Test Product New",tax_category="standard",description="Test Product Description",image_url="https://example.com/image.png",custom_data=dict(foo="bar"),))# Get all productsproducts=client.list_products()# Get all pricesplans=client.list_prices()# Paginationfrompaddle_billing_client.paginationimportpaginatefrompaddle_billing_client.models.notificationimportNotificationQueryParamsfornotificationinpaginate(client.list_notifications,query_params=NotificationQueryParams(status="delivered",after='ntf_01hb1n6nw8yx1wwts2cyh632s9',per_page=10)):# Process notifications page by pageprint("Notification:")print(len(notification.data))print(notification.data[-1].id)DebuggingTo print the raw exception response, you can use theVerboseErrorHandler:frompaddle_billing_client.clientimportPaddleApiClientfromapiclientimportHeaderAuthenticationfrompaddle_billing_client.errorsimportVerboseErrorHandlerclient=PaddleApiClient(base_url="https://sandbox-api.paddle.com",authentication_method=HeaderAuthentication(token="your-paddle-token"),error_handler=VerboseErrorHandler)Sandbox API url:https://sandbox-api.paddle.com/Live API url:https://api.paddle.com/More usage examples can be found intests.Helper functionsfrompaddle_billing_client.helpersimportvalidate_webhook_signature# Validate webhook signatureis_valid=validate_webhook_signature(signature_header=request.headers.get("HTTP_PADDLE_SIGNATURE"),raw_body=request.data,secret_key="your-paddle-secret-key",)Makefile usageMakefilecontains a lot of functions for faster development.1. Download and remove PoetryTo download and install Poetry run:makepoetry-downloadTo uninstallmakepoetry-remove2. Install all dependencies and pre-commit hooksInstall requirements:makeinstallPre-commit hooks coulb be installed aftergit initviamakepre-commit-install3. CodestyleAutomatic formatting usespyupgrade,isortandblack.makecodestyle# or use synonymmakeformattingCodestyle checks only, without rewriting files:makecheck-codestyleNote:check-codestyleusesisort,blackanddarglintlibraryUpdate all dev libraries to the latest version using one comandmakeupdate-dev-deps4. Code securitymakecheck-safetyThis command launchesPoetryintegrity checks as well as identifies security issues withSafetyandBandit.makecheck-safety5. Type checksRunmypystatic type checkermakemypy6. Tests with coverage badgesRunpytestmaketest7. All lintersOf course there is a command torulerun all linters in one:makelintthe same as:maketest&&makecheck-codestyle&&makemypy&&makecheck-safety8. Dockermakedocker-buildwhich is equivalent to:makedocker-buildVERSION=latestRemove docker image withmakedocker-removeMore informationabout docker.9. CleanupDelete pycache filesmakepycache-removeRemove package buildmakebuild-removeDelete .DS_STORE filesmakedsstore-removeRemove .mypycachemakemypycache-removeOr to remove all above run:makecleanup📈 ReleasesYou can see the list of available releases on theGitHub Releasespage.We followSemantic Versionsspecification.We useRelease Drafter. As pull requests are merged, a draft release is kept up-to-date listing the changes, ready to publish when you’re ready. With the categories option, you can categorize pull requests in release notes using labels.List of labels and corresponding titlesLabelTitle in Releasesenhancement,feature🚀 Featuresbug,refactoring,bugfix,fix🔧 Fixes & Refactoringbuild,ci,testing📦 Build System & CI/CDbreaking💥 Breaking Changesdocumentation📝 Documentationdependencies⬆️ Dependencies updatesYou can update it inrelease-drafter.yml.GitHub creates thebug,enhancement, anddocumentationlabels for you. Dependabot creates thedependencieslabel. Create the remaining labels on the Issues tab of your GitHub repository, when you need them.Building and releasing your packageBuilding a new version of the application contains steps:Bump the version of your packagepoetry version <version>. You can pass the new version explicitly, or a rule such asmajor,minor, orpatch. For more details, refer to theSemantic Versionsstandard.Make a commit toGitHub.Create aGitHub release.And... publish 🙂poetry publish --build🚀 Package Template FeaturesDevelopment featuresSupports forPython 3.7and higher.Poetryas the dependencies manager. See configuration inpyproject.tomlandsetup.cfg.Automatic codestyle withblack,isortandpyupgrade.Ready-to-usepre-commithooks with code-formatting.Type checks withmypy; docstring checks withdarglint; security checks withsafetyandbanditTesting withpytest.Ready-to-use.editorconfig,.dockerignore, and.gitignore. You don't have to worry about those things.Deployment featuresGitHubintegration: issue and pr templates.Github Actionswith predefinedbuild workflowas the default CI/CD.Everything is already set up for security checks, codestyle checks, code formatting, testing, linting, docker builds, etc withMakefile. More details inmakefile-usage.Dockerfilefor your package.Always up-to-date dependencies with@dependabot. You will onlyenable it.Automatic drafts of new releases withRelease Drafter. You may see the list of labels inrelease-drafter.yml. Works perfectly withSemantic Versionsspecification.Open source community featuresReady-to-usePull Requests templatesand severalIssue templates.Files such as:LICENSE,CONTRIBUTING.md,CODE_OF_CONDUCT.md, andSECURITY.mdare generated automatically.Stale botthat closes abandoned issues after a period of inactivity. (You will onlyneed to setup free plan). Configuration ishere.Semantic Versionsspecification withRelease Drafter.🛡 LicenseThis project is licensed under the terms of theMITlicense. SeeLICENSEfor more details.📃 Citation@misc{paddle-billing-client,author={Benjamin Gervan},title={Python wrapper around the new Paddle Billing API},year={2023},publisher={GitHub},journal={GitHub repository},howpublished={\url{https://github.com/websideproject/paddle-billing-client}}}CreditsThis project was generated withpython-package-template