From 194c888b2fd75eebe95951fa4fc6224036e97b14 Mon Sep 17 00:00:00 2001 From: Michael Woodward Date: Wed, 18 Sep 2024 12:07:25 +0100 Subject: [PATCH] feat!: API alignment (#29) - General documentation updates - Support new errors - Adjustment credit note PDF - Support disposition query param on credit note and invoice - Notification setting active query param - CatalogType nullable in notifications - PricePreview moved to PreviewPrices to match docs - PaymentMethodID on Transaction payments is nullable - Support non catalog items on Subscription updates - Align non catalog item type names for consistency on all resources - fix(lint): ignore G115 potential integer overflow err - docs(release): 2.0.0 documentation - docs(examples): Migrate examples for v2.0.0 - chore(version): Bump version to 2.0.0 --- .golangci.yml | 3 + CHANGELOG.md | 20 ++ UPGRADING.md | 65 ++++- adjustments.go | 31 ++- discounts.go | 52 +++- example_create_test.go | 6 +- example_update_test.go | 6 +- internal/client/version.txt | 2 +- notification_settings.go | 3 + pkg/paddlenotification/adjustments.go | 8 +- pkg/paddlenotification/discounts.go | 28 +- pkg/paddlenotification/prices.go | 2 +- pkg/paddlenotification/products.go | 2 +- pkg/paddlenotification/transactions.go | 4 +- pricing_preview.go | 8 +- shared.go | 120 +++++++-- subscriptions.go | 242 ++++++++++++----- transactions.go | 348 ++++++++++++------------- 18 files changed, 646 insertions(+), 304 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 42dd94a..a896c4d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -44,6 +44,9 @@ linters-settings: allow-cuddle-with-calls: ["Lock", "RLock"] allow-cuddle-with-rhs: ["Unlock", "RUnlock"] error-variable-names: ["err"] + gosec: + excludes: + - G115 # Potential integer overflow when converting between integer types linters: disable-all: true diff --git a/CHANGELOG.md b/CHANGELOG.md index c0013e1..a9bcf8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,26 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx&utm_medium=paddle-go-sdk) for information about changes to the Paddle Billing platform, the Paddle API, and other developer tools. +## 2.0.0 - 2024-09-18 + +### Changed + +- `PricePreview` has moved to `PreviewPrices` to match API documentation +- Refactored non catalog item types for consistency through the SDK, see [UPGRADING](./UPGRADING.md) for details + +### Added + +- Support for new Paddle API errors +- Adjustment credit notes (`GetAdjustmentCreditNote`) +- `disposition` query parameter for `GetTransactionInvoice` and `GetAdjustmentCreditNote` +- `active` query parameter filter support for NotificationSettings +- Subscription update and preview update support non catalog items + +### Fixed + +- `Type` for Product and Price notifications are nullable `*CatalogType` +- `PaymentMethodID` on Transaction payments is nullable `*PaymentMethodID` for both notifications and API calls + ## 1.0.0 - 2024-08-15 No documented changes. diff --git a/UPGRADING.md b/UPGRADING.md index 337214d..e5f6670 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,6 +1,69 @@ # Upgrading -All breaking changes prior to v1 will be documented in this file to assist with upgrading. +All breaking changes will be documented in this file to assist with upgrading. + +## v2.0.0 + +This release brings 2 breaking changes and fixes that may require some changes in your code to upgrade. + +1. `PricePreview` has moved to `PreviewPrices` to match API documentation + +Any usage of the method `PricePreview` will need to me refactored to `PreviewPrices` which also includes the request type `PricePreviewRequest` to `PreviewPricesRequest`. + +2. Refactored non catalog item types for consistency through the SDK + +This release added support for non catalog items on Subscription updates and preview of Subscription updates. With this introduction naming conflicts occurred and were standardised throughout. + +Subscription updates now accepts a `[]UpdateSubscriptionItems`instead of `[]SubscriptionUpdateCatalogItem` use `NewUpdateSubscriptionItemsSubscriptionUpdateItem*` functions to create this. + +Preview subscription updates now accepts a `[]PreviewSubscriptionUpdateItems` instead of a `[]SubscriptionUpdateCatalogItem` use `NewPreviewSubscriptionUpdateItemsSubscriptionUpdateItem*` functions to create this. + +To support these changes you may have to refactor some of your type usage, see the below table for reference: + +| Previous Type | New Type | +|-------------------------------------------------|-----------------------------------------| +| CatalogItem | TransactionItemFromCatalog | +| NonCatalogPriceForAnExistingProduct | TransactionItemCreateWithPrice | +| NonCatalogPriceAndProduct | TransactionItemCreateWithProduct | +| TransactionCatalogItem | TransactionPreviewItemFromCatalog | +| TransactionNonCatalogPriceForAnExistingProduct | TransactionPreviewItemCreateWithPrice | +| TransactionNonCatalogPriceAndProduct | TransactionPreviewItemCreateWithProduct | +| SubscriptionUpdateCatalogItem | SubscriptionUpdateItemFromCatalog | +| SubscriptionCatalogItem | SubscriptionChargeItemFromCatalog | +| SubscriptionNonCatalogPriceForAnExistingProduct | SubscriptionChargeItemCreateWithPrice | +| SubscriptionNonCatalogPriceAndProduct | SubscriptionChargeItemCreateWithProduct | + +Functions names have also changed as part of this standardisation, see the following table and update your code accordingly: + +| Previous Function | New Function | +|------------------------------------------------------------------------------------|-----------------------------------------------------------------------------| +| NewCreateTransactionItemsCatalogItem | NewCreateTransactionItemsTransactionItemFromCatalog | +| NewCreateTransactionItemsNonCatalogPriceForAnExistingProduct | NewCreateTransactionItemsTransactionItemCreateWithPrice | +| NewCreateTransactionItemsNonCatalogPriceAndProduct | NewCreateTransactionItemsTransactionItemCreateWithProduct | +| NewUpdateTransactionItemsCatalogItem | NewUpdateTransactionItemsTransactionItemFromCatalog | +| NewUpdateTransactionItemsNonCatalogPriceForAnExistingProduct | NewUpdateTransactionItemsTransactionItemCreateWithPrice | +| NewUpdateTransactionItemsNonCatalogPriceAndProduct | NewUpdateTransactionItemsTransactionItemCreateWithProduct | +| NewTransactionPreviewByAddressItemsTransactionCatalogItem | NewTransactionPreviewByAddressItemsTransactionPreviewItemFromCatalog | +| NewTransactionPreviewByAddressItemsTransactionNonCatalogPriceForAnExistingProduct | NewTransactionPreviewByAddressItemsTransactionPreviewItemCreateWithPrice | +| NewTransactionPreviewByAddressItemsTransactionNonCatalogPriceAndProduct | NewTransactionPreviewByAddressItemsTransactionPreviewItemCreateWithProduct | +| NewTransactionPreviewByIPItemsTransactionCatalogItem | NewTransactionPreviewByIPItemsTransactionPreviewItemFromCatalog | +| NewTransactionPreviewByIPItemsTransactionNonCatalogPriceForAnExistingProduct | NewTransactionPreviewByIPItemsTransactionPreviewItemCreateWithPrice | +| NewTransactionPreviewByIPItemsTransactionNonCatalogPriceAndProduct | NewTransactionPreviewByIPItemsTransactionPreviewItemCreateWithProduct | +| NewTransactionPreviewByCustomerItemsTransactionCatalogItem | NewTransactionPreviewByCustomerItemsTransactionPreviewItemFromCatalog | +| NewTransactionPreviewByCustomerItemsTransactionNonCatalogPriceForAnExistingProduct | NewTransactionPreviewByCustomerItemsTransactionPreviewItemCreateWithPrice | +| NewTransactionPreviewByCustomerItemsTransactionNonCatalogPriceAndProduct | NewTransactionPreviewByCustomerItemsTransactionPreviewItemCreateWithProduct | + +3. Some fields have been moved to pointers to correctly facilitate them being nullable. + +- `Type` for Product and Price notifications are nullable `*CatalogType` +- `PaymentMethodID` on Transaction payments is nullable `*PaymentMethodID` for both notifications and API calls + +Any usages of `Type` on `PriceNotification` or `ProductNotification` types will need to be changed to handle the `*CatalogType` type. +Any usages of `PaymentMethodID` on `TransactionPaymentAttempt` will need to be changed to handle a `*string` type. + +## v1.0.0 + +- No documented change ## v0.7.0 diff --git a/adjustments.go b/adjustments.go index 6d43686..099da83 100644 --- a/adjustments.go +++ b/adjustments.go @@ -132,6 +132,11 @@ const ( AdjustmentActionQueryRefund AdjustmentActionQuery = "refund" ) +type AdjustmentCreditNotePDF struct { + // URL: URL of the requested resource. + URL string `json:"url,omitempty"` +} + // CustomerBalance: Totals for this credit balance. Where a customer has more than one subscription in this currency with a credit balance, includes totals for all subscriptions. type CustomerBalance struct { // Available: Total amount of credit available to use. @@ -215,7 +220,8 @@ type CreateAdjustmentRequest struct { Reason string `json:"reason,omitempty"` /* TransactionID: Paddle ID of the transaction that this adjustment is for, prefixed with `txn_`. - Transactions must be manually-collected, and have a status of `billed` or `completed`. + + Automatically-collected transactions must be `completed`; manually-collected transactions must have a status of `billed` or `past_due` You can't create an adjustment for a transaction that has a refund that's pending approval. */ @@ -231,6 +237,29 @@ func (c *AdjustmentsClient) CreateAdjustment(ctx context.Context, req *CreateAdj return res, nil } +// GetAdjustmentCreditNoteRequest is given as an input to GetAdjustmentCreditNote. +type GetAdjustmentCreditNoteRequest struct { + // URL path parameters. + AdjustmentID string `in:"path=adjustment_id" json:"-"` + + // Disposition is a query parameter. + /* + Determine whether the generated URL should download the PDF as an attachment saved locally, or open it inline in the browser. + + Default: `attachment`. + */ + Disposition *string `in:"query=disposition;omitempty" json:"-"` +} + +// GetAdjustmentCreditNote performs the GET operation on a Adjustments resource. +func (c *AdjustmentsClient) GetAdjustmentCreditNote(ctx context.Context, req *GetAdjustmentCreditNoteRequest) (res *AdjustmentCreditNotePDF, err error) { + if err := c.doer.Do(ctx, "GET", "/adjustments/{adjustment_id}/credit-note", req, &res); err != nil { + return nil, err + } + + return res, nil +} + // ListCreditBalancesRequest is given as an input to ListCreditBalances. type ListCreditBalancesRequest struct { // URL path parameters. diff --git a/discounts.go b/discounts.go index ea6364e..41e9783 100644 --- a/discounts.go +++ b/discounts.go @@ -100,23 +100,35 @@ type CreateDiscountRequest struct { Amount string `json:"amount,omitempty"` // Description: Short description for this discount for your reference. Not shown to customers. Description string `json:"description,omitempty"` - // Type: Type of discount. Determines how this discount impacts the transaction total. + // Type: Type of discount. Determines how this discount impacts the checkout or transaction total. Type DiscountType `json:"type,omitempty"` - // EnabledForCheckout: Whether this discount can be applied by customers at checkout. If omitted, defaults to `false`. + // EnabledForCheckout: Whether this discount can be redeemed by customers at checkout (`true`) or not (`false`). EnabledForCheckout *bool `json:"enabled_for_checkout,omitempty"` - // Code: Unique code that customers can use to apply this discount at checkout. Use letters and numbers only, up to 16 characters. If omitted and `enabled_for_checkout` is `true`, Paddle generates a random 10-character code. + // Code: Unique code that customers can use to redeem this discount at checkout. Use letters and numbers only, up to 16 characters. If omitted and `enabled_for_checkout` is `true`, Paddle generates a random 10-character code. Code *string `json:"code,omitempty"` // CurrencyCode: Supported three-letter ISO 4217 currency code. Required where discount type is `flat` or `flat_per_seat`. CurrencyCode *CurrencyCode `json:"currency_code,omitempty"` - // Recur: Whether this discount applies for multiple subscription billing periods. If omitted, defaults to `false`. + // Recur: Whether this discount applies for multiple subscription billing periods (`true`) or not (`false`). If omitted, defaults to `false`. Recur *bool `json:"recur,omitempty"` - // MaximumRecurringIntervals: Amount of subscription billing periods that this discount recurs for. Requires `recur`. `null` if this discount recurs forever. + /* + MaximumRecurringIntervals: Number of subscription billing periods that this discount recurs for. Requires `recur`. `null` if this discount recurs forever. + + Subscription renewals, midcycle changes, and one-time charges billed to a subscription aren't considered a redemption. `times_used` is not incremented in these cases. + */ MaximumRecurringIntervals *int `json:"maximum_recurring_intervals,omitempty"` - // UsageLimit: Maximum amount of times this discount can be used. This is an overall limit, rather than a per-customer limit. `null` if this discount can be used an unlimited amount of times. + /* + UsageLimit: Maximum number of times this discount can be redeemed. This is an overall limit for this discount, rather than a per-customer limit. `null` if this discount can be redeemed an unlimited amount of times. + + Paddle counts a usage as a redemption on a checkout, transaction, or the initial application against a subscription. Transactions created for subscription renewals, midcycle changes, and one-time charges aren't considered a redemption. + */ UsageLimit *int `json:"usage_limit,omitempty"` // RestrictTo: Product or price IDs that this discount is for. When including a product ID, all prices for that product can be discounted. `null` if this discount applies to all products and prices. RestrictTo []string `json:"restrict_to,omitempty"` - // ExpiresAt: RFC 3339 datetime string of when this discount expires. Discount can no longer be applied after this date has elapsed. `null` if this discount can be applied forever. If omitted, defaults to `null`. + /* + ExpiresAt: RFC 3339 datetime string of when this discount expires. Discount can no longer be redeemed after this date has elapsed. `null` if this discount can be redeemed forever. + + Expired discounts can't be redeemed against transactions or checkouts, but can be applied when updating subscriptions. + */ ExpiresAt *string `json:"expires_at,omitempty"` // CustomData: Your own structured key-value data. CustomData CustomData `json:"custom_data,omitempty"` @@ -155,25 +167,37 @@ type UpdateDiscountRequest struct { Status *PatchField[DiscountStatus] `json:"status,omitempty"` // Description: Short description for this discount for your reference. Not shown to customers. Description *PatchField[string] `json:"description,omitempty"` - // EnabledForCheckout: Whether this discount can be applied by customers at checkout. + // EnabledForCheckout: Whether this discount can be redeemed by customers at checkout (`true`) or not (`false`). EnabledForCheckout *PatchField[bool] `json:"enabled_for_checkout,omitempty"` - // Code: Unique code that customers can use to apply this discount at checkout. + // Code: Unique code that customers can use to redeem this discount at checkout. Code *PatchField[*string] `json:"code,omitempty"` - // Type: Type of discount. Determines how this discount impacts the transaction total. + // Type: Type of discount. Determines how this discount impacts the checkout or transaction total. Type *PatchField[DiscountType] `json:"type,omitempty"` // Amount: Amount to discount by. For `percentage` discounts, must be an amount between `0.01` and `100`. For `flat` and `flat_per_seat` discounts, amount in the lowest denomination for a currency. Amount *PatchField[string] `json:"amount,omitempty"` // CurrencyCode: Supported three-letter ISO 4217 currency code. Required where discount type is `flat` or `flat_per_seat`. CurrencyCode *PatchField[*CurrencyCode] `json:"currency_code,omitempty"` - // Recur: Whether this discount applies for multiple subscription billing periods. + // Recur: Whether this discount applies for multiple subscription billing periods (`true`) or not (`false`). Recur *PatchField[bool] `json:"recur,omitempty"` - // MaximumRecurringIntervals: Amount of subscription billing periods that this discount recurs for. Requires `recur`. `null` if this discount recurs forever. + /* + MaximumRecurringIntervals: Number of subscription billing periods that this discount recurs for. Requires `recur`. `null` if this discount recurs forever. + + Subscription renewals, midcycle changes, and one-time charges billed to a subscription aren't considered a redemption. `times_used` is not incremented in these cases. + */ MaximumRecurringIntervals *PatchField[*int] `json:"maximum_recurring_intervals,omitempty"` - // UsageLimit: Maximum amount of times this discount can be used. This is an overall limit, rather than a per-customer limit. `null` if this discount can be used an unlimited amount of times. + /* + UsageLimit: Maximum number of times this discount can be redeemed. This is an overall limit for this discount, rather than a per-customer limit. `null` if this discount can be redeemed an unlimited amount of times. + + Paddle counts a usage as a redemption on a checkout, transaction, or the initial application against a subscription. Transactions created for subscription renewals, midcycle changes, and one-time charges aren't considered a redemption. + */ UsageLimit *PatchField[*int] `json:"usage_limit,omitempty"` // RestrictTo: Product or price IDs that this discount is for. When including a product ID, all prices for that product can be discounted. `null` if this discount applies to all products and prices. RestrictTo *PatchField[[]string] `json:"restrict_to,omitempty"` - // ExpiresAt: RFC 3339 datetime string of when this discount expires. Discount can no longer be applied after this date has elapsed. `null` if this discount can be applied forever. + /* + ExpiresAt: RFC 3339 datetime string of when this discount expires. Discount can no longer be redeemed after this date has elapsed. `null` if this discount can be redeemed forever. + + Expired discounts can't be redeemed against transactions or checkouts, but can be applied when updating subscriptions. + */ ExpiresAt *PatchField[*string] `json:"expires_at,omitempty"` // CustomData: Your own structured key-value data. CustomData *PatchField[CustomData] `json:"custom_data,omitempty"` diff --git a/example_create_test.go b/example_create_test.go index 30644f3..1acd6b7 100644 --- a/example_create_test.go +++ b/example_create_test.go @@ -34,15 +34,15 @@ func Example_create() { // Create a transaction. res, err := client.CreateTransaction(ctx, &paddle.CreateTransactionRequest{ Items: []paddle.CreateTransactionItems{ - *paddle.NewCreateTransactionItemsCatalogItem(&paddle.CatalogItem{ + *paddle.NewCreateTransactionItemsTransactionItemFromCatalog(&paddle.TransactionItemFromCatalog{ Quantity: 20, PriceID: "pri_01gsz91wy9k1yn7kx82aafwvea", }), - *paddle.NewCreateTransactionItemsCatalogItem(&paddle.CatalogItem{ + *paddle.NewCreateTransactionItemsTransactionItemFromCatalog(&paddle.TransactionItemFromCatalog{ Quantity: 1, PriceID: "pri_01gsz96z29d88jrmsf2ztbfgjg", }), - *paddle.NewCreateTransactionItemsCatalogItem(&paddle.CatalogItem{ + *paddle.NewCreateTransactionItemsTransactionItemFromCatalog(&paddle.TransactionItemFromCatalog{ Quantity: 1, PriceID: "pri_01gsz98e27ak2tyhexptwc58yk", }), diff --git a/example_update_test.go b/example_update_test.go index 907f68d..83a6316 100644 --- a/example_update_test.go +++ b/example_update_test.go @@ -34,15 +34,15 @@ func Example_update() { res, err := client.UpdateTransaction(ctx, &paddle.UpdateTransactionRequest{ DiscountID: paddle.NewPtrPatchField("dsc_01gtgztp8fpchantd5g1wrksa3"), Items: paddle.NewPatchField([]paddle.UpdateTransactionItems{ - *paddle.NewUpdateTransactionItemsCatalogItem(&paddle.CatalogItem{ + *paddle.NewUpdateTransactionItemsTransactionItemFromCatalog(&paddle.TransactionItemFromCatalog{ Quantity: 50, PriceID: "pri_01gsz91wy9k1yn7kx82aafwvea", }), - *paddle.NewUpdateTransactionItemsCatalogItem(&paddle.CatalogItem{ + *paddle.NewUpdateTransactionItemsTransactionItemFromCatalog(&paddle.TransactionItemFromCatalog{ Quantity: 1, PriceID: "pri_01gsz96z29d88jrmsf2ztbfgjg", }), - *paddle.NewUpdateTransactionItemsCatalogItem(&paddle.CatalogItem{ + *paddle.NewUpdateTransactionItemsTransactionItemFromCatalog(&paddle.TransactionItemFromCatalog{ Quantity: 1, PriceID: "pri_01gsz98e27ak2tyhexptwc58yk", }), diff --git a/internal/client/version.txt b/internal/client/version.txt index 3eefcb9..227cea2 100644 --- a/internal/client/version.txt +++ b/internal/client/version.txt @@ -1 +1 @@ -1.0.0 +2.0.0 diff --git a/notification_settings.go b/notification_settings.go index a543b37..31a5336 100644 --- a/notification_settings.go +++ b/notification_settings.go @@ -58,6 +58,9 @@ type ListNotificationSettingsRequest struct { Valid fields for ordering: `id`. */ OrderBy *string `in:"query=order_by;omitempty" json:"-"` + // Active is a query parameter. + // Determine whether returned entities are active (`true`) or not (`false`). + Active *bool `in:"query=active;omitempty" json:"-"` } // ListNotificationSettings performs the GET operation on a Notification settings resource. diff --git a/pkg/paddlenotification/adjustments.go b/pkg/paddlenotification/adjustments.go index 0ebee90..4057b04 100644 --- a/pkg/paddlenotification/adjustments.go +++ b/pkg/paddlenotification/adjustments.go @@ -163,13 +163,7 @@ type AdjustmentNotification struct { CustomerID string `json:"customer_id,omitempty"` // Reason: Why this adjustment was created. Appears in the Paddle dashboard. Retained for record-keeping purposes. Reason string `json:"reason,omitempty"` - /* - CreditAppliedToBalance: Whether this adjustment was applied to the related customer's credit balance. Only returned for `credit` adjustments. - - `false` where the related transaction is `billed`. The adjustment reduces the amount due on the transaction. - - `true` where the related transaction is `completed`. The amount is added the customer's credit balance and used to pay future transactions. - */ + // CreditAppliedToBalance: Whether this adjustment was applied to the related customer's credit balance. `null` unless adjustment `action` is not `credit`. CreditAppliedToBalance *bool `json:"credit_applied_to_balance,omitempty"` // CurrencyCode: Three-letter ISO 4217 currency code for this adjustment. Set automatically by Paddle based on the `currency_code` of the related transaction. CurrencyCode CurrencyCode `json:"currency_code,omitempty"` diff --git a/pkg/paddlenotification/discounts.go b/pkg/paddlenotification/discounts.go index 1cde55c..1a86a4c 100644 --- a/pkg/paddlenotification/discounts.go +++ b/pkg/paddlenotification/discounts.go @@ -33,7 +33,7 @@ const ( DiscountStatusUsed DiscountStatus = "used" ) -// Type: Type of discount. Determines how this discount impacts the transaction total.. +// Type: Type of discount. Determines how this discount impacts the checkout or transaction total.. type Type string const ( @@ -50,21 +50,29 @@ type DiscountNotification struct { Status DiscountStatus `json:"status,omitempty"` // Description: Short description for this discount for your reference. Not shown to customers. Description string `json:"description,omitempty"` - // EnabledForCheckout: Whether this discount can be applied by customers at checkout. + // EnabledForCheckout: Whether this discount can be redeemed by customers at checkout (`true`) or not (`false`). EnabledForCheckout bool `json:"enabled_for_checkout,omitempty"` - // Code: Unique code that customers can use to apply this discount at checkout. + // Code: Unique code that customers can use to redeem this discount at checkout. Code *string `json:"code,omitempty"` - // Type: Type of discount. Determines how this discount impacts the transaction total. + // Type: Type of discount. Determines how this discount impacts the checkout or transaction total. Type Type `json:"type,omitempty"` // Amount: Amount to discount by. For `percentage` discounts, must be an amount between `0.01` and `100`. For `flat` and `flat_per_seat` discounts, amount in the lowest denomination for a currency. Amount string `json:"amount,omitempty"` // CurrencyCode: Supported three-letter ISO 4217 currency code. Required where discount type is `flat` or `flat_per_seat`. CurrencyCode *CurrencyCode `json:"currency_code,omitempty"` - // Recur: Whether this discount applies for multiple subscription billing periods. + // Recur: Whether this discount applies for multiple subscription billing periods (`true`) or not (`false`). Recur bool `json:"recur,omitempty"` - // MaximumRecurringIntervals: Amount of subscription billing periods that this discount recurs for. Requires `recur`. `null` if this discount recurs forever. + /* + MaximumRecurringIntervals: Number of subscription billing periods that this discount recurs for. Requires `recur`. `null` if this discount recurs forever. + + Subscription renewals, midcycle changes, and one-time charges billed to a subscription aren't considered a redemption. `times_used` is not incremented in these cases. + */ MaximumRecurringIntervals *int `json:"maximum_recurring_intervals,omitempty"` - // UsageLimit: Maximum amount of times this discount can be used. This is an overall limit, rather than a per-customer limit. `null` if this discount can be used an unlimited amount of times. + /* + UsageLimit: Maximum number of times this discount can be redeemed. This is an overall limit for this discount, rather than a per-customer limit. `null` if this discount can be redeemed an unlimited amount of times. + + Paddle counts a usage as a redemption on a checkout, transaction, or the initial application against a subscription. Transactions created for subscription renewals, midcycle changes, and one-time charges aren't considered a redemption. + */ UsageLimit *int `json:"usage_limit,omitempty"` // RestrictTo: Product or price IDs that this discount is for. When including a product ID, all prices for that product can be discounted. `null` if this discount applies to all products and prices. RestrictTo []string `json:"restrict_to,omitempty"` @@ -72,7 +80,11 @@ type DiscountNotification struct { CustomData CustomData `json:"custom_data,omitempty"` // ImportMeta: Import information for this entity. `null` if this entity is not imported. ImportMeta *ImportMeta `json:"import_meta,omitempty"` - // ExpiresAt: RFC 3339 datetime string of when this discount expires. Discount can no longer be applied after this date has elapsed. `null` if this discount can be applied forever. + /* + ExpiresAt: RFC 3339 datetime string of when this discount expires. Discount can no longer be redeemed after this date has elapsed. `null` if this discount can be redeemed forever. + + Expired discounts can't be redeemed against transactions or checkouts, but can be applied when updating subscriptions. + */ ExpiresAt *string `json:"expires_at,omitempty"` // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. CreatedAt string `json:"created_at,omitempty"` diff --git a/pkg/paddlenotification/prices.go b/pkg/paddlenotification/prices.go index b16fe02..4c72fd8 100644 --- a/pkg/paddlenotification/prices.go +++ b/pkg/paddlenotification/prices.go @@ -32,7 +32,7 @@ type PriceNotification struct { // Description: Internal description for this price, not shown to customers. Typically notes for your team. Description string `json:"description,omitempty"` // Type: Type of item. Standard items are considered part of your catalog and are shown on the Paddle web app. - Type CatalogType `json:"type,omitempty"` + Type *CatalogType `json:"type,omitempty"` // Name: Name of this price, shown to customers at checkout and on invoices. Typically describes how often the related product bills. Name *string `json:"name,omitempty"` // BillingCycle: How often this price should be charged. `null` if price is non-recurring (one-time). diff --git a/pkg/paddlenotification/products.go b/pkg/paddlenotification/products.go index 0406a3e..25c32c5 100644 --- a/pkg/paddlenotification/products.go +++ b/pkg/paddlenotification/products.go @@ -32,7 +32,7 @@ type ProductNotification struct { // Description: Short description for this product. Description *string `json:"description,omitempty"` // Type: Type of item. Standard items are considered part of your catalog and are shown on the Paddle web app. - Type CatalogType `json:"type,omitempty"` + Type *CatalogType `json:"type,omitempty"` // TaxCategory: Tax category for this product. Used for charging the correct rate of tax. Selected tax category must be enabled on your Paddle account. TaxCategory TaxCategory `json:"tax_category,omitempty"` // ImageURL: Image for this product. Included in the checkout and on some customer documents. diff --git a/pkg/paddlenotification/transactions.go b/pkg/paddlenotification/transactions.go index de7069f..885300f 100644 --- a/pkg/paddlenotification/transactions.go +++ b/pkg/paddlenotification/transactions.go @@ -226,7 +226,7 @@ type TransactionPayoutTotalsAdjusted struct { // TransactionLineItem: Information about line items for this transaction. Different from transaction `items` as they include totals calculated by Paddle. Considered the source of truth for line item totals. type TransactionLineItem struct { - // ID: Unique Paddle ID for this transaction item, prefixed with `txnitm_`. + // ID: Unique Paddle ID for this transaction item, prefixed with `txnitm_`. Used when working with [adjustments](https://developer.paddle.com/build/transactions/create-transaction-adjustments). ID string `json:"id,omitempty"` // PriceID: Paddle ID for the price related to this transaction line item, prefixed with `pri_`. PriceID string `json:"price_id,omitempty"` @@ -361,7 +361,7 @@ type TransactionPaymentAttempt struct { // StoredPaymentMethodID: UUID for the stored payment method used for this payment attempt. Deprecated - use `payment_method_id` instead. StoredPaymentMethodID string `json:"stored_payment_method_id,omitempty"` // PaymentMethodID: Paddle ID of the payment method used for this payment attempt, prefixed with `paymtd_`. - PaymentMethodID string `json:"payment_method_id,omitempty"` + PaymentMethodID *string `json:"payment_method_id,omitempty"` // Amount: Amount for collection in the lowest denomination of a currency (e.g. cents for USD). Amount string `json:"amount,omitempty"` // Status: Status of this payment attempt. diff --git a/pricing_preview.go b/pricing_preview.go index ef6b3f9..b8f2969 100644 --- a/pricing_preview.go +++ b/pricing_preview.go @@ -78,8 +78,8 @@ type PricingPreviewClient struct { doer Doer } -// PricePreviewRequest is given as an input to PricePreview. -type PricePreviewRequest struct { +// PreviewPricesRequest is given as an input to PreviewPrices. +type PreviewPricesRequest struct { // Items: List of items to preview price calculations for. Items []PricePreviewItem `json:"items,omitempty"` // CustomerID: Paddle ID of the customer that this preview is for, prefixed with `ctm_`. @@ -98,8 +98,8 @@ type PricePreviewRequest struct { CustomerIPAddress *string `json:"customer_ip_address,omitempty"` } -// PricePreview performs the POST operation on a Pricing preview resource. -func (c *PricingPreviewClient) PricePreview(ctx context.Context, req *PricePreviewRequest) (res *PricePreview, err error) { +// PreviewPrices performs the POST operation on a Pricing preview resource. +func (c *PricingPreviewClient) PreviewPrices(ctx context.Context, req *PreviewPricesRequest) (res *PricePreview, err error) { if err := c.doer.Do(ctx, "POST", "/pricing-preview", req, &res); err != nil { return nil, err } diff --git a/shared.go b/shared.go index f997c7b..9123a47 100644 --- a/shared.go +++ b/shared.go @@ -137,6 +137,13 @@ var ErrInvalidJson = &paddleerr.Error{ Type: paddleerr.ErrorTypeRequestError, } +// ErrUnexpectedRequestBody represents a `unexpected_request_body` error. +// See https://developer.paddle.com/errors/shared/unexpected_request_body for more information. +var ErrUnexpectedRequestBody = &paddleerr.Error{ + Code: "unexpected_request_body", + Type: paddleerr.ErrorTypeRequestError, +} + // ErrInvalidTimeQueryParameter represents a `invalid_time_query_parameter` error. // See https://developer.paddle.com/errors/shared/invalid_time_query_parameter for more information. var ErrInvalidTimeQueryParameter = &paddleerr.Error{ @@ -158,6 +165,13 @@ var ErrReceiptDataNotEnabled = &paddleerr.Error{ Type: paddleerr.ErrorTypeRequestError, } +// ErrRequestHeadersTooLarge represents a `request_headers_too_large` error. +// See https://developer.paddle.com/errors/apigateway/request_headers_too_large for more information. +var ErrRequestHeadersTooLarge = &paddleerr.Error{ + Code: "request_headers_too_large", + Type: paddleerr.ErrorTypeRequestError, +} + // CatalogType: Return items that match the specified type.. type CatalogType string @@ -788,7 +802,7 @@ type TransactionPayoutTotalsAdjusted struct { // TransactionLineItem: Information about line items for this transaction. Different from transaction `items` as they include totals calculated by Paddle. Considered the source of truth for line item totals. type TransactionLineItem struct { - // ID: Unique Paddle ID for this transaction item, prefixed with `txnitm_`. + // ID: Unique Paddle ID for this transaction item, prefixed with `txnitm_`. Used when working with [adjustments](https://developer.paddle.com/build/transactions/create-transaction-adjustments). ID string `json:"id,omitempty"` // PriceID: Paddle ID for the price related to this transaction line item, prefixed with `pri_`. PriceID string `json:"price_id,omitempty"` @@ -923,7 +937,7 @@ type TransactionPaymentAttempt struct { // StoredPaymentMethodID: UUID for the stored payment method used for this payment attempt. Deprecated - use `payment_method_id` instead. StoredPaymentMethodID string `json:"stored_payment_method_id,omitempty"` // PaymentMethodID: Paddle ID of the payment method used for this payment attempt, prefixed with `paymtd_`. - PaymentMethodID string `json:"payment_method_id,omitempty"` + PaymentMethodID *string `json:"payment_method_id,omitempty"` // Amount: Amount for collection in the lowest denomination of a currency (e.g. cents for USD). Amount string `json:"amount,omitempty"` // Status: Status of this payment attempt. @@ -1123,13 +1137,7 @@ type Adjustment struct { CustomerID string `json:"customer_id,omitempty"` // Reason: Why this adjustment was created. Appears in the Paddle dashboard. Retained for record-keeping purposes. Reason string `json:"reason,omitempty"` - /* - CreditAppliedToBalance: Whether this adjustment was applied to the related customer's credit balance. Only returned for `credit` adjustments. - - `false` where the related transaction is `billed`. The adjustment reduces the amount due on the transaction. - - `true` where the related transaction is `completed`. The amount is added the customer's credit balance and used to pay future transactions. - */ + // CreditAppliedToBalance: Whether this adjustment was applied to the related customer's credit balance. Only returned for `credit` adjustments. CreditAppliedToBalance *bool `json:"credit_applied_to_balance,omitempty"` // CurrencyCode: Three-letter ISO 4217 currency code for this adjustment. Set automatically by Paddle based on the `currency_code` of the related transaction. CurrencyCode CurrencyCode `json:"currency_code,omitempty"` @@ -1199,7 +1207,7 @@ const ( DiscountStatusUsed DiscountStatus = "used" ) -// DiscountType: Type of discount. Determines how this discount impacts the transaction total.. +// DiscountType: Type of discount. Determines how this discount impacts the checkout or transaction total.. type DiscountType string const ( @@ -1216,29 +1224,45 @@ type Discount struct { Status DiscountStatus `json:"status,omitempty"` // Description: Short description for this discount for your reference. Not shown to customers. Description string `json:"description,omitempty"` - // EnabledForCheckout: Whether this discount can be applied by customers at checkout. + // EnabledForCheckout: Whether this discount can be redeemed by customers at checkout (`true`) or not (`false`). EnabledForCheckout bool `json:"enabled_for_checkout,omitempty"` - // Code: Unique code that customers can use to apply this discount at checkout. + // Code: Unique code that customers can use to redeem this discount at checkout. Code *string `json:"code,omitempty"` - // Type: Type of discount. Determines how this discount impacts the transaction total. + // Type: Type of discount. Determines how this discount impacts the checkout or transaction total. Type DiscountType `json:"type,omitempty"` // Amount: Amount to discount by. For `percentage` discounts, must be an amount between `0.01` and `100`. For `flat` and `flat_per_seat` discounts, amount in the lowest denomination for a currency. Amount string `json:"amount,omitempty"` // CurrencyCode: Supported three-letter ISO 4217 currency code. Required where discount type is `flat` or `flat_per_seat`. CurrencyCode *CurrencyCode `json:"currency_code,omitempty"` - // Recur: Whether this discount applies for multiple subscription billing periods. + // Recur: Whether this discount applies for multiple subscription billing periods (`true`) or not (`false`). Recur bool `json:"recur,omitempty"` - // MaximumRecurringIntervals: Amount of subscription billing periods that this discount recurs for. Requires `recur`. `null` if this discount recurs forever. + /* + MaximumRecurringIntervals: Number of subscription billing periods that this discount recurs for. Requires `recur`. `null` if this discount recurs forever. + + Subscription renewals, midcycle changes, and one-time charges billed to a subscription aren't considered a redemption. `times_used` is not incremented in these cases. + */ MaximumRecurringIntervals *int `json:"maximum_recurring_intervals,omitempty"` - // UsageLimit: Maximum amount of times this discount can be used. This is an overall limit, rather than a per-customer limit. `null` if this discount can be used an unlimited amount of times. + /* + UsageLimit: Maximum number of times this discount can be redeemed. This is an overall limit for this discount, rather than a per-customer limit. `null` if this discount can be redeemed an unlimited amount of times. + + Paddle counts a usage as a redemption on a checkout, transaction, or the initial application against a subscription. Transactions created for subscription renewals, midcycle changes, and one-time charges aren't considered a redemption. + */ UsageLimit *int `json:"usage_limit,omitempty"` // RestrictTo: Product or price IDs that this discount is for. When including a product ID, all prices for that product can be discounted. `null` if this discount applies to all products and prices. RestrictTo []string `json:"restrict_to,omitempty"` - // ExpiresAt: RFC 3339 datetime string of when this discount expires. Discount can no longer be applied after this date has elapsed. `null` if this discount can be applied forever. + /* + ExpiresAt: RFC 3339 datetime string of when this discount expires. Discount can no longer be redeemed after this date has elapsed. `null` if this discount can be redeemed forever. + + Expired discounts can't be redeemed against transactions or checkouts, but can be applied when updating subscriptions. + */ ExpiresAt *string `json:"expires_at,omitempty"` // CustomData: Your own structured key-value data. CustomData CustomData `json:"custom_data,omitempty"` - // TimesUsed: How many times this discount has been redeemed. Automatically incremented by Paddle when an order completes. + /* + TimesUsed: How many times this discount has been redeemed. Automatically incremented by Paddle. + + Paddle counts a usage as a redemption on a checkout, transaction, or subscription. Transactions created for subscription renewals, midcycle changes, and one-time charges aren't considered a redemption. + */ TimesUsed int `json:"times_used,omitempty"` // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. CreatedAt string `json:"created_at,omitempty"` @@ -1248,6 +1272,30 @@ type Discount struct { ImportMeta *ImportMeta `json:"import_meta,omitempty"` } +// TransactionPriceCreateWithProductID: Price object for a non-catalog item to charge for. Include a `product_id` to relate this non-catalog price to an existing catalog price. +type TransactionPriceCreateWithProductID struct { + // Description: Internal description for this price, not shown to customers. Typically notes for your team. + Description string `json:"description,omitempty"` + // Name: Name of this price, shown to customers at checkout and on invoices. Typically describes how often the related product bills. + Name *string `json:"name,omitempty"` + // BillingCycle: How often this price should be charged. `null` if price is non-recurring (one-time). + BillingCycle *Duration `json:"billing_cycle,omitempty"` + // TrialPeriod: Trial period for the product related to this price. The billing cycle begins once the trial period is over. `null` for no trial period. Requires `billing_cycle`. + TrialPeriod *Duration `json:"trial_period,omitempty"` + // TaxMode: How tax is calculated for this price. + TaxMode TaxMode `json:"tax_mode,omitempty"` + // UnitPrice: Base price. This price applies to all customers, except for customers located in countries where you have `unit_price_overrides`. + UnitPrice Money `json:"unit_price,omitempty"` + // UnitPriceOverrides: List of unit price overrides. Use to override the base price with a custom price and currency for a country or group of countries. + UnitPriceOverrides []UnitPriceOverride `json:"unit_price_overrides,omitempty"` + // Quantity: Limits on how many times the related product can be purchased at this price. Useful for discount campaigns. If omitted, defaults to 1-100. + Quantity PriceQuantity `json:"quantity,omitempty"` + // CustomData: Your own structured key-value data. + CustomData CustomData `json:"custom_data,omitempty"` + // ProductID: Paddle ID for the product that this price is for, prefixed with `pro_`. + ProductID string `json:"product_id,omitempty"` +} + // TransactionSubscriptionProductCreate: Product object for a non-catalog item to charge for. type TransactionSubscriptionProductCreate struct { // Name: Name of this product. @@ -1262,6 +1310,30 @@ type TransactionSubscriptionProductCreate struct { CustomData CustomData `json:"custom_data,omitempty"` } +// TransactionPriceCreateWithProduct: Price object for a non-catalog item to charge for. Include a `product` object to create a non-catalog product for this non-catalog price. +type TransactionPriceCreateWithProduct struct { + // Description: Internal description for this price, not shown to customers. Typically notes for your team. + Description string `json:"description,omitempty"` + // Name: Name of this price, shown to customers at checkout and on invoices. Typically describes how often the related product bills. + Name *string `json:"name,omitempty"` + // BillingCycle: How often this price should be charged. `null` if price is non-recurring (one-time). + BillingCycle *Duration `json:"billing_cycle,omitempty"` + // TrialPeriod: Trial period for the product related to this price. The billing cycle begins once the trial period is over. `null` for no trial period. Requires `billing_cycle`. + TrialPeriod *Duration `json:"trial_period,omitempty"` + // TaxMode: How tax is calculated for this price. + TaxMode TaxMode `json:"tax_mode,omitempty"` + // UnitPrice: Base price. This price applies to all customers, except for customers located in countries where you have `unit_price_overrides`. + UnitPrice Money `json:"unit_price,omitempty"` + // UnitPriceOverrides: List of unit price overrides. Use to override the base price with a custom price and currency for a country or group of countries. + UnitPriceOverrides []UnitPriceOverride `json:"unit_price_overrides,omitempty"` + // Quantity: Limits on how many times the related product can be purchased at this price. Useful for discount campaigns. If omitted, defaults to 1-100. + Quantity PriceQuantity `json:"quantity,omitempty"` + // CustomData: Your own structured key-value data. + CustomData CustomData `json:"custom_data,omitempty"` + // Product: Product object for a non-catalog item to charge for. + Product TransactionSubscriptionProductCreate `json:"product,omitempty"` +} + // AddressPreview: Address for this preview. Send one of `address_id`, `customer_ip_address`, or the `address` object when previewing. type AddressPreview struct { // PostalCode: ZIP or postal code of this address. Include for more accurate tax calculations. @@ -1282,6 +1354,18 @@ type BillingDetailsUpdate struct { PaymentTerms Duration `json:"payment_terms,omitempty"` } +/* +Disposition: Determine whether the generated URL should download the PDF as an attachment saved locally, or open it inline in the browser. + +Default: `attachment`.. +*/ +type Disposition string + +const ( + DispositionAttachment Disposition = "attachment" + DispositionInline Disposition = "inline" +) + // EventTypeName: Type of event sent by Paddle, in the format `entity.event_type`.. type EventTypeName string diff --git a/subscriptions.go b/subscriptions.go index 846a9cd..0a289ec 100644 --- a/subscriptions.go +++ b/subscriptions.go @@ -575,14 +575,30 @@ type SubscriptionDiscountEffectiveFrom struct { EffectiveFrom EffectiveFrom `json:"effective_from,omitempty"` } -// SubscriptionUpdateCatalogItem: Add or update a catalog item to a subscription. In this case, the product and price that you're billing for exist in your product catalog in Paddle. -type SubscriptionUpdateCatalogItem struct { +// SubscriptionUpdateItemFromCatalog: Add or update a catalog item to a subscription. In this case, the product and price that you're billing for exist in your product catalog in Paddle. +type SubscriptionUpdateItemFromCatalog struct { // PriceID: Paddle ID for the price to add to this subscription, prefixed with `pri_`. PriceID string `json:"price_id,omitempty"` // Quantity: Quantity of this item to add to the subscription. If updating an existing item and not changing the quantity, you may omit `quantity`. Quantity int `json:"quantity,omitempty"` } +// SubscriptionUpdateItemCreateWithPrice: Add a non-catalog price for an existing product in your catalog to a subscription. In this case, the product you're billing for is a catalog product, but you charge a specific price for it. +type SubscriptionUpdateItemCreateWithPrice struct { + // Quantity: Quantity to bill for. + Quantity int `json:"quantity,omitempty"` + // Price: Price object for a non-catalog item to bill for. Include a `product_id` to relate this non-catalog price to an existing catalog price. + Price TransactionPriceCreateWithProductID `json:"price,omitempty"` +} + +// SubscriptionUpdateItemCreateWithProduct: Add a non-catalog price for a non-catalog product in your catalog to a subscription. In this case, the product and price that you're billing for are specific to this subscription. +type SubscriptionUpdateItemCreateWithProduct struct { + // Quantity: Quantity to bill for. + Quantity int `json:"quantity,omitempty"` + // Price: Price object for a non-catalog item to charge for. Include a `product` object to create a non-catalog product for this non-catalog price. + Price TransactionPriceCreateWithProduct `json:"price,omitempty"` +} + /* ProrationBillingMode: How Paddle should handle proration calculation for changes made to a subscription or its items. Required when making changes that impact billing. @@ -712,8 +728,8 @@ type SubscriptionPreview struct { ImportMeta *ImportMeta `json:"import_meta,omitempty"` } -// SubscriptionCatalogItem: Add a catalog item to a subscription. In this case, the product and price that you're billing for exist in your product catalog in Paddle. -type SubscriptionCatalogItem struct { +// SubscriptionChargeItemFromCatalog: Add a catalog item to a subscription. In this case, the product and price that you're billing for exist in your product catalog in Paddle. +type SubscriptionChargeItemFromCatalog struct { // Quantity: Quantity to bill for. Quantity int `json:"quantity,omitempty"` // PriceID: Paddle ID of an an existing catalog price to bill for. @@ -740,8 +756,8 @@ type SubscriptionChargeCreateWithPrice struct { CustomData CustomData `json:"custom_data,omitempty"` } -// SubscriptionNonCatalogPriceForAnExistingProduct: Add a non-catalog price for an existing product in your catalog to a subscription. In this case, the product you're billing for is a catalog product, but you charge a specific price for it. -type SubscriptionNonCatalogPriceForAnExistingProduct struct { +// SubscriptionChargeItemCreateWithPrice: Add a non-catalog price for an existing product in your catalog to a subscription. In this case, the product you're billing for is a catalog product, but you charge a specific price for it. +type SubscriptionChargeItemCreateWithPrice struct { // Quantity: Quantity to bill for. Quantity int `json:"quantity,omitempty"` // Price: Price object for a non-catalog item to bill for. Include a `product_id` to relate this non-catalog price to an existing catalog price. @@ -768,8 +784,8 @@ type SubscriptionChargeCreateWithProduct struct { Product TransactionSubscriptionProductCreate `json:"product,omitempty"` } -// SubscriptionNonCatalogPriceAndProduct: Add a non-catalog price for a non-catalog product in your catalog to a subscription. In this case, the product and price that you're billing for are specific to this transaction. -type SubscriptionNonCatalogPriceAndProduct struct { +// SubscriptionChargeItemCreateWithProduct: Add a non-catalog price for a non-catalog product in your catalog to a subscription. In this case, the product and price that you're billing for are specific to this transaction. +type SubscriptionChargeItemCreateWithProduct struct { // Quantity: Quantity to bill for. Quantity int `json:"quantity,omitempty"` // Price: Price object for a non-catalog item to charge for. Include a `product` object to create a non-catalog product for this non-catalog price. @@ -804,6 +820,59 @@ func (c *SubscriptionsClient) GetSubscription(ctx context.Context, req *GetSubsc return res, nil } +// NewUpdateSubscriptionItemsSubscriptionUpdateItemFromCatalog takes a SubscriptionUpdateItemFromCatalog type +// and creates a UpdateSubscriptionItems for use in a request. +func NewUpdateSubscriptionItemsSubscriptionUpdateItemFromCatalog(r *SubscriptionUpdateItemFromCatalog) *UpdateSubscriptionItems { + return &UpdateSubscriptionItems{SubscriptionUpdateItemFromCatalog: r} +} + +// NewUpdateSubscriptionItemsSubscriptionUpdateItemCreateWithPrice takes a SubscriptionUpdateItemCreateWithPrice type +// and creates a UpdateSubscriptionItems for use in a request. +func NewUpdateSubscriptionItemsSubscriptionUpdateItemCreateWithPrice(r *SubscriptionUpdateItemCreateWithPrice) *UpdateSubscriptionItems { + return &UpdateSubscriptionItems{SubscriptionUpdateItemCreateWithPrice: r} +} + +// NewUpdateSubscriptionItemsSubscriptionUpdateItemCreateWithProduct takes a SubscriptionUpdateItemCreateWithProduct type +// and creates a UpdateSubscriptionItems for use in a request. +func NewUpdateSubscriptionItemsSubscriptionUpdateItemCreateWithProduct(r *SubscriptionUpdateItemCreateWithProduct) *UpdateSubscriptionItems { + return &UpdateSubscriptionItems{SubscriptionUpdateItemCreateWithProduct: r} +} + +// UpdateSubscriptionItems represents a union request type of the following types: +// - `SubscriptionUpdateItemFromCatalog` +// - `SubscriptionUpdateItemCreateWithPrice` +// - `SubscriptionUpdateItemCreateWithProduct` +// +// The following constructor functions can be used to create a new instance of this type. +// - `NewUpdateSubscriptionItemsSubscriptionUpdateItemFromCatalog()` +// - `NewUpdateSubscriptionItemsSubscriptionUpdateItemCreateWithPrice()` +// - `NewUpdateSubscriptionItemsSubscriptionUpdateItemCreateWithProduct()` +// +// Only one of the values can be set at a time, the first non-nil value will be used in the request. +// Items: Add a non-catalog price for a non-catalog product in your catalog to a subscription. In this case, the product and price that you're billing for are specific to this subscription. +type UpdateSubscriptionItems struct { + *SubscriptionUpdateItemFromCatalog + *SubscriptionUpdateItemCreateWithPrice + *SubscriptionUpdateItemCreateWithProduct +} + +// MarshalJSON implements the json.Marshaler interface. +func (u UpdateSubscriptionItems) MarshalJSON() ([]byte, error) { + if u.SubscriptionUpdateItemFromCatalog != nil { + return json.Marshal(u.SubscriptionUpdateItemFromCatalog) + } + + if u.SubscriptionUpdateItemCreateWithPrice != nil { + return json.Marshal(u.SubscriptionUpdateItemCreateWithPrice) + } + + if u.SubscriptionUpdateItemCreateWithProduct != nil { + return json.Marshal(u.SubscriptionUpdateItemCreateWithProduct) + } + + return nil, nil +} + // UpdateSubscriptionRequest is given as an input to UpdateSubscription. type UpdateSubscriptionRequest struct { // URL path parameters. @@ -827,8 +896,8 @@ type UpdateSubscriptionRequest struct { BillingDetails *PatchField[*BillingDetailsUpdate] `json:"billing_details,omitempty"` // ScheduledChange: Change that's scheduled to be applied to a subscription. When updating, you may only set to `null` to remove a scheduled change. Use the pause subscription, cancel subscription, and resume subscription operations to create scheduled changes. ScheduledChange *PatchField[*SubscriptionScheduledChange] `json:"scheduled_change,omitempty"` - // Items: Add or update a catalog item to a subscription. In this case, the product and price that you're billing for exist in your product catalog in Paddle. - Items *PatchField[[]SubscriptionUpdateCatalogItem] `json:"items,omitempty"` + // Items: Add a non-catalog price for a non-catalog product in your catalog to a subscription. In this case, the product and price that you're billing for are specific to this subscription. + Items *PatchField[[]UpdateSubscriptionItems] `json:"items,omitempty"` // CustomData: Your own structured key-value data. CustomData *PatchField[CustomData] `json:"custom_data,omitempty"` /* @@ -1028,6 +1097,59 @@ func (c *SubscriptionsClient) GetSubscriptionUpdatePaymentMethodTransaction(ctx return res, nil } +// NewPreviewSubscriptionUpdateItemsSubscriptionUpdateItemFromCatalog takes a SubscriptionUpdateItemFromCatalog type +// and creates a PreviewSubscriptionUpdateItems for use in a request. +func NewPreviewSubscriptionUpdateItemsSubscriptionUpdateItemFromCatalog(r *SubscriptionUpdateItemFromCatalog) *PreviewSubscriptionUpdateItems { + return &PreviewSubscriptionUpdateItems{SubscriptionUpdateItemFromCatalog: r} +} + +// NewPreviewSubscriptionUpdateItemsSubscriptionUpdateItemCreateWithPrice takes a SubscriptionUpdateItemCreateWithPrice type +// and creates a PreviewSubscriptionUpdateItems for use in a request. +func NewPreviewSubscriptionUpdateItemsSubscriptionUpdateItemCreateWithPrice(r *SubscriptionUpdateItemCreateWithPrice) *PreviewSubscriptionUpdateItems { + return &PreviewSubscriptionUpdateItems{SubscriptionUpdateItemCreateWithPrice: r} +} + +// NewPreviewSubscriptionUpdateItemsSubscriptionUpdateItemCreateWithProduct takes a SubscriptionUpdateItemCreateWithProduct type +// and creates a PreviewSubscriptionUpdateItems for use in a request. +func NewPreviewSubscriptionUpdateItemsSubscriptionUpdateItemCreateWithProduct(r *SubscriptionUpdateItemCreateWithProduct) *PreviewSubscriptionUpdateItems { + return &PreviewSubscriptionUpdateItems{SubscriptionUpdateItemCreateWithProduct: r} +} + +// PreviewSubscriptionUpdateItems represents a union request type of the following types: +// - `SubscriptionUpdateItemFromCatalog` +// - `SubscriptionUpdateItemCreateWithPrice` +// - `SubscriptionUpdateItemCreateWithProduct` +// +// The following constructor functions can be used to create a new instance of this type. +// - `NewPreviewSubscriptionUpdateItemsSubscriptionUpdateItemFromCatalog()` +// - `NewPreviewSubscriptionUpdateItemsSubscriptionUpdateItemCreateWithPrice()` +// - `NewPreviewSubscriptionUpdateItemsSubscriptionUpdateItemCreateWithProduct()` +// +// Only one of the values can be set at a time, the first non-nil value will be used in the request. +// Items: Add a non-catalog price for a non-catalog product in your catalog to a subscription. In this case, the product and price that you're billing for are specific to this subscription. +type PreviewSubscriptionUpdateItems struct { + *SubscriptionUpdateItemFromCatalog + *SubscriptionUpdateItemCreateWithPrice + *SubscriptionUpdateItemCreateWithProduct +} + +// MarshalJSON implements the json.Marshaler interface. +func (u PreviewSubscriptionUpdateItems) MarshalJSON() ([]byte, error) { + if u.SubscriptionUpdateItemFromCatalog != nil { + return json.Marshal(u.SubscriptionUpdateItemFromCatalog) + } + + if u.SubscriptionUpdateItemCreateWithPrice != nil { + return json.Marshal(u.SubscriptionUpdateItemCreateWithPrice) + } + + if u.SubscriptionUpdateItemCreateWithProduct != nil { + return json.Marshal(u.SubscriptionUpdateItemCreateWithProduct) + } + + return nil, nil +} + // PreviewSubscriptionUpdateRequest is given as an input to PreviewSubscriptionUpdate. type PreviewSubscriptionUpdateRequest struct { // URL path parameters. @@ -1051,8 +1173,8 @@ type PreviewSubscriptionUpdateRequest struct { BillingDetails *PatchField[*BillingDetailsUpdate] `json:"billing_details,omitempty"` // ScheduledChange: Change that's scheduled to be applied to a subscription. When updating, you may only set to `null` to remove a scheduled change. Use the pause subscription, cancel subscription, and resume subscription operations to create scheduled changes. ScheduledChange *PatchField[*SubscriptionScheduledChange] `json:"scheduled_change,omitempty"` - // Items: Add or update a catalog item to a subscription. In this case, the product and price that you're billing for exist in your product catalog in Paddle. - Items *PatchField[[]SubscriptionUpdateCatalogItem] `json:"items,omitempty"` + // Items: Add a non-catalog price for a non-catalog product in your catalog to a subscription. In this case, the product and price that you're billing for are specific to this subscription. + Items *PatchField[[]PreviewSubscriptionUpdateItems] `json:"items,omitempty"` // CustomData: Your own structured key-value data. CustomData *PatchField[CustomData] `json:"custom_data,omitempty"` /* @@ -1076,54 +1198,54 @@ func (c *SubscriptionsClient) PreviewSubscriptionUpdate(ctx context.Context, req return res, nil } -// NewCreateSubscriptionChargeItemsSubscriptionCatalogItem takes a SubscriptionCatalogItem type +// NewCreateSubscriptionChargeItemsSubscriptionChargeItemFromCatalog takes a SubscriptionChargeItemFromCatalog type // and creates a CreateSubscriptionChargeItems for use in a request. -func NewCreateSubscriptionChargeItemsSubscriptionCatalogItem(r *SubscriptionCatalogItem) *CreateSubscriptionChargeItems { - return &CreateSubscriptionChargeItems{SubscriptionCatalogItem: r} +func NewCreateSubscriptionChargeItemsSubscriptionChargeItemFromCatalog(r *SubscriptionChargeItemFromCatalog) *CreateSubscriptionChargeItems { + return &CreateSubscriptionChargeItems{SubscriptionChargeItemFromCatalog: r} } -// NewCreateSubscriptionChargeItemsSubscriptionNonCatalogPriceForAnExistingProduct takes a SubscriptionNonCatalogPriceForAnExistingProduct type +// NewCreateSubscriptionChargeItemsSubscriptionChargeItemCreateWithPrice takes a SubscriptionChargeItemCreateWithPrice type // and creates a CreateSubscriptionChargeItems for use in a request. -func NewCreateSubscriptionChargeItemsSubscriptionNonCatalogPriceForAnExistingProduct(r *SubscriptionNonCatalogPriceForAnExistingProduct) *CreateSubscriptionChargeItems { - return &CreateSubscriptionChargeItems{SubscriptionNonCatalogPriceForAnExistingProduct: r} +func NewCreateSubscriptionChargeItemsSubscriptionChargeItemCreateWithPrice(r *SubscriptionChargeItemCreateWithPrice) *CreateSubscriptionChargeItems { + return &CreateSubscriptionChargeItems{SubscriptionChargeItemCreateWithPrice: r} } -// NewCreateSubscriptionChargeItemsSubscriptionNonCatalogPriceAndProduct takes a SubscriptionNonCatalogPriceAndProduct type +// NewCreateSubscriptionChargeItemsSubscriptionChargeItemCreateWithProduct takes a SubscriptionChargeItemCreateWithProduct type // and creates a CreateSubscriptionChargeItems for use in a request. -func NewCreateSubscriptionChargeItemsSubscriptionNonCatalogPriceAndProduct(r *SubscriptionNonCatalogPriceAndProduct) *CreateSubscriptionChargeItems { - return &CreateSubscriptionChargeItems{SubscriptionNonCatalogPriceAndProduct: r} +func NewCreateSubscriptionChargeItemsSubscriptionChargeItemCreateWithProduct(r *SubscriptionChargeItemCreateWithProduct) *CreateSubscriptionChargeItems { + return &CreateSubscriptionChargeItems{SubscriptionChargeItemCreateWithProduct: r} } // CreateSubscriptionChargeItems represents a union request type of the following types: -// - `SubscriptionCatalogItem` -// - `SubscriptionNonCatalogPriceForAnExistingProduct` -// - `SubscriptionNonCatalogPriceAndProduct` +// - `SubscriptionChargeItemFromCatalog` +// - `SubscriptionChargeItemCreateWithPrice` +// - `SubscriptionChargeItemCreateWithProduct` // // The following constructor functions can be used to create a new instance of this type. -// - `NewCreateSubscriptionChargeItemsSubscriptionCatalogItem()` -// - `NewCreateSubscriptionChargeItemsSubscriptionNonCatalogPriceForAnExistingProduct()` -// - `NewCreateSubscriptionChargeItemsSubscriptionNonCatalogPriceAndProduct()` +// - `NewCreateSubscriptionChargeItemsSubscriptionChargeItemFromCatalog()` +// - `NewCreateSubscriptionChargeItemsSubscriptionChargeItemCreateWithPrice()` +// - `NewCreateSubscriptionChargeItemsSubscriptionChargeItemCreateWithProduct()` // // Only one of the values can be set at a time, the first non-nil value will be used in the request. // Items: Add a non-catalog price for a non-catalog product in your catalog to a subscription. In this case, the product and price that you're billing for are specific to this transaction. type CreateSubscriptionChargeItems struct { - *SubscriptionCatalogItem - *SubscriptionNonCatalogPriceForAnExistingProduct - *SubscriptionNonCatalogPriceAndProduct + *SubscriptionChargeItemFromCatalog + *SubscriptionChargeItemCreateWithPrice + *SubscriptionChargeItemCreateWithProduct } // MarshalJSON implements the json.Marshaler interface. func (u CreateSubscriptionChargeItems) MarshalJSON() ([]byte, error) { - if u.SubscriptionCatalogItem != nil { - return json.Marshal(u.SubscriptionCatalogItem) + if u.SubscriptionChargeItemFromCatalog != nil { + return json.Marshal(u.SubscriptionChargeItemFromCatalog) } - if u.SubscriptionNonCatalogPriceForAnExistingProduct != nil { - return json.Marshal(u.SubscriptionNonCatalogPriceForAnExistingProduct) + if u.SubscriptionChargeItemCreateWithPrice != nil { + return json.Marshal(u.SubscriptionChargeItemCreateWithPrice) } - if u.SubscriptionNonCatalogPriceAndProduct != nil { - return json.Marshal(u.SubscriptionNonCatalogPriceAndProduct) + if u.SubscriptionChargeItemCreateWithProduct != nil { + return json.Marshal(u.SubscriptionChargeItemCreateWithProduct) } return nil, nil @@ -1151,54 +1273,54 @@ func (c *SubscriptionsClient) CreateSubscriptionCharge(ctx context.Context, req return res, nil } -// NewPreviewSubscriptionChargeItemsSubscriptionCatalogItem takes a SubscriptionCatalogItem type +// NewPreviewSubscriptionChargeItemsSubscriptionChargeItemFromCatalog takes a SubscriptionChargeItemFromCatalog type // and creates a PreviewSubscriptionChargeItems for use in a request. -func NewPreviewSubscriptionChargeItemsSubscriptionCatalogItem(r *SubscriptionCatalogItem) *PreviewSubscriptionChargeItems { - return &PreviewSubscriptionChargeItems{SubscriptionCatalogItem: r} +func NewPreviewSubscriptionChargeItemsSubscriptionChargeItemFromCatalog(r *SubscriptionChargeItemFromCatalog) *PreviewSubscriptionChargeItems { + return &PreviewSubscriptionChargeItems{SubscriptionChargeItemFromCatalog: r} } -// NewPreviewSubscriptionChargeItemsSubscriptionNonCatalogPriceForAnExistingProduct takes a SubscriptionNonCatalogPriceForAnExistingProduct type +// NewPreviewSubscriptionChargeItemsSubscriptionChargeItemCreateWithPrice takes a SubscriptionChargeItemCreateWithPrice type // and creates a PreviewSubscriptionChargeItems for use in a request. -func NewPreviewSubscriptionChargeItemsSubscriptionNonCatalogPriceForAnExistingProduct(r *SubscriptionNonCatalogPriceForAnExistingProduct) *PreviewSubscriptionChargeItems { - return &PreviewSubscriptionChargeItems{SubscriptionNonCatalogPriceForAnExistingProduct: r} +func NewPreviewSubscriptionChargeItemsSubscriptionChargeItemCreateWithPrice(r *SubscriptionChargeItemCreateWithPrice) *PreviewSubscriptionChargeItems { + return &PreviewSubscriptionChargeItems{SubscriptionChargeItemCreateWithPrice: r} } -// NewPreviewSubscriptionChargeItemsSubscriptionNonCatalogPriceAndProduct takes a SubscriptionNonCatalogPriceAndProduct type +// NewPreviewSubscriptionChargeItemsSubscriptionChargeItemCreateWithProduct takes a SubscriptionChargeItemCreateWithProduct type // and creates a PreviewSubscriptionChargeItems for use in a request. -func NewPreviewSubscriptionChargeItemsSubscriptionNonCatalogPriceAndProduct(r *SubscriptionNonCatalogPriceAndProduct) *PreviewSubscriptionChargeItems { - return &PreviewSubscriptionChargeItems{SubscriptionNonCatalogPriceAndProduct: r} +func NewPreviewSubscriptionChargeItemsSubscriptionChargeItemCreateWithProduct(r *SubscriptionChargeItemCreateWithProduct) *PreviewSubscriptionChargeItems { + return &PreviewSubscriptionChargeItems{SubscriptionChargeItemCreateWithProduct: r} } // PreviewSubscriptionChargeItems represents a union request type of the following types: -// - `SubscriptionCatalogItem` -// - `SubscriptionNonCatalogPriceForAnExistingProduct` -// - `SubscriptionNonCatalogPriceAndProduct` +// - `SubscriptionChargeItemFromCatalog` +// - `SubscriptionChargeItemCreateWithPrice` +// - `SubscriptionChargeItemCreateWithProduct` // // The following constructor functions can be used to create a new instance of this type. -// - `NewPreviewSubscriptionChargeItemsSubscriptionCatalogItem()` -// - `NewPreviewSubscriptionChargeItemsSubscriptionNonCatalogPriceForAnExistingProduct()` -// - `NewPreviewSubscriptionChargeItemsSubscriptionNonCatalogPriceAndProduct()` +// - `NewPreviewSubscriptionChargeItemsSubscriptionChargeItemFromCatalog()` +// - `NewPreviewSubscriptionChargeItemsSubscriptionChargeItemCreateWithPrice()` +// - `NewPreviewSubscriptionChargeItemsSubscriptionChargeItemCreateWithProduct()` // // Only one of the values can be set at a time, the first non-nil value will be used in the request. // Items: Add a non-catalog price for a non-catalog product in your catalog to a subscription. In this case, the product and price that you're billing for are specific to this transaction. type PreviewSubscriptionChargeItems struct { - *SubscriptionCatalogItem - *SubscriptionNonCatalogPriceForAnExistingProduct - *SubscriptionNonCatalogPriceAndProduct + *SubscriptionChargeItemFromCatalog + *SubscriptionChargeItemCreateWithPrice + *SubscriptionChargeItemCreateWithProduct } // MarshalJSON implements the json.Marshaler interface. func (u PreviewSubscriptionChargeItems) MarshalJSON() ([]byte, error) { - if u.SubscriptionCatalogItem != nil { - return json.Marshal(u.SubscriptionCatalogItem) + if u.SubscriptionChargeItemFromCatalog != nil { + return json.Marshal(u.SubscriptionChargeItemFromCatalog) } - if u.SubscriptionNonCatalogPriceForAnExistingProduct != nil { - return json.Marshal(u.SubscriptionNonCatalogPriceForAnExistingProduct) + if u.SubscriptionChargeItemCreateWithPrice != nil { + return json.Marshal(u.SubscriptionChargeItemCreateWithPrice) } - if u.SubscriptionNonCatalogPriceAndProduct != nil { - return json.Marshal(u.SubscriptionNonCatalogPriceAndProduct) + if u.SubscriptionChargeItemCreateWithProduct != nil { + return json.Marshal(u.SubscriptionChargeItemCreateWithProduct) } return nil, nil diff --git a/transactions.go b/transactions.go index 9e869c6..aa4e565 100644 --- a/transactions.go +++ b/transactions.go @@ -240,6 +240,34 @@ var ErrTransactionPaymentMethodChangeFieldImmutable = &paddleerr.Error{ Type: paddleerr.ErrorTypeRequestError, } +// ErrTransactionInvalidStatusToRevise represents a `transaction_invalid_status_to_revise` error. +// See https://developer.paddle.com/errors/transactions/transaction_invalid_status_to_revise for more information. +var ErrTransactionInvalidStatusToRevise = &paddleerr.Error{ + Code: "transaction_invalid_status_to_revise", + Type: paddleerr.ErrorTypeRequestError, +} + +// ErrTransactionRevisedLimitReached represents a `transaction_revised_limit_reached` error. +// See https://developer.paddle.com/errors/transactions/transaction_revised_limit_reached for more information. +var ErrTransactionRevisedLimitReached = &paddleerr.Error{ + Code: "transaction_revised_limit_reached", + Type: paddleerr.ErrorTypeRequestError, +} + +// ErrTransactionAdjustedUnableToRevise represents a `transaction_adjusted_unable_to_revise` error. +// See https://developer.paddle.com/errors/transactions/transaction_adjusted_unable_to_revise for more information. +var ErrTransactionAdjustedUnableToRevise = &paddleerr.Error{ + Code: "transaction_adjusted_unable_to_revise", + Type: paddleerr.ErrorTypeRequestError, +} + +// ErrTransactionImmutableWhileProcessingPayment represents a `transaction_immutable_while_processing_payment` error. +// See https://developer.paddle.com/errors/transactions/transaction_immutable_while_processing_payment for more information. +var ErrTransactionImmutableWhileProcessingPayment = &paddleerr.Error{ + Code: "transaction_immutable_while_processing_payment", + Type: paddleerr.ErrorTypeRequestError, +} + // AdjustmentTotalsBreakdown: Breakdown of the total adjustments by adjustment action. type AdjustmentTotalsBreakdown struct { // Credit: Total amount of credit adjustments. @@ -336,8 +364,8 @@ type Transaction struct { AvailablePaymentMethods []PaymentMethodType `json:"available_payment_methods,omitempty"` } -// CatalogItem: Add a catalog item to a transaction. In this case, the product and price that you're billing for exist in your product catalog in Paddle. -type CatalogItem struct { +// TransactionItemFromCatalog: Add a catalog item to a transaction. In this case, the product and price that you're billing for exist in your product catalog in Paddle. +type TransactionItemFromCatalog struct { // Quantity: Quantity of this item on the transaction. Quantity int `json:"quantity,omitempty"` // Proration: How proration was calculated for this item. Populated when a transaction is created from a subscription change, where `proration_billing_mode` was `prorated_immediately` or `prorated_next_billing_period`. Set automatically by Paddle. @@ -346,32 +374,8 @@ type CatalogItem struct { PriceID string `json:"price_id,omitempty"` } -// TransactionPriceCreateWithProductID: Price object for a non-catalog item to charge for. Include a `product_id` to relate this non-catalog price to an existing catalog price. -type TransactionPriceCreateWithProductID struct { - // Description: Internal description for this price, not shown to customers. Typically notes for your team. - Description string `json:"description,omitempty"` - // Name: Name of this price, shown to customers at checkout and on invoices. Typically describes how often the related product bills. - Name *string `json:"name,omitempty"` - // BillingCycle: How often this price should be charged. `null` if price is non-recurring (one-time). - BillingCycle *Duration `json:"billing_cycle,omitempty"` - // TrialPeriod: Trial period for the product related to this price. The billing cycle begins once the trial period is over. `null` for no trial period. Requires `billing_cycle`. - TrialPeriod *Duration `json:"trial_period,omitempty"` - // TaxMode: How tax is calculated for this price. - TaxMode TaxMode `json:"tax_mode,omitempty"` - // UnitPrice: Base price. This price applies to all customers, except for customers located in countries where you have `unit_price_overrides`. - UnitPrice Money `json:"unit_price,omitempty"` - // UnitPriceOverrides: List of unit price overrides. Use to override the base price with a custom price and currency for a country or group of countries. - UnitPriceOverrides []UnitPriceOverride `json:"unit_price_overrides,omitempty"` - // Quantity: Limits on how many times the related product can be purchased at this price. Useful for discount campaigns. If omitted, defaults to 1-100. - Quantity PriceQuantity `json:"quantity,omitempty"` - // CustomData: Your own structured key-value data. - CustomData CustomData `json:"custom_data,omitempty"` - // ProductID: Paddle ID for the product that this price is for, prefixed with `pro_`. - ProductID string `json:"product_id,omitempty"` -} - -// NonCatalogPriceForAnExistingProduct: Add a non-catalog price for an existing product in your catalog to a transaction. In this case, the product you're billing for is a catalog product, but you charge a specific price for it. -type NonCatalogPriceForAnExistingProduct struct { +// TransactionItemCreateWithPrice: Add a non-catalog price for an existing product in your catalog to a transaction. In this case, the product you're billing for is a catalog product, but you charge a specific price for it. +type TransactionItemCreateWithPrice struct { // Quantity: Quantity of this item on the transaction. Quantity int `json:"quantity,omitempty"` // Proration: How proration was calculated for this item. Populated when a transaction is created from a subscription change, where `proration_billing_mode` was `prorated_immediately` or `prorated_next_billing_period`. Set automatically by Paddle. @@ -380,32 +384,8 @@ type NonCatalogPriceForAnExistingProduct struct { Price TransactionPriceCreateWithProductID `json:"price,omitempty"` } -// TransactionPriceCreateWithProduct: Price object for a non-catalog item to charge for. Include a `product` object to create a non-catalog product for this non-catalog price. -type TransactionPriceCreateWithProduct struct { - // Description: Internal description for this price, not shown to customers. Typically notes for your team. - Description string `json:"description,omitempty"` - // Name: Name of this price, shown to customers at checkout and on invoices. Typically describes how often the related product bills. - Name *string `json:"name,omitempty"` - // BillingCycle: How often this price should be charged. `null` if price is non-recurring (one-time). - BillingCycle *Duration `json:"billing_cycle,omitempty"` - // TrialPeriod: Trial period for the product related to this price. The billing cycle begins once the trial period is over. `null` for no trial period. Requires `billing_cycle`. - TrialPeriod *Duration `json:"trial_period,omitempty"` - // TaxMode: How tax is calculated for this price. - TaxMode TaxMode `json:"tax_mode,omitempty"` - // UnitPrice: Base price. This price applies to all customers, except for customers located in countries where you have `unit_price_overrides`. - UnitPrice Money `json:"unit_price,omitempty"` - // UnitPriceOverrides: List of unit price overrides. Use to override the base price with a custom price and currency for a country or group of countries. - UnitPriceOverrides []UnitPriceOverride `json:"unit_price_overrides,omitempty"` - // Quantity: Limits on how many times the related product can be purchased at this price. Useful for discount campaigns. If omitted, defaults to 1-100. - Quantity PriceQuantity `json:"quantity,omitempty"` - // CustomData: Your own structured key-value data. - CustomData CustomData `json:"custom_data,omitempty"` - // Product: Product object for a non-catalog item to charge for. - Product TransactionSubscriptionProductCreate `json:"product,omitempty"` -} - -// NonCatalogPriceAndProduct: Add a non-catalog price for a non-catalog product in your catalog to a transaction. In this case, the product and price that you're billing for are specific to this transaction. -type NonCatalogPriceAndProduct struct { +// TransactionItemCreateWithProduct: Add a non-catalog price for a non-catalog product in your catalog to a transaction. In this case, the product and price that you're billing for are specific to this transaction. +type TransactionItemCreateWithProduct struct { // Quantity: Quantity of this item on the transaction. Quantity int `json:"quantity,omitempty"` // Proration: How proration was calculated for this item. Populated when a transaction is created from a subscription change, where `proration_billing_mode` was `prorated_immediately` or `prorated_next_billing_period`. Set automatically by Paddle. @@ -414,8 +394,8 @@ type NonCatalogPriceAndProduct struct { Price TransactionPriceCreateWithProduct `json:"price,omitempty"` } -// TransactionCatalogItem: Add a catalog item to a transaction. In this case, the product and price that you're billing for exist in your product catalog in Paddle. -type TransactionCatalogItem struct { +// TransactionPreviewItemFromCatalog: Add a catalog item to a transaction. In this case, the product and price that you're billing for exist in your product catalog in Paddle. +type TransactionPreviewItemFromCatalog struct { // Quantity: Quantity of this item on the transaction. Quantity int `json:"quantity,omitempty"` // IncludeInTotals: Whether this item should be included in totals for this transaction preview. Typically used to exclude one-time charges from calculations. @@ -426,8 +406,8 @@ type TransactionCatalogItem struct { PriceID string `json:"price_id,omitempty"` } -// TransactionNonCatalogPriceForAnExistingProduct: Add a non-catalog price for an existing product in your catalog to a transaction. In this case, the product you're billing for is a catalog product, but you charge a specific price for it. -type TransactionNonCatalogPriceForAnExistingProduct struct { +// TransactionPreviewItemCreateWithPrice: Add a non-catalog price for an existing product in your catalog to a transaction. In this case, the product you're billing for is a catalog product, but you charge a specific price for it. +type TransactionPreviewItemCreateWithPrice struct { // Quantity: Quantity of this item on the transaction. Quantity int `json:"quantity,omitempty"` // IncludeInTotals: Whether this item should be included in totals for this transaction preview. Typically used to exclude one-time charges from calculations. @@ -438,8 +418,8 @@ type TransactionNonCatalogPriceForAnExistingProduct struct { Price TransactionPriceCreateWithProductID `json:"price,omitempty"` } -// TransactionNonCatalogPriceAndProduct: Add a non-catalog price for a non-catalog product in your catalog to a transaction. In this case, the product and price that you're billing for are specific to this transaction. -type TransactionNonCatalogPriceAndProduct struct { +// TransactionPreviewItemCreateWithProduct: Add a non-catalog price for a non-catalog product in your catalog to a transaction. In this case, the product and price that you're billing for are specific to this transaction. +type TransactionPreviewItemCreateWithProduct struct { // Quantity: Quantity of this item on the transaction. Quantity int `json:"quantity,omitempty"` // IncludeInTotals: Whether this item should be included in totals for this transaction preview. Typically used to exclude one-time charges from calculations. @@ -450,54 +430,54 @@ type TransactionNonCatalogPriceAndProduct struct { Price TransactionPriceCreateWithProduct `json:"price,omitempty"` } -// NewTransactionPreviewByAddressItemsTransactionCatalogItem takes a TransactionCatalogItem type +// NewTransactionPreviewByAddressItemsTransactionPreviewItemFromCatalog takes a TransactionPreviewItemFromCatalog type // and creates a TransactionPreviewByAddressItems for use in a request. -func NewTransactionPreviewByAddressItemsTransactionCatalogItem(r *TransactionCatalogItem) *TransactionPreviewByAddressItems { - return &TransactionPreviewByAddressItems{TransactionCatalogItem: r} +func NewTransactionPreviewByAddressItemsTransactionPreviewItemFromCatalog(r *TransactionPreviewItemFromCatalog) *TransactionPreviewByAddressItems { + return &TransactionPreviewByAddressItems{TransactionPreviewItemFromCatalog: r} } -// NewTransactionPreviewByAddressItemsTransactionNonCatalogPriceForAnExistingProduct takes a TransactionNonCatalogPriceForAnExistingProduct type +// NewTransactionPreviewByAddressItemsTransactionPreviewItemCreateWithPrice takes a TransactionPreviewItemCreateWithPrice type // and creates a TransactionPreviewByAddressItems for use in a request. -func NewTransactionPreviewByAddressItemsTransactionNonCatalogPriceForAnExistingProduct(r *TransactionNonCatalogPriceForAnExistingProduct) *TransactionPreviewByAddressItems { - return &TransactionPreviewByAddressItems{TransactionNonCatalogPriceForAnExistingProduct: r} +func NewTransactionPreviewByAddressItemsTransactionPreviewItemCreateWithPrice(r *TransactionPreviewItemCreateWithPrice) *TransactionPreviewByAddressItems { + return &TransactionPreviewByAddressItems{TransactionPreviewItemCreateWithPrice: r} } -// NewTransactionPreviewByAddressItemsTransactionNonCatalogPriceAndProduct takes a TransactionNonCatalogPriceAndProduct type +// NewTransactionPreviewByAddressItemsTransactionPreviewItemCreateWithProduct takes a TransactionPreviewItemCreateWithProduct type // and creates a TransactionPreviewByAddressItems for use in a request. -func NewTransactionPreviewByAddressItemsTransactionNonCatalogPriceAndProduct(r *TransactionNonCatalogPriceAndProduct) *TransactionPreviewByAddressItems { - return &TransactionPreviewByAddressItems{TransactionNonCatalogPriceAndProduct: r} +func NewTransactionPreviewByAddressItemsTransactionPreviewItemCreateWithProduct(r *TransactionPreviewItemCreateWithProduct) *TransactionPreviewByAddressItems { + return &TransactionPreviewByAddressItems{TransactionPreviewItemCreateWithProduct: r} } // TransactionPreviewByAddressItems represents a union request type of the following types: -// - `TransactionCatalogItem` -// - `TransactionNonCatalogPriceForAnExistingProduct` -// - `TransactionNonCatalogPriceAndProduct` +// - `TransactionPreviewItemFromCatalog` +// - `TransactionPreviewItemCreateWithPrice` +// - `TransactionPreviewItemCreateWithProduct` // // The following constructor functions can be used to create a new instance of this type. -// - `NewTransactionPreviewByAddressItemsTransactionCatalogItem()` -// - `NewTransactionPreviewByAddressItemsTransactionNonCatalogPriceForAnExistingProduct()` -// - `NewTransactionPreviewByAddressItemsTransactionNonCatalogPriceAndProduct()` +// - `NewTransactionPreviewByAddressItemsTransactionPreviewItemFromCatalog()` +// - `NewTransactionPreviewByAddressItemsTransactionPreviewItemCreateWithPrice()` +// - `NewTransactionPreviewByAddressItemsTransactionPreviewItemCreateWithProduct()` // // Only one of the values can be set at a time, the first non-nil value will be used in the request. // Items: Add a non-catalog price for a non-catalog product in your catalog to a transaction. In this case, the product and price that you're billing for are specific to this transaction. type TransactionPreviewByAddressItems struct { - *TransactionCatalogItem - *TransactionNonCatalogPriceForAnExistingProduct - *TransactionNonCatalogPriceAndProduct + *TransactionPreviewItemFromCatalog + *TransactionPreviewItemCreateWithPrice + *TransactionPreviewItemCreateWithProduct } // MarshalJSON implements the json.Marshaler interface. func (u TransactionPreviewByAddressItems) MarshalJSON() ([]byte, error) { - if u.TransactionCatalogItem != nil { - return json.Marshal(u.TransactionCatalogItem) + if u.TransactionPreviewItemFromCatalog != nil { + return json.Marshal(u.TransactionPreviewItemFromCatalog) } - if u.TransactionNonCatalogPriceForAnExistingProduct != nil { - return json.Marshal(u.TransactionNonCatalogPriceForAnExistingProduct) + if u.TransactionPreviewItemCreateWithPrice != nil { + return json.Marshal(u.TransactionPreviewItemCreateWithPrice) } - if u.TransactionNonCatalogPriceAndProduct != nil { - return json.Marshal(u.TransactionNonCatalogPriceAndProduct) + if u.TransactionPreviewItemCreateWithProduct != nil { + return json.Marshal(u.TransactionPreviewItemCreateWithProduct) } return nil, nil @@ -523,54 +503,54 @@ type TransactionPreviewByAddress struct { Items []TransactionPreviewByAddressItems `json:"items,omitempty"` } -// NewTransactionPreviewByIPItemsTransactionCatalogItem takes a TransactionCatalogItem type +// NewTransactionPreviewByIPItemsTransactionPreviewItemFromCatalog takes a TransactionPreviewItemFromCatalog type // and creates a TransactionPreviewByIPItems for use in a request. -func NewTransactionPreviewByIPItemsTransactionCatalogItem(r *TransactionCatalogItem) *TransactionPreviewByIPItems { - return &TransactionPreviewByIPItems{TransactionCatalogItem: r} +func NewTransactionPreviewByIPItemsTransactionPreviewItemFromCatalog(r *TransactionPreviewItemFromCatalog) *TransactionPreviewByIPItems { + return &TransactionPreviewByIPItems{TransactionPreviewItemFromCatalog: r} } -// NewTransactionPreviewByIPItemsTransactionNonCatalogPriceForAnExistingProduct takes a TransactionNonCatalogPriceForAnExistingProduct type +// NewTransactionPreviewByIPItemsTransactionPreviewItemCreateWithPrice takes a TransactionPreviewItemCreateWithPrice type // and creates a TransactionPreviewByIPItems for use in a request. -func NewTransactionPreviewByIPItemsTransactionNonCatalogPriceForAnExistingProduct(r *TransactionNonCatalogPriceForAnExistingProduct) *TransactionPreviewByIPItems { - return &TransactionPreviewByIPItems{TransactionNonCatalogPriceForAnExistingProduct: r} +func NewTransactionPreviewByIPItemsTransactionPreviewItemCreateWithPrice(r *TransactionPreviewItemCreateWithPrice) *TransactionPreviewByIPItems { + return &TransactionPreviewByIPItems{TransactionPreviewItemCreateWithPrice: r} } -// NewTransactionPreviewByIPItemsTransactionNonCatalogPriceAndProduct takes a TransactionNonCatalogPriceAndProduct type +// NewTransactionPreviewByIPItemsTransactionPreviewItemCreateWithProduct takes a TransactionPreviewItemCreateWithProduct type // and creates a TransactionPreviewByIPItems for use in a request. -func NewTransactionPreviewByIPItemsTransactionNonCatalogPriceAndProduct(r *TransactionNonCatalogPriceAndProduct) *TransactionPreviewByIPItems { - return &TransactionPreviewByIPItems{TransactionNonCatalogPriceAndProduct: r} +func NewTransactionPreviewByIPItemsTransactionPreviewItemCreateWithProduct(r *TransactionPreviewItemCreateWithProduct) *TransactionPreviewByIPItems { + return &TransactionPreviewByIPItems{TransactionPreviewItemCreateWithProduct: r} } // TransactionPreviewByIPItems represents a union request type of the following types: -// - `TransactionCatalogItem` -// - `TransactionNonCatalogPriceForAnExistingProduct` -// - `TransactionNonCatalogPriceAndProduct` +// - `TransactionPreviewItemFromCatalog` +// - `TransactionPreviewItemCreateWithPrice` +// - `TransactionPreviewItemCreateWithProduct` // // The following constructor functions can be used to create a new instance of this type. -// - `NewTransactionPreviewByIPItemsTransactionCatalogItem()` -// - `NewTransactionPreviewByIPItemsTransactionNonCatalogPriceForAnExistingProduct()` -// - `NewTransactionPreviewByIPItemsTransactionNonCatalogPriceAndProduct()` +// - `NewTransactionPreviewByIPItemsTransactionPreviewItemFromCatalog()` +// - `NewTransactionPreviewByIPItemsTransactionPreviewItemCreateWithPrice()` +// - `NewTransactionPreviewByIPItemsTransactionPreviewItemCreateWithProduct()` // // Only one of the values can be set at a time, the first non-nil value will be used in the request. // Items: Add a non-catalog price for a non-catalog product in your catalog to a transaction. In this case, the product and price that you're billing for are specific to this transaction. type TransactionPreviewByIPItems struct { - *TransactionCatalogItem - *TransactionNonCatalogPriceForAnExistingProduct - *TransactionNonCatalogPriceAndProduct + *TransactionPreviewItemFromCatalog + *TransactionPreviewItemCreateWithPrice + *TransactionPreviewItemCreateWithProduct } // MarshalJSON implements the json.Marshaler interface. func (u TransactionPreviewByIPItems) MarshalJSON() ([]byte, error) { - if u.TransactionCatalogItem != nil { - return json.Marshal(u.TransactionCatalogItem) + if u.TransactionPreviewItemFromCatalog != nil { + return json.Marshal(u.TransactionPreviewItemFromCatalog) } - if u.TransactionNonCatalogPriceForAnExistingProduct != nil { - return json.Marshal(u.TransactionNonCatalogPriceForAnExistingProduct) + if u.TransactionPreviewItemCreateWithPrice != nil { + return json.Marshal(u.TransactionPreviewItemCreateWithPrice) } - if u.TransactionNonCatalogPriceAndProduct != nil { - return json.Marshal(u.TransactionNonCatalogPriceAndProduct) + if u.TransactionPreviewItemCreateWithProduct != nil { + return json.Marshal(u.TransactionPreviewItemCreateWithProduct) } return nil, nil @@ -596,54 +576,54 @@ type TransactionPreviewByIP struct { Items []TransactionPreviewByIPItems `json:"items,omitempty"` } -// NewTransactionPreviewByCustomerItemsTransactionCatalogItem takes a TransactionCatalogItem type +// NewTransactionPreviewByCustomerItemsTransactionPreviewItemFromCatalog takes a TransactionPreviewItemFromCatalog type // and creates a TransactionPreviewByCustomerItems for use in a request. -func NewTransactionPreviewByCustomerItemsTransactionCatalogItem(r *TransactionCatalogItem) *TransactionPreviewByCustomerItems { - return &TransactionPreviewByCustomerItems{TransactionCatalogItem: r} +func NewTransactionPreviewByCustomerItemsTransactionPreviewItemFromCatalog(r *TransactionPreviewItemFromCatalog) *TransactionPreviewByCustomerItems { + return &TransactionPreviewByCustomerItems{TransactionPreviewItemFromCatalog: r} } -// NewTransactionPreviewByCustomerItemsTransactionNonCatalogPriceForAnExistingProduct takes a TransactionNonCatalogPriceForAnExistingProduct type +// NewTransactionPreviewByCustomerItemsTransactionPreviewItemCreateWithPrice takes a TransactionPreviewItemCreateWithPrice type // and creates a TransactionPreviewByCustomerItems for use in a request. -func NewTransactionPreviewByCustomerItemsTransactionNonCatalogPriceForAnExistingProduct(r *TransactionNonCatalogPriceForAnExistingProduct) *TransactionPreviewByCustomerItems { - return &TransactionPreviewByCustomerItems{TransactionNonCatalogPriceForAnExistingProduct: r} +func NewTransactionPreviewByCustomerItemsTransactionPreviewItemCreateWithPrice(r *TransactionPreviewItemCreateWithPrice) *TransactionPreviewByCustomerItems { + return &TransactionPreviewByCustomerItems{TransactionPreviewItemCreateWithPrice: r} } -// NewTransactionPreviewByCustomerItemsTransactionNonCatalogPriceAndProduct takes a TransactionNonCatalogPriceAndProduct type +// NewTransactionPreviewByCustomerItemsTransactionPreviewItemCreateWithProduct takes a TransactionPreviewItemCreateWithProduct type // and creates a TransactionPreviewByCustomerItems for use in a request. -func NewTransactionPreviewByCustomerItemsTransactionNonCatalogPriceAndProduct(r *TransactionNonCatalogPriceAndProduct) *TransactionPreviewByCustomerItems { - return &TransactionPreviewByCustomerItems{TransactionNonCatalogPriceAndProduct: r} +func NewTransactionPreviewByCustomerItemsTransactionPreviewItemCreateWithProduct(r *TransactionPreviewItemCreateWithProduct) *TransactionPreviewByCustomerItems { + return &TransactionPreviewByCustomerItems{TransactionPreviewItemCreateWithProduct: r} } // TransactionPreviewByCustomerItems represents a union request type of the following types: -// - `TransactionCatalogItem` -// - `TransactionNonCatalogPriceForAnExistingProduct` -// - `TransactionNonCatalogPriceAndProduct` +// - `TransactionPreviewItemFromCatalog` +// - `TransactionPreviewItemCreateWithPrice` +// - `TransactionPreviewItemCreateWithProduct` // // The following constructor functions can be used to create a new instance of this type. -// - `NewTransactionPreviewByCustomerItemsTransactionCatalogItem()` -// - `NewTransactionPreviewByCustomerItemsTransactionNonCatalogPriceForAnExistingProduct()` -// - `NewTransactionPreviewByCustomerItemsTransactionNonCatalogPriceAndProduct()` +// - `NewTransactionPreviewByCustomerItemsTransactionPreviewItemFromCatalog()` +// - `NewTransactionPreviewByCustomerItemsTransactionPreviewItemCreateWithPrice()` +// - `NewTransactionPreviewByCustomerItemsTransactionPreviewItemCreateWithProduct()` // // Only one of the values can be set at a time, the first non-nil value will be used in the request. // Items: Add a non-catalog price for a non-catalog product in your catalog to a transaction. In this case, the product and price that you're billing for are specific to this transaction. type TransactionPreviewByCustomerItems struct { - *TransactionCatalogItem - *TransactionNonCatalogPriceForAnExistingProduct - *TransactionNonCatalogPriceAndProduct + *TransactionPreviewItemFromCatalog + *TransactionPreviewItemCreateWithPrice + *TransactionPreviewItemCreateWithProduct } // MarshalJSON implements the json.Marshaler interface. func (u TransactionPreviewByCustomerItems) MarshalJSON() ([]byte, error) { - if u.TransactionCatalogItem != nil { - return json.Marshal(u.TransactionCatalogItem) + if u.TransactionPreviewItemFromCatalog != nil { + return json.Marshal(u.TransactionPreviewItemFromCatalog) } - if u.TransactionNonCatalogPriceForAnExistingProduct != nil { - return json.Marshal(u.TransactionNonCatalogPriceForAnExistingProduct) + if u.TransactionPreviewItemCreateWithPrice != nil { + return json.Marshal(u.TransactionPreviewItemCreateWithPrice) } - if u.TransactionNonCatalogPriceAndProduct != nil { - return json.Marshal(u.TransactionNonCatalogPriceAndProduct) + if u.TransactionPreviewItemCreateWithProduct != nil { + return json.Marshal(u.TransactionPreviewItemCreateWithProduct) } return nil, nil @@ -833,54 +813,54 @@ func (c *TransactionsClient) ListTransactions(ctx context.Context, req *ListTran return res, nil } -// NewCreateTransactionItemsCatalogItem takes a CatalogItem type +// NewCreateTransactionItemsTransactionItemFromCatalog takes a TransactionItemFromCatalog type // and creates a CreateTransactionItems for use in a request. -func NewCreateTransactionItemsCatalogItem(r *CatalogItem) *CreateTransactionItems { - return &CreateTransactionItems{CatalogItem: r} +func NewCreateTransactionItemsTransactionItemFromCatalog(r *TransactionItemFromCatalog) *CreateTransactionItems { + return &CreateTransactionItems{TransactionItemFromCatalog: r} } -// NewCreateTransactionItemsNonCatalogPriceForAnExistingProduct takes a NonCatalogPriceForAnExistingProduct type +// NewCreateTransactionItemsTransactionItemCreateWithPrice takes a TransactionItemCreateWithPrice type // and creates a CreateTransactionItems for use in a request. -func NewCreateTransactionItemsNonCatalogPriceForAnExistingProduct(r *NonCatalogPriceForAnExistingProduct) *CreateTransactionItems { - return &CreateTransactionItems{NonCatalogPriceForAnExistingProduct: r} +func NewCreateTransactionItemsTransactionItemCreateWithPrice(r *TransactionItemCreateWithPrice) *CreateTransactionItems { + return &CreateTransactionItems{TransactionItemCreateWithPrice: r} } -// NewCreateTransactionItemsNonCatalogPriceAndProduct takes a NonCatalogPriceAndProduct type +// NewCreateTransactionItemsTransactionItemCreateWithProduct takes a TransactionItemCreateWithProduct type // and creates a CreateTransactionItems for use in a request. -func NewCreateTransactionItemsNonCatalogPriceAndProduct(r *NonCatalogPriceAndProduct) *CreateTransactionItems { - return &CreateTransactionItems{NonCatalogPriceAndProduct: r} +func NewCreateTransactionItemsTransactionItemCreateWithProduct(r *TransactionItemCreateWithProduct) *CreateTransactionItems { + return &CreateTransactionItems{TransactionItemCreateWithProduct: r} } // CreateTransactionItems represents a union request type of the following types: -// - `CatalogItem` -// - `NonCatalogPriceForAnExistingProduct` -// - `NonCatalogPriceAndProduct` +// - `TransactionItemFromCatalog` +// - `TransactionItemCreateWithPrice` +// - `TransactionItemCreateWithProduct` // // The following constructor functions can be used to create a new instance of this type. -// - `NewCreateTransactionItemsCatalogItem()` -// - `NewCreateTransactionItemsNonCatalogPriceForAnExistingProduct()` -// - `NewCreateTransactionItemsNonCatalogPriceAndProduct()` +// - `NewCreateTransactionItemsTransactionItemFromCatalog()` +// - `NewCreateTransactionItemsTransactionItemCreateWithPrice()` +// - `NewCreateTransactionItemsTransactionItemCreateWithProduct()` // // Only one of the values can be set at a time, the first non-nil value will be used in the request. // Items: Add a non-catalog price for a non-catalog product in your catalog to a transaction. In this case, the product and price that you're billing for are specific to this transaction. type CreateTransactionItems struct { - *CatalogItem - *NonCatalogPriceForAnExistingProduct - *NonCatalogPriceAndProduct + *TransactionItemFromCatalog + *TransactionItemCreateWithPrice + *TransactionItemCreateWithProduct } // MarshalJSON implements the json.Marshaler interface. func (u CreateTransactionItems) MarshalJSON() ([]byte, error) { - if u.CatalogItem != nil { - return json.Marshal(u.CatalogItem) + if u.TransactionItemFromCatalog != nil { + return json.Marshal(u.TransactionItemFromCatalog) } - if u.NonCatalogPriceForAnExistingProduct != nil { - return json.Marshal(u.NonCatalogPriceForAnExistingProduct) + if u.TransactionItemCreateWithPrice != nil { + return json.Marshal(u.TransactionItemCreateWithPrice) } - if u.NonCatalogPriceAndProduct != nil { - return json.Marshal(u.NonCatalogPriceAndProduct) + if u.TransactionItemCreateWithProduct != nil { + return json.Marshal(u.TransactionItemCreateWithProduct) } return nil, nil @@ -1063,54 +1043,54 @@ func (c *TransactionsClient) GetTransaction(ctx context.Context, req *GetTransac return res, nil } -// NewUpdateTransactionItemsCatalogItem takes a CatalogItem type +// NewUpdateTransactionItemsTransactionItemFromCatalog takes a TransactionItemFromCatalog type // and creates a UpdateTransactionItems for use in a request. -func NewUpdateTransactionItemsCatalogItem(r *CatalogItem) *UpdateTransactionItems { - return &UpdateTransactionItems{CatalogItem: r} +func NewUpdateTransactionItemsTransactionItemFromCatalog(r *TransactionItemFromCatalog) *UpdateTransactionItems { + return &UpdateTransactionItems{TransactionItemFromCatalog: r} } -// NewUpdateTransactionItemsNonCatalogPriceForAnExistingProduct takes a NonCatalogPriceForAnExistingProduct type +// NewUpdateTransactionItemsTransactionItemCreateWithPrice takes a TransactionItemCreateWithPrice type // and creates a UpdateTransactionItems for use in a request. -func NewUpdateTransactionItemsNonCatalogPriceForAnExistingProduct(r *NonCatalogPriceForAnExistingProduct) *UpdateTransactionItems { - return &UpdateTransactionItems{NonCatalogPriceForAnExistingProduct: r} +func NewUpdateTransactionItemsTransactionItemCreateWithPrice(r *TransactionItemCreateWithPrice) *UpdateTransactionItems { + return &UpdateTransactionItems{TransactionItemCreateWithPrice: r} } -// NewUpdateTransactionItemsNonCatalogPriceAndProduct takes a NonCatalogPriceAndProduct type +// NewUpdateTransactionItemsTransactionItemCreateWithProduct takes a TransactionItemCreateWithProduct type // and creates a UpdateTransactionItems for use in a request. -func NewUpdateTransactionItemsNonCatalogPriceAndProduct(r *NonCatalogPriceAndProduct) *UpdateTransactionItems { - return &UpdateTransactionItems{NonCatalogPriceAndProduct: r} +func NewUpdateTransactionItemsTransactionItemCreateWithProduct(r *TransactionItemCreateWithProduct) *UpdateTransactionItems { + return &UpdateTransactionItems{TransactionItemCreateWithProduct: r} } // UpdateTransactionItems represents a union request type of the following types: -// - `CatalogItem` -// - `NonCatalogPriceForAnExistingProduct` -// - `NonCatalogPriceAndProduct` +// - `TransactionItemFromCatalog` +// - `TransactionItemCreateWithPrice` +// - `TransactionItemCreateWithProduct` // // The following constructor functions can be used to create a new instance of this type. -// - `NewUpdateTransactionItemsCatalogItem()` -// - `NewUpdateTransactionItemsNonCatalogPriceForAnExistingProduct()` -// - `NewUpdateTransactionItemsNonCatalogPriceAndProduct()` +// - `NewUpdateTransactionItemsTransactionItemFromCatalog()` +// - `NewUpdateTransactionItemsTransactionItemCreateWithPrice()` +// - `NewUpdateTransactionItemsTransactionItemCreateWithProduct()` // // Only one of the values can be set at a time, the first non-nil value will be used in the request. // Items: Add a non-catalog price for a non-catalog product in your catalog to a transaction. In this case, the product and price that you're billing for are specific to this transaction. type UpdateTransactionItems struct { - *CatalogItem - *NonCatalogPriceForAnExistingProduct - *NonCatalogPriceAndProduct + *TransactionItemFromCatalog + *TransactionItemCreateWithPrice + *TransactionItemCreateWithProduct } // MarshalJSON implements the json.Marshaler interface. func (u UpdateTransactionItems) MarshalJSON() ([]byte, error) { - if u.CatalogItem != nil { - return json.Marshal(u.CatalogItem) + if u.TransactionItemFromCatalog != nil { + return json.Marshal(u.TransactionItemFromCatalog) } - if u.NonCatalogPriceForAnExistingProduct != nil { - return json.Marshal(u.NonCatalogPriceForAnExistingProduct) + if u.TransactionItemCreateWithPrice != nil { + return json.Marshal(u.TransactionItemCreateWithPrice) } - if u.NonCatalogPriceAndProduct != nil { - return json.Marshal(u.NonCatalogPriceAndProduct) + if u.TransactionItemCreateWithProduct != nil { + return json.Marshal(u.TransactionItemCreateWithProduct) } return nil, nil @@ -1192,6 +1172,14 @@ func (c *TransactionsClient) UpdateTransaction(ctx context.Context, req *UpdateT type GetTransactionInvoiceRequest struct { // URL path parameters. TransactionID string `in:"path=transaction_id" json:"-"` + + // Disposition is a query parameter. + /* + Determine whether the generated URL should download the PDF as an attachment saved locally, or open it inline in the browser. + + Default: `attachment`. + */ + Disposition *string `in:"query=disposition;omitempty" json:"-"` } // GetTransactionInvoice performs the GET operation on a Transactions resource.