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
|
File without changes
|
|
@@ -0,0 +1,585 @@
|
|
|
1
|
+
from json import loads
|
|
2
|
+
from pytest import mark
|
|
3
|
+
from urllib.parse import unquote
|
|
4
|
+
|
|
5
|
+
from paddle_billing.Entities.Collections import TransactionCollection
|
|
6
|
+
from paddle_billing.Entities.DateTime import DateTime
|
|
7
|
+
from paddle_billing.Entities.Transaction import Transaction
|
|
8
|
+
from paddle_billing.Entities.TransactionData import TransactionData
|
|
9
|
+
from paddle_billing.Entities.TransactionPreview import TransactionPreview
|
|
10
|
+
from paddle_billing.Resources.Shared.Operations import Comparator, DateComparison, Pager
|
|
11
|
+
|
|
12
|
+
from paddle_billing.Entities.Shared import (
|
|
13
|
+
BillingDetails,
|
|
14
|
+
CollectionMode,
|
|
15
|
+
CurrencyCode,
|
|
16
|
+
CustomData,
|
|
17
|
+
Interval,
|
|
18
|
+
Money,
|
|
19
|
+
PriceQuantity,
|
|
20
|
+
TransactionStatus,
|
|
21
|
+
TaxMode,
|
|
22
|
+
TimePeriod,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
from paddle_billing.Entities.Transactions import (
|
|
26
|
+
TransactionCreateItem,
|
|
27
|
+
TransactionCreateItemWithPrice,
|
|
28
|
+
TransactionNonCatalogPrice,
|
|
29
|
+
TransactionItemPreviewWithNonCatalogPrice,
|
|
30
|
+
TransactionItemPreviewWithPriceId,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
from paddle_billing.Resources.Transactions.Operations import (
|
|
34
|
+
CreateTransaction,
|
|
35
|
+
ListTransactions,
|
|
36
|
+
TransactionIncludes,
|
|
37
|
+
TransactionOrigin,
|
|
38
|
+
PreviewTransaction,
|
|
39
|
+
UpdateTransaction,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
from tests.Utils.TestClient import mock_requests, test_client
|
|
43
|
+
from tests.Utils.ReadsFixture import ReadsFixtures
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class TestTransactionsClient:
|
|
47
|
+
@mark.parametrize("operation", [ListTransactions()])
|
|
48
|
+
def test_list_transaction_can_paginate(self, test_client, mock_requests, operation):
|
|
49
|
+
expected_response_status = 200
|
|
50
|
+
expected_page_one_url = f"{test_client.base_url}/transactions"
|
|
51
|
+
expected_page_one_response_body = ReadsFixtures.read_raw_json_fixture('response/list_paginated_page_one')
|
|
52
|
+
|
|
53
|
+
# meta.pagination.next value is hardcoded in response/list_paginated_page_one, so this must be an absolute value
|
|
54
|
+
expected_page_two_url = 'https://api.paddle.com/transactions?after=txn_01h69ddtrb11km0wk46dn607ya'
|
|
55
|
+
expected_page_two_response_body = ReadsFixtures.read_raw_json_fixture('response/list_paginated_page_two')
|
|
56
|
+
|
|
57
|
+
mock_requests.get(
|
|
58
|
+
url = expected_page_one_url,
|
|
59
|
+
status_code = expected_response_status,
|
|
60
|
+
text = ReadsFixtures.read_raw_json_fixture('response/list_paginated_page_one'),
|
|
61
|
+
)
|
|
62
|
+
mock_requests.get(
|
|
63
|
+
url = expected_page_two_url,
|
|
64
|
+
status_code = expected_response_status,
|
|
65
|
+
text = ReadsFixtures.read_raw_json_fixture('response/list_paginated_page_two'),
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
transactions = test_client.client.transactions.list(operation)
|
|
69
|
+
response_json = test_client.client.transactions.response.json()
|
|
70
|
+
|
|
71
|
+
# Assertions for first request
|
|
72
|
+
assert len(mock_requests.request_history) > 0
|
|
73
|
+
first_request = mock_requests.request_history[0]
|
|
74
|
+
assert first_request is not None
|
|
75
|
+
assert first_request.method == 'GET'
|
|
76
|
+
assert test_client.client.status_code == expected_response_status
|
|
77
|
+
assert unquote(first_request.url) == expected_page_one_url, \
|
|
78
|
+
"The URL does not match the expected URL, verify the query string is correct"
|
|
79
|
+
assert response_json == loads(expected_page_one_response_body), \
|
|
80
|
+
"The response JSON doesn't match the expected fixture JSON"
|
|
81
|
+
|
|
82
|
+
for transaction in transactions:
|
|
83
|
+
assert isinstance(transaction, Transaction)
|
|
84
|
+
|
|
85
|
+
# Assertions for second request
|
|
86
|
+
second_request = mock_requests.request_history[1]
|
|
87
|
+
assert second_request is not None
|
|
88
|
+
assert second_request.method == 'GET'
|
|
89
|
+
assert test_client.client.status_code == expected_response_status
|
|
90
|
+
assert unquote(second_request.url) == expected_page_two_url, \
|
|
91
|
+
"The URL does not match the expected URL, verify the query string is correct"
|
|
92
|
+
|
|
93
|
+
# Due to limitations of how TransactionsClient.list() sets test_client.client.transactions.response,
|
|
94
|
+
# we can't test the response body of subsequent paginated pages
|
|
95
|
+
# assert response_json == loads(expected_page_two_response_body), \
|
|
96
|
+
# "The response JSON doesn't match the expected fixture JSON"
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
@mark.parametrize(
|
|
100
|
+
'operation, expected_request_body, expected_response_status, expected_response_body, expected_url',
|
|
101
|
+
[
|
|
102
|
+
(
|
|
103
|
+
CreateTransaction(items=[TransactionCreateItem(price_id='pri_01he5kxqey1k8ankgef29cj4bv', quantity=1)]),
|
|
104
|
+
ReadsFixtures.read_raw_json_fixture('request/create_basic'),
|
|
105
|
+
200,
|
|
106
|
+
ReadsFixtures.read_raw_json_fixture('response/minimal_entity'),
|
|
107
|
+
'/transactions',
|
|
108
|
+
), (
|
|
109
|
+
CreateTransaction(
|
|
110
|
+
items = [
|
|
111
|
+
TransactionCreateItemWithPrice(
|
|
112
|
+
price = TransactionNonCatalogPrice(
|
|
113
|
+
description = 'Annual (per seat)',
|
|
114
|
+
name = 'Annual (per seat)',
|
|
115
|
+
billing_cycle = TimePeriod(Interval.Year, 1),
|
|
116
|
+
trial_period = None,
|
|
117
|
+
tax_mode = TaxMode.AccountSetting,
|
|
118
|
+
unit_price = Money('30000', CurrencyCode.USD),
|
|
119
|
+
unit_price_overrides = [],
|
|
120
|
+
quantity = PriceQuantity(10, 999),
|
|
121
|
+
custom_data = None,
|
|
122
|
+
product_id = 'pro_01gsz4t5hdjse780zja8vvr7jg',
|
|
123
|
+
),
|
|
124
|
+
quantity = 20,
|
|
125
|
+
),
|
|
126
|
+
],
|
|
127
|
+
),
|
|
128
|
+
ReadsFixtures.read_raw_json_fixture('request/create_with_non_catalog_price'),
|
|
129
|
+
200,
|
|
130
|
+
ReadsFixtures.read_raw_json_fixture('response/minimal_entity'),
|
|
131
|
+
'/transactions',
|
|
132
|
+
), (
|
|
133
|
+
CreateTransaction(
|
|
134
|
+
items = [TransactionCreateItem(price_id='pri_01gsz8x8sawmvhz1pv30nge1ke', quantity=1)],
|
|
135
|
+
status = TransactionStatus.Billed,
|
|
136
|
+
customer_id = 'ctm_01he849dseyj0zgrc589eeb1c7',
|
|
137
|
+
address_id = 'add_01hen28ebw1ew99y295jhd4n3n',
|
|
138
|
+
business_id = 'biz_01hen2ng2290g84twtefdn5s00',
|
|
139
|
+
currency_code = CurrencyCode.GBP,
|
|
140
|
+
collection_mode = CollectionMode.Manual,
|
|
141
|
+
discount_id = 'dsc_01hen7bjzh12m0v2peer15d9qt',
|
|
142
|
+
billing_details = BillingDetails(
|
|
143
|
+
enable_checkout = True,
|
|
144
|
+
payment_terms = TimePeriod(interval=Interval.Month, frequency=1),
|
|
145
|
+
purchase_order_number = '10009',
|
|
146
|
+
),
|
|
147
|
+
),
|
|
148
|
+
ReadsFixtures.read_raw_json_fixture('request/create_manual'),
|
|
149
|
+
200,
|
|
150
|
+
ReadsFixtures.read_raw_json_fixture('response/full_entity'),
|
|
151
|
+
'/transactions',
|
|
152
|
+
),
|
|
153
|
+
],
|
|
154
|
+
ids=[
|
|
155
|
+
"Create transaction with basic data",
|
|
156
|
+
"Create transaction with non-catalog price",
|
|
157
|
+
"Create transaction with manual collection mode",
|
|
158
|
+
],
|
|
159
|
+
)
|
|
160
|
+
def test_create_transaction_uses_expected_payload(
|
|
161
|
+
self,
|
|
162
|
+
test_client,
|
|
163
|
+
mock_requests,
|
|
164
|
+
operation,
|
|
165
|
+
expected_request_body,
|
|
166
|
+
expected_response_status,
|
|
167
|
+
expected_response_body,
|
|
168
|
+
expected_url,
|
|
169
|
+
):
|
|
170
|
+
expected_url = f"{test_client.base_url}{expected_url}"
|
|
171
|
+
mock_requests.post(expected_url, status_code=expected_response_status, text=expected_response_body)
|
|
172
|
+
|
|
173
|
+
response = test_client.client.transactions.create(operation)
|
|
174
|
+
response_json = test_client.client.transactions.response.json()
|
|
175
|
+
request_json = test_client.client.payload
|
|
176
|
+
last_request = mock_requests.last_request
|
|
177
|
+
|
|
178
|
+
assert isinstance(response, Transaction)
|
|
179
|
+
assert last_request is not None
|
|
180
|
+
assert last_request.method == 'POST'
|
|
181
|
+
assert test_client.client.status_code == expected_response_status
|
|
182
|
+
assert unquote(last_request.url) == expected_url, \
|
|
183
|
+
"The URL does not match the expected URL, verify the query string is correct"
|
|
184
|
+
assert loads(request_json) == loads(expected_request_body), \
|
|
185
|
+
"The request JSON doesn't match the expected fixture JSON"
|
|
186
|
+
assert response_json == loads(str(expected_response_body)), \
|
|
187
|
+
"The response JSON doesn't match the expected fixture JSON"
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
@mark.parametrize(
|
|
191
|
+
'operation, includes, expected_response_status, expected_response_body, expected_url',
|
|
192
|
+
[(
|
|
193
|
+
CreateTransaction(items=[
|
|
194
|
+
TransactionCreateItem(price_id='pri_01he5kxqey1k8ankgef29cj4bv', quantity=1)
|
|
195
|
+
]),
|
|
196
|
+
[TransactionIncludes.Customer, TransactionIncludes.Business],
|
|
197
|
+
200,
|
|
198
|
+
ReadsFixtures.read_raw_json_fixture('response/minimal_entity'),
|
|
199
|
+
'/transactions?include=customer,business',
|
|
200
|
+
)],
|
|
201
|
+
ids=["Create transaction with multiple includes"],
|
|
202
|
+
)
|
|
203
|
+
def test_create_transaction_with_includes_returns_expected_payload(
|
|
204
|
+
self,
|
|
205
|
+
test_client,
|
|
206
|
+
mock_requests,
|
|
207
|
+
operation,
|
|
208
|
+
includes,
|
|
209
|
+
expected_response_status,
|
|
210
|
+
expected_response_body,
|
|
211
|
+
expected_url,
|
|
212
|
+
):
|
|
213
|
+
expected_url = f"{test_client.base_url}{expected_url}"
|
|
214
|
+
mock_requests.post(expected_url, status_code=expected_response_status, text=expected_response_body)
|
|
215
|
+
|
|
216
|
+
response = test_client.client.transactions.create(operation, includes=includes)
|
|
217
|
+
response_json = test_client.client.transactions.response.json()
|
|
218
|
+
last_request = mock_requests.last_request
|
|
219
|
+
|
|
220
|
+
assert isinstance(response, Transaction)
|
|
221
|
+
assert last_request is not None
|
|
222
|
+
assert last_request.method == 'POST'
|
|
223
|
+
assert test_client.client.status_code == expected_response_status
|
|
224
|
+
assert unquote(last_request.url) == expected_url, \
|
|
225
|
+
"The URL does not match the expected URL, verify the query string is correct"
|
|
226
|
+
assert response_json == loads(str(expected_response_body)), \
|
|
227
|
+
"The response JSON doesn't match the expected fixture JSON"
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
@mark.parametrize(
|
|
231
|
+
'transaction_id, operation, expected_request_body, expected_response_status, expected_response_body, expected_url',
|
|
232
|
+
[
|
|
233
|
+
(
|
|
234
|
+
'txn_01h7zcgmdc6tmwtjehp3sh7azf',
|
|
235
|
+
UpdateTransaction(status=TransactionStatus.Billed),
|
|
236
|
+
ReadsFixtures.read_raw_json_fixture('request/update_single'),
|
|
237
|
+
200,
|
|
238
|
+
ReadsFixtures.read_raw_json_fixture('response/full_entity'),
|
|
239
|
+
'/transactions/txn_01h7zcgmdc6tmwtjehp3sh7azf',
|
|
240
|
+
), (
|
|
241
|
+
'txn_01h7zcgmdc6tmwtjehp3sh7azf',
|
|
242
|
+
UpdateTransaction(status=TransactionStatus.Billed, custom_data=CustomData({'completed_by': 'Frank T'})),
|
|
243
|
+
ReadsFixtures.read_raw_json_fixture('request/update_partial'),
|
|
244
|
+
200,
|
|
245
|
+
ReadsFixtures.read_raw_json_fixture('response/full_entity'),
|
|
246
|
+
'/transactions/txn_01h7zcgmdc6tmwtjehp3sh7azf',
|
|
247
|
+
),
|
|
248
|
+
],
|
|
249
|
+
ids=[
|
|
250
|
+
"Update transaction with single new value",
|
|
251
|
+
"Update transaction with partial new values",
|
|
252
|
+
],
|
|
253
|
+
)
|
|
254
|
+
def test_update_transaction_uses_expected_payload(
|
|
255
|
+
self,
|
|
256
|
+
test_client,
|
|
257
|
+
mock_requests,
|
|
258
|
+
transaction_id,
|
|
259
|
+
operation,
|
|
260
|
+
expected_request_body,
|
|
261
|
+
expected_response_status,
|
|
262
|
+
expected_response_body,
|
|
263
|
+
expected_url,
|
|
264
|
+
):
|
|
265
|
+
expected_url = f"{test_client.base_url}{expected_url}"
|
|
266
|
+
mock_requests.patch(expected_url, status_code=expected_response_status, text=expected_response_body)
|
|
267
|
+
|
|
268
|
+
response = test_client.client.transactions.update(transaction_id, operation)
|
|
269
|
+
response_json = test_client.client.transactions.response.json()
|
|
270
|
+
request_json = test_client.client.payload
|
|
271
|
+
last_request = mock_requests.last_request
|
|
272
|
+
|
|
273
|
+
assert isinstance(response, Transaction)
|
|
274
|
+
assert last_request is not None
|
|
275
|
+
assert last_request.method == 'PATCH'
|
|
276
|
+
assert test_client.client.status_code == expected_response_status
|
|
277
|
+
assert unquote(last_request.url) == expected_url, \
|
|
278
|
+
"The URL does not match the expected URL, verify the query string is correct"
|
|
279
|
+
assert loads(request_json) == loads(expected_request_body), \
|
|
280
|
+
"The request JSON doesn't match the expected fixture JSON"
|
|
281
|
+
assert response_json == loads(str(expected_response_body)), \
|
|
282
|
+
"The response JSON doesn't match the expected fixture JSON"
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
@mark.parametrize(
|
|
286
|
+
'operation, expected_response_status, expected_response_body, expected_url',
|
|
287
|
+
[
|
|
288
|
+
(
|
|
289
|
+
ListTransactions(),
|
|
290
|
+
200,
|
|
291
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
292
|
+
'/transactions',
|
|
293
|
+
), (
|
|
294
|
+
ListTransactions(Pager()),
|
|
295
|
+
200,
|
|
296
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
297
|
+
'/transactions?order_by=id[asc]&per_page=50',
|
|
298
|
+
), (
|
|
299
|
+
ListTransactions(Pager(after='pro_01gsz4s0w61y0pp88528f1wvvb')),
|
|
300
|
+
200,
|
|
301
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
302
|
+
'/transactions?after=pro_01gsz4s0w61y0pp88528f1wvvb&order_by=id[asc]&per_page=50',
|
|
303
|
+
), (
|
|
304
|
+
ListTransactions(statuses=[TransactionStatus.Billed]),
|
|
305
|
+
200,
|
|
306
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
307
|
+
'/transactions?status=billed',
|
|
308
|
+
), (
|
|
309
|
+
ListTransactions(statuses=[TransactionStatus.Billed, TransactionStatus.Completed]),
|
|
310
|
+
200,
|
|
311
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
312
|
+
'/transactions?status=billed,completed',
|
|
313
|
+
), (
|
|
314
|
+
ListTransactions(ids=['txn_01gsz4s0w61y0pp88528f1wvvb']),
|
|
315
|
+
200,
|
|
316
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
317
|
+
'/transactions?id=txn_01gsz4s0w61y0pp88528f1wvvb',
|
|
318
|
+
), (
|
|
319
|
+
ListTransactions(ids=['txn_01gsz4s0w61y0pp88528f1wvvb', 'txn_01h1vjes1y163xfj1rh1tkfb65']),
|
|
320
|
+
200,
|
|
321
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
322
|
+
'/transactions?id=txn_01gsz4s0w61y0pp88528f1wvvb,txn_01h1vjes1y163xfj1rh1tkfb65',
|
|
323
|
+
), (
|
|
324
|
+
ListTransactions(collection_mode=CollectionMode.Automatic),
|
|
325
|
+
200,
|
|
326
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
327
|
+
'/transactions?collection_mode=automatic',
|
|
328
|
+
), (
|
|
329
|
+
ListTransactions(billed_at=DateComparison(DateTime('2023-11-06 14:00:00').as_datetime)),
|
|
330
|
+
200,
|
|
331
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
332
|
+
"/transactions?billed_at=2023-11-06T14:00:00.000000Z",
|
|
333
|
+
), (
|
|
334
|
+
ListTransactions(billed_at=DateComparison(DateTime('2023-11-06 14:00:00').as_datetime, Comparator.GT)),
|
|
335
|
+
200,
|
|
336
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
337
|
+
"/transactions?billed_at[GT]=2023-11-06T14:00:00.000000Z",
|
|
338
|
+
), (
|
|
339
|
+
ListTransactions(invoice_numbers=['inv_01gsz4s0w61y0pp88528f1wvvb']),
|
|
340
|
+
200,
|
|
341
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
342
|
+
'/transactions?invoice_number=inv_01gsz4s0w61y0pp88528f1wvvb',
|
|
343
|
+
), (
|
|
344
|
+
ListTransactions(invoice_numbers=['inv_01gsz4s0w61y0pp88528f1wvvb', 'inv_01h1vjes1y163xfj1rh1tkfb65']),
|
|
345
|
+
200,
|
|
346
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
347
|
+
'/transactions?invoice_number=inv_01gsz4s0w61y0pp88528f1wvvb,inv_01h1vjes1y163xfj1rh1tkfb65',
|
|
348
|
+
), (
|
|
349
|
+
ListTransactions(subscription_ids=['sub_01gsz4s0w61y0pp88528f1wvvb']),
|
|
350
|
+
200,
|
|
351
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
352
|
+
'/transactions?subscription_id=sub_01gsz4s0w61y0pp88528f1wvvb',
|
|
353
|
+
), (
|
|
354
|
+
ListTransactions(subscription_ids=['sub_01gsz4s0w61y0pp88528f1wvvb', 'sub_01h1vjes1y163xfj1rh1tkfb65']),
|
|
355
|
+
200,
|
|
356
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
357
|
+
'/transactions?subscription_id=sub_01gsz4s0w61y0pp88528f1wvvb,sub_01h1vjes1y163xfj1rh1tkfb65',
|
|
358
|
+
), (
|
|
359
|
+
ListTransactions(updated_at=DateComparison(DateTime('2023-11-06 14:00:00').as_datetime)),
|
|
360
|
+
200,
|
|
361
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
362
|
+
"/transactions?updated_at=2023-11-06T14:00:00.000000Z",
|
|
363
|
+
), (
|
|
364
|
+
ListTransactions(updated_at=DateComparison(DateTime('2023-11-06 14:00:00').as_datetime, Comparator.GT)),
|
|
365
|
+
200,
|
|
366
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
367
|
+
"/transactions?updated_at[GT]=2023-11-06T14:00:00.000000Z",
|
|
368
|
+
), (
|
|
369
|
+
ListTransactions(created_at=DateComparison(DateTime('2023-11-06 14:00:00').as_datetime)),
|
|
370
|
+
200,
|
|
371
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
372
|
+
"/transactions?created_at=2023-11-06T14:00:00.000000Z",
|
|
373
|
+
), (
|
|
374
|
+
ListTransactions(created_at=DateComparison(DateTime('2023-11-06 14:00:00').as_datetime, Comparator.GT)),
|
|
375
|
+
200,
|
|
376
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
377
|
+
"/transactions?created_at[GT]=2023-11-06T14:00:00.000000Z",
|
|
378
|
+
), (
|
|
379
|
+
ListTransactions(includes=[TransactionIncludes.Customer]),
|
|
380
|
+
200,
|
|
381
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
382
|
+
"/transactions?include=customer",
|
|
383
|
+
), (
|
|
384
|
+
ListTransactions(includes=[TransactionIncludes.Customer, TransactionIncludes.Address, TransactionIncludes.Discount]),
|
|
385
|
+
200,
|
|
386
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
387
|
+
'/transactions?include=customer,address,discount',
|
|
388
|
+
), (
|
|
389
|
+
ListTransactions(origins=[TransactionOrigin.Web, TransactionOrigin.Api, TransactionOrigin.SubscriptionRecurring]),
|
|
390
|
+
200,
|
|
391
|
+
ReadsFixtures.read_raw_json_fixture('response/list_default'),
|
|
392
|
+
'/transactions?origin=web,api,subscription_recurring',
|
|
393
|
+
),
|
|
394
|
+
],
|
|
395
|
+
ids=[
|
|
396
|
+
"List transactions without pagination",
|
|
397
|
+
"List transactions with default pagination",
|
|
398
|
+
"List paginated transactions after specified transaction_id",
|
|
399
|
+
"List transactions filtered by status",
|
|
400
|
+
"List transactions filtered by multiple statuses",
|
|
401
|
+
"List transactions filtered by id",
|
|
402
|
+
"List transactions filtered by multiple ids",
|
|
403
|
+
"List transactions filtered by automatic collection_mode",
|
|
404
|
+
"List transactions filtered by billed_at without a comparator",
|
|
405
|
+
"List transactions filtered by billed at with a comparator",
|
|
406
|
+
"List transactions filtered by invoice_number",
|
|
407
|
+
"List transactions filtered by multiple invoice_numbers",
|
|
408
|
+
"List transactions filtered by subscription_id",
|
|
409
|
+
"List transactions filtered by multiple subscription_ids",
|
|
410
|
+
"List transactions filtered by updated_at without a comparator",
|
|
411
|
+
"List transactions filtered by updated_at with a comparator",
|
|
412
|
+
"List transactions filtered by created_at without a comparator",
|
|
413
|
+
"List transactions filtered by created_at with a comparator",
|
|
414
|
+
"List transactions with includes",
|
|
415
|
+
"List transactions with multiple includes",
|
|
416
|
+
"List transactions with origins",
|
|
417
|
+
],
|
|
418
|
+
)
|
|
419
|
+
def test_list_transactions_returns_expected_response(
|
|
420
|
+
self,
|
|
421
|
+
test_client,
|
|
422
|
+
mock_requests,
|
|
423
|
+
operation,
|
|
424
|
+
expected_response_status,
|
|
425
|
+
expected_response_body,
|
|
426
|
+
expected_url,
|
|
427
|
+
):
|
|
428
|
+
expected_url = f"{test_client.base_url}{expected_url}"
|
|
429
|
+
mock_requests.get(expected_url, status_code=expected_response_status, text=expected_response_body)
|
|
430
|
+
|
|
431
|
+
response = test_client.client.transactions.list(operation)
|
|
432
|
+
last_request = mock_requests.last_request
|
|
433
|
+
|
|
434
|
+
assert isinstance(response, TransactionCollection)
|
|
435
|
+
assert last_request is not None
|
|
436
|
+
assert last_request.method == 'GET'
|
|
437
|
+
assert test_client.client.status_code == expected_response_status
|
|
438
|
+
assert unquote(last_request.url) == expected_url, \
|
|
439
|
+
"The URL does not match the expected URL, verify the query string is correct"
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
@mark.parametrize(
|
|
443
|
+
'transaction_id, includes, expected_response_status, expected_response_body, expected_url',
|
|
444
|
+
[
|
|
445
|
+
(
|
|
446
|
+
'txn_01hen7bxc1p8ep4yk7n5jbzk9r',
|
|
447
|
+
None,
|
|
448
|
+
200,
|
|
449
|
+
ReadsFixtures.read_raw_json_fixture('response/full_entity'),
|
|
450
|
+
'/transactions/txn_01hen7bxc1p8ep4yk7n5jbzk9r',
|
|
451
|
+
), (
|
|
452
|
+
'txn_01hen7bxc1p8ep4yk7n5jbzk9r',
|
|
453
|
+
[TransactionIncludes.Customer, TransactionIncludes.Address, TransactionIncludes.Business, TransactionIncludes.Discount, TransactionIncludes.AvailablePaymentMethods],
|
|
454
|
+
200,
|
|
455
|
+
ReadsFixtures.read_raw_json_fixture('response/full_entity'),
|
|
456
|
+
'/transactions/txn_01hen7bxc1p8ep4yk7n5jbzk9r?include=customer,address,business,discount,available_payment_methods',
|
|
457
|
+
),
|
|
458
|
+
],
|
|
459
|
+
ids=[
|
|
460
|
+
"Get transaction",
|
|
461
|
+
"Get transaction with includes",
|
|
462
|
+
],
|
|
463
|
+
)
|
|
464
|
+
def test_get_transactions_returns_expected_response(
|
|
465
|
+
self,
|
|
466
|
+
test_client,
|
|
467
|
+
mock_requests,
|
|
468
|
+
transaction_id,
|
|
469
|
+
includes,
|
|
470
|
+
expected_response_status,
|
|
471
|
+
expected_response_body,
|
|
472
|
+
expected_url,
|
|
473
|
+
):
|
|
474
|
+
expected_url = f"{test_client.base_url}{expected_url}"
|
|
475
|
+
mock_requests.get(expected_url, status_code=expected_response_status, text=expected_response_body)
|
|
476
|
+
|
|
477
|
+
response = test_client.client.transactions.get(transaction_id, includes=includes)
|
|
478
|
+
response_json = test_client.client.transactions.response.json()
|
|
479
|
+
last_request = mock_requests.last_request
|
|
480
|
+
|
|
481
|
+
assert isinstance(response, Transaction)
|
|
482
|
+
assert last_request is not None
|
|
483
|
+
assert last_request.method == 'GET'
|
|
484
|
+
assert test_client.client.status_code == expected_response_status
|
|
485
|
+
assert unquote(last_request.url) == expected_url, \
|
|
486
|
+
"The URL does not match the expected URL, verify the query string is correct"
|
|
487
|
+
assert response_json == loads(str(expected_response_body)), \
|
|
488
|
+
"The response JSON generated by ResponseParser() doesn't match the expected fixture JSON"
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
@mark.parametrize(
|
|
492
|
+
'operation, expected_request_body, expected_response_status, expected_response_body, expected_url',
|
|
493
|
+
[
|
|
494
|
+
(
|
|
495
|
+
PreviewTransaction(items=[
|
|
496
|
+
TransactionItemPreviewWithPriceId(
|
|
497
|
+
price_id = 'pri_01he5kxqey1k8ankgef29cj4bv',
|
|
498
|
+
quantity = 1,
|
|
499
|
+
include_in_totals = True,
|
|
500
|
+
)
|
|
501
|
+
]),
|
|
502
|
+
ReadsFixtures.read_raw_json_fixture('request/preview_basic'),
|
|
503
|
+
200,
|
|
504
|
+
ReadsFixtures.read_raw_json_fixture('response/preview_entity'),
|
|
505
|
+
'/transactions/preview',
|
|
506
|
+
), (
|
|
507
|
+
PreviewTransaction(items=[
|
|
508
|
+
TransactionItemPreviewWithNonCatalogPrice(
|
|
509
|
+
quantity = 20,
|
|
510
|
+
include_in_totals = True,
|
|
511
|
+
price = TransactionNonCatalogPrice(
|
|
512
|
+
description = 'Annual (per seat)',
|
|
513
|
+
name = 'Annual (per seat)',
|
|
514
|
+
billing_cycle = TimePeriod(Interval.Year, 1),
|
|
515
|
+
trial_period = None,
|
|
516
|
+
tax_mode = TaxMode.AccountSetting,
|
|
517
|
+
unit_price = Money('30000', CurrencyCode.USD),
|
|
518
|
+
unit_price_overrides = [],
|
|
519
|
+
quantity = PriceQuantity(minimum=10, maximum=999),
|
|
520
|
+
custom_data = None,
|
|
521
|
+
product_id = 'pro_01gsz4t5hdjse780zja8vvr7jg',
|
|
522
|
+
),
|
|
523
|
+
)
|
|
524
|
+
]),
|
|
525
|
+
ReadsFixtures.read_raw_json_fixture('request/preview_with_non_catalog_price'),
|
|
526
|
+
200,
|
|
527
|
+
ReadsFixtures.read_raw_json_fixture('response/preview_entity'),
|
|
528
|
+
'/transactions/preview',
|
|
529
|
+
),
|
|
530
|
+
],
|
|
531
|
+
ids=[
|
|
532
|
+
"Basic transaction preview",
|
|
533
|
+
"Preview transaction with non-catalog price",
|
|
534
|
+
],
|
|
535
|
+
)
|
|
536
|
+
def test_preview_transaction_returns_expected_response(
|
|
537
|
+
self,
|
|
538
|
+
test_client,
|
|
539
|
+
mock_requests,
|
|
540
|
+
operation,
|
|
541
|
+
expected_request_body,
|
|
542
|
+
expected_response_status,
|
|
543
|
+
expected_response_body,
|
|
544
|
+
expected_url,
|
|
545
|
+
):
|
|
546
|
+
expected_url = f"{test_client.base_url}{expected_url}"
|
|
547
|
+
mock_requests.post(expected_url, status_code=expected_response_status, text=expected_response_body)
|
|
548
|
+
|
|
549
|
+
response = test_client.client.transactions.preview(operation)
|
|
550
|
+
response_json = test_client.client.transactions.response.json()
|
|
551
|
+
request_json = test_client.client.payload
|
|
552
|
+
last_request = mock_requests.last_request
|
|
553
|
+
|
|
554
|
+
assert isinstance(response, TransactionPreview)
|
|
555
|
+
assert last_request is not None
|
|
556
|
+
assert last_request.method == 'POST'
|
|
557
|
+
assert test_client.client.status_code == expected_response_status
|
|
558
|
+
assert unquote(last_request.url) == expected_url, \
|
|
559
|
+
"The URL does not match the expected URL, verify the query string is correct"
|
|
560
|
+
assert loads(request_json) == loads(expected_request_body), \
|
|
561
|
+
"The request JSON doesn't match the expected fixture JSON"
|
|
562
|
+
assert response_json == loads(str(expected_response_body)), \
|
|
563
|
+
"The response JSON doesn't match the expected fixture JSON"
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
def test_get_transaction_invoice_pdf_returns_expected_response(self, test_client, mock_requests):
|
|
567
|
+
transaction_id = 'txn_01hen7bxc1p8ep4yk7n5jbzk9r'
|
|
568
|
+
expected_response_status = 200
|
|
569
|
+
expected_response_body = ReadsFixtures.read_raw_json_fixture('response/get_invoice_pdf_default')
|
|
570
|
+
expected_url = f"{test_client.base_url}/transactions/{transaction_id}/invoice"
|
|
571
|
+
|
|
572
|
+
mock_requests.get(expected_url, status_code=expected_response_status, text=expected_response_body)
|
|
573
|
+
|
|
574
|
+
response = test_client.client.transactions.get_invoice_pdf(transaction_id)
|
|
575
|
+
response_json = test_client.client.transactions.response.json()
|
|
576
|
+
last_request = mock_requests.last_request
|
|
577
|
+
|
|
578
|
+
assert isinstance(response, TransactionData)
|
|
579
|
+
assert last_request is not None
|
|
580
|
+
assert last_request.method == 'GET'
|
|
581
|
+
assert test_client.client.status_code == expected_response_status
|
|
582
|
+
assert unquote(last_request.url) == expected_url, \
|
|
583
|
+
"The URL does not match the expected URL, verify the query string is correct"
|
|
584
|
+
assert response_json == loads(str(expected_response_body)), \
|
|
585
|
+
"The response JSON doesn't match the expected fixture JSON"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from logging import Logger
|
|
2
|
+
|
|
3
|
+
from paddle_billing.Logger import get_logger, CustomLogger
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_validate_paddle_signature_header_integrity():
|
|
7
|
+
log = get_logger()
|
|
8
|
+
assert isinstance(log, Logger), "Our logger instance did not initialize correctly"
|
|
9
|
+
assert isinstance(log.filters[0], CustomLogger), "Our CustomLogger logger filter is not removing sensitive secrets"
|
|
10
|
+
assert log.name == 'paddle_billing'
|
|
File without changes
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
from json import loads
|
|
2
|
+
from pytest import mark
|
|
3
|
+
from urllib.parse import unquote
|
|
4
|
+
|
|
5
|
+
from paddle_billing.Notifications import PaddleSignature, Verifier, Secret
|
|
6
|
+
|
|
7
|
+
from tests.Utils import FakeResponse
|
|
8
|
+
from tests.Utils.ReadsFixture import ReadsFixtures
|
|
9
|
+
from tests.Utils.TestClient import mock_requests, test_client
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TestVerifier:
|
|
13
|
+
def test_validate_paddle_signature_header_integrity(self):
|
|
14
|
+
test_headers = {
|
|
15
|
+
PaddleSignature().HEADER:
|
|
16
|
+
'ts=1696195954;h1=dummy;h1=d96299976a6eb066f484d7fde011ac56fc32b38fc9940bc419d6e537fdc6ef02',
|
|
17
|
+
}
|
|
18
|
+
test_data = 'hello-world'
|
|
19
|
+
|
|
20
|
+
request = FakeResponse(test_headers, test_data)
|
|
21
|
+
secrets = [
|
|
22
|
+
Secret('pdl_ntf_01hbpjmytsa32fhr36nqgc3kgb_TjIG2BXbm83HPXqNfziwe506sBEdqL/4'), # should fail
|
|
23
|
+
Secret('pdl_ntf_01hbpjmytsa32fhr36nqgc3kgb_vB/yIOnTOCWIvpBadM5jzBZPHc7OmdSo'), # should fail
|
|
24
|
+
Secret('pdl_ntf_01hbpjmytsa32fhr36nqgc3kgb_WvRO0eL4Bj9rgYYIBZY6wZhG4EHy9jzh'), # should pass
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
verifier = Verifier(0)
|
|
28
|
+
assert verifier.verify(request, secrets)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@mark.parametrize(
|
|
32
|
+
'signature, payload',
|
|
33
|
+
[
|
|
34
|
+
(
|
|
35
|
+
'ts=1710498758;h1=558bf93944dbeb4790c7a8af6cb2ea435c8ca9c8396aafc1a4e37424ac132744',
|
|
36
|
+
ReadsFixtures.read_raw_json_fixture('standard_payload').strip(),
|
|
37
|
+
), (
|
|
38
|
+
'ts=1710498288;h1=38219b3ba1578184e625c29d201a27cd25bd69e2ec9c3ab87dcb90d87ff73a41',
|
|
39
|
+
ReadsFixtures.read_raw_json_fixture('special_chars_payload').strip(),
|
|
40
|
+
),
|
|
41
|
+
],
|
|
42
|
+
ids=[
|
|
43
|
+
"Standard payload",
|
|
44
|
+
"Special characters payload",
|
|
45
|
+
],
|
|
46
|
+
)
|
|
47
|
+
def test_validate_payload_body_integrity(
|
|
48
|
+
self,
|
|
49
|
+
monkeypatch,
|
|
50
|
+
test_client,
|
|
51
|
+
mock_requests,
|
|
52
|
+
signature,
|
|
53
|
+
payload,
|
|
54
|
+
):
|
|
55
|
+
monkeypatch.setenv('TEST_MODE', '1') # Required to disable time drift verification in Verifier.verify()
|
|
56
|
+
|
|
57
|
+
headers = {PaddleSignature().HEADER: signature}
|
|
58
|
+
secret = 'pdl_ntfset_01hs0t3tw21j988db1pam5xg8m_GrOWLNef+vmtjJYq4mSnHNzvc8uWoJ1I'
|
|
59
|
+
request = FakeResponse(headers, payload)
|
|
60
|
+
assert request is not None
|
|
61
|
+
|
|
62
|
+
integrity_check = Verifier().verify(request, Secret(secret))
|
|
63
|
+
assert integrity_check is True
|
|
File without changes
|