paddle-python-sdk 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- examples/__init__.py +0 -0
- examples/catalog_management.py +166 -0
- examples/event_polling.py +56 -0
- examples/get_products.py +46 -0
- examples/logger.py +31 -0
- paddle_billing/Client.py +201 -0
- paddle_billing/ConditionallyRemoveImportMeta.py +14 -0
- paddle_billing/Entities/Address.py +44 -0
- paddle_billing/Entities/Adjustment.py +45 -0
- paddle_billing/Entities/Adjustments/AdjustmentCustomerBalance.py +18 -0
- paddle_billing/Entities/Adjustments/AdjustmentItem.py +26 -0
- paddle_billing/Entities/Adjustments/__init__.py +2 -0
- paddle_billing/Entities/Business.py +38 -0
- paddle_billing/Entities/Collections/AddressCollection.py +18 -0
- paddle_billing/Entities/Collections/AdjustmentCollection.py +18 -0
- paddle_billing/Entities/Collections/BusinessCollection.py +18 -0
- paddle_billing/Entities/Collections/Collection.py +47 -0
- paddle_billing/Entities/Collections/CreditBalanceCollection.py +18 -0
- paddle_billing/Entities/Collections/CustomerCollection.py +18 -0
- paddle_billing/Entities/Collections/DiscountCollection.py +18 -0
- paddle_billing/Entities/Collections/EventCollection.py +18 -0
- paddle_billing/Entities/Collections/EventTypeCollection.py +18 -0
- paddle_billing/Entities/Collections/NotificationCollection.py +18 -0
- paddle_billing/Entities/Collections/NotificationLogCollection.py +18 -0
- paddle_billing/Entities/Collections/NotificationSettingCollection.py +18 -0
- paddle_billing/Entities/Collections/Paginator.py +29 -0
- paddle_billing/Entities/Collections/PriceCollection.py +18 -0
- paddle_billing/Entities/Collections/ProductCollection.py +18 -0
- paddle_billing/Entities/Collections/ReportCollection.py +18 -0
- paddle_billing/Entities/Collections/SubscriptionCollection.py +18 -0
- paddle_billing/Entities/Collections/SubscriptionPreviewCollection.py +18 -0
- paddle_billing/Entities/Collections/TransactionCollection.py +18 -0
- paddle_billing/Entities/Collections/TransactionPreviewCollection.py +18 -0
- paddle_billing/Entities/Collections/TransactionsDataCollection.py +18 -0
- paddle_billing/Entities/Collections/__init__.py +21 -0
- paddle_billing/Entities/CreditBalance.py +22 -0
- paddle_billing/Entities/Customer.py +36 -0
- paddle_billing/Entities/DateTime.py +43 -0
- paddle_billing/Entities/Discount.py +51 -0
- paddle_billing/Entities/Discounts/DiscountStatus.py +8 -0
- paddle_billing/Entities/Discounts/DiscountType.py +7 -0
- paddle_billing/Entities/Discounts/__init__.py +2 -0
- paddle_billing/Entities/Entity.py +12 -0
- paddle_billing/Entities/Event.py +51 -0
- paddle_billing/Entities/EventType.py +23 -0
- paddle_billing/Entities/Events/EventTypeName.py +52 -0
- paddle_billing/Entities/Events/__init__.py +1 -0
- paddle_billing/Entities/Notification.py +42 -0
- paddle_billing/Entities/NotificationLog.py +25 -0
- paddle_billing/Entities/NotificationSetting.py +34 -0
- paddle_billing/Entities/NotificationSettings/NotificationSettingType.py +6 -0
- paddle_billing/Entities/NotificationSettings/__init__.py +1 -0
- paddle_billing/Entities/Notifications/NotificationOrigin.py +6 -0
- paddle_billing/Entities/Notifications/NotificationPayout.py +24 -0
- paddle_billing/Entities/Notifications/NotificationPayoutStatus.py +6 -0
- paddle_billing/Entities/Notifications/NotificationStatus.py +8 -0
- paddle_billing/Entities/Notifications/__init__.py +4 -0
- paddle_billing/Entities/Price.py +68 -0
- paddle_billing/Entities/PricePreview.py +34 -0
- paddle_billing/Entities/PricingPreviews/PricePreviewDetails.py +15 -0
- paddle_billing/Entities/PricingPreviews/PricePreviewDiscounts.py +20 -0
- paddle_billing/Entities/PricingPreviews/PricePreviewItem.py +16 -0
- paddle_billing/Entities/PricingPreviews/PricePreviewLineItem.py +38 -0
- paddle_billing/Entities/PricingPreviews/PricePreviewTotalsFormatted.py +20 -0
- paddle_billing/Entities/PricingPreviews/PricePreviewUnitTotalsFormatted.py +20 -0
- paddle_billing/Entities/PricingPreviews/__init__.py +6 -0
- paddle_billing/Entities/Product.py +45 -0
- paddle_billing/Entities/Report.py +32 -0
- paddle_billing/Entities/ReportCSV.py +13 -0
- paddle_billing/Entities/Reports/ReportFilter.py +20 -0
- paddle_billing/Entities/Reports/ReportFilterName.py +17 -0
- paddle_billing/Entities/Reports/ReportFilterOperator.py +6 -0
- paddle_billing/Entities/Reports/ReportStatus.py +8 -0
- paddle_billing/Entities/Reports/ReportType.py +10 -0
- paddle_billing/Entities/Reports/__init__.py +5 -0
- paddle_billing/Entities/Shared/Action.py +10 -0
- paddle_billing/Entities/Shared/AddressPreview.py +18 -0
- paddle_billing/Entities/Shared/AdjustmentItemTotals.py +18 -0
- paddle_billing/Entities/Shared/AdjustmentProration.py +18 -0
- paddle_billing/Entities/Shared/AdjustmentStatus.py +8 -0
- paddle_billing/Entities/Shared/AdjustmentTimePeriod.py +17 -0
- paddle_billing/Entities/Shared/AdjustmentTotals.py +26 -0
- paddle_billing/Entities/Shared/AdjustmentType.py +8 -0
- paddle_billing/Entities/Shared/AvailablePaymentMethods.py +11 -0
- paddle_billing/Entities/Shared/BillingDetails.py +22 -0
- paddle_billing/Entities/Shared/BillingDetailsUpdate.py +22 -0
- paddle_billing/Entities/Shared/Card.py +24 -0
- paddle_billing/Entities/Shared/CatalogType.py +6 -0
- paddle_billing/Entities/Shared/ChargebackFee.py +18 -0
- paddle_billing/Entities/Shared/Checkout.py +12 -0
- paddle_billing/Entities/Shared/CollectionMode.py +6 -0
- paddle_billing/Entities/Shared/Contacts.py +16 -0
- paddle_billing/Entities/Shared/CountryCode.py +233 -0
- paddle_billing/Entities/Shared/CurrencyCode.py +34 -0
- paddle_billing/Entities/Shared/CurrencyCodeAdjustments.py +7 -0
- paddle_billing/Entities/Shared/CurrencyCodePayouts.py +17 -0
- paddle_billing/Entities/Shared/CustomData.py +10 -0
- paddle_billing/Entities/Shared/Data.py +9 -0
- paddle_billing/Entities/Shared/ErrorCode.py +21 -0
- paddle_billing/Entities/Shared/ImportMeta.py +16 -0
- paddle_billing/Entities/Shared/Interval.py +8 -0
- paddle_billing/Entities/Shared/Meta.py +7 -0
- paddle_billing/Entities/Shared/MetaPaginated.py +18 -0
- paddle_billing/Entities/Shared/MethodDetails.py +19 -0
- paddle_billing/Entities/Shared/Money.py +28 -0
- paddle_billing/Entities/Shared/Original.py +18 -0
- paddle_billing/Entities/Shared/Pagination.py +20 -0
- paddle_billing/Entities/Shared/PaymentAttemptStatus.py +13 -0
- paddle_billing/Entities/Shared/PaymentMethodType.py +14 -0
- paddle_billing/Entities/Shared/PayoutTotalsAdjustment.py +29 -0
- paddle_billing/Entities/Shared/PriceQuantity.py +16 -0
- paddle_billing/Entities/Shared/Status.py +6 -0
- paddle_billing/Entities/Shared/TaxCategory.py +13 -0
- paddle_billing/Entities/Shared/TaxMode.py +7 -0
- paddle_billing/Entities/Shared/TaxRatesUsed.py +18 -0
- paddle_billing/Entities/Shared/TimePeriod.py +18 -0
- paddle_billing/Entities/Shared/Totals.py +20 -0
- paddle_billing/Entities/Shared/TransactionDetailsPreview.py +22 -0
- paddle_billing/Entities/Shared/TransactionLineItemPreview.py +28 -0
- paddle_billing/Entities/Shared/TransactionOrigin.py +10 -0
- paddle_billing/Entities/Shared/TransactionPaymentAttempt.py +35 -0
- paddle_billing/Entities/Shared/TransactionPayoutTotals.py +36 -0
- paddle_billing/Entities/Shared/TransactionPayoutTotalsAdjusted.py +29 -0
- paddle_billing/Entities/Shared/TransactionStatus.py +11 -0
- paddle_billing/Entities/Shared/TransactionTotals.py +36 -0
- paddle_billing/Entities/Shared/TransactionTotalsAdjusted.py +28 -0
- paddle_billing/Entities/Shared/UnitPriceOverride.py +19 -0
- paddle_billing/Entities/Shared/UnitTotals.py +20 -0
- paddle_billing/Entities/Shared/__init__.py +56 -0
- paddle_billing/Entities/Subscription.py +86 -0
- paddle_billing/Entities/SubscriptionPreview.py +79 -0
- paddle_billing/Entities/Subscriptions/SubscriptionAdjustmentItem.py +24 -0
- paddle_billing/Entities/Subscriptions/SubscriptionAdjustmentPreview.py +22 -0
- paddle_billing/Entities/Subscriptions/SubscriptionCharge.py +18 -0
- paddle_billing/Entities/Subscriptions/SubscriptionCredit.py +18 -0
- paddle_billing/Entities/Subscriptions/SubscriptionDetails.py +34 -0
- paddle_billing/Entities/Subscriptions/SubscriptionDiscount.py +19 -0
- paddle_billing/Entities/Subscriptions/SubscriptionEffectiveFrom.py +6 -0
- paddle_billing/Entities/Subscriptions/SubscriptionItem.py +35 -0
- paddle_billing/Entities/Subscriptions/SubscriptionItemStatus.py +7 -0
- paddle_billing/Entities/Subscriptions/SubscriptionItems.py +20 -0
- paddle_billing/Entities/Subscriptions/SubscriptionItemsWithPrice.py +19 -0
- paddle_billing/Entities/Subscriptions/SubscriptionManagementUrls.py +16 -0
- paddle_billing/Entities/Subscriptions/SubscriptionNextTransaction.py +23 -0
- paddle_billing/Entities/Subscriptions/SubscriptionNonCatalogPrice.py +30 -0
- paddle_billing/Entities/Subscriptions/SubscriptionNonCatalogPriceWithProduct.py +32 -0
- paddle_billing/Entities/Subscriptions/SubscriptionNonCatalogProduct.py +26 -0
- paddle_billing/Entities/Subscriptions/SubscriptionOnPaymentFailure.py +6 -0
- paddle_billing/Entities/Subscriptions/SubscriptionPreviewSubscriptionUpdateSummary.py +22 -0
- paddle_billing/Entities/Subscriptions/SubscriptionPrice.py +28 -0
- paddle_billing/Entities/Subscriptions/SubscriptionProration.py +18 -0
- paddle_billing/Entities/Subscriptions/SubscriptionProrationBillingMode.py +9 -0
- paddle_billing/Entities/Subscriptions/SubscriptionResult.py +22 -0
- paddle_billing/Entities/Subscriptions/SubscriptionResultAction.py +6 -0
- paddle_billing/Entities/Subscriptions/SubscriptionResumeEffectiveFrom.py +5 -0
- paddle_billing/Entities/Subscriptions/SubscriptionScheduledChange.py +21 -0
- paddle_billing/Entities/Subscriptions/SubscriptionScheduledChangeAction.py +7 -0
- paddle_billing/Entities/Subscriptions/SubscriptionStatus.py +10 -0
- paddle_billing/Entities/Subscriptions/SubscriptionTimePeriod.py +17 -0
- paddle_billing/Entities/Subscriptions/SubscriptionTransactionItem.py +23 -0
- paddle_billing/Entities/Subscriptions/SubscriptionTransactionLineItem.py +33 -0
- paddle_billing/Entities/Subscriptions/SubscriptionUpdateItem.py +16 -0
- paddle_billing/Entities/Subscriptions/__init__.py +31 -0
- paddle_billing/Entities/Transaction.py +98 -0
- paddle_billing/Entities/TransactionData.py +15 -0
- paddle_billing/Entities/TransactionPreview.py +40 -0
- paddle_billing/Entities/Transactions/TransactionAdjustmentsTotals.py +30 -0
- paddle_billing/Entities/Transactions/TransactionBreakdown.py +18 -0
- paddle_billing/Entities/Transactions/TransactionCardType.py +14 -0
- paddle_billing/Entities/Transactions/TransactionCreateItem.py +16 -0
- paddle_billing/Entities/Transactions/TransactionCreateItemWithPrice.py +11 -0
- paddle_billing/Entities/Transactions/TransactionDetails.py +32 -0
- paddle_billing/Entities/Transactions/TransactionItem.py +24 -0
- paddle_billing/Entities/Transactions/TransactionItemPreviewWithNonCatalogPrice.py +21 -0
- paddle_billing/Entities/Transactions/TransactionItemPreviewWithPrice.py +24 -0
- paddle_billing/Entities/Transactions/TransactionItemPreviewWithPriceId.py +18 -0
- paddle_billing/Entities/Transactions/TransactionLineItem.py +35 -0
- paddle_billing/Entities/Transactions/TransactionNonCatalogPrice.py +39 -0
- paddle_billing/Entities/Transactions/TransactionNonCatalogPriceWithProduct.py +41 -0
- paddle_billing/Entities/Transactions/TransactionNonCatalogProduct.py +25 -0
- paddle_billing/Entities/Transactions/TransactionProration.py +18 -0
- paddle_billing/Entities/Transactions/TransactionTimePeriod.py +17 -0
- paddle_billing/Entities/Transactions/TransactionUpdateTransactionItem.py +8 -0
- paddle_billing/Entities/Transactions/__init__.py +20 -0
- paddle_billing/Entities/__init__.py +0 -0
- paddle_billing/EnumStringify.py +2 -0
- paddle_billing/Environment.py +14 -0
- paddle_billing/Exceptions/ApiError.py +28 -0
- paddle_billing/Exceptions/ApiErrors/AddressApiError.py +5 -0
- paddle_billing/Exceptions/ApiErrors/AdjustmentApiError.py +5 -0
- paddle_billing/Exceptions/ApiErrors/BusinessApiError.py +5 -0
- paddle_billing/Exceptions/ApiErrors/CustomerApiError.py +5 -0
- paddle_billing/Exceptions/ApiErrors/DiscountApiError.py +5 -0
- paddle_billing/Exceptions/ApiErrors/PriceApiError.py +5 -0
- paddle_billing/Exceptions/ApiErrors/ProductApiError.py +5 -0
- paddle_billing/Exceptions/ApiErrors/SubscriptionApiError.py +5 -0
- paddle_billing/Exceptions/ApiErrors/TransactionApiError.py +5 -0
- paddle_billing/Exceptions/ApiErrors/__init__.py +0 -0
- paddle_billing/Exceptions/FieldError.py +8 -0
- paddle_billing/Exceptions/SdkException.py +2 -0
- paddle_billing/Exceptions/SdkExceptions/InvalidArgumentException.py +8 -0
- paddle_billing/Exceptions/SdkExceptions/MalformedResponse.py +7 -0
- paddle_billing/Exceptions/SdkExceptions/__init__.py +0 -0
- paddle_billing/Exceptions/__init__.py +0 -0
- paddle_billing/FiltersNone.py +8 -0
- paddle_billing/FiltersUndefined.py +11 -0
- paddle_billing/HasParameters.py +11 -0
- paddle_billing/Logger/Formatter.py +18 -0
- paddle_billing/Logger/NullHandler.py +6 -0
- paddle_billing/Logger/__init__.py +30 -0
- paddle_billing/Notifications/Entities/Address.py +44 -0
- paddle_billing/Notifications/Entities/Adjustment.py +45 -0
- paddle_billing/Notifications/Entities/Adjustments/AdjustmentItem.py +26 -0
- paddle_billing/Notifications/Entities/Adjustments/__init__.py +1 -0
- paddle_billing/Notifications/Entities/Business.py +39 -0
- paddle_billing/Notifications/Entities/Businesses/BusinessesContacts.py +16 -0
- paddle_billing/Notifications/Entities/Businesses/__init__.py +1 -0
- paddle_billing/Notifications/Entities/Customer.py +36 -0
- paddle_billing/Notifications/Entities/DateTime.py +43 -0
- paddle_billing/Notifications/Entities/Discount.py +51 -0
- paddle_billing/Notifications/Entities/Discounts/DiscountStatus.py +8 -0
- paddle_billing/Notifications/Entities/Discounts/DiscountType.py +7 -0
- paddle_billing/Notifications/Entities/Discounts/__init__.py +2 -0
- paddle_billing/Notifications/Entities/Entity.py +12 -0
- paddle_billing/Notifications/Entities/Payout.py +24 -0
- paddle_billing/Notifications/Entities/Payouts/PayoutStatus.py +6 -0
- paddle_billing/Notifications/Entities/Payouts/__init__.py +1 -0
- paddle_billing/Notifications/Entities/Price.py +66 -0
- paddle_billing/Notifications/Entities/Product.py +45 -0
- paddle_billing/Notifications/Entities/Report.py +32 -0
- paddle_billing/Notifications/Entities/Reports/ReportFilter.py +20 -0
- paddle_billing/Notifications/Entities/Reports/ReportFilterName.py +17 -0
- paddle_billing/Notifications/Entities/Reports/ReportFilterOperator.py +6 -0
- paddle_billing/Notifications/Entities/Reports/ReportStatus.py +8 -0
- paddle_billing/Notifications/Entities/Reports/ReportType.py +10 -0
- paddle_billing/Notifications/Entities/Reports/__init__.py +5 -0
- paddle_billing/Notifications/Entities/Shared/Action.py +10 -0
- paddle_billing/Notifications/Entities/Shared/AddressPreview.py +18 -0
- paddle_billing/Notifications/Entities/Shared/AdjustmentItemTotals.py +18 -0
- paddle_billing/Notifications/Entities/Shared/AdjustmentProration.py +18 -0
- paddle_billing/Notifications/Entities/Shared/AdjustmentStatus.py +8 -0
- paddle_billing/Notifications/Entities/Shared/AdjustmentTimePeriod.py +17 -0
- paddle_billing/Notifications/Entities/Shared/AdjustmentTotals.py +26 -0
- paddle_billing/Notifications/Entities/Shared/AdjustmentType.py +8 -0
- paddle_billing/Notifications/Entities/Shared/AvailablePaymentMethods.py +11 -0
- paddle_billing/Notifications/Entities/Shared/BillingDetails.py +22 -0
- paddle_billing/Notifications/Entities/Shared/Card.py +24 -0
- paddle_billing/Notifications/Entities/Shared/CatalogType.py +6 -0
- paddle_billing/Notifications/Entities/Shared/ChargebackFee.py +18 -0
- paddle_billing/Notifications/Entities/Shared/Checkout.py +12 -0
- paddle_billing/Notifications/Entities/Shared/CollectionMode.py +6 -0
- paddle_billing/Notifications/Entities/Shared/CountryCode.py +233 -0
- paddle_billing/Notifications/Entities/Shared/CurrencyCode.py +34 -0
- paddle_billing/Notifications/Entities/Shared/CurrencyCodeAdjustments.py +7 -0
- paddle_billing/Notifications/Entities/Shared/CurrencyCodePayouts.py +17 -0
- paddle_billing/Notifications/Entities/Shared/CustomData.py +10 -0
- paddle_billing/Notifications/Entities/Shared/Data.py +9 -0
- paddle_billing/Notifications/Entities/Shared/ErrorCode.py +21 -0
- paddle_billing/Notifications/Entities/Shared/ImportMeta.py +16 -0
- paddle_billing/Notifications/Entities/Shared/Interval.py +8 -0
- paddle_billing/Notifications/Entities/Shared/MethodDetails.py +19 -0
- paddle_billing/Notifications/Entities/Shared/Money.py +28 -0
- paddle_billing/Notifications/Entities/Shared/Original.py +18 -0
- paddle_billing/Notifications/Entities/Shared/PaymentAttemptStatus.py +13 -0
- paddle_billing/Notifications/Entities/Shared/PaymentMethodType.py +15 -0
- paddle_billing/Notifications/Entities/Shared/PayoutTotalsAdjustment.py +29 -0
- paddle_billing/Notifications/Entities/Shared/PriceQuantity.py +16 -0
- paddle_billing/Notifications/Entities/Shared/Status.py +6 -0
- paddle_billing/Notifications/Entities/Shared/TaxCategory.py +13 -0
- paddle_billing/Notifications/Entities/Shared/TaxMode.py +7 -0
- paddle_billing/Notifications/Entities/Shared/TaxRatesUsed.py +18 -0
- paddle_billing/Notifications/Entities/Shared/TimePeriod.py +18 -0
- paddle_billing/Notifications/Entities/Shared/Totals.py +20 -0
- paddle_billing/Notifications/Entities/Shared/TransactionOrigin.py +10 -0
- paddle_billing/Notifications/Entities/Shared/TransactionPaymentAttempt.py +35 -0
- paddle_billing/Notifications/Entities/Shared/TransactionPayoutTotals.py +36 -0
- paddle_billing/Notifications/Entities/Shared/TransactionPayoutTotalsAdjusted.py +29 -0
- paddle_billing/Notifications/Entities/Shared/TransactionStatus.py +11 -0
- paddle_billing/Notifications/Entities/Shared/TransactionTotals.py +36 -0
- paddle_billing/Notifications/Entities/Shared/TransactionTotalsAdjusted.py +28 -0
- paddle_billing/Notifications/Entities/Shared/UnitPriceOverride.py +19 -0
- paddle_billing/Notifications/Entities/Shared/UnitTotals.py +20 -0
- paddle_billing/Notifications/Entities/Shared/__init__.py +46 -0
- paddle_billing/Notifications/Entities/Subscription.py +76 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionAdjustmentItem.py +24 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionCharge.py +18 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionCredit.py +18 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionDiscount.py +19 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionEffectiveFrom.py +6 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionItem.py +35 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionItemStatus.py +7 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionOnPaymentFailure.py +6 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionPrice.py +28 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionScheduledChange.py +21 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionScheduledChangeAction.py +7 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionStatus.py +10 -0
- paddle_billing/Notifications/Entities/Subscriptions/SubscriptionTimePeriod.py +17 -0
- paddle_billing/Notifications/Entities/Subscriptions/__init__.py +13 -0
- paddle_billing/Notifications/Entities/Transaction.py +75 -0
- paddle_billing/Notifications/Entities/Transactions/TransactionAdjustmentsTotals.py +30 -0
- paddle_billing/Notifications/Entities/Transactions/TransactionBreakdown.py +18 -0
- paddle_billing/Notifications/Entities/Transactions/TransactionCardType.py +14 -0
- paddle_billing/Notifications/Entities/Transactions/TransactionDetails.py +32 -0
- paddle_billing/Notifications/Entities/Transactions/TransactionItem.py +24 -0
- paddle_billing/Notifications/Entities/Transactions/TransactionLineItem.py +35 -0
- paddle_billing/Notifications/Entities/Transactions/TransactionProration.py +18 -0
- paddle_billing/Notifications/Entities/Transactions/TransactionTimePeriod.py +17 -0
- paddle_billing/Notifications/Entities/Transactions/__init__.py +11 -0
- paddle_billing/Notifications/Entities/__init__.py +0 -0
- paddle_billing/Notifications/Events/AddressCreated.py +17 -0
- paddle_billing/Notifications/Events/AddressUpdated.py +17 -0
- paddle_billing/Notifications/Events/AdjustmentCreated.py +17 -0
- paddle_billing/Notifications/Events/AdjustmentUpdated.py +17 -0
- paddle_billing/Notifications/Events/BusinessCreated.py +17 -0
- paddle_billing/Notifications/Events/BusinessUpdated.py +17 -0
- paddle_billing/Notifications/Events/CustomerCreated.py +17 -0
- paddle_billing/Notifications/Events/CustomerUpdated.py +17 -0
- paddle_billing/Notifications/Events/DiscountCreated.py +17 -0
- paddle_billing/Notifications/Events/DiscountImported.py +17 -0
- paddle_billing/Notifications/Events/DiscountUpdated.py +17 -0
- paddle_billing/Notifications/Events/PayoutCreated.py +17 -0
- paddle_billing/Notifications/Events/PayoutPaid.py +17 -0
- paddle_billing/Notifications/Events/PriceCreated.py +17 -0
- paddle_billing/Notifications/Events/PriceUpdated.py +17 -0
- paddle_billing/Notifications/Events/ProductCreated.py +17 -0
- paddle_billing/Notifications/Events/ProductUpdated.py +17 -0
- paddle_billing/Notifications/Events/ReportCreated.py +17 -0
- paddle_billing/Notifications/Events/ReportUpdated.py +17 -0
- paddle_billing/Notifications/Events/SubscriptionActivated.py +17 -0
- paddle_billing/Notifications/Events/SubscriptionCanceled.py +17 -0
- paddle_billing/Notifications/Events/SubscriptionCreated.py +17 -0
- paddle_billing/Notifications/Events/SubscriptionImported.py +17 -0
- paddle_billing/Notifications/Events/SubscriptionPastDue.py +17 -0
- paddle_billing/Notifications/Events/SubscriptionPaused.py +17 -0
- paddle_billing/Notifications/Events/SubscriptionResumed.py +17 -0
- paddle_billing/Notifications/Events/SubscriptionTrialing.py +17 -0
- paddle_billing/Notifications/Events/SubscriptionUpdated.py +17 -0
- paddle_billing/Notifications/Events/TransactionBilled.py +17 -0
- paddle_billing/Notifications/Events/TransactionCanceled.py +17 -0
- paddle_billing/Notifications/Events/TransactionCompleted.py +16 -0
- paddle_billing/Notifications/Events/TransactionCreated.py +17 -0
- paddle_billing/Notifications/Events/TransactionPaid.py +17 -0
- paddle_billing/Notifications/Events/TransactionPastDue.py +17 -0
- paddle_billing/Notifications/Events/TransactionPaymentFailed.py +17 -0
- paddle_billing/Notifications/Events/TransactionReady.py +17 -0
- paddle_billing/Notifications/Events/TransactionUpdated.py +17 -0
- paddle_billing/Notifications/Events/__init__.py +0 -0
- paddle_billing/Notifications/PaddleSignature.py +128 -0
- paddle_billing/Notifications/Secret.py +8 -0
- paddle_billing/Notifications/Verifier.py +55 -0
- paddle_billing/Notifications/__init__.py +3 -0
- paddle_billing/Options.py +10 -0
- paddle_billing/PaddleStrEnum.py +44 -0
- paddle_billing/RecursivelyRemoveKey.py +14 -0
- paddle_billing/Resources/Addresses/AddressesClient.py +58 -0
- paddle_billing/Resources/Addresses/Operations/CreateAddress.py +20 -0
- paddle_billing/Resources/Addresses/Operations/ListAddresses.py +42 -0
- paddle_billing/Resources/Addresses/Operations/UpdateAddress.py +21 -0
- paddle_billing/Resources/Addresses/Operations/__init__.py +3 -0
- paddle_billing/Resources/Addresses/__init__.py +0 -0
- paddle_billing/Resources/Adjustments/AdjustmentsClient.py +36 -0
- paddle_billing/Resources/Adjustments/Operations/Create/AdjustmentItem.py +11 -0
- paddle_billing/Resources/Adjustments/Operations/Create/__init__.py +0 -0
- paddle_billing/Resources/Adjustments/Operations/CreateAdjustment.py +28 -0
- paddle_billing/Resources/Adjustments/Operations/ListAdjustments.py +60 -0
- paddle_billing/Resources/Adjustments/Operations/__init__.py +3 -0
- paddle_billing/Resources/Adjustments/__init__.py +0 -0
- paddle_billing/Resources/Businesses/BusinessesClient.py +58 -0
- paddle_billing/Resources/Businesses/Operations/CreateBusiness.py +17 -0
- paddle_billing/Resources/Businesses/Operations/ListBusinesses.py +45 -0
- paddle_billing/Resources/Businesses/Operations/UpdateBusiness.py +18 -0
- paddle_billing/Resources/Businesses/Operations/__init__.py +3 -0
- paddle_billing/Resources/Businesses/__init__.py +0 -0
- paddle_billing/Resources/Customers/CustomersClient.py +65 -0
- paddle_billing/Resources/Customers/Operations/CreateCustomer.py +16 -0
- paddle_billing/Resources/Customers/Operations/ListCreditBalances.py +28 -0
- paddle_billing/Resources/Customers/Operations/ListCustomers.py +50 -0
- paddle_billing/Resources/Customers/Operations/UpdateCustomer.py +17 -0
- paddle_billing/Resources/Customers/Operations/__init__.py +4 -0
- paddle_billing/Resources/Customers/__init__.py +0 -0
- paddle_billing/Resources/Discounts/DiscountsClient.py +55 -0
- paddle_billing/Resources/Discounts/Operations/CreateDiscount.py +24 -0
- paddle_billing/Resources/Discounts/Operations/ListDiscounts.py +46 -0
- paddle_billing/Resources/Discounts/Operations/UpdateDiscount.py +25 -0
- paddle_billing/Resources/Discounts/Operations/__init__.py +3 -0
- paddle_billing/Resources/Discounts/__init__.py +0 -0
- paddle_billing/Resources/EventTypes/EventTypesClient.py +22 -0
- paddle_billing/Resources/EventTypes/__init__.py +0 -0
- paddle_billing/Resources/Events/EventsClient.py +26 -0
- paddle_billing/Resources/Events/Operations/ListEvents.py +12 -0
- paddle_billing/Resources/Events/Operations/__init__.py +1 -0
- paddle_billing/Resources/Events/__init__.py +0 -0
- paddle_billing/Resources/NotificationLogs/NotificationLogsClient.py +26 -0
- paddle_billing/Resources/NotificationLogs/Operations/ListNotificationLogs.py +11 -0
- paddle_billing/Resources/NotificationLogs/Operations/__init__.py +1 -0
- paddle_billing/Resources/NotificationLogs/__init__.py +0 -0
- paddle_billing/Resources/NotificationSettings/NotificationSettingsClient.py +54 -0
- paddle_billing/Resources/NotificationSettings/Operations/CreateNotificationSetting.py +21 -0
- paddle_billing/Resources/NotificationSettings/Operations/UpdateNotificationSetting.py +20 -0
- paddle_billing/Resources/NotificationSettings/Operations/__init__.py +2 -0
- paddle_billing/Resources/NotificationSettings/__init__.py +0 -0
- paddle_billing/Resources/Notifications/NotificationsClient.py +44 -0
- paddle_billing/Resources/Notifications/Operations/ListNotifications.py +58 -0
- paddle_billing/Resources/Notifications/Operations/__init__.py +1 -0
- paddle_billing/Resources/Notifications/__init__.py +0 -0
- paddle_billing/Resources/Prices/Operations/CreatePrice.py +23 -0
- paddle_billing/Resources/Prices/Operations/List/Includes.py +5 -0
- paddle_billing/Resources/Prices/Operations/List/__init__.py +0 -0
- paddle_billing/Resources/Prices/Operations/ListPrices.py +62 -0
- paddle_billing/Resources/Prices/Operations/UpdatePrice.py +23 -0
- paddle_billing/Resources/Prices/Operations/__init__.py +4 -0
- paddle_billing/Resources/Prices/PricesClient.py +65 -0
- paddle_billing/Resources/Prices/__init__.py +0 -0
- paddle_billing/Resources/PricingPreviews/Operations/PreviewPrice.py +20 -0
- paddle_billing/Resources/PricingPreviews/Operations/__init__.py +1 -0
- paddle_billing/Resources/PricingPreviews/PricingPreviewsClient.py +20 -0
- paddle_billing/Resources/PricingPreviews/__init__.py +0 -0
- paddle_billing/Resources/Products/Operations/CreateProduct.py +18 -0
- paddle_billing/Resources/Products/Operations/List/Includes.py +5 -0
- paddle_billing/Resources/Products/Operations/List/__init__.py +0 -0
- paddle_billing/Resources/Products/Operations/ListProducts.py +59 -0
- paddle_billing/Resources/Products/Operations/UpdateProduct.py +19 -0
- paddle_billing/Resources/Products/Operations/__init__.py +4 -0
- paddle_billing/Resources/Products/ProductsClient.py +70 -0
- paddle_billing/Resources/Products/__init__.py +0 -0
- paddle_billing/Resources/Reports/Operations/CreateReport.py +27 -0
- paddle_billing/Resources/Reports/Operations/ListReports.py +35 -0
- paddle_billing/Resources/Reports/Operations/__init__.py +2 -0
- paddle_billing/Resources/Reports/ReportsClient.py +51 -0
- paddle_billing/Resources/Reports/__init__.py +0 -0
- paddle_billing/Resources/Shared/Operations/List/Comparator.py +8 -0
- paddle_billing/Resources/Shared/Operations/List/DateComparison.py +31 -0
- paddle_billing/Resources/Shared/Operations/List/OrderBy.py +21 -0
- paddle_billing/Resources/Shared/Operations/List/Pager.py +24 -0
- paddle_billing/Resources/Shared/Operations/List/__init__.py +0 -0
- paddle_billing/Resources/Shared/Operations/__init__.py +4 -0
- paddle_billing/Resources/Shared/__init__.py +0 -0
- paddle_billing/Resources/Subscriptions/Operations/CancelSubscription.py +12 -0
- paddle_billing/Resources/Subscriptions/Operations/CreateOneTimeCharge.py +22 -0
- paddle_billing/Resources/Subscriptions/Operations/Get/Includes.py +6 -0
- paddle_billing/Resources/Subscriptions/Operations/Get/__init__.py +0 -0
- paddle_billing/Resources/Subscriptions/Operations/ListSubscriptions.py +59 -0
- paddle_billing/Resources/Subscriptions/Operations/PauseSubscription.py +19 -0
- paddle_billing/Resources/Subscriptions/Operations/PreviewOneTimeCharge.py +22 -0
- paddle_billing/Resources/Subscriptions/Operations/PreviewUpdateSubscription.py +37 -0
- paddle_billing/Resources/Subscriptions/Operations/ResumeSubscription.py +17 -0
- paddle_billing/Resources/Subscriptions/Operations/Update/SubscriptionDiscount.py +9 -0
- paddle_billing/Resources/Subscriptions/Operations/Update/__init__.py +0 -0
- paddle_billing/Resources/Subscriptions/Operations/UpdateSubscription.py +37 -0
- paddle_billing/Resources/Subscriptions/Operations/__init__.py +10 -0
- paddle_billing/Resources/Subscriptions/SubscriptionsClient.py +121 -0
- paddle_billing/Resources/Subscriptions/__init__.py +0 -0
- paddle_billing/Resources/Transactions/Operations/CreateTransaction.py +25 -0
- paddle_billing/Resources/Transactions/Operations/List/Includes.py +11 -0
- paddle_billing/Resources/Transactions/Operations/List/Origin.py +10 -0
- paddle_billing/Resources/Transactions/Operations/List/__init__.py +0 -0
- paddle_billing/Resources/Transactions/Operations/ListTransactions.py +86 -0
- paddle_billing/Resources/Transactions/Operations/PreviewTransaction.py +24 -0
- paddle_billing/Resources/Transactions/Operations/UpdateTransaction.py +25 -0
- paddle_billing/Resources/Transactions/Operations/__init__.py +6 -0
- paddle_billing/Resources/Transactions/TransactionsClient.py +90 -0
- paddle_billing/Resources/Transactions/__init__.py +0 -0
- paddle_billing/Resources/__init__.py +0 -0
- paddle_billing/ResponseParser.py +65 -0
- paddle_billing/Undefined.py +2 -0
- paddle_billing/__init__.py +4 -0
- paddle_python_sdk-0.1.0.dist-info/LICENSE +190 -0
- paddle_python_sdk-0.1.0.dist-info/METADATA +184 -0
- paddle_python_sdk-0.1.0.dist-info/RECORD +517 -0
- paddle_python_sdk-0.1.0.dist-info/WHEEL +5 -0
- paddle_python_sdk-0.1.0.dist-info/top_level.txt +3 -0
- tests/Functional/Resources/Addresses/__init__.py +0 -0
- tests/Functional/Resources/Addresses/test_AddressesClient.py +274 -0
- tests/Functional/Resources/Adjustments/__init__.py +0 -0
- tests/Functional/Resources/Adjustments/test_AdjustmentsClient.py +188 -0
- tests/Functional/Resources/Businesses/__init__.py +0 -0
- tests/Functional/Resources/Businesses/test_BusinessesClient.py +279 -0
- tests/Functional/Resources/Customers/__init__.py +0 -0
- tests/Functional/Resources/Customers/test_CustomersClient.py +291 -0
- tests/Functional/Resources/Discounts/__init__.py +0 -0
- tests/Functional/Resources/Discounts/test_DiscountsClient.py +280 -0
- tests/Functional/Resources/EventTypes/__init__.py +0 -0
- tests/Functional/Resources/EventTypes/test_EventTypesClient.py +43 -0
- tests/Functional/Resources/Events/__init__.py +0 -0
- tests/Functional/Resources/Events/test_EventsClient.py +64 -0
- tests/Functional/Resources/NotificationLogs/__init__.py +0 -0
- tests/Functional/Resources/NotificationLogs/test_NotificationLogsClient.py +68 -0
- tests/Functional/Resources/NotificationSettings/__init__.py +0 -0
- tests/Functional/Resources/NotificationSettings/test_NotificationSettingsClient.py +287 -0
- tests/Functional/Resources/Notifications/__init__.py +0 -0
- tests/Functional/Resources/Notifications/test_NotificationsClient.py +202 -0
- tests/Functional/Resources/Prices/__init__.py +0 -0
- tests/Functional/Resources/Prices/test_PricesClient.py +307 -0
- tests/Functional/Resources/PricingPreviews/__init__.py +0 -0
- tests/Functional/Resources/PricingPreviews/test_PricingPreviewsClient.py +92 -0
- tests/Functional/Resources/Products/__init__.py +0 -0
- tests/Functional/Resources/Products/test_ProductsClient.py +271 -0
- tests/Functional/Resources/Reports/__init__.py +0 -0
- tests/Functional/Resources/Reports/test_ReportsClient.py +197 -0
- tests/Functional/Resources/Subscriptions/__init__.py +0 -0
- tests/Functional/Resources/Subscriptions/test_SubscriptionsClient.py +758 -0
- tests/Functional/Resources/Transactions/__init__.py +0 -0
- tests/Functional/Resources/Transactions/test_TransactionsClient.py +585 -0
- tests/Functional/Resources/__init__.py +0 -0
- tests/Functional/__init__.py +0 -0
- tests/Unit/Logger/__init__.py +0 -0
- tests/Unit/Logger/test_Logger.py +10 -0
- tests/Unit/Notification/__init__.py +0 -0
- tests/Unit/Notification/test_Verifier.py +63 -0
- tests/Unit/PaddleStrEnum/__init__.py +0 -0
- tests/Unit/PaddleStrEnum/test_PaddleStrEnum.py +52 -0
- tests/Unit/__init__.py +0 -0
- tests/Utils/FakeResponse.py +6 -0
- tests/Utils/ReadsFixture.py +33 -0
- tests/Utils/TestClient.py +48 -0
- tests/Utils/__init__.py +1 -0
- tests/__init__.py +0 -0
examples/__init__.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
from logging import getLogger
|
|
2
|
+
from os import getenv
|
|
3
|
+
from sys import exit # You should use classes/functions that returns instead of exits
|
|
4
|
+
|
|
5
|
+
from paddle_billing import Client, Environment, Options
|
|
6
|
+
|
|
7
|
+
from paddle_billing.Entities.Shared import (
|
|
8
|
+
CountryCode,
|
|
9
|
+
CurrencyCode,
|
|
10
|
+
CustomData,
|
|
11
|
+
Money,
|
|
12
|
+
TimePeriod,
|
|
13
|
+
PriceQuantity,
|
|
14
|
+
UnitPriceOverride,
|
|
15
|
+
Interval,
|
|
16
|
+
Status,
|
|
17
|
+
TaxCategory
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
from paddle_billing.Exceptions.ApiError import ApiError
|
|
21
|
+
from paddle_billing.Exceptions.SdkExceptions.MalformedResponse import MalformedResponse
|
|
22
|
+
|
|
23
|
+
from paddle_billing.Resources.Prices.Operations import CreatePrice, UpdatePrice, PriceIncludes
|
|
24
|
+
from paddle_billing.Resources.Products.Operations import CreateProduct, UpdateProduct, ProductIncludes, ListProducts
|
|
25
|
+
|
|
26
|
+
log = getLogger('my_app')
|
|
27
|
+
|
|
28
|
+
# Verify your Paddle API key was provided by a PADDLE_SECRET_API_KEY environment variable
|
|
29
|
+
# It is strongly advised that you do not include secrets in your source code
|
|
30
|
+
# Use environment variables, and/or secrets management like Vault to obtain your secrets
|
|
31
|
+
api_key: str = getenv('PADDLE_SECRET_API_KEY', None)
|
|
32
|
+
if not api_key:
|
|
33
|
+
raise ValueError("You must provide the PADDLE_SECRET_API_KEY in your environment variables")
|
|
34
|
+
|
|
35
|
+
# Determine the environment, defaulting to sandbox
|
|
36
|
+
environment = getenv('PADDLE_ENVIRONMENT', 'sandbox')
|
|
37
|
+
paddle_environment = getattr(Environment, environment) # E.g. Environment.sandbox
|
|
38
|
+
|
|
39
|
+
# Initialize the Paddle client
|
|
40
|
+
paddle = Client(api_key, options=Options(paddle_environment), logger=log)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# ┌───
|
|
44
|
+
# │ Create Product │
|
|
45
|
+
# └────────────────┘
|
|
46
|
+
try:
|
|
47
|
+
product = paddle.products.create(CreateProduct(
|
|
48
|
+
name = 'Kitten Service',
|
|
49
|
+
tax_category = TaxCategory.Standard,
|
|
50
|
+
description = 'Simply an awesome product',
|
|
51
|
+
image_url = 'https://placekitten.com/200/300',
|
|
52
|
+
custom_data = CustomData({'foo': 'bar'}),
|
|
53
|
+
))
|
|
54
|
+
except (ApiError, MalformedResponse) as error:
|
|
55
|
+
print(error)
|
|
56
|
+
exit(1)
|
|
57
|
+
|
|
58
|
+
print(f"Created product '{product.id}': {product.description}")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# ┌───
|
|
62
|
+
# │ Update Product │
|
|
63
|
+
# └────────────────┘
|
|
64
|
+
try:
|
|
65
|
+
product = paddle.products.update(product.id, UpdateProduct(
|
|
66
|
+
name = 'Bear Service',
|
|
67
|
+
image_url = 'https://placebear.com/200/300',
|
|
68
|
+
custom_data = CustomData({'beep': 'boop'}),
|
|
69
|
+
))
|
|
70
|
+
except (ApiError, MalformedResponse) as error:
|
|
71
|
+
print(error)
|
|
72
|
+
exit(1)
|
|
73
|
+
|
|
74
|
+
print(f"Updated product '{product.id}': {product.description}")
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
# ┌───
|
|
78
|
+
# │ Create Price │
|
|
79
|
+
# └──────────────┘
|
|
80
|
+
try:
|
|
81
|
+
price = paddle.prices.create(CreatePrice(
|
|
82
|
+
description = 'Bear Hug',
|
|
83
|
+
product_id = product.id,
|
|
84
|
+
unit_price = Money('1000', CurrencyCode.GBP),
|
|
85
|
+
trial_period = TimePeriod(Interval.Week, 1),
|
|
86
|
+
billing_cycle = TimePeriod(Interval.Year, 1),
|
|
87
|
+
quantity = PriceQuantity(1, 1),
|
|
88
|
+
custom_data = CustomData({'foo': 'bar'}),
|
|
89
|
+
|
|
90
|
+
unit_price_overrides=[
|
|
91
|
+
UnitPriceOverride(
|
|
92
|
+
[CountryCode.CA, CountryCode.US],
|
|
93
|
+
Money('5000', CurrencyCode.USD),
|
|
94
|
+
),
|
|
95
|
+
],
|
|
96
|
+
))
|
|
97
|
+
except (ApiError, MalformedResponse) as error:
|
|
98
|
+
print(error)
|
|
99
|
+
exit(1)
|
|
100
|
+
|
|
101
|
+
print(f"Created price '{price.id}': {price.description}")
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# ┌───
|
|
105
|
+
# │ Update Price │
|
|
106
|
+
# └──────────────┘
|
|
107
|
+
try:
|
|
108
|
+
price = paddle.prices.update(price.id, UpdatePrice(
|
|
109
|
+
description = 'One-off Bear Hug',
|
|
110
|
+
unit_price = Money('500', CurrencyCode.GBP),
|
|
111
|
+
custom_data = CustomData({'beep': 'boop'}),
|
|
112
|
+
))
|
|
113
|
+
except (ApiError, MalformedResponse) as error:
|
|
114
|
+
print(error)
|
|
115
|
+
exit(1)
|
|
116
|
+
|
|
117
|
+
print(f"Updated price '{price.id}': {price.description}")
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
# ┌───
|
|
121
|
+
# │ Get Product with Prices │
|
|
122
|
+
# └─────────────────────────┘
|
|
123
|
+
try:
|
|
124
|
+
product = paddle.products.get(product.id, [ProductIncludes.Prices])
|
|
125
|
+
except (ApiError, MalformedResponse) as error:
|
|
126
|
+
print(error)
|
|
127
|
+
exit(1)
|
|
128
|
+
|
|
129
|
+
print(f"product.prices={product.prices}")
|
|
130
|
+
print(f"Read product '{product.id}' with prices " + ', '.join([str(price.id) for price in product.prices]))
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
# ┌───
|
|
134
|
+
# │ Get Price with Product │
|
|
135
|
+
# └────────────────────────┘
|
|
136
|
+
try:
|
|
137
|
+
price = paddle.prices.get(price.id, [PriceIncludes.Product])
|
|
138
|
+
except (ApiError, MalformedResponse) as error:
|
|
139
|
+
print(error)
|
|
140
|
+
exit(1)
|
|
141
|
+
|
|
142
|
+
print(f"Read price '{price.id}' with product {price.product.id if price.product else 'MISSING PRODUCT'}")
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
# ┌───
|
|
146
|
+
# │ Get Products │
|
|
147
|
+
# └──────────────┘
|
|
148
|
+
try:
|
|
149
|
+
products = paddle.products.list(ListProducts(
|
|
150
|
+
includes = [ProductIncludes.Prices],
|
|
151
|
+
statuses = [Status.Active],
|
|
152
|
+
))
|
|
153
|
+
except (ApiError, MalformedResponse) as error:
|
|
154
|
+
print(error)
|
|
155
|
+
exit(1)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
# ┌───
|
|
159
|
+
# │ Iterate Products and Prices │
|
|
160
|
+
# └─────────────────────────────┘
|
|
161
|
+
for product in products:
|
|
162
|
+
print(f"Product: {product.name}")
|
|
163
|
+
print('-' * len(product.name))
|
|
164
|
+
for price in product.prices:
|
|
165
|
+
print(f"Price: {price.name} - {price.description}")
|
|
166
|
+
print()
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
from logging import getLogger
|
|
2
|
+
from os import getenv
|
|
3
|
+
from sys import exit # You should use classes/functions that returns instead of exits
|
|
4
|
+
|
|
5
|
+
from paddle_billing import Client, Environment, Options
|
|
6
|
+
|
|
7
|
+
from paddle_billing.Exceptions.ApiError import ApiError
|
|
8
|
+
from paddle_billing.Exceptions.SdkExceptions.MalformedResponse import MalformedResponse
|
|
9
|
+
|
|
10
|
+
from paddle_billing.Resources.Events.Operations import ListEvents
|
|
11
|
+
from paddle_billing.Resources.Shared.Operations import Pager
|
|
12
|
+
|
|
13
|
+
log = getLogger('my_app')
|
|
14
|
+
|
|
15
|
+
# Verify your Paddle API key was provided by a PADDLE_SECRET_API_KEY environment variable
|
|
16
|
+
# It is strongly advised that you do not include secrets in your source code
|
|
17
|
+
# Use environment variables, and/or secrets management like Vault to obtain your secrets
|
|
18
|
+
api_key: str = getenv('PADDLE_SECRET_API_KEY', None)
|
|
19
|
+
if not api_key:
|
|
20
|
+
raise ValueError("You must provide the PADDLE_SECRET_API_KEY in your environment variables")
|
|
21
|
+
|
|
22
|
+
# Determine the environment, defaulting to sandbox
|
|
23
|
+
environment = getenv('PADDLE_ENVIRONMENT', 'sandbox')
|
|
24
|
+
paddle_environment = getattr(Environment, environment) # E.g. Environment.sandbox
|
|
25
|
+
|
|
26
|
+
# Initialize the Paddle client
|
|
27
|
+
paddle = Client(api_key, options=Options(paddle_environment), logger=log)
|
|
28
|
+
|
|
29
|
+
# Placeholder for the last processed event ID
|
|
30
|
+
last_processed_event_id = 'evt_01hfxx8t6ek9h399srcrp36jt3'
|
|
31
|
+
|
|
32
|
+
events = None
|
|
33
|
+
try:
|
|
34
|
+
# List events starting after the last processed event ID
|
|
35
|
+
events = paddle.events.list(ListEvents(Pager(after=last_processed_event_id)))
|
|
36
|
+
except (ApiError, MalformedResponse) as error:
|
|
37
|
+
log.error(error)
|
|
38
|
+
# Your additional logic that can handle Paddle's hints about what went wrong
|
|
39
|
+
except Exception as error:
|
|
40
|
+
log.error(f"We received an error listing events: {error}")
|
|
41
|
+
|
|
42
|
+
if not events:
|
|
43
|
+
print("There was an error trying to list events")
|
|
44
|
+
exit(1)
|
|
45
|
+
if not len(events.items):
|
|
46
|
+
log.warning("There are no events to list")
|
|
47
|
+
print("There are no products to list")
|
|
48
|
+
exit(0)
|
|
49
|
+
|
|
50
|
+
for event in events:
|
|
51
|
+
last_processed_event_id = event.event_id # Update the last processed event ID
|
|
52
|
+
print(f"event: {event.event_id}\t\t Type: {event.event_type.value:28}\t\t Occurred At: {event.occurred_at.format()}")
|
|
53
|
+
# Your additional logic for using each event
|
|
54
|
+
|
|
55
|
+
# Now you're up-to-date, you should keep a record of the last processed event...
|
|
56
|
+
# db.save(db_events.update({last_processed_event_id=last_processed_event_id})
|
examples/get_products.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from logging import getLogger
|
|
2
|
+
from os import getenv
|
|
3
|
+
from sys import exit # You should use classes/functions that returns instead of exits
|
|
4
|
+
|
|
5
|
+
from paddle_billing import Client, Environment, Options
|
|
6
|
+
|
|
7
|
+
from paddle_billing.Exceptions.ApiError import ApiError
|
|
8
|
+
from paddle_billing.Exceptions.SdkExceptions.MalformedResponse import MalformedResponse
|
|
9
|
+
|
|
10
|
+
log = getLogger('my_app')
|
|
11
|
+
|
|
12
|
+
# Verify your Paddle API key was provided by a PADDLE_SECRET_API_KEY environment variable
|
|
13
|
+
# It is strongly advised that you do not include secrets in your source code
|
|
14
|
+
# Use environment variables, and/or secrets management like Vault to obtain your secrets
|
|
15
|
+
api_key = getenv('PADDLE_SECRET_API_KEY', None)
|
|
16
|
+
if not api_key:
|
|
17
|
+
raise ValueError("You must provide the PADDLE_SECRET_API_KEY in your environment variables")
|
|
18
|
+
|
|
19
|
+
# Determine the environment, defaulting to sandbox
|
|
20
|
+
environment = getenv('PADDLE_ENVIRONMENT', 'sandbox')
|
|
21
|
+
paddle_environment = getattr(Environment, environment) # E.g. Environment.sandbox
|
|
22
|
+
|
|
23
|
+
# Initialize the Paddle client
|
|
24
|
+
paddle = Client(api_key, options=Options(paddle_environment), logger=log)
|
|
25
|
+
|
|
26
|
+
products = None
|
|
27
|
+
try:
|
|
28
|
+
products = paddle.products.list()
|
|
29
|
+
except (ApiError, MalformedResponse) as error:
|
|
30
|
+
log.error(error)
|
|
31
|
+
# Your additional logic that can handle Paddle's hints about what went wrong
|
|
32
|
+
except Exception as error:
|
|
33
|
+
log.error(f"We received an error listing products: {error}")
|
|
34
|
+
|
|
35
|
+
if not products:
|
|
36
|
+
print("There was an error trying to list products")
|
|
37
|
+
exit(1)
|
|
38
|
+
if not len(products.items):
|
|
39
|
+
log.warning("There are no products to list, have you created one?")
|
|
40
|
+
print("There are no products to list")
|
|
41
|
+
exit(0)
|
|
42
|
+
|
|
43
|
+
# No need to specifically iterate products.items, products itself is iterable
|
|
44
|
+
for product in products:
|
|
45
|
+
print(f"Product's id: {product.id}")
|
|
46
|
+
# Your additional logic for using each product
|
examples/logger.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from os import getenv
|
|
4
|
+
from paddle_billing import Client, Environment, Options
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# Verify your Paddle API key was provided by a PADDLE_SECRET_API_KEY environment variable
|
|
8
|
+
# It is strongly advised that you do not include secrets in your source code
|
|
9
|
+
# Use environment variables, and/or secrets management like Vault to obtain your secrets
|
|
10
|
+
api_key = getenv('PADDLE_SECRET_API_KEY', None)
|
|
11
|
+
if not api_key:
|
|
12
|
+
raise ValueError("You must provide the PADDLE_SECRET_API_KEY in your environment variables")
|
|
13
|
+
|
|
14
|
+
# Determine the environment, defaulting to sandbox
|
|
15
|
+
environment = getenv('PADDLE_ENVIRONMENT', 'sandbox')
|
|
16
|
+
paddle_environment = getattr(Environment, environment) # E.g. Environment.sandbox
|
|
17
|
+
|
|
18
|
+
# Initialize the Paddle client
|
|
19
|
+
paddle = Client(
|
|
20
|
+
api_key,
|
|
21
|
+
options = Options(paddle_environment),
|
|
22
|
+
logger = logging.getLogger('my_app'),
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
# Set up logging to standard output
|
|
26
|
+
stdout_handler = logging.StreamHandler()
|
|
27
|
+
stdout_handler.setLevel(logging.INFO)
|
|
28
|
+
paddle.log.addHandler(stdout_handler)
|
|
29
|
+
|
|
30
|
+
# List products
|
|
31
|
+
paddle.products.list()
|
paddle_billing/Client.py
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
from json import dumps as json_dumps
|
|
2
|
+
from logging import Logger, getLogger
|
|
3
|
+
from requests import Response, RequestException, Session
|
|
4
|
+
from requests.adapters import HTTPAdapter
|
|
5
|
+
from urllib3.util.retry import Retry
|
|
6
|
+
from urllib.parse import urljoin, urlencode
|
|
7
|
+
from uuid import uuid4
|
|
8
|
+
|
|
9
|
+
from paddle_billing.FiltersUndefined import FiltersUndefined
|
|
10
|
+
from paddle_billing.HasParameters import HasParameters
|
|
11
|
+
from paddle_billing.Options import Options
|
|
12
|
+
|
|
13
|
+
from paddle_billing.Logger.NullHandler import NullHandler
|
|
14
|
+
|
|
15
|
+
from paddle_billing.Resources.Addresses.AddressesClient import AddressesClient
|
|
16
|
+
from paddle_billing.Resources.Adjustments.AdjustmentsClient import AdjustmentsClient
|
|
17
|
+
from paddle_billing.Resources.Businesses.BusinessesClient import BusinessesClient
|
|
18
|
+
from paddle_billing.Resources.Customers.CustomersClient import CustomersClient
|
|
19
|
+
from paddle_billing.Resources.Discounts.DiscountsClient import DiscountsClient
|
|
20
|
+
from paddle_billing.Resources.Events.EventsClient import EventsClient
|
|
21
|
+
from paddle_billing.Resources.EventTypes.EventTypesClient import EventTypesClient
|
|
22
|
+
from paddle_billing.Resources.Notifications.NotificationsClient import NotificationsClient
|
|
23
|
+
from paddle_billing.Resources.NotificationLogs.NotificationLogsClient import NotificationLogsClient
|
|
24
|
+
from paddle_billing.Resources.NotificationSettings.NotificationSettingsClient import NotificationSettingsClient
|
|
25
|
+
from paddle_billing.Resources.Prices.PricesClient import PricesClient
|
|
26
|
+
from paddle_billing.Resources.PricingPreviews.PricingPreviewsClient import PricingPreviewsClient
|
|
27
|
+
from paddle_billing.Resources.Products.ProductsClient import ProductsClient
|
|
28
|
+
from paddle_billing.Resources.Reports.ReportsClient import ReportsClient
|
|
29
|
+
from paddle_billing.Resources.Subscriptions.SubscriptionsClient import SubscriptionsClient
|
|
30
|
+
from paddle_billing.Resources.Transactions.TransactionsClient import TransactionsClient
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class Client:
|
|
34
|
+
"""
|
|
35
|
+
Client for making API requests using Python's requests library.
|
|
36
|
+
"""
|
|
37
|
+
def __init__(
|
|
38
|
+
self,
|
|
39
|
+
api_key: str,
|
|
40
|
+
options: Options = None,
|
|
41
|
+
http_client: Session = None,
|
|
42
|
+
logger: Logger = None,
|
|
43
|
+
retry_count: int = 3,
|
|
44
|
+
use_api_version: int = 1,
|
|
45
|
+
):
|
|
46
|
+
self.__api_key = api_key
|
|
47
|
+
self.retry_count = retry_count
|
|
48
|
+
self.transaction_id = None
|
|
49
|
+
self.use_api_version = use_api_version
|
|
50
|
+
self.options = options if options else Options()
|
|
51
|
+
self.log = logger if logger else Client.null_logger()
|
|
52
|
+
self.client = http_client if http_client else self.build_request_session()
|
|
53
|
+
self.payload = None # Used by pytest
|
|
54
|
+
self.status_code = None # Used by pytest
|
|
55
|
+
|
|
56
|
+
# Initialize the various clients
|
|
57
|
+
self.addresses = AddressesClient(self)
|
|
58
|
+
self.adjustments = AdjustmentsClient(self)
|
|
59
|
+
self.businesses = BusinessesClient(self)
|
|
60
|
+
self.customers = CustomersClient(self)
|
|
61
|
+
self.discounts = DiscountsClient(self)
|
|
62
|
+
self.events = EventsClient(self)
|
|
63
|
+
self.event_types = EventTypesClient(self)
|
|
64
|
+
self.notifications = NotificationsClient(self)
|
|
65
|
+
self.notification_logs = NotificationLogsClient(self)
|
|
66
|
+
self.notification_settings = NotificationSettingsClient(self)
|
|
67
|
+
self.prices = PricesClient(self)
|
|
68
|
+
self.pricing_previews = PricingPreviewsClient(self)
|
|
69
|
+
self.products = ProductsClient(self)
|
|
70
|
+
self.reports = ReportsClient(self)
|
|
71
|
+
self.subscriptions = SubscriptionsClient(self)
|
|
72
|
+
self.transactions = TransactionsClient(self)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@staticmethod
|
|
76
|
+
def null_logger() -> Logger:
|
|
77
|
+
"""
|
|
78
|
+
Create a logger instance that logs everything to nowhere
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
null_logger = getLogger('null_logger')
|
|
82
|
+
null_logger.addHandler(NullHandler())
|
|
83
|
+
|
|
84
|
+
return null_logger
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def logging_hook(self, response, *args, **kwargs):
|
|
88
|
+
"""
|
|
89
|
+
Requests logs were redirected here and to our custom logger which filters out sensitive data
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
self.log.info(f"Request: {response.request.method} {response.request.url}")
|
|
93
|
+
self.log.debug(f"Response: {response.status_code} {response.text}")
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@staticmethod
|
|
97
|
+
def serialize_json_payload(payload: dict) -> str:
|
|
98
|
+
# Removes unneeded level of nested CustomData data
|
|
99
|
+
if payload.get('custom_data') and 'data' in payload['custom_data']:
|
|
100
|
+
payload['custom_data'] = payload['custom_data']['data']
|
|
101
|
+
|
|
102
|
+
json_payload = json_dumps(payload)
|
|
103
|
+
final_json = json_payload if json_payload != '[]' else '{}'
|
|
104
|
+
|
|
105
|
+
return final_json
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def _make_request(
|
|
109
|
+
self,
|
|
110
|
+
method: str,
|
|
111
|
+
url: str,
|
|
112
|
+
payload: dict | None = None,
|
|
113
|
+
) -> Response:
|
|
114
|
+
"""
|
|
115
|
+
Makes an actual API call to Paddle
|
|
116
|
+
"""
|
|
117
|
+
# Parse and update URL with base URL components if necessary
|
|
118
|
+
if isinstance(url, str):
|
|
119
|
+
url = urljoin(self.options.environment.base_url, url)
|
|
120
|
+
|
|
121
|
+
self.client.headers.update({
|
|
122
|
+
'X-Transaction-ID': str(self.transaction_id) if self.transaction_id else str(uuid4())
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
self.payload = self.serialize_json_payload(payload) if payload else None
|
|
126
|
+
try:
|
|
127
|
+
# We use data= instead of json= because we manually serialize data into JSON
|
|
128
|
+
response = self.client.request(method.upper(), url, data=self.payload)
|
|
129
|
+
self.status_code = response.status_code
|
|
130
|
+
response.raise_for_status()
|
|
131
|
+
|
|
132
|
+
return response
|
|
133
|
+
except RequestException as e:
|
|
134
|
+
self.status_code = e.response.status_code
|
|
135
|
+
|
|
136
|
+
if self.log:
|
|
137
|
+
self.log.error(f"Request failed: {e}")
|
|
138
|
+
raise
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
@staticmethod
|
|
142
|
+
def format_uri_parameters(uri: str, parameters: HasParameters | dict) -> str:
|
|
143
|
+
if isinstance(parameters, HasParameters):
|
|
144
|
+
parameters = parameters.get_parameters()
|
|
145
|
+
|
|
146
|
+
query = urlencode(parameters)
|
|
147
|
+
uri += '&' if '?' in uri else '?'
|
|
148
|
+
uri += query
|
|
149
|
+
|
|
150
|
+
return uri
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def get_raw(self, url: str, parameters: HasParameters | dict = None) -> Response:
|
|
154
|
+
url = Client.format_uri_parameters(url, parameters) if parameters else url
|
|
155
|
+
|
|
156
|
+
return self._make_request('GET', url, None)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def post_raw(
|
|
160
|
+
self,
|
|
161
|
+
url: str,
|
|
162
|
+
payload: dict | None = None,
|
|
163
|
+
parameters: HasParameters | dict | None = None
|
|
164
|
+
) -> Response:
|
|
165
|
+
if payload:
|
|
166
|
+
payload = FiltersUndefined.filter_undefined_values(payload) # Strip Undefined items from the dict
|
|
167
|
+
|
|
168
|
+
url = Client.format_uri_parameters(url, parameters) if parameters else url
|
|
169
|
+
|
|
170
|
+
return self._make_request('POST', url, payload)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def patch_raw(self, url: str, payload: dict | None) -> Response:
|
|
174
|
+
if payload:
|
|
175
|
+
payload = FiltersUndefined.filter_undefined_values(payload) # Strip Undefined items from the dict
|
|
176
|
+
|
|
177
|
+
return self._make_request('PATCH', url, payload)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def delete_raw(self, url: str) -> Response:
|
|
181
|
+
return self._make_request('DELETE', url)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def build_request_session(self) -> Session:
|
|
185
|
+
session = Session()
|
|
186
|
+
session.headers.update({
|
|
187
|
+
'Authorization': f"Bearer {self.__api_key}",
|
|
188
|
+
'Content-Type': 'application/json',
|
|
189
|
+
'Paddle-Version': str(self.use_api_version),
|
|
190
|
+
'User-Agent': 'PaddleSDK/python 0.1.0',
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
# Configure retries
|
|
194
|
+
retries = Retry(total=self.retry_count, backoff_factor=1, status_forcelist=[429, 500, 502, 503, 504])
|
|
195
|
+
session.mount('https://', HTTPAdapter(max_retries=retries))
|
|
196
|
+
|
|
197
|
+
# Handle logging
|
|
198
|
+
if self.log:
|
|
199
|
+
session.hooks['response'] = self.logging_hook
|
|
200
|
+
|
|
201
|
+
return session
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from dataclasses import fields
|
|
2
|
+
|
|
3
|
+
from paddle_billing.RecursivelyRemoveKey import recursively_remove_key
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def conditionally_remove_import_meta(entity_class, data: dict):
|
|
7
|
+
"""
|
|
8
|
+
Paddle sends us import_meta in the data, but not all Entities support this, causing dynamic class instantiation
|
|
9
|
+
to break. We selectively remove import_meta if the target Entity class doesn't define it.
|
|
10
|
+
"""
|
|
11
|
+
import_meta_in_class = 'import_meta' in [field.name for field in fields(entity_class)]
|
|
12
|
+
import_meta_in_data = 'import_meta' in data['data']
|
|
13
|
+
if not import_meta_in_class and import_meta_in_data:
|
|
14
|
+
recursively_remove_key(data, 'import_meta')
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
|
|
5
|
+
from paddle_billing.Entities.Entity import Entity
|
|
6
|
+
from paddle_billing.Entities.Shared import CountryCode, CustomData, ImportMeta, Status
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class Address(Entity):
|
|
11
|
+
id: str
|
|
12
|
+
customer_id: str
|
|
13
|
+
description: str | None
|
|
14
|
+
first_line: str | None
|
|
15
|
+
second_line: str | None
|
|
16
|
+
city: str | None
|
|
17
|
+
postal_code: str | None
|
|
18
|
+
region: str | None
|
|
19
|
+
country_code: CountryCode
|
|
20
|
+
custom_data: CustomData | None
|
|
21
|
+
status: Status
|
|
22
|
+
created_at: datetime
|
|
23
|
+
updated_at: datetime
|
|
24
|
+
import_meta: ImportMeta | None
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@classmethod
|
|
28
|
+
def from_dict(cls, data: dict) -> Address:
|
|
29
|
+
return Address(
|
|
30
|
+
id = data['id'],
|
|
31
|
+
customer_id = data['customer_id'],
|
|
32
|
+
description = data.get('description'),
|
|
33
|
+
first_line = data.get('first_line'),
|
|
34
|
+
second_line = data.get('second_line'),
|
|
35
|
+
city = data.get('city'),
|
|
36
|
+
postal_code = data.get('postal_code'),
|
|
37
|
+
region = data.get('region'),
|
|
38
|
+
country_code = CountryCode(data['country_code']),
|
|
39
|
+
status = Status(data['status']),
|
|
40
|
+
created_at = datetime.fromisoformat(data['created_at']),
|
|
41
|
+
updated_at = datetime.fromisoformat(data['updated_at']),
|
|
42
|
+
custom_data = CustomData(data['custom_data']) if data.get('custom_data') else None,
|
|
43
|
+
import_meta = ImportMeta.from_dict(data['import_meta']) if data.get('import_meta') else None,
|
|
44
|
+
)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
|
|
5
|
+
from paddle_billing.Entities.Entity import Entity
|
|
6
|
+
from paddle_billing.Entities.Adjustments import AdjustmentItem
|
|
7
|
+
from paddle_billing.Entities.Shared import Action, AdjustmentStatus, CurrencyCode, PayoutTotalsAdjustment, AdjustmentTotals
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass
|
|
11
|
+
class Adjustment(Entity):
|
|
12
|
+
id: str
|
|
13
|
+
action: Action
|
|
14
|
+
transaction_id: str
|
|
15
|
+
subscription_id: str | None
|
|
16
|
+
customer_id: str
|
|
17
|
+
reason: str
|
|
18
|
+
credit_applied_to_balance: bool | None
|
|
19
|
+
currency_code: CurrencyCode
|
|
20
|
+
status: AdjustmentStatus
|
|
21
|
+
items: list[AdjustmentItem]
|
|
22
|
+
totals: AdjustmentTotals
|
|
23
|
+
payout_totals: PayoutTotalsAdjustment | None
|
|
24
|
+
created_at: datetime
|
|
25
|
+
updated_at: datetime | None
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@classmethod
|
|
29
|
+
def from_dict(cls, data: dict) -> Adjustment:
|
|
30
|
+
return Adjustment(
|
|
31
|
+
id = data['id'],
|
|
32
|
+
action = Action(data['action']),
|
|
33
|
+
transaction_id = data['transaction_id'],
|
|
34
|
+
subscription_id = data.get('subscription_id'),
|
|
35
|
+
customer_id = data['customer_id'],
|
|
36
|
+
reason = data['reason'],
|
|
37
|
+
credit_applied_to_balance = data.get('credit_applied_to_balance'),
|
|
38
|
+
currency_code = CurrencyCode(data['currency_code']),
|
|
39
|
+
status = AdjustmentStatus(data['status']),
|
|
40
|
+
totals = AdjustmentTotals.from_dict(data['totals']),
|
|
41
|
+
created_at = datetime.fromisoformat(data['created_at']),
|
|
42
|
+
items = [AdjustmentItem.from_dict(item) for item in data['items']],
|
|
43
|
+
payout_totals = PayoutTotalsAdjustment.from_dict(data['payout_totals']) if data.get('payout_totals') else None,
|
|
44
|
+
updated_at = datetime.fromisoformat(data['updated_at']) if data.get('updated_at') else None,
|
|
45
|
+
)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class AdjustmentCustomerBalance:
|
|
7
|
+
available: str
|
|
8
|
+
reserved: str
|
|
9
|
+
used: str
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@staticmethod
|
|
13
|
+
def from_dict(data: dict) -> AdjustmentCustomerBalance:
|
|
14
|
+
return AdjustmentCustomerBalance(
|
|
15
|
+
available = data['available'],
|
|
16
|
+
reserved = data['reserved'],
|
|
17
|
+
used = data['used'],
|
|
18
|
+
)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
|
|
4
|
+
from paddle_billing.Entities.Shared import AdjustmentItemTotals, AdjustmentProration, AdjustmentType
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class AdjustmentItem:
|
|
9
|
+
id: str
|
|
10
|
+
item_id: str
|
|
11
|
+
type: AdjustmentType
|
|
12
|
+
amount: str | None
|
|
13
|
+
proration: AdjustmentProration | None
|
|
14
|
+
totals: AdjustmentItemTotals
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@staticmethod
|
|
18
|
+
def from_dict(data: dict) -> AdjustmentItem:
|
|
19
|
+
return AdjustmentItem(
|
|
20
|
+
id = data['id'],
|
|
21
|
+
item_id = data['item_id'],
|
|
22
|
+
type = AdjustmentType(data['type']),
|
|
23
|
+
amount = data.get('amount'),
|
|
24
|
+
proration = AdjustmentProration.from_dict(data['proration']) if data.get('proration') else None,
|
|
25
|
+
totals = AdjustmentItemTotals.from_dict(data['totals']),
|
|
26
|
+
)
|