diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ef5fc1..f46f466 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx ### Breaking changes - Shared types `TransactionSubscriptionPriceCreateWithProduct` and `TransactionSubscriptionPriceCreateWithProductID` have diverged into 2 new types for Transactions and Subscriptions +- Include entity types are unified with their non-include variant, e.g. `ProductWithIncludes` and `Product` are now just `Product` ### Added diff --git a/UPGRADING.md b/UPGRADING.md index f0d2e84..959eb97 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -4,7 +4,7 @@ All breaking changes prior to v1 will be documented in this file to assist with ## v0.4.0 -This version includes a breaking change to shared types between Transactions and Subscriptions resources which have now been split into their own respective types. +1. This version includes a breaking change to shared types between Transactions and Subscriptions resources which have now been split into their own respective types. To upgrade to `0.4.0` from any earlier version you will need to refactor your use of these types as noted below depending on the resource: @@ -13,4 +13,14 @@ To upgrade to `0.4.0` from any earlier version you will need to refactor your us | `TransactionSubscriptionPriceCreateWithProduct` | `TransactionPriceCreateWithProduct` | `SubscriptionChargeCreateWithProduct` | | `TransactionSubscriptionPriceCreateWithProductID` | `TransactionPriceCreateWithProductID` | `SubscriptionChargeCreateWithPrice` | +2. We have unified types that have includes with their non-include variant, e.g. `ProductWithIncludes` and `Product` are now just `Product` +To upgrade to `0.4.0` any references to the types below need to be refactored accordingly + +| Previous Type | New Type | +|------------------------|---------------------| +| `ProductWithIncludes` | `Product` | +| `CustomerIncludes` | `Customer` | +| `TransactionIncludes` | `Transaction` | +| `SubscriptionIncludes` | `Subscription` | +| `PriceIncludes` | `Price` | diff --git a/customers.go b/customers.go index 27f558c..48c9c55 100644 --- a/customers.go +++ b/customers.go @@ -29,8 +29,8 @@ var ErrCustomerEmailInvalid = &paddleerr.Error{ Type: paddleerr.ErrorTypeRequestError, } -// CustomerIncludes: Represents a customer entity with included entities. -type CustomerIncludes struct { +// Customer: Represents a customer entity with included entities. +type Customer struct { // ID: Unique Paddle ID for this customer entity, prefixed with `ctm_`. ID string `json:"id,omitempty"` // Name: Full name of this customer. Required when creating transactions where `collection_mode` is `manual` (invoices). @@ -131,7 +131,7 @@ type GetCustomerRequest struct { } // GetCustomer performs the GET operation on a Customers resource. -func (c *CustomersClient) GetCustomer(ctx context.Context, req *GetCustomerRequest) (res *CustomerIncludes, err error) { +func (c *CustomersClient) GetCustomer(ctx context.Context, req *GetCustomerRequest) (res *Customer, err error) { if err := c.doer.Do(ctx, "GET", "/customers/{customer_id}", req, &res); err != nil { return nil, err } diff --git a/example_list_test.go b/example_list_test.go index 1c4e55c..c27e7e1 100644 --- a/example_list_test.go +++ b/example_list_test.go @@ -34,7 +34,7 @@ func Example_list() { res, err := client.ListTransactions(ctx, &paddle.ListTransactionsRequest{}) // Iterate the transactions. - err = res.Iter(ctx, func(v *paddle.TransactionIncludes) (bool, error) { + err = res.Iter(ctx, func(v *paddle.Transaction) (bool, error) { fmt.Println(v.ID) return true, nil }) @@ -76,7 +76,7 @@ func Example_pagination() { res, err := client.ListTransactions(ctx, &paddle.ListTransactionsRequest{}) // Iterate the transactions which will internally paginate to the next page. - err = res.Iter(ctx, func(v *paddle.TransactionIncludes) (bool, error) { + err = res.Iter(ctx, func(v *paddle.Transaction) (bool, error) { fmt.Println(v.ID) return true, nil }) diff --git a/pkg/paddlenotification/address.go b/pkg/paddlenotification/addresses.go similarity index 91% rename from pkg/paddlenotification/address.go rename to pkg/paddlenotification/addresses.go index 238ecd8..ba1ebbc 100644 --- a/pkg/paddlenotification/address.go +++ b/pkg/paddlenotification/addresses.go @@ -2,21 +2,21 @@ package paddlenotification -// AddressCreated represents a address webhook notification entity. +// AddressCreated represents the address.created event. // See https://developer.paddle.com/webhooks/overview for more information. type AddressCreated struct { GenericNotificationsEvent Data AddressNotification `json:"data"` } -// AddressImported represents a address webhook notification entity. +// AddressImported represents the address.imported event. // See https://developer.paddle.com/webhooks/overview for more information. type AddressImported struct { GenericNotificationsEvent Data AddressNotification `json:"data"` } -// AddressUpdated represents a address webhook notification entity. +// AddressUpdated represents the address.updated event. // See https://developer.paddle.com/webhooks/overview for more information. type AddressUpdated struct { GenericNotificationsEvent diff --git a/pkg/paddlenotification/adjustment.go b/pkg/paddlenotification/adjustment.go deleted file mode 100644 index f9c770f..0000000 --- a/pkg/paddlenotification/adjustment.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by the Paddle SDK Generator; DO NOT EDIT. - -package paddlenotification - -// AdjustmentCreated represents a adjustment webhook notification entity. -// See https://developer.paddle.com/webhooks/overview for more information. -type AdjustmentCreated struct { - GenericNotificationsEvent - Data AdjustmentNotification `json:"data"` -} - -// AdjustmentUpdated represents a adjustment webhook notification entity. -// See https://developer.paddle.com/webhooks/overview for more information. -type AdjustmentUpdated struct { - GenericNotificationsEvent - Data AdjustmentNotification `json:"data"` -} - -// AdjustmentNotification: New or changed entity. -type AdjustmentNotification struct { - // ID: Unique Paddle ID for this adjustment entity, prefixed with `adj_`. - ID string `json:"id,omitempty"` - // Action: How this adjustment impacts the related transaction. `refund` adjustments must be approved by Paddle, and are created with the status `pending_approval`. - Action string `json:"action,omitempty"` - // TransactionID: Paddle ID for the transaction related to this adjustment, prefixed with `txn_`. - TransactionID string `json:"transaction_id,omitempty"` - /* - SubscriptionID: Paddle ID for the subscription related to this adjustment, prefixed with `sub_`. - Set automatically by Paddle based on the `subscription_id` of the related transaction. - */ - SubscriptionID *string `json:"subscription_id,omitempty"` - /* - CustomerID: Paddle ID for the customer related to this adjustment, prefixed with `ctm_`. - Set automatically by Paddle based on the `customer_id` of the related transaction. - */ - 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` when the related transaction `collection_mode` is `manual` and its `status` is `billed`. The adjustment is used - to reduce the `balance` due on the transaction. - - `true` for automatically-collected transactions and `completed` manually-collected transactions. - */ - 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 string `json:"currency_code,omitempty"` - /* - Status: Status of this adjustment. Set automatically by Paddle. - - `refund` adjustments must be approved by Paddle, and are created with the status `pending_approval` - until they move to `approved` or `rejected` on review. Other kinds of adjustment do not need approval, - so are created with the status `approved`. - */ - Status string `json:"status,omitempty"` - // Items: List of items on this adjustment. - Items []AdjustmentItem `json:"items,omitempty"` - // Totals: Breakdown of the total for an adjustment. - Totals AdjustmentTotals `json:"totals,omitempty"` - // PayoutTotals: Breakdown of how this adjustment affects your payout balance. - PayoutTotals *PayoutTotalsAdjustment `json:"payout_totals,omitempty"` - // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. - CreatedAt string `json:"created_at,omitempty"` - // UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle. - UpdatedAt string `json:"updated_at,omitempty"` -} diff --git a/pkg/paddlenotification/adjustments.go b/pkg/paddlenotification/adjustments.go new file mode 100644 index 0000000..8e59bcc --- /dev/null +++ b/pkg/paddlenotification/adjustments.go @@ -0,0 +1,180 @@ +// Code generated by the Paddle SDK Generator; DO NOT EDIT. + +package paddlenotification + +// AdjustmentCreated represents the adjustment.created event. +// See https://developer.paddle.com/webhooks/overview for more information. +type AdjustmentCreated struct { + GenericNotificationsEvent + Data AdjustmentNotification `json:"data"` +} + +// AdjustmentUpdated represents the adjustment.updated event. +// See https://developer.paddle.com/webhooks/overview for more information. +type AdjustmentUpdated struct { + GenericNotificationsEvent + Data AdjustmentNotification `json:"data"` +} + +// Action: How this adjustment impacts the related transaction. `refund` adjustments must be approved by Paddle, and are created with the status `pending_approval`.. +type Action string + +const ( + ActionCredit = "credit" + ActionRefund = "refund" + ActionChargeback = "chargeback" + ActionChargebackReverse = "chargeback_reverse" + ActionChargebackWarning = "chargeback_warning" + ActionCreditReverse = "credit_reverse" +) + +/* +AdjustmentStatus: Status of this adjustment. Set automatically by Paddle. + +`refund` adjustments must be approved by Paddle, and are created with the status `pending_approval` +until they move to `approved` or `rejected` on review. Other kinds of adjustment do not need approval, +so are created with the status `approved`.. +*/ +type AdjustmentStatus string + +const ( + AdjustmentStatusPendingApproval = "pending_approval" + AdjustmentStatusApproved = "approved" + AdjustmentStatusRejected = "rejected" + AdjustmentStatusReversed = "reversed" +) + +/* +AdjustmentType: Type of adjustment for this transaction item. `tax` and `proration` are automatically created by Paddle. +Include `amount` when creating a `partial` adjustment.. +*/ +type AdjustmentType string + +const ( + AdjustmentTypeFull = "full" + AdjustmentTypePartial = "partial" + AdjustmentTypeTax = "tax" + AdjustmentTypeProration = "proration" +) + +// AdjustmentItemTotals: Breakdown of the total for an adjustment item. +type AdjustmentItemTotals struct { + // Subtotal: Amount multiplied by quantity. + Subtotal string `json:"subtotal,omitempty"` + // Tax: Total tax on the subtotal. + Tax string `json:"tax,omitempty"` + // Total: Total after tax. + Total string `json:"total,omitempty"` +} + +// AdjustmentItem: List of items on this adjustment. +type AdjustmentItem struct { + // ID: Unique Paddle ID for this adjustment item, prefixed with `adjitm_`. + ID string `json:"id,omitempty"` + // ItemID: Paddle ID for the transaction item that this adjustment item relates to, prefixed with `txnitm_`. + ItemID string `json:"item_id,omitempty"` + /* + Type: Type of adjustment for this transaction item. `tax` and `proration` are automatically created by Paddle. + Include `amount` when creating a `partial` adjustment. + */ + Type string `json:"type,omitempty"` + // Amount: Amount adjusted for this transaction item. Required when adjustment type is `partial`. + Amount *string `json:"amount,omitempty"` + /* + Proration: How proration was calculated for this adjustment item. Populated when an adjustment type is `proration`. + Set automatically by Paddle. + */ + Proration *Proration `json:"proration,omitempty"` + // Totals: Breakdown of the total for an adjustment item. + Totals AdjustmentItemTotals `json:"totals,omitempty"` +} + +// AdjustmentTotals: Breakdown of the total for an adjustment. +type AdjustmentTotals struct { + // Subtotal: Total before tax. For tax adjustments, the value is 0. + Subtotal string `json:"subtotal,omitempty"` + // Tax: Total tax on the subtotal. + Tax string `json:"tax,omitempty"` + // Total: Total after tax. + Total string `json:"total,omitempty"` + // Fee: Total fee taken by Paddle for this adjustment. + Fee string `json:"fee,omitempty"` + /* + Earnings: Total earnings. This is the subtotal minus the Paddle fee. + For tax adjustments, this value is negative, which means a positive effect in the transaction earnings. + This is because the fee is originally calculated from the transaction total, so if a tax adjustment is made, + then the fee portion of it is returned. + */ + Earnings string `json:"earnings,omitempty"` + // CurrencyCode: Three-letter ISO 4217 currency code used for this adjustment. + CurrencyCode string `json:"currency_code,omitempty"` +} + +// PayoutTotalsAdjustment: Breakdown of how this adjustment affects your payout balance. +type PayoutTotalsAdjustment struct { + // Subtotal: Adjustment total before tax and fees. + Subtotal string `json:"subtotal,omitempty"` + // Tax: Total tax on the adjustment subtotal. + Tax string `json:"tax,omitempty"` + // Total: Adjustment total after tax. + Total string `json:"total,omitempty"` + // Fee: Adjusted Paddle fee. + Fee string `json:"fee,omitempty"` + // ChargebackFee: Chargeback fees incurred for this adjustment. Only returned when the adjustment `action` is `chargeback` or `chargeback_warning`. + ChargebackFee ChargebackFee `json:"chargeback_fee,omitempty"` + // Earnings: Adjusted payout earnings. This is the adjustment total plus adjusted Paddle fees, excluding chargeback fees. + Earnings string `json:"earnings,omitempty"` + // CurrencyCode: Three-letter ISO 4217 currency code used for the payout for this transaction. If your primary currency has changed, this reflects the primary currency at the time the transaction was billed. + CurrencyCode string `json:"currency_code,omitempty"` +} + +// AdjustmentNotification: New or changed entity. +type AdjustmentNotification struct { + // ID: Unique Paddle ID for this adjustment entity, prefixed with `adj_`. + ID string `json:"id,omitempty"` + // Action: How this adjustment impacts the related transaction. `refund` adjustments must be approved by Paddle, and are created with the status `pending_approval`. + Action string `json:"action,omitempty"` + // TransactionID: Paddle ID for the transaction related to this adjustment, prefixed with `txn_`. + TransactionID string `json:"transaction_id,omitempty"` + /* + SubscriptionID: Paddle ID for the subscription related to this adjustment, prefixed with `sub_`. + Set automatically by Paddle based on the `subscription_id` of the related transaction. + */ + SubscriptionID *string `json:"subscription_id,omitempty"` + /* + CustomerID: Paddle ID for the customer related to this adjustment, prefixed with `ctm_`. + Set automatically by Paddle based on the `customer_id` of the related transaction. + */ + 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` when the related transaction `collection_mode` is `manual` and its `status` is `billed`. The adjustment is used + to reduce the `balance` due on the transaction. + + `true` for automatically-collected transactions and `completed` manually-collected transactions. + */ + 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 string `json:"currency_code,omitempty"` + /* + Status: Status of this adjustment. Set automatically by Paddle. + + `refund` adjustments must be approved by Paddle, and are created with the status `pending_approval` + until they move to `approved` or `rejected` on review. Other kinds of adjustment do not need approval, + so are created with the status `approved`. + */ + Status string `json:"status,omitempty"` + // Items: List of items on this adjustment. + Items []AdjustmentItem `json:"items,omitempty"` + // Totals: Breakdown of the total for an adjustment. + Totals AdjustmentTotals `json:"totals,omitempty"` + // PayoutTotals: Breakdown of how this adjustment affects your payout balance. + PayoutTotals *PayoutTotalsAdjustment `json:"payout_totals,omitempty"` + // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. + CreatedAt string `json:"created_at,omitempty"` + // UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle. + UpdatedAt string `json:"updated_at,omitempty"` +} diff --git a/pkg/paddlenotification/business.go b/pkg/paddlenotification/businesses.go similarity index 81% rename from pkg/paddlenotification/business.go rename to pkg/paddlenotification/businesses.go index ce1e33c..67b5b35 100644 --- a/pkg/paddlenotification/business.go +++ b/pkg/paddlenotification/businesses.go @@ -2,27 +2,35 @@ package paddlenotification -// BusinessCreated represents a business webhook notification entity. +// BusinessCreated represents the business.created event. // See https://developer.paddle.com/webhooks/overview for more information. type BusinessCreated struct { GenericNotificationsEvent Data BusinessNotification `json:"data"` } -// BusinessImported represents a business webhook notification entity. +// BusinessImported represents the business.imported event. // See https://developer.paddle.com/webhooks/overview for more information. type BusinessImported struct { GenericNotificationsEvent Data BusinessNotification `json:"data"` } -// BusinessUpdated represents a business webhook notification entity. +// BusinessUpdated represents the business.updated event. // See https://developer.paddle.com/webhooks/overview for more information. type BusinessUpdated struct { GenericNotificationsEvent Data BusinessNotification `json:"data"` } +// Contacts: List of contacts related to this business, typically used for sending invoices. +type Contacts struct { + // Name: Full name of this contact. + Name string `json:"name,omitempty"` + // Email: Email address for this contact. + Email string `json:"email,omitempty"` +} + // BusinessNotification: New or changed entity. type BusinessNotification struct { // ID: Unique Paddle ID for this business entity, prefixed with `biz_`. diff --git a/pkg/paddlenotification/customer.go b/pkg/paddlenotification/customers.go similarity index 90% rename from pkg/paddlenotification/customer.go rename to pkg/paddlenotification/customers.go index b7ba2c9..0b61555 100644 --- a/pkg/paddlenotification/customer.go +++ b/pkg/paddlenotification/customers.go @@ -2,21 +2,21 @@ package paddlenotification -// CustomerCreated represents a customer webhook notification entity. +// CustomerCreated represents the customer.created event. // See https://developer.paddle.com/webhooks/overview for more information. type CustomerCreated struct { GenericNotificationsEvent Data CustomerNotification `json:"data"` } -// CustomerImported represents a customer webhook notification entity. +// CustomerImported represents the customer.imported event. // See https://developer.paddle.com/webhooks/overview for more information. type CustomerImported struct { GenericNotificationsEvent Data CustomerNotification `json:"data"` } -// CustomerUpdated represents a customer webhook notification entity. +// CustomerUpdated represents the customer.updated event. // See https://developer.paddle.com/webhooks/overview for more information. type CustomerUpdated struct { GenericNotificationsEvent diff --git a/pkg/paddlenotification/discount.go b/pkg/paddlenotification/discounts.go similarity index 85% rename from pkg/paddlenotification/discount.go rename to pkg/paddlenotification/discounts.go index b2c4a5e..2ba53bf 100644 --- a/pkg/paddlenotification/discount.go +++ b/pkg/paddlenotification/discounts.go @@ -2,27 +2,46 @@ package paddlenotification -// DiscountCreated represents a discount webhook notification entity. +// DiscountCreated represents the discount.created event. // See https://developer.paddle.com/webhooks/overview for more information. type DiscountCreated struct { GenericNotificationsEvent Data DiscountNotification `json:"data"` } -// DiscountImported represents a discount webhook notification entity. +// DiscountImported represents the discount.imported event. // See https://developer.paddle.com/webhooks/overview for more information. type DiscountImported struct { GenericNotificationsEvent Data DiscountNotification `json:"data"` } -// DiscountUpdated represents a discount webhook notification entity. +// DiscountUpdated represents the discount.updated event. // See https://developer.paddle.com/webhooks/overview for more information. type DiscountUpdated struct { GenericNotificationsEvent Data DiscountNotification `json:"data"` } +// DiscountStatus: Whether this entity can be used in Paddle. `expired` and `used` are set automatically by Paddle.. +type DiscountStatus string + +const ( + DiscountStatusActive = "active" + DiscountStatusArchived = "archived" + DiscountStatusExpired = "expired" + DiscountStatusUsed = "used" +) + +// Type: Type of discount.. +type Type string + +const ( + TypeFlat = "flat" + TypeFlatPerSeat = "flat_per_seat" + TypePercentage = "percentage" +) + // DiscountNotification: New or changed entity. type DiscountNotification struct { // ID: Unique Paddle ID for this discount, prefixed with `dsc_`. diff --git a/pkg/paddlenotification/payout.go b/pkg/paddlenotification/payouts.go similarity index 87% rename from pkg/paddlenotification/payout.go rename to pkg/paddlenotification/payouts.go index a5ba556..770341b 100644 --- a/pkg/paddlenotification/payout.go +++ b/pkg/paddlenotification/payouts.go @@ -2,14 +2,14 @@ package paddlenotification -// PayoutCreated represents a payout webhook notification entity. +// PayoutCreated represents the payout.created event. // See https://developer.paddle.com/webhooks/overview for more information. type PayoutCreated struct { GenericNotificationsEvent Data PayoutNotification `json:"data"` } -// PayoutPaid represents a payout webhook notification entity. +// PayoutPaid represents the payout.paid event. // See https://developer.paddle.com/webhooks/overview for more information. type PayoutPaid struct { GenericNotificationsEvent diff --git a/pkg/paddlenotification/price.go b/pkg/paddlenotification/prices.go similarity index 94% rename from pkg/paddlenotification/price.go rename to pkg/paddlenotification/prices.go index e3d156d..621f880 100644 --- a/pkg/paddlenotification/price.go +++ b/pkg/paddlenotification/prices.go @@ -2,21 +2,21 @@ package paddlenotification -// PriceCreated represents a price webhook notification entity. +// PriceCreated represents the price.created event. // See https://developer.paddle.com/webhooks/overview for more information. type PriceCreated struct { GenericNotificationsEvent Data PriceNotification `json:"data"` } -// PriceImported represents a price webhook notification entity. +// PriceImported represents the price.imported event. // See https://developer.paddle.com/webhooks/overview for more information. type PriceImported struct { GenericNotificationsEvent Data PriceNotification `json:"data"` } -// PriceUpdated represents a price webhook notification entity. +// PriceUpdated represents the price.updated event. // See https://developer.paddle.com/webhooks/overview for more information. type PriceUpdated struct { GenericNotificationsEvent diff --git a/pkg/paddlenotification/product.go b/pkg/paddlenotification/products.go similarity index 91% rename from pkg/paddlenotification/product.go rename to pkg/paddlenotification/products.go index 44538a6..24a35ee 100644 --- a/pkg/paddlenotification/product.go +++ b/pkg/paddlenotification/products.go @@ -2,21 +2,21 @@ package paddlenotification -// ProductCreated represents a product webhook notification entity. +// ProductCreated represents the product.created event. // See https://developer.paddle.com/webhooks/overview for more information. type ProductCreated struct { GenericNotificationsEvent Data ProductNotification `json:"data"` } -// ProductImported represents a product webhook notification entity. +// ProductImported represents the product.imported event. // See https://developer.paddle.com/webhooks/overview for more information. type ProductImported struct { GenericNotificationsEvent Data ProductNotification `json:"data"` } -// ProductUpdated represents a product webhook notification entity. +// ProductUpdated represents the product.updated event. // See https://developer.paddle.com/webhooks/overview for more information. type ProductUpdated struct { GenericNotificationsEvent diff --git a/pkg/paddlenotification/report.go b/pkg/paddlenotification/report.go deleted file mode 100644 index 6983d9f..0000000 --- a/pkg/paddlenotification/report.go +++ /dev/null @@ -1,41 +0,0 @@ -// Code generated by the Paddle SDK Generator; DO NOT EDIT. - -package paddlenotification - -// ReportCreated represents a report webhook notification entity. -// See https://developer.paddle.com/webhooks/overview for more information. -type ReportCreated struct { - GenericNotificationsEvent - Data ReportNotification `json:"data"` -} - -// ReportUpdated represents a report webhook notification entity. -// See https://developer.paddle.com/webhooks/overview for more information. -type ReportUpdated struct { - GenericNotificationsEvent - Data ReportNotification `json:"data"` -} - -// ReportNotification: New or changed entity. -type ReportNotification struct { - // ID: Unique Paddle ID for this report, prefixed with `rep_` - ID string `json:"id,omitempty"` - /* - Status: Status of this report. Set automatically by Paddle. - - Reports are created as `pending` initially, then move to `ready` when they're available to download. - */ - Status string `json:"status,omitempty"` - // Rows: Number of records in this report. `null` if the report is `pending`. - Rows *int `json:"rows,omitempty"` - // Type: Type of report. - Type string `json:"type,omitempty"` - // Filters: List of filters applied to this report. - Filters []ReportFilters `json:"filters,omitempty"` - // ExpiresAt: RFC 3339 datetime string of when this report expires. The report is no longer available to download after this date. - ExpiresAt *string `json:"expires_at,omitempty"` - // UpdatedAt: RFC 3339 datetime string of when this report was last updated. - UpdatedAt string `json:"updated_at,omitempty"` - // CreatedAt: RFC 3339 datetime string of when this report was created. - CreatedAt string `json:"created_at,omitempty"` -} diff --git a/pkg/paddlenotification/reports.go b/pkg/paddlenotification/reports.go new file mode 100644 index 0000000..ac6ecbb --- /dev/null +++ b/pkg/paddlenotification/reports.go @@ -0,0 +1,104 @@ +// Code generated by the Paddle SDK Generator; DO NOT EDIT. + +package paddlenotification + +// ReportCreated represents the report.created event. +// See https://developer.paddle.com/webhooks/overview for more information. +type ReportCreated struct { + GenericNotificationsEvent + Data ReportNotification `json:"data"` +} + +// ReportUpdated represents the report.updated event. +// See https://developer.paddle.com/webhooks/overview for more information. +type ReportUpdated struct { + GenericNotificationsEvent + Data ReportNotification `json:"data"` +} + +/* +ReportStatus: Status of this report. Set automatically by Paddle. + +Reports are created as `pending` initially, then move to `ready` when they're available to download.. +*/ +type ReportStatus string + +const ( + ReportStatusPending = "pending" + ReportStatusReady = "ready" + ReportStatusFailed = "failed" + ReportStatusExpired = "expired" +) + +// ReportTypeTransactions: Type of report.. +type ReportTypeTransactions string + +const ( + ReportTypeTransactionsAdjustments = "adjustments" + ReportTypeTransactionsAdjustmentLineItems = "adjustment_line_items" + ReportTypeTransactionsTransactions = "transactions" + ReportTypeTransactionsTransactionLineItems = "transaction_line_items" + ReportTypeTransactionsProductsPrices = "products_prices" + ReportTypeTransactionsDiscounts = "discounts" +) + +// Name: Field name to filter by.. +type ReportsName string + +const ( + ReportsNameAction = "action" + ReportsNameCurrencyCode = "currency_code" + ReportsNameStatus = "status" + ReportsNameUpdatedAt = "updated_at" + ReportsNameCollectionMode = "collection_mode" + ReportsNameOrigin = "origin" + ReportsNameProductStatus = "product_status" + ReportsNamePriceStatus = "price_status" + ReportsNameProductType = "product_type" + ReportsNamePriceType = "price_type" + ReportsNameProductUpdatedAt = "product_updated_at" + ReportsNamePriceUpdatedAt = "price_updated_at" + ReportsNameType = "type" +) + +// Operator: Operator to use when filtering. Valid when filtering by `updated_at`, `null` otherwise.. +type ReportsOperator *string + +const ( + ReportsOperatorLt = "lt" + ReportsOperatorGte = "gte" +) + +// ReportFilters: List of filters applied to this report. +type ReportFilters struct { + // Name: Field name to filter by. + Name string `json:"name,omitempty"` + // Operator: Operator to use when filtering. Valid when filtering by `updated_at`, `null` otherwise. + Operator *string `json:"operator,omitempty"` + // Value: Value to filter by. Check the allowed values descriptions for the `name` field to see valid values for a field. + Value string `json:"value,omitempty"` +} + +// ReportNotification: New or changed entity. +type ReportNotification struct { + // ID: Unique Paddle ID for this report, prefixed with `rep_` + ID string `json:"id,omitempty"` + /* + Status: Status of this report. Set automatically by Paddle. + + Reports are created as `pending` initially, then move to `ready` when they're available to download. + */ + Status string `json:"status,omitempty"` + // Rows: Number of records in this report. `null` if the report is `pending`. + Rows *int `json:"rows,omitempty"` + // Type: Type of report. + Type string `json:"type,omitempty"` + // Filters: List of filters applied to this report. + Filters []ReportFilters `json:"filters,omitempty"` + // ExpiresAt: RFC 3339 datetime string of when this report expires. The report is no longer available to download after this date. + ExpiresAt *string `json:"expires_at,omitempty"` + // UpdatedAt: RFC 3339 datetime string of when this report was last updated. + UpdatedAt string `json:"updated_at,omitempty"` + // CreatedAt: RFC 3339 datetime string of when this report was created. + CreatedAt string `json:"created_at,omitempty"` +} diff --git a/pkg/paddlenotification/shared.go b/pkg/paddlenotification/shared.go index a816bbb..4eb04f7 100644 --- a/pkg/paddlenotification/shared.go +++ b/pkg/paddlenotification/shared.go @@ -2,117 +2,7 @@ package paddlenotification -// CatalogType: Return items that match the specified type.. -type CatalogType string - -const ( - CatalogTypeCustom = "custom" - CatalogTypeStandard = "standard" -) - -// TaxCategory: Tax category for this product. Used for charging the correct rate of tax. Selected tax category must be enabled on your Paddle account.. -type TaxCategory string - -const ( - TaxCategoryDigitalGoods = "digital-goods" - TaxCategoryEbooks = "ebooks" - TaxCategoryImplementationServices = "implementation-services" - TaxCategoryProfessionalServices = "professional-services" - TaxCategorySaas = "saas" - TaxCategorySoftwareProgrammingServices = "software-programming-services" - TaxCategoryStandard = "standard" - TaxCategoryTrainingServices = "training-services" - TaxCategoryWebsiteHosting = "website-hosting" -) - -// Status: Whether this entity can be used in Paddle.. -type Status string - -const ( - StatusActive = "active" - StatusArchived = "archived" -) - -// ImportMeta: Import information for this entity. `null` if this entity is not imported. -type ImportMeta struct { - // ExternalID: Reference or identifier for this entity from the solution where it was imported from. - ExternalID *string `json:"external_id,omitempty"` - // ImportedFrom: Name of the platform where this entity was imported from. - ImportedFrom string `json:"imported_from,omitempty"` -} - -// Interval: Unit of time.. -type Interval string - -const ( - IntervalDay = "day" - IntervalWeek = "week" - IntervalMonth = "month" - IntervalYear = "year" -) - -// Duration: How often this price should be charged. `null` if price is non-recurring (one-time). -type Duration struct { - // Interval: Unit of time. - Interval string `json:"interval,omitempty"` - // Frequency: Amount of time. - Frequency int `json:"frequency,omitempty"` -} - -// TaxMode: How tax is calculated for this price.. -type TaxMode string - -const ( - TaxModeAccountSetting = "account_setting" - TaxModeExternal = "external" - TaxModeInternal = "internal" -) - -// CurrencyCode: Supported three-letter ISO 4217 currency code.. -type CurrencyCode string - -const ( - CurrencyCodeUSD = "USD" - CurrencyCodeEUR = "EUR" - CurrencyCodeGBP = "GBP" - CurrencyCodeJPY = "JPY" - CurrencyCodeAUD = "AUD" - CurrencyCodeCAD = "CAD" - CurrencyCodeCHF = "CHF" - CurrencyCodeHKD = "HKD" - CurrencyCodeSGD = "SGD" - CurrencyCodeSEK = "SEK" - CurrencyCodeARS = "ARS" - CurrencyCodeBRL = "BRL" - CurrencyCodeCNY = "CNY" - CurrencyCodeCOP = "COP" - CurrencyCodeCZK = "CZK" - CurrencyCodeDKK = "DKK" - CurrencyCodeHUF = "HUF" - CurrencyCodeILS = "ILS" - CurrencyCodeINR = "INR" - CurrencyCodeKRW = "KRW" - CurrencyCodeMXN = "MXN" - CurrencyCodeNOK = "NOK" - CurrencyCodeNZD = "NZD" - CurrencyCodePLN = "PLN" - CurrencyCodeRUB = "RUB" - CurrencyCodeTHB = "THB" - CurrencyCodeTRY = "TRY" - CurrencyCodeTWD = "TWD" - CurrencyCodeUAH = "UAH" - CurrencyCodeZAR = "ZAR" -) - -// Money: Base price. This price applies to all customers, except for customers located in countries where you have `unit_price_overrides`. -type Money struct { - // Amount: Amount in the lowest denomination for the currency, e.g. 10 USD = 1000 (cents). - Amount string `json:"amount,omitempty"` - // CurrencyCode: Supported three-letter ISO 4217 currency code. - CurrencyCode string `json:"currency_code,omitempty"` -} - -// CountryCode: Supported two-letter ISO 3166-1 alpha-2 country code.. +// CountryCode: Supported two-letter ISO 3166-1 alpha-2 country code for this address.. type CountryCode string const ( @@ -347,156 +237,59 @@ const ( CountryCodeZM = "ZM" ) -// UnitPriceOverride: List of unit price overrides. Use to override the base price with a custom price and currency for a country or group of countries. -type UnitPriceOverride struct { - // CountryCodes: Supported two-letter ISO 3166-1 alpha-2 country code. - CountryCodes []CountryCode `json:"country_codes,omitempty"` - // UnitPrice: Override price. This price applies to customers located in the countries for this unit price override. - UnitPrice Money `json:"unit_price,omitempty"` -} - -// PriceQuantity: Limits on how many times the related product can be purchased at this price. Useful for discount campaigns. -type PriceQuantity struct { - // Minimum: Minimum quantity of the product related to this price that can be bought. Required if `maximum` set. - Minimum int `json:"minimum,omitempty"` - // Maximum: Maximum quantity of the product related to this price that can be bought. Required if `minimum` set. Must be greater than or equal to the `minimum` value. - Maximum int `json:"maximum,omitempty"` -} - -// Price: Represents a price entity. -type Price struct { - // ID: Unique Paddle ID for this price, prefixed with `pri_`. - ID string `json:"id,omitempty"` - // ProductID: Paddle ID for the product that this price is for, prefixed with `pro_`. - ProductID string `json:"product_id,omitempty"` - // 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 string `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). - 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 string `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. - Quantity PriceQuantity `json:"quantity,omitempty"` - // Status: Whether this entity can be used in Paddle. - Status string `json:"status,omitempty"` - // CustomData: Your own structured key-value data. - 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"` - // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. - CreatedAt string `json:"created_at,omitempty"` - // UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle. - UpdatedAt string `json:"updated_at,omitempty"` -} - -// Pagination: Keys used for working with paginated results. -type Pagination struct { - // PerPage: Number of entities per page for this response. May differ from the number requested if the requested number is greater than the maximum. - PerPage int `json:"per_page,omitempty"` - // Next: URL containing the query parameters of the original request, along with the `after` parameter that marks the starting point of the next page. Always returned, even if `has_more` is `false`. - Next string `json:"next,omitempty"` - // HasMore: Whether this response has another page. - HasMore bool `json:"has_more,omitempty"` - // EstimatedTotal: Estimated number of entities for this response. - EstimatedTotal int `json:"estimated_total,omitempty"` -} - -// MetaPaginated: Information about this response. -type MetaPaginated struct { - // RequestID: Unique ID for the request relating to this response. Provide this when contacting Paddle support about a specific request. - RequestID string `json:"request_id,omitempty"` - // Pagination: Keys used for working with paginated results. - Pagination Pagination `json:"pagination,omitempty"` -} - -// Product: Represents a product entity. -type Product struct { - // ID: Unique Paddle ID for this product, prefixed with `pro_`. - ID string `json:"id,omitempty"` - // Name: Name of this product. - Name string `json:"name,omitempty"` - // 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 string `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 string `json:"tax_category,omitempty"` - // ImageURL: Image for this product. Included in the checkout and on some customer documents. - ImageURL *string `json:"image_url,omitempty"` - // CustomData: Your own structured key-value data. - CustomData CustomData `json:"custom_data,omitempty"` - // Status: Whether this entity can be used in Paddle. - Status string `json:"status,omitempty"` - // ImportMeta: Import information for this entity. `null` if this entity is not imported. - ImportMeta *ImportMeta `json:"import_meta,omitempty"` - // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. - CreatedAt string `json:"created_at,omitempty"` - // UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle. - UpdatedAt string `json:"updated_at,omitempty"` -} - -// Meta: Information about this response. -type Meta struct { - // RequestID: Unique ID for the request relating to this response. Provide this when contacting Paddle support about a specific request. - RequestID string `json:"request_id,omitempty"` -} - -// CollectionMode: Return entities that match the specified collection mode.. -type CollectionMode string +// Status: Whether this entity can be used in Paddle.. +type Status string const ( - CollectionModeAutomatic = "automatic" - CollectionModeManual = "manual" + StatusActive = "active" + StatusArchived = "archived" ) -// TransactionStatus: Status of this transaction. You may set a transaction to `billed` or `canceled`, other statuses are set automatically by Paddle. Automatically-collected transactions may return `completed` if payment is captured successfully, or `past_due` if payment failed.. -type TransactionStatus string - -const ( - TransactionStatusDraft = "draft" - TransactionStatusReady = "ready" - TransactionStatusBilled = "billed" - TransactionStatusPaid = "paid" - TransactionStatusCompleted = "completed" - TransactionStatusCanceled = "canceled" - TransactionStatusPastDue = "past_due" -) +// ImportMeta: Import information for this entity. `null` if this entity is not imported. +type ImportMeta struct { + // ExternalID: Reference or identifier for this entity from the solution where it was imported from. + ExternalID *string `json:"external_id,omitempty"` + // ImportedFrom: Name of the platform where this entity was imported from. + ImportedFrom string `json:"imported_from,omitempty"` +} -// TransactionOrigin: Describes how this transaction was created.. -type TransactionOrigin string +// CurrencyCode: Three-letter ISO 4217 currency code for this adjustment. Set automatically by Paddle based on the `currency_code` of the related transaction.. +type CurrencyCode string const ( - TransactionOriginAPI = "api" - TransactionOriginSubscriptionCharge = "subscription_charge" - TransactionOriginSubscriptionPaymentMethodChange = "subscription_payment_method_change" - TransactionOriginSubscriptionRecurring = "subscription_recurring" - TransactionOriginSubscriptionUpdate = "subscription_update" - TransactionOriginWeb = "web" + CurrencyCodeUSD = "USD" + CurrencyCodeEUR = "EUR" + CurrencyCodeGBP = "GBP" + CurrencyCodeJPY = "JPY" + CurrencyCodeAUD = "AUD" + CurrencyCodeCAD = "CAD" + CurrencyCodeCHF = "CHF" + CurrencyCodeHKD = "HKD" + CurrencyCodeSGD = "SGD" + CurrencyCodeSEK = "SEK" + CurrencyCodeARS = "ARS" + CurrencyCodeBRL = "BRL" + CurrencyCodeCNY = "CNY" + CurrencyCodeCOP = "COP" + CurrencyCodeCZK = "CZK" + CurrencyCodeDKK = "DKK" + CurrencyCodeHUF = "HUF" + CurrencyCodeILS = "ILS" + CurrencyCodeINR = "INR" + CurrencyCodeKRW = "KRW" + CurrencyCodeMXN = "MXN" + CurrencyCodeNOK = "NOK" + CurrencyCodeNZD = "NZD" + CurrencyCodePLN = "PLN" + CurrencyCodeRUB = "RUB" + CurrencyCodeTHB = "THB" + CurrencyCodeTRY = "TRY" + CurrencyCodeTWD = "TWD" + CurrencyCodeUAH = "UAH" + CurrencyCodeZAR = "ZAR" ) -// BillingDetails: Details for invoicing. Required if `collection_mode` is `manual`. -type BillingDetails struct { - // EnableCheckout: Whether the related transaction may be paid using a Paddle Checkout. - EnableCheckout bool `json:"enable_checkout,omitempty"` - // PurchaseOrderNumber: Customer purchase order number. Appears on invoice documents. - PurchaseOrderNumber string `json:"purchase_order_number,omitempty"` - // AdditionalInformation: Notes or other information to include on this invoice. Appears on invoice documents. - AdditionalInformation *string `json:"additional_information,omitempty"` - // PaymentTerms: How long a customer has to pay this invoice once issued. - PaymentTerms Duration `json:"payment_terms,omitempty"` -} - -// TimePeriod: Time period that this transaction is for. Set automatically by Paddle for subscription renewals to describe the period that charges are for. +// TimePeriod: Billing period that proration is based on. type TimePeriod struct { // StartsAt: RFC 3339 datetime string of when this period starts. StartsAt string `json:"starts_at,omitempty"` @@ -504,7 +297,10 @@ type TimePeriod struct { EndsAt string `json:"ends_at,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. +/* +Proration: How proration was calculated for this adjustment item. Populated when an adjustment type is `proration`. +Set automatically by Paddle. +*/ type Proration struct { // Rate: Rate used to calculate proration. Rate string `json:"rate,omitempty"` @@ -512,91 +308,31 @@ type Proration struct { BillingPeriod TimePeriod `json:"billing_period,omitempty"` } -// TransactionItem: List of items on this transaction. For calculated totals, use `details.line_items`. -type TransactionItem struct { - // PriceID: Paddle ID for the price to add to this transaction, prefixed with `pri_`. - PriceID string `json:"price_id,omitempty"` - // Price: Represents a price entity. - Price Price `json:"price,omitempty"` - // 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. - Proration *Proration `json:"proration,omitempty"` -} - -// Totals: Calculated totals for the tax applied to this transaction. -type Totals struct { - // Subtotal: Subtotal before discount, tax, and deductions. If an item, unit price multiplied by quantity. - Subtotal string `json:"subtotal,omitempty"` - /* - Discount: Total discount as a result of any discounts applied. - - Except for percentage discounts, Paddle applies tax to discounts based on the line item `price.tax_mode`. If `price.tax_mode` for a line item is `internal`, Paddle removes tax from the discount applied. - */ - Discount string `json:"discount,omitempty"` - // Tax: Total tax on the subtotal. - Tax string `json:"tax,omitempty"` - // Total: Total after discount and tax. - Total string `json:"total,omitempty"` -} +// CurrencyCodeChargebacks: Three-letter ISO 4217 currency code for the original chargeback fee.. +type CurrencyCodeChargebacks string -// TaxRatesUsed: List of tax rates applied for this transaction. -type TaxRatesUsed struct { - // TaxRate: Rate used to calculate tax for this transaction. - TaxRate string `json:"tax_rate,omitempty"` - // Totals: Calculated totals for the tax applied to this transaction. - Totals Totals `json:"totals,omitempty"` -} +const ( + CurrencyCodeChargebacksAUD = "AUD" + CurrencyCodeChargebacksCAD = "CAD" + CurrencyCodeChargebacksEUR = "EUR" + CurrencyCodeChargebacksGBP = "GBP" + CurrencyCodeChargebacksUSD = "USD" +) -// TransactionTotals: Breakdown of the total for a transaction. These numbers can become negative when dealing with subscription updates that result in credit. -type TransactionTotals struct { - // Subtotal: Subtotal before discount, tax, and deductions. If an item, unit price multiplied by quantity. - Subtotal string `json:"subtotal,omitempty"` - /* - Discount: Total discount as a result of any discounts applied. - - Except for percentage discounts, Paddle applies tax to discounts based on the line item `price.tax_mode`. If `price.tax_mode` for a line item is `internal`, Paddle removes tax from the discount applied. - */ - Discount string `json:"discount,omitempty"` - // Tax: Total tax on the subtotal. - Tax string `json:"tax,omitempty"` - // Total: Total after discount and tax. - Total string `json:"total,omitempty"` - // Credit: Total credit applied to this transaction. This includes credits applied using a customer's credit balance and adjustments to a `billed` transaction. - Credit string `json:"credit,omitempty"` - // CreditToBalance: Additional credit generated from negative `details.line_items`. This credit is added to the customer balance. - CreditToBalance string `json:"credit_to_balance,omitempty"` - // Balance: Total due on a transaction after credits and any payments. - Balance string `json:"balance,omitempty"` - // GrandTotal: Total due on a transaction after credits but before any payments. - GrandTotal string `json:"grand_total,omitempty"` - // Fee: Total fee taken by Paddle for this transaction. `null` until the transaction is `completed` and the fee is processed. - Fee *string `json:"fee,omitempty"` - // Earnings: Total earnings for this transaction. This is the total minus the Paddle fee. `null` until the transaction is `completed` and the fee is processed. - Earnings *string `json:"earnings,omitempty"` - // CurrencyCode: Three-letter ISO 4217 currency code of the currency used for this transaction. +// Original: Chargeback fee before conversion to the payout currency. `null` when the chargeback fee is the same as the payout currency. +type Original struct { + // Amount: Fee amount for this chargeback in the original currency. + Amount string `json:"amount,omitempty"` + // CurrencyCode: Three-letter ISO 4217 currency code for the original chargeback fee. CurrencyCode string `json:"currency_code,omitempty"` } -// TransactionTotalsAdjusted: Breakdown of the payout totals for a transaction after adjustments. `null` until the transaction is `completed`. -type TransactionTotalsAdjusted struct { - // Subtotal: Subtotal before discount, tax, and deductions. If an item, unit price multiplied by quantity. - Subtotal string `json:"subtotal,omitempty"` - // Tax: Total tax on the subtotal. - Tax string `json:"tax,omitempty"` - // Total: Total after tax. - Total string `json:"total,omitempty"` - // GrandTotal: Total due after credits but before any payments. - GrandTotal string `json:"grand_total,omitempty"` - // Fee: Total fee taken by Paddle for this transaction. `null` until the transaction is `completed` and the fee is processed. - Fee *string `json:"fee,omitempty"` - /* - Earnings: Total earnings for this transaction. This is the total minus the Paddle fee. - `null` until the transaction is `completed` and the fee is processed. - */ - Earnings *string `json:"earnings,omitempty"` - // CurrencyCode: Three-letter ISO 4217 currency code of the currency used for this transaction. - CurrencyCode string `json:"currency_code,omitempty"` +// ChargebackFee: Chargeback fees incurred for this adjustment. Only returned when the adjustment `action` is `chargeback` or `chargeback_warning`. +type ChargebackFee struct { + // Amount: Chargeback fee converted into the payout currency. + Amount string `json:"amount,omitempty"` + // Original: Chargeback fee before conversion to the payout currency. `null` when the chargeback fee is the same as the payout currency. + Original *Original `json:"original,omitempty"` } // CurrencyCodePayouts: Three-letter ISO 4217 currency code used for the payout for this transaction. If your primary currency has changed, this reflects the primary currency at the time the transaction was billed.. @@ -618,592 +354,90 @@ const ( CurrencyCodePayoutsZAR = "ZAR" ) -// TransactionPayoutTotals: Breakdown of the payout total for a transaction. `null` until the transaction is `completed`. Returned in your payout currency. -type TransactionPayoutTotals struct { - // Subtotal: Total before tax and fees. - Subtotal string `json:"subtotal,omitempty"` - /* - Discount: Total discount as a result of any discounts applied. - Except for percentage discounts, Paddle applies tax to discounts based on the line item `price.tax_mode`. If `price.tax_mode` for a line item is `internal`, Paddle removes tax from the discount applied. - */ - Discount string `json:"discount,omitempty"` - // Tax: Total tax on the subtotal. - Tax string `json:"tax,omitempty"` - // Total: Total after tax. - Total string `json:"total,omitempty"` - // Credit: Total credit applied to this transaction. This includes credits applied using a customer's credit balance and adjustments to a `billed` transaction. - Credit string `json:"credit,omitempty"` - // CreditToBalance: Additional credit generated from negative `details.line_items`. This credit is added to the customer balance. - CreditToBalance string `json:"credit_to_balance,omitempty"` - // Balance: Total due on a transaction after credits and any payments. - Balance string `json:"balance,omitempty"` - // GrandTotal: Total due on a transaction after credits but before any payments. - GrandTotal string `json:"grand_total,omitempty"` - // Fee: Total fee taken by Paddle for this payout. - Fee string `json:"fee,omitempty"` - // Earnings: Total earnings for this payout. This is the subtotal minus the Paddle fee. - Earnings string `json:"earnings,omitempty"` - // CurrencyCode: Three-letter ISO 4217 currency code used for the payout for this transaction. If your primary currency has changed, this reflects the primary currency at the time the transaction was billed. - CurrencyCode string `json:"currency_code,omitempty"` -} - -// CurrencyCodeChargebacks: Three-letter ISO 4217 currency code for the original chargeback fee.. -type CurrencyCodeChargebacks string - -const ( - CurrencyCodeChargebacksAUD = "AUD" - CurrencyCodeChargebacksCAD = "CAD" - CurrencyCodeChargebacksEUR = "EUR" - CurrencyCodeChargebacksGBP = "GBP" - CurrencyCodeChargebacksUSD = "USD" -) - -// Original: Chargeback fee before conversion to the payout currency. `null` when the chargeback fee is the same as the payout currency. -type Original struct { - // Amount: Fee amount for this chargeback in the original currency. - Amount string `json:"amount,omitempty"` - // CurrencyCode: Three-letter ISO 4217 currency code for the original chargeback fee. - CurrencyCode string `json:"currency_code,omitempty"` -} - -// ChargebackFee: Details of any chargeback fees incurred for this transaction. -type ChargebackFee struct { - // Amount: Chargeback fee converted into the payout currency. - Amount string `json:"amount,omitempty"` - // Original: Chargeback fee before conversion to the payout currency. `null` when the chargeback fee is the same as the payout currency. - Original *Original `json:"original,omitempty"` -} - -// TransactionPayoutTotalsAdjusted: Breakdown of the payout total for a transaction after adjustments. `null` until the transaction is `completed`. -type TransactionPayoutTotalsAdjusted struct { - // Subtotal: Total before tax and fees. - Subtotal string `json:"subtotal,omitempty"` - // Tax: Total tax on the subtotal. - Tax string `json:"tax,omitempty"` - // Total: Total after tax. - Total string `json:"total,omitempty"` - // Fee: Total fee taken by Paddle for this payout. - Fee string `json:"fee,omitempty"` - // ChargebackFee: Details of any chargeback fees incurred for this transaction. - ChargebackFee ChargebackFee `json:"chargeback_fee,omitempty"` - // Earnings: Total earnings for this payout. This is the subtotal minus the Paddle fee, excluding chargeback fees. - Earnings string `json:"earnings,omitempty"` - // CurrencyCode: Three-letter ISO 4217 currency code used for the payout for this transaction. If your primary currency has changed, this reflects the primary currency at the time the transaction was billed. - CurrencyCode string `json:"currency_code,omitempty"` -} - -// UnitTotals: Breakdown of the charge for one unit in the lowest denomination of a currency (e.g. cents for USD). -type UnitTotals struct { - // Subtotal: Unit price. - Subtotal string `json:"subtotal,omitempty"` - /* - Discount: Total discount as a result of any discounts applied. - Except for percentage discounts, Paddle applies tax to discounts based on the line item `price.tax_mode`. If `price.tax_mode` for a line item is `internal`, Paddle removes tax from the discount applied. - */ - Discount string `json:"discount,omitempty"` - // Tax: Total tax on the subtotal. - Tax string `json:"tax,omitempty"` - // Total: Total after discount and tax. - Total string `json:"total,omitempty"` -} - -// 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 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"` - // Quantity: Quantity of this transaction line item. - 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. - Proration *Proration `json:"proration,omitempty"` - // TaxRate: Rate used to calculate tax for this transaction line item. - TaxRate string `json:"tax_rate,omitempty"` - // UnitTotals: Breakdown of the charge for one unit in the lowest denomination of a currency (e.g. cents for USD). - UnitTotals UnitTotals `json:"unit_totals,omitempty"` - // Totals: Breakdown of a charge in the lowest denomination of a currency (e.g. cents for USD). - Totals Totals `json:"totals,omitempty"` - // Product: Related product entity for this transaction line item price. - Product Product `json:"product,omitempty"` -} - -// TransactionDetails: Calculated totals for a transaction, including proration, discounts, tax, and currency conversion. Considered the source of truth for totals on a transaction. -type TransactionDetails struct { - // TaxRatesUsed: List of tax rates applied for this transaction. - TaxRatesUsed []TaxRatesUsed `json:"tax_rates_used,omitempty"` - // Totals: Breakdown of the total for a transaction. These numbers can become negative when dealing with subscription updates that result in credit. - Totals TransactionTotals `json:"totals,omitempty"` - // AdjustedTotals: Breakdown of the payout totals for a transaction after adjustments. `null` until the transaction is `completed`. - AdjustedTotals TransactionTotalsAdjusted `json:"adjusted_totals,omitempty"` - // PayoutTotals: Breakdown of the payout total for a transaction. `null` until the transaction is `completed`. Returned in your payout currency. - PayoutTotals *TransactionPayoutTotals `json:"payout_totals,omitempty"` - // AdjustedPayoutTotals: Breakdown of the payout total for a transaction after adjustments. `null` until the transaction is `completed`. - AdjustedPayoutTotals *TransactionPayoutTotalsAdjusted `json:"adjusted_payout_totals,omitempty"` - // LineItems: 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. - LineItems []TransactionLineItem `json:"line_items,omitempty"` -} - -// PaymentAttemptStatus: Status of this payment attempt.. -type PaymentAttemptStatus string - -const ( - PaymentAttemptStatusAuthorized = "authorized" - PaymentAttemptStatusAuthorizedFlagged = "authorized_flagged" - PaymentAttemptStatusCanceled = "canceled" - PaymentAttemptStatusCaptured = "captured" - PaymentAttemptStatusError = "error" - PaymentAttemptStatusActionRequired = "action_required" - PaymentAttemptStatusPendingNoActionRequired = "pending_no_action_required" - PaymentAttemptStatusCreated = "created" - PaymentAttemptStatusUnknown = "unknown" - PaymentAttemptStatusDropped = "dropped" -) - -// ErrorCode: Reason why a payment attempt failed. Returns `null` if payment captured successfully.. -type ErrorCode *string - -const ( - ErrorCodeAlreadyCanceled = "already_canceled" - ErrorCodeAlreadyRefunded = "already_refunded" - ErrorCodeAuthenticationFailed = "authentication_failed" - ErrorCodeBlockedCard = "blocked_card" - ErrorCodeCanceled = "canceled" - ErrorCodeDeclined = "declined" - ErrorCodeDeclinedNotRetryable = "declined_not_retryable" - ErrorCodeExpiredCard = "expired_card" - ErrorCodeFraud = "fraud" - ErrorCodeInvalidAmount = "invalid_amount" - ErrorCodeInvalidPaymentDetails = "invalid_payment_details" - ErrorCodeIssuerUnavailable = "issuer_unavailable" - ErrorCodeNotEnoughBalance = "not_enough_balance" - ErrorCodePspError = "psp_error" - ErrorCodeRedactedPaymentMethod = "redacted_payment_method" - ErrorCodeSystemError = "system_error" - ErrorCodeTransactionNotPermitted = "transaction_not_permitted" - ErrorCodeUnknown = "unknown" -) - -// PaymentMethodType: Type of payment method used for this payment attempt.. -type PaymentMethodType string +// CatalogType: Type of item. Standard items are considered part of your catalog and are shown on the Paddle web app.. +type CatalogType string const ( - PaymentMethodTypeAlipay = "alipay" - PaymentMethodTypeApplePay = "apple_pay" - PaymentMethodTypeBancontact = "bancontact" - PaymentMethodTypeCard = "card" - PaymentMethodTypeGooglePay = "google_pay" - PaymentMethodTypeIdeal = "ideal" - PaymentMethodTypeOffline = "offline" - PaymentMethodTypePaypal = "paypal" - PaymentMethodTypeUnknown = "unknown" - PaymentMethodTypeWireTransfer = "wire_transfer" + CatalogTypeCustom = "custom" + CatalogTypeStandard = "standard" ) -// CardType: Type of credit or debit card used to pay.. -type CardType string +// Interval: Unit of time.. +type Interval string const ( - CardTypeAmericanExpress = "american_express" - CardTypeDinersClub = "diners_club" - CardTypeDiscover = "discover" - CardTypeJcb = "jcb" - CardTypeMada = "mada" - CardTypeMaestro = "maestro" - CardTypeMastercard = "mastercard" - CardTypeUnionPay = "union_pay" - CardTypeUnknown = "unknown" - CardTypeVisa = "visa" + IntervalDay = "day" + IntervalWeek = "week" + IntervalMonth = "month" + IntervalYear = "year" ) -// Card: Information about the credit or debit card used to pay. `null` unless `type` is `card`. -type Card struct { - // Type: Type of credit or debit card used to pay. - Type string `json:"type,omitempty"` - // Last4: Last four digits of the card used to pay. - Last4 string `json:"last4,omitempty"` - // ExpiryMonth: Month of the expiry date of the card used to pay. - ExpiryMonth int `json:"expiry_month,omitempty"` - // ExpiryYear: Year of the expiry year of the card used to pay. - ExpiryYear int `json:"expiry_year,omitempty"` - // CardholderName: The name on the card used to pay. - CardholderName string `json:"cardholder_name,omitempty"` -} - -// MethodDetails: Information about the payment method used for a payment attempt. -type MethodDetails struct { - // Type: Type of payment method used for this payment attempt. - Type string `json:"type,omitempty"` - // Card: Information about the credit or debit card used to pay. `null` unless `type` is `card`. - Card *Card `json:"card,omitempty"` -} - -// TransactionPaymentAttempt: List of payment attempts for this transaction, including successful payments. Sorted by `created_at` in descending order, so most recent attempts are returned first. -type TransactionPaymentAttempt struct { - // PaymentAttemptID: UUID for this payment attempt. - PaymentAttemptID string `json:"payment_attempt_id,omitempty"` - // 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"` - // 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. - Status string `json:"status,omitempty"` - // ErrorCode: Reason why a payment attempt failed. Returns `null` if payment captured successfully. - ErrorCode *string `json:"error_code,omitempty"` - // MethodDetails: Information about the payment method used for a payment attempt. - MethodDetails MethodDetails `json:"method_details,omitempty"` - // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. - CreatedAt string `json:"created_at,omitempty"` - // CapturedAt: RFC 3339 datetime string of when this payment was captured. `null` if `status` is not `captured`. - CapturedAt *string `json:"captured_at,omitempty"` -} - -// Checkout: Paddle Checkout details for this transaction. Returned for automatically-collected transactions and where `billing_details.enable_checkout` is `true` for manually-collected transactions; `null` otherwise. -type Checkout struct { - // URL: Paddle Checkout URL for this transaction, composed of the URL passed in the request or your default payment URL + `_?txn=` and the Paddle ID for this transaction. - URL *string `json:"url,omitempty"` -} - -// Address: Address for this transaction. Returned when the `include` parameter is used with the `address` value and the transaction has an `address_id`. -type Address struct { - // ID: Unique Paddle ID for this address entity, prefixed with `add_`. - ID string `json:"id,omitempty"` - // CustomerID: Paddle ID for the customer related to this address, prefixed with `cus_`. - CustomerID string `json:"customer_id,omitempty"` - // Description: Memorable description for this address. - Description *string `json:"description,omitempty"` - // FirstLine: First line of this address. - FirstLine *string `json:"first_line,omitempty"` - // SecondLine: Second line of this address. - SecondLine *string `json:"second_line,omitempty"` - // City: City of this address. - City *string `json:"city,omitempty"` - // PostalCode: ZIP or postal code of this address. Required for some countries. - PostalCode *string `json:"postal_code,omitempty"` - // Region: State, county, or region of this address. - Region *string `json:"region,omitempty"` - // CountryCode: Supported two-letter ISO 3166-1 alpha-2 country code for this address. - CountryCode string `json:"country_code,omitempty"` - // CustomData: Your own structured key-value data. - CustomData CustomData `json:"custom_data,omitempty"` - // Status: Whether this entity can be used in Paddle. - Status string `json:"status,omitempty"` - // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. - CreatedAt string `json:"created_at,omitempty"` - // UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle. - UpdatedAt string `json:"updated_at,omitempty"` - // ImportMeta: Import information for this entity. `null` if this entity is not imported. - ImportMeta *ImportMeta `json:"import_meta,omitempty"` +// Duration: How often this price should be charged. `null` if price is non-recurring (one-time). +type Duration struct { + // Interval: Unit of time. + Interval string `json:"interval,omitempty"` + // Frequency: Amount of time. + Frequency int `json:"frequency,omitempty"` } -// Action: How this adjustment impacts the related transaction. `refund` adjustments must be approved by Paddle, and are created with the status `pending_approval`.. -type Action string - -const ( - ActionCredit = "credit" - ActionRefund = "refund" - ActionChargeback = "chargeback" - ActionChargebackReverse = "chargeback_reverse" - ActionChargebackWarning = "chargeback_warning" - ActionCreditReverse = "credit_reverse" -) - -/* -AdjustmentStatus: Status of this adjustment. Set automatically by Paddle. - -`refund` adjustments must be approved by Paddle, and are created with the status `pending_approval` -until they move to `approved` or `rejected` on review. Other kinds of adjustment do not need approval, -so are created with the status `approved`.. -*/ -type AdjustmentStatus string - -const ( - AdjustmentStatusPendingApproval = "pending_approval" - AdjustmentStatusApproved = "approved" - AdjustmentStatusRejected = "rejected" - AdjustmentStatusReversed = "reversed" -) - -/* -AdjustmentType: Type of adjustment for this transaction item. `tax` and `proration` are automatically created by Paddle. -Include `amount` when creating a `partial` adjustment.. -*/ -type AdjustmentType string +// TaxMode: How tax is calculated for this price.. +type TaxMode string const ( - AdjustmentTypeFull = "full" - AdjustmentTypePartial = "partial" - AdjustmentTypeTax = "tax" - AdjustmentTypeProration = "proration" + TaxModeAccountSetting = "account_setting" + TaxModeExternal = "external" + TaxModeInternal = "internal" ) -// AdjustmentItemTotals: Breakdown of the total for an adjustment item. -type AdjustmentItemTotals struct { - // Subtotal: Amount multiplied by quantity. - Subtotal string `json:"subtotal,omitempty"` - // Tax: Total tax on the subtotal. - Tax string `json:"tax,omitempty"` - // Total: Total after tax. - Total string `json:"total,omitempty"` -} - -// AdjustmentItem: List of items on this adjustment. -type AdjustmentItem struct { - // ID: Unique Paddle ID for this adjustment item, prefixed with `adjitm_`. - ID string `json:"id,omitempty"` - // ItemID: Paddle ID for the transaction item that this adjustment item relates to, prefixed with `txnitm_`. - ItemID string `json:"item_id,omitempty"` - /* - Type: Type of adjustment for this transaction item. `tax` and `proration` are automatically created by Paddle. - Include `amount` when creating a `partial` adjustment. - */ - Type string `json:"type,omitempty"` - // Amount: Amount adjusted for this transaction item. Required when adjustment type is `partial`. - Amount *string `json:"amount,omitempty"` - /* - Proration: How proration was calculated for this adjustment item. Populated when an adjustment type is `proration`. - Set automatically by Paddle. - */ - Proration *Proration `json:"proration,omitempty"` - // Totals: Breakdown of the total for an adjustment item. - Totals AdjustmentItemTotals `json:"totals,omitempty"` -} - -// AdjustmentTotals: Breakdown of the total for an adjustment. -type AdjustmentTotals struct { - // Subtotal: Total before tax. For tax adjustments, the value is 0. - Subtotal string `json:"subtotal,omitempty"` - // Tax: Total tax on the subtotal. - Tax string `json:"tax,omitempty"` - // Total: Total after tax. - Total string `json:"total,omitempty"` - // Fee: Total fee taken by Paddle for this adjustment. - Fee string `json:"fee,omitempty"` - /* - Earnings: Total earnings. This is the subtotal minus the Paddle fee. - For tax adjustments, this value is negative, which means a positive effect in the transaction earnings. - This is because the fee is originally calculated from the transaction total, so if a tax adjustment is made, - then the fee portion of it is returned. - */ - Earnings string `json:"earnings,omitempty"` - // CurrencyCode: Three-letter ISO 4217 currency code used for this adjustment. - CurrencyCode string `json:"currency_code,omitempty"` -} - -// PayoutTotalsAdjustment: Breakdown of how this adjustment affects your payout balance. -type PayoutTotalsAdjustment struct { - // Subtotal: Adjustment total before tax and fees. - Subtotal string `json:"subtotal,omitempty"` - // Tax: Total tax on the adjustment subtotal. - Tax string `json:"tax,omitempty"` - // Total: Adjustment total after tax. - Total string `json:"total,omitempty"` - // Fee: Adjusted Paddle fee. - Fee string `json:"fee,omitempty"` - // ChargebackFee: Chargeback fees incurred for this adjustment. Only returned when the adjustment `action` is `chargeback` or `chargeback_warning`. - ChargebackFee ChargebackFee `json:"chargeback_fee,omitempty"` - // Earnings: Adjusted payout earnings. This is the adjustment total plus adjusted Paddle fees, excluding chargeback fees. - Earnings string `json:"earnings,omitempty"` - // CurrencyCode: Three-letter ISO 4217 currency code used for the payout for this transaction. If your primary currency has changed, this reflects the primary currency at the time the transaction was billed. - CurrencyCode string `json:"currency_code,omitempty"` -} - -// Adjustment: Represents an adjustment entity. -type Adjustment struct { - // ID: Unique Paddle ID for this adjustment entity, prefixed with `adj_`. - ID string `json:"id,omitempty"` - // Action: How this adjustment impacts the related transaction. `refund` adjustments must be approved by Paddle, and are created with the status `pending_approval`. - Action string `json:"action,omitempty"` - // TransactionID: Paddle ID for the transaction related to this adjustment, prefixed with `txn_`. - TransactionID string `json:"transaction_id,omitempty"` - /* - SubscriptionID: Paddle ID for the subscription related to this adjustment, prefixed with `sub_`. - Set automatically by Paddle based on the `subscription_id` of the related transaction. - */ - SubscriptionID *string `json:"subscription_id,omitempty"` - /* - CustomerID: Paddle ID for the customer related to this adjustment, prefixed with `ctm_`. - Set automatically by Paddle based on the `customer_id` of the related transaction. - */ - 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` when the related transaction `collection_mode` is `manual` and its `status` is `billed`. The adjustment is used - to reduce the `balance` due on the transaction. - - `true` for automatically-collected transactions and `completed` manually-collected transactions. - */ - 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. +// Money: Base price. This price applies to all customers, except for customers located in countries where you have `unit_price_overrides`. +type Money struct { + // Amount: Amount in the lowest denomination for the currency, e.g. 10 USD = 1000 (cents). + Amount string `json:"amount,omitempty"` + // CurrencyCode: Supported three-letter ISO 4217 currency code. CurrencyCode string `json:"currency_code,omitempty"` - /* - Status: Status of this adjustment. Set automatically by Paddle. - - `refund` adjustments must be approved by Paddle, and are created with the status `pending_approval` - until they move to `approved` or `rejected` on review. Other kinds of adjustment do not need approval, - so are created with the status `approved`. - */ - Status string `json:"status,omitempty"` - // Items: List of items on this adjustment. - Items []AdjustmentItem `json:"items,omitempty"` - // Totals: Breakdown of the total for an adjustment. - Totals AdjustmentTotals `json:"totals,omitempty"` - // PayoutTotals: Breakdown of how this adjustment affects your payout balance. - PayoutTotals *PayoutTotalsAdjustment `json:"payout_totals,omitempty"` - // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. - CreatedAt string `json:"created_at,omitempty"` - // UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle. - UpdatedAt string `json:"updated_at,omitempty"` -} - -// Contacts: List of contacts related to this business, typically used for sending invoices. -type Contacts struct { - // Name: Full name of this contact. - Name string `json:"name,omitempty"` - // Email: Email address for this contact. - Email string `json:"email,omitempty"` } -// Business: Business for this transaction. Returned when the `include` parameter is used with the `business` value and the transaction has a `business_id`. -type Business struct { - // ID: Unique Paddle ID for this business entity, prefixed with `biz_`. - ID string `json:"id,omitempty"` - // CustomerID: Paddle ID for the customer related to this business, prefixed with `cus_`. - CustomerID string `json:"customer_id,omitempty"` - // Name: Name of this business. - Name string `json:"name,omitempty"` - // CompanyNumber: Company number for this business. - CompanyNumber *string `json:"company_number,omitempty"` - // TaxIdentifier: Tax or VAT Number for this business. - TaxIdentifier *string `json:"tax_identifier,omitempty"` - // Status: Whether this entity can be used in Paddle. - Status string `json:"status,omitempty"` - // Contacts: List of contacts related to this business, typically used for sending invoices. - Contacts []Contacts `json:"contacts,omitempty"` - // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. - CreatedAt string `json:"created_at,omitempty"` - // UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle. - UpdatedAt string `json:"updated_at,omitempty"` - // CustomData: Your own structured key-value data. - 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"` +// UnitPriceOverride: List of unit price overrides. Use to override the base price with a custom price and currency for a country or group of countries. +type UnitPriceOverride struct { + // CountryCodes: Supported two-letter ISO 3166-1 alpha-2 country code. + CountryCodes []CountryCode `json:"country_codes,omitempty"` + // UnitPrice: Override price. This price applies to customers located in the countries for this unit price override. + UnitPrice Money `json:"unit_price,omitempty"` } -// Customer: Customer for this transaction. Returned when the `include` parameter is used with the `customer` value and the transaction has a `customer_id`. -type Customer struct { - // ID: Unique Paddle ID for this customer entity, prefixed with `ctm_`. - ID string `json:"id,omitempty"` - // Name: Full name of this customer. Required when creating transactions where `collection_mode` is `manual` (invoices). - Name *string `json:"name,omitempty"` - // Email: Email address for this customer. - Email string `json:"email,omitempty"` - /* - MarketingConsent: Whether this customer opted into marketing from you. - Set to `true` by Paddle where a customer checks the marketing consent box when using Paddle Checkout; `false` otherwise. - */ - MarketingConsent bool `json:"marketing_consent,omitempty"` - // Status: Whether this entity can be used in Paddle. - Status string `json:"status,omitempty"` - // CustomData: Your own structured key-value data. - CustomData CustomData `json:"custom_data,omitempty"` - // Locale: Valid IETF BCP 47 short form locale tag. If omitted, defaults to `en`. - Locale string `json:"locale,omitempty"` - // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. - CreatedAt string `json:"created_at,omitempty"` - // UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle. - UpdatedAt string `json:"updated_at,omitempty"` - // ImportMeta: Import information for this entity. `null` if this entity is not imported. - ImportMeta *ImportMeta `json:"import_meta,omitempty"` +// PriceQuantity: Limits on how many times the related product can be purchased at this price. Useful for discount campaigns. +type PriceQuantity struct { + // Minimum: Minimum quantity of the product related to this price that can be bought. Required if `maximum` set. + Minimum int `json:"minimum,omitempty"` + // Maximum: Maximum quantity of the product related to this price that can be bought. Required if `minimum` set. Must be greater than or equal to the `minimum` value. + Maximum int `json:"maximum,omitempty"` } -// DiscountStatus: Whether this entity can be used in Paddle. `expired` and `used` are set automatically by Paddle.. -type DiscountStatus string +// TaxCategory: Tax category for this product. Used for charging the correct rate of tax. Selected tax category must be enabled on your Paddle account.. +type TaxCategory string const ( - DiscountStatusActive = "active" - DiscountStatusArchived = "archived" - DiscountStatusExpired = "expired" - DiscountStatusUsed = "used" + TaxCategoryDigitalGoods = "digital-goods" + TaxCategoryEbooks = "ebooks" + TaxCategoryImplementationServices = "implementation-services" + TaxCategoryProfessionalServices = "professional-services" + TaxCategorySaas = "saas" + TaxCategorySoftwareProgrammingServices = "software-programming-services" + TaxCategoryStandard = "standard" + TaxCategoryTrainingServices = "training-services" + TaxCategoryWebsiteHosting = "website-hosting" ) -// DiscountType: Type of discount.. -type DiscountType string +// CollectionMode: How payment is collected for transactions created for this subscription. `automatic` for checkout, `manual` for invoices.. +type CollectionMode string const ( - DiscountTypeFlat = "flat" - DiscountTypeFlatPerSeat = "flat_per_seat" - DiscountTypePercentage = "percentage" + CollectionModeAutomatic = "automatic" + CollectionModeManual = "manual" ) -// Discount: Discount for this transaction. Returned when the `include` parameter is used with the `discount` value and the transaction has a `discount_id`. -type Discount struct { - // ID: Unique Paddle ID for this discount, prefixed with `dsc_`. - ID string `json:"id,omitempty"` - // Status: Whether this entity can be used in Paddle. `expired` and `used` are set automatically by Paddle. - Status string `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 a customer at checkout. - 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. Paddle generates a random 10-character code if a code is not provided and `enabled_for_checkout` is `true`. - Code *string `json:"code,omitempty"` - // Type: Type of discount. - Type string `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 *string `json:"currency_code,omitempty"` - // Recur: Whether this discount applies for multiple billing periods. - 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 *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 *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 *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 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"` - // UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle. - UpdatedAt string `json:"updated_at,omitempty"` - // ImportMeta: Import information for this entity. `null` if this entity is not imported. - ImportMeta *ImportMeta `json:"import_meta,omitempty"` -} - -// TransactionSubscriptionProductCreate: Product object for a non-catalog item to charge for. -type TransactionSubscriptionProductCreate struct { - // Name: Name of this product. - Name string `json:"name,omitempty"` - // Description: Short description for this product. - Description *string `json:"description,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 string `json:"tax_category,omitempty"` - // ImageURL: Image for this product. Included in the checkout and on some customer documents. - ImageURL *string `json:"image_url,omitempty"` - // CustomData: Your own structured key-value data. - CustomData CustomData `json:"custom_data,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. - PostalCode *string `json:"postal_code,omitempty"` - // CountryCode: Supported two-letter ISO 3166-1 alpha-2 country code for this address. - CountryCode string `json:"country_code,omitempty"` -} - -// BillingDetailsUpdate: Details for invoicing. Required if `collection_mode` is `manual`. -type BillingDetailsUpdate struct { +// BillingDetails: Details for invoicing. Required if `collection_mode` is `manual`. +type BillingDetails struct { // EnableCheckout: Whether the related transaction may be paid using a Paddle Checkout. EnableCheckout bool `json:"enable_checkout,omitempty"` // PurchaseOrderNumber: Customer purchase order number. Appears on invoice documents. @@ -1214,155 +448,39 @@ type BillingDetailsUpdate struct { PaymentTerms Duration `json:"payment_terms,omitempty"` } -// EventType: Represents an event type. -type EventType struct { - // Name: Type of event sent by Paddle, in the format `entity.event_type`. - Name string `json:"name,omitempty"` - // Description: Short description of this event type. - Description string `json:"description,omitempty"` - // Group: Group for this event type. Typically the entity that this event relates to. - Group string `json:"group,omitempty"` - // AvailableVersions: List of API versions that this event type supports. - AvailableVersions []int `json:"available_versions,omitempty"` -} - -// SubscriptionStatus: Status of this subscription. Set automatically by Paddle. Use the pause subscription or cancel subscription operations to change.. -type SubscriptionStatus string - -const ( - SubscriptionStatusActive = "active" - SubscriptionStatusCanceled = "canceled" - SubscriptionStatusPastDue = "past_due" - SubscriptionStatusPaused = "paused" - SubscriptionStatusTrialing = "trialing" -) - -// SubscriptionDiscount: Details of the discount applied to this subscription. -type SubscriptionDiscount struct { - // ID: Unique Paddle ID for this discount, prefixed with `dsc_`. +// Price: Related price entity for this item. This reflects the price entity at the time it was added to the subscription. +type Price struct { + // ID: Unique Paddle ID for this price, prefixed with `pri_`. ID string `json:"id,omitempty"` - // StartsAt: RFC 3339 datetime string of when this discount was first applied. - StartsAt string `json:"starts_at,omitempty"` - // EndsAt: RFC 3339 datetime string of when this discount no longer applies. Where a discount has `maximum_recurring_intervals`, this is the date of the last billing period where this discount applies. `null` where a discount recurs forever. - EndsAt *string `json:"ends_at,omitempty"` -} - -// ScheduledChangeAction: Kind of change that's scheduled to be applied to this subscription.. -type ScheduledChangeAction string - -const ( - ScheduledChangeActionCancel = "cancel" - ScheduledChangeActionPause = "pause" - ScheduledChangeActionResume = "resume" -) - -// SubscriptionScheduledChange: Change that's scheduled to be applied to a subscription. Use the pause subscription, cancel subscription, and resume subscription operations to create scheduled changes. `null` if no scheduled changes. -type SubscriptionScheduledChange struct { - // Action: Kind of change that's scheduled to be applied to this subscription. - Action string `json:"action,omitempty"` - // EffectiveAt: RFC 3339 datetime string of when this scheduled change takes effect. - EffectiveAt string `json:"effective_at,omitempty"` - // ResumeAt: RFC 3339 datetime string of when a paused subscription should resume. Only used for `pause` scheduled changes. - ResumeAt *string `json:"resume_at,omitempty"` -} - -// SubscriptionItemStatus: Status of this subscription item. Set automatically by Paddle.. -type SubscriptionItemStatus string - -const ( - SubscriptionItemStatusActive = "active" - SubscriptionItemStatusInactive = "inactive" - SubscriptionItemStatusTrialing = "trialing" -) - -// SubscriptionItem: Represents a subscription item. -type SubscriptionItem struct { - // Status: Status of this subscription item. Set automatically by Paddle. + // ProductID: Paddle ID for the product that this price is for, prefixed with `pro_`. + ProductID string `json:"product_id,omitempty"` + // 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 string `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). + 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 string `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. + Quantity PriceQuantity `json:"quantity,omitempty"` + // Status: Whether this entity can be used in Paddle. Status string `json:"status,omitempty"` - // Quantity: Quantity of this item on the subscription. - Quantity int `json:"quantity,omitempty"` - // Recurring: Whether this is a recurring item. `false` if one-time. - Recurring bool `json:"recurring,omitempty"` - // CreatedAt: RFC 3339 datetime string of when this item was added to this subscription. + // CustomData: Your own structured key-value data. + 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"` + // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. CreatedAt string `json:"created_at,omitempty"` - // UpdatedAt: RFC 3339 datetime string of when this item was last updated on this subscription. + // UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle. UpdatedAt string `json:"updated_at,omitempty"` - // PreviouslyBilledAt: RFC 3339 datetime string of when this item was last billed. - PreviouslyBilledAt *string `json:"previously_billed_at,omitempty"` - // NextBilledAt: RFC 3339 datetime string of when this item is next scheduled to be billed. - NextBilledAt *string `json:"next_billed_at,omitempty"` - // TrialDates: Trial dates for this item. - TrialDates *TimePeriod `json:"trial_dates,omitempty"` - // Price: Related price entity for this item. This reflects the price entity at the time it was added to the subscription. - Price Price `json:"price,omitempty"` -} - -/* -ReportStatus: Status of this report. Set automatically by Paddle. - -Reports are created as `pending` initially, then move to `ready` when they're available to download.. -*/ -type ReportStatus string - -const ( - ReportStatusPending = "pending" - ReportStatusReady = "ready" - ReportStatusFailed = "failed" - ReportStatusExpired = "expired" -) - -// ReportTypeTransactions: Type of report.. -type ReportTypeTransactions string - -const ( - ReportTypeTransactionsAdjustments = "adjustments" - ReportTypeTransactionsAdjustmentLineItems = "adjustment_line_items" - ReportTypeTransactionsTransactions = "transactions" - ReportTypeTransactionsTransactionLineItems = "transaction_line_items" - ReportTypeTransactionsProductsPrices = "products_prices" - ReportTypeTransactionsDiscounts = "discounts" -) - -// SharedName: Field name to filter by.. -type SharedName string - -const ( - SharedNameAction = "action" - SharedNameCurrencyCode = "currency_code" - SharedNameStatus = "status" - SharedNameUpdatedAt = "updated_at" - SharedNameCollectionMode = "collection_mode" - SharedNameOrigin = "origin" - SharedNameProductStatus = "product_status" - SharedNamePriceStatus = "price_status" - SharedNameProductType = "product_type" - SharedNamePriceType = "price_type" - SharedNameProductUpdatedAt = "product_updated_at" - SharedNamePriceUpdatedAt = "price_updated_at" - SharedNameType = "type" -) - -// SharedOperator: Operator to use when filtering. Valid when filtering by `updated_at`, `null` otherwise.. -type SharedOperator *string - -const ( - SharedOperatorLt = "lt" - SharedOperatorGte = "gte" -) - -// ReportFilters: List of filters applied to this report. -type ReportFilters struct { - // Name: Field name to filter by. - Name string `json:"name,omitempty"` - // Operator: Operator to use when filtering. Valid when filtering by `updated_at`, `null` otherwise. - Operator *string `json:"operator,omitempty"` - // Value: Value to filter by. Check the allowed values descriptions for the `name` field to see valid values for a field. - Value string `json:"value,omitempty"` } - -// Type: Type of report to create.. -type Type string - -const TypeProductsPrices = "products_prices" - type CustomData map[string]any diff --git a/pkg/paddlenotification/subscription.go b/pkg/paddlenotification/subscriptions.go similarity index 70% rename from pkg/paddlenotification/subscription.go rename to pkg/paddlenotification/subscriptions.go index 527ff83..e7903c5 100644 --- a/pkg/paddlenotification/subscription.go +++ b/pkg/paddlenotification/subscriptions.go @@ -2,69 +2,140 @@ package paddlenotification -// SubscriptionActivated represents a subscription webhook notification entity. +// SubscriptionActivated represents the subscription.activated event. // See https://developer.paddle.com/webhooks/overview for more information. type SubscriptionActivated struct { GenericNotificationsEvent Data SubscriptionNotification `json:"data"` } -// SubscriptionCanceled represents a subscription webhook notification entity. +// SubscriptionCanceled represents the subscription.canceled event. // See https://developer.paddle.com/webhooks/overview for more information. type SubscriptionCanceled struct { GenericNotificationsEvent Data SubscriptionNotification `json:"data"` } -// SubscriptionCreated represents a subscription webhook notification entity. +// SubscriptionCreated represents the subscription.created event. // See https://developer.paddle.com/webhooks/overview for more information. type SubscriptionCreated struct { GenericNotificationsEvent Data SubscriptionCreatedNotification `json:"data"` } -// SubscriptionPastDue represents a subscription webhook notification entity. +// SubscriptionPastDue represents the subscription.past_due event. // See https://developer.paddle.com/webhooks/overview for more information. type SubscriptionPastDue struct { GenericNotificationsEvent Data SubscriptionNotification `json:"data"` } -// SubscriptionImported represents a subscription webhook notification entity. +// SubscriptionImported represents the subscription.imported event. // See https://developer.paddle.com/webhooks/overview for more information. type SubscriptionImported struct { GenericNotificationsEvent Data SubscriptionNotification `json:"data"` } -// SubscriptionPaused represents a subscription webhook notification entity. +// SubscriptionPaused represents the subscription.paused event. // See https://developer.paddle.com/webhooks/overview for more information. type SubscriptionPaused struct { GenericNotificationsEvent Data SubscriptionNotification `json:"data"` } -// SubscriptionResumed represents a subscription webhook notification entity. +// SubscriptionResumed represents the subscription.resumed event. // See https://developer.paddle.com/webhooks/overview for more information. type SubscriptionResumed struct { GenericNotificationsEvent Data SubscriptionNotification `json:"data"` } -// SubscriptionTrialing represents a subscription webhook notification entity. +// SubscriptionTrialing represents the subscription.trialing event. // See https://developer.paddle.com/webhooks/overview for more information. type SubscriptionTrialing struct { GenericNotificationsEvent Data SubscriptionNotification `json:"data"` } -// SubscriptionUpdated represents a subscription webhook notification entity. +// SubscriptionUpdated represents the subscription.updated event. // See https://developer.paddle.com/webhooks/overview for more information. type SubscriptionUpdated struct { GenericNotificationsEvent Data SubscriptionNotification `json:"data"` } +// SubscriptionStatus: Status of this subscription. Set automatically by Paddle. Use the pause subscription or cancel subscription operations to change.. +type SubscriptionStatus string + +const ( + SubscriptionStatusActive = "active" + SubscriptionStatusCanceled = "canceled" + SubscriptionStatusPastDue = "past_due" + SubscriptionStatusPaused = "paused" + SubscriptionStatusTrialing = "trialing" +) + +// SubscriptionDiscount: Details of the discount applied to this subscription. +type SubscriptionDiscount struct { + // ID: Unique Paddle ID for this discount, prefixed with `dsc_`. + ID string `json:"id,omitempty"` + // StartsAt: RFC 3339 datetime string of when this discount was first applied. + StartsAt string `json:"starts_at,omitempty"` + // EndsAt: RFC 3339 datetime string of when this discount no longer applies. Where a discount has `maximum_recurring_intervals`, this is the date of the last billing period where this discount applies. `null` where a discount recurs forever. + EndsAt *string `json:"ends_at,omitempty"` +} + +// ScheduledChangeAction: Kind of change that's scheduled to be applied to this subscription.. +type ScheduledChangeAction string + +const ( + ScheduledChangeActionCancel = "cancel" + ScheduledChangeActionPause = "pause" + ScheduledChangeActionResume = "resume" +) + +// SubscriptionScheduledChange: Change that's scheduled to be applied to a subscription. Use the pause subscription, cancel subscription, and resume subscription operations to create scheduled changes. `null` if no scheduled changes. +type SubscriptionScheduledChange struct { + // Action: Kind of change that's scheduled to be applied to this subscription. + Action string `json:"action,omitempty"` + // EffectiveAt: RFC 3339 datetime string of when this scheduled change takes effect. + EffectiveAt string `json:"effective_at,omitempty"` + // ResumeAt: RFC 3339 datetime string of when a paused subscription should resume. Only used for `pause` scheduled changes. + ResumeAt *string `json:"resume_at,omitempty"` +} + +// SubscriptionItemStatus: Status of this subscription item. Set automatically by Paddle.. +type SubscriptionItemStatus string + +const ( + SubscriptionItemStatusActive = "active" + SubscriptionItemStatusInactive = "inactive" + SubscriptionItemStatusTrialing = "trialing" +) + +// SubscriptionItem: Represents a subscription item. +type SubscriptionItem struct { + // Status: Status of this subscription item. Set automatically by Paddle. + Status string `json:"status,omitempty"` + // Quantity: Quantity of this item on the subscription. + Quantity int `json:"quantity,omitempty"` + // Recurring: Whether this is a recurring item. `false` if one-time. + Recurring bool `json:"recurring,omitempty"` + // CreatedAt: RFC 3339 datetime string of when this item was added to this subscription. + CreatedAt string `json:"created_at,omitempty"` + // UpdatedAt: RFC 3339 datetime string of when this item was last updated on this subscription. + UpdatedAt string `json:"updated_at,omitempty"` + // PreviouslyBilledAt: RFC 3339 datetime string of when this item was last billed. + PreviouslyBilledAt *string `json:"previously_billed_at,omitempty"` + // NextBilledAt: RFC 3339 datetime string of when this item is next scheduled to be billed. + NextBilledAt *string `json:"next_billed_at,omitempty"` + // TrialDates: Trial dates for this item. + TrialDates *TimePeriod `json:"trial_dates,omitempty"` + // Price: Related price entity for this item. This reflects the price entity at the time it was added to the subscription. + Price Price `json:"price,omitempty"` +} + // SubscriptionNotification: New or changed entity. type SubscriptionNotification struct { // ID: Unique Paddle ID for this subscription entity, prefixed with `sub_`. diff --git a/pkg/paddlenotification/transaction.go b/pkg/paddlenotification/transaction.go deleted file mode 100644 index 16c9529..0000000 --- a/pkg/paddlenotification/transaction.go +++ /dev/null @@ -1,114 +0,0 @@ -// Code generated by the Paddle SDK Generator; DO NOT EDIT. - -package paddlenotification - -// TransactionBilled represents a transaction webhook notification entity. -// See https://developer.paddle.com/webhooks/overview for more information. -type TransactionBilled struct { - GenericNotificationsEvent - Data TransactionNotification `json:"data"` -} - -// TransactionCanceled represents a transaction webhook notification entity. -// See https://developer.paddle.com/webhooks/overview for more information. -type TransactionCanceled struct { - GenericNotificationsEvent - Data TransactionNotification `json:"data"` -} - -// TransactionCompleted represents a transaction webhook notification entity. -// See https://developer.paddle.com/webhooks/overview for more information. -type TransactionCompleted struct { - GenericNotificationsEvent - Data TransactionNotification `json:"data"` -} - -// TransactionCreated represents a transaction webhook notification entity. -// See https://developer.paddle.com/webhooks/overview for more information. -type TransactionCreated struct { - GenericNotificationsEvent - Data TransactionNotification `json:"data"` -} - -// TransactionPaid represents a transaction webhook notification entity. -// See https://developer.paddle.com/webhooks/overview for more information. -type TransactionPaid struct { - GenericNotificationsEvent - Data TransactionNotification `json:"data"` -} - -// TransactionPastDue represents a transaction webhook notification entity. -// See https://developer.paddle.com/webhooks/overview for more information. -type TransactionPastDue struct { - GenericNotificationsEvent - Data TransactionNotification `json:"data"` -} - -// TransactionPaymentFailed represents a transaction webhook notification entity. -// See https://developer.paddle.com/webhooks/overview for more information. -type TransactionPaymentFailed struct { - GenericNotificationsEvent - Data TransactionNotification `json:"data"` -} - -// TransactionReady represents a transaction webhook notification entity. -// See https://developer.paddle.com/webhooks/overview for more information. -type TransactionReady struct { - GenericNotificationsEvent - Data TransactionNotification `json:"data"` -} - -// TransactionUpdated represents a transaction webhook notification entity. -// See https://developer.paddle.com/webhooks/overview for more information. -type TransactionUpdated struct { - GenericNotificationsEvent - Data TransactionNotification `json:"data"` -} - -// TransactionNotification: New or changed entity. -type TransactionNotification struct { - // ID: Unique Paddle ID for this transaction entity, prefixed with `txn_`. - ID string `json:"id,omitempty"` - // Status: Status of this transaction. You may set a transaction to `billed` or `canceled`, other statuses are set automatically by Paddle. Automatically-collected transactions may return `completed` if payment is captured successfully, or `past_due` if payment failed. - Status string `json:"status,omitempty"` - // CustomerID: Paddle ID of the customer that this transaction is for, prefixed with `ctm_`. - CustomerID *string `json:"customer_id,omitempty"` - // AddressID: Paddle ID of the address that this transaction is for, prefixed with `add_`. - AddressID *string `json:"address_id,omitempty"` - // BusinessID: Paddle ID of the business that this transaction is for, prefixed with `biz_`. - BusinessID *string `json:"business_id,omitempty"` - // CustomData: Your own structured key-value data. - CustomData CustomData `json:"custom_data,omitempty"` - // CurrencyCode: Supported three-letter ISO 4217 currency code. Must be `USD`, `EUR`, or `GBP` if `collection_mode` is `manual`. - CurrencyCode string `json:"currency_code,omitempty"` - // Origin: Describes how this transaction was created. - Origin string `json:"origin,omitempty"` - // SubscriptionID: Paddle ID of the subscription that this transaction is for, prefixed with `sub_`. - SubscriptionID *string `json:"subscription_id,omitempty"` - // InvoiceID: Paddle ID of the invoice that this transaction is related to, prefixed with `inv_`. Used for compatibility with the Paddle Invoice API, which is now deprecated. This field is scheduled to be removed in the next version of the Paddle API. - InvoiceID *string `json:"invoice_id,omitempty"` - // InvoiceNumber: Invoice number for this transaction. Automatically generated by Paddle when you mark a transaction as `billed` where `collection_mode` is `manual`. - InvoiceNumber *string `json:"invoice_number,omitempty"` - // CollectionMode: How payment is collected for this transaction. `automatic` for checkout, `manual` for invoices. - CollectionMode string `json:"collection_mode,omitempty"` - // DiscountID: Paddle ID of the discount applied to this transaction, prefixed with `dsc_`. - DiscountID *string `json:"discount_id,omitempty"` - // BillingDetails: Details for invoicing. Required if `collection_mode` is `manual`. - BillingDetails *BillingDetails `json:"billing_details,omitempty"` - // BillingPeriod: Time period that this transaction is for. Set automatically by Paddle for subscription renewals to describe the period that charges are for. - BillingPeriod *TimePeriod `json:"billing_period,omitempty"` - // Items: List of items on this transaction. For calculated totals, use `details.line_items`. - Items []TransactionItem `json:"items,omitempty"` - // Details: Calculated totals for a transaction, including proration, discounts, tax, and currency conversion. Considered the source of truth for totals on a transaction. - Details TransactionDetails `json:"details,omitempty"` - // Payments: List of payment attempts for this transaction, including successful payments. Sorted by `created_at` in descending order, so most recent attempts are returned first. - Payments []TransactionPaymentAttempt `json:"payments,omitempty"` - // Checkout: Paddle Checkout details for this transaction. Returned for automatically-collected transactions and where `billing_details.enable_checkout` is `true` for manually-collected transactions; `null` otherwise. - Checkout *Checkout `json:"checkout,omitempty"` - // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. - CreatedAt string `json:"created_at,omitempty"` - // UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle. - UpdatedAt string `json:"updated_at,omitempty"` - // BilledAt: RFC 3339 datetime string of when this transaction was marked as `billed`. `null` for transactions that are not `billed` or `completed`. Set automatically by Paddle. - BilledAt *string `json:"billed_at,omitempty"` -} diff --git a/pkg/paddlenotification/transactions.go b/pkg/paddlenotification/transactions.go new file mode 100644 index 0000000..94fa79b --- /dev/null +++ b/pkg/paddlenotification/transactions.go @@ -0,0 +1,472 @@ +// Code generated by the Paddle SDK Generator; DO NOT EDIT. + +package paddlenotification + +// TransactionBilled represents the transaction.billed event. +// See https://developer.paddle.com/webhooks/overview for more information. +type TransactionBilled struct { + GenericNotificationsEvent + Data TransactionNotification `json:"data"` +} + +// TransactionCanceled represents the transaction.canceled event. +// See https://developer.paddle.com/webhooks/overview for more information. +type TransactionCanceled struct { + GenericNotificationsEvent + Data TransactionNotification `json:"data"` +} + +// TransactionCompleted represents the transaction.completed event. +// See https://developer.paddle.com/webhooks/overview for more information. +type TransactionCompleted struct { + GenericNotificationsEvent + Data TransactionNotification `json:"data"` +} + +// TransactionCreated represents the transaction.created event. +// See https://developer.paddle.com/webhooks/overview for more information. +type TransactionCreated struct { + GenericNotificationsEvent + Data TransactionNotification `json:"data"` +} + +// TransactionPaid represents the transaction.paid event. +// See https://developer.paddle.com/webhooks/overview for more information. +type TransactionPaid struct { + GenericNotificationsEvent + Data TransactionNotification `json:"data"` +} + +// TransactionPastDue represents the transaction.past_due event. +// See https://developer.paddle.com/webhooks/overview for more information. +type TransactionPastDue struct { + GenericNotificationsEvent + Data TransactionNotification `json:"data"` +} + +// TransactionPaymentFailed represents the transaction.payment_failed event. +// See https://developer.paddle.com/webhooks/overview for more information. +type TransactionPaymentFailed struct { + GenericNotificationsEvent + Data TransactionNotification `json:"data"` +} + +// TransactionReady represents the transaction.ready event. +// See https://developer.paddle.com/webhooks/overview for more information. +type TransactionReady struct { + GenericNotificationsEvent + Data TransactionNotification `json:"data"` +} + +// TransactionUpdated represents the transaction.updated event. +// See https://developer.paddle.com/webhooks/overview for more information. +type TransactionUpdated struct { + GenericNotificationsEvent + Data TransactionNotification `json:"data"` +} + +// TransactionStatus: Status of this transaction. You may set a transaction to `billed` or `canceled`, other statuses are set automatically by Paddle. Automatically-collected transactions may return `completed` if payment is captured successfully, or `past_due` if payment failed.. +type TransactionStatus string + +const ( + TransactionStatusDraft = "draft" + TransactionStatusReady = "ready" + TransactionStatusBilled = "billed" + TransactionStatusPaid = "paid" + TransactionStatusCompleted = "completed" + TransactionStatusCanceled = "canceled" + TransactionStatusPastDue = "past_due" +) + +// TransactionOrigin: Describes how this transaction was created.. +type TransactionOrigin string + +const ( + TransactionOriginAPI = "api" + TransactionOriginSubscriptionCharge = "subscription_charge" + TransactionOriginSubscriptionPaymentMethodChange = "subscription_payment_method_change" + TransactionOriginSubscriptionRecurring = "subscription_recurring" + TransactionOriginSubscriptionUpdate = "subscription_update" + TransactionOriginWeb = "web" +) + +// TransactionItem: List of items on this transaction. For calculated totals, use `details.line_items`. +type TransactionItem struct { + // PriceID: Paddle ID for the price to add to this transaction, prefixed with `pri_`. + PriceID string `json:"price_id,omitempty"` + // Price: Represents a price entity. + Price Price `json:"price,omitempty"` + // 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. + Proration *Proration `json:"proration,omitempty"` +} + +// Totals: Calculated totals for the tax applied to this transaction. +type Totals struct { + // Subtotal: Subtotal before discount, tax, and deductions. If an item, unit price multiplied by quantity. + Subtotal string `json:"subtotal,omitempty"` + /* + Discount: Total discount as a result of any discounts applied. + + Except for percentage discounts, Paddle applies tax to discounts based on the line item `price.tax_mode`. If `price.tax_mode` for a line item is `internal`, Paddle removes tax from the discount applied. + */ + Discount string `json:"discount,omitempty"` + // Tax: Total tax on the subtotal. + Tax string `json:"tax,omitempty"` + // Total: Total after discount and tax. + Total string `json:"total,omitempty"` +} + +// TaxRatesUsed: List of tax rates applied for this transaction. +type TaxRatesUsed struct { + // TaxRate: Rate used to calculate tax for this transaction. + TaxRate string `json:"tax_rate,omitempty"` + // Totals: Calculated totals for the tax applied to this transaction. + Totals Totals `json:"totals,omitempty"` +} + +// TransactionTotals: Breakdown of the total for a transaction. These numbers can become negative when dealing with subscription updates that result in credit. +type TransactionTotals struct { + // Subtotal: Subtotal before discount, tax, and deductions. If an item, unit price multiplied by quantity. + Subtotal string `json:"subtotal,omitempty"` + /* + Discount: Total discount as a result of any discounts applied. + + Except for percentage discounts, Paddle applies tax to discounts based on the line item `price.tax_mode`. If `price.tax_mode` for a line item is `internal`, Paddle removes tax from the discount applied. + */ + Discount string `json:"discount,omitempty"` + // Tax: Total tax on the subtotal. + Tax string `json:"tax,omitempty"` + // Total: Total after discount and tax. + Total string `json:"total,omitempty"` + // Credit: Total credit applied to this transaction. This includes credits applied using a customer's credit balance and adjustments to a `billed` transaction. + Credit string `json:"credit,omitempty"` + // CreditToBalance: Additional credit generated from negative `details.line_items`. This credit is added to the customer balance. + CreditToBalance string `json:"credit_to_balance,omitempty"` + // Balance: Total due on a transaction after credits and any payments. + Balance string `json:"balance,omitempty"` + // GrandTotal: Total due on a transaction after credits but before any payments. + GrandTotal string `json:"grand_total,omitempty"` + // Fee: Total fee taken by Paddle for this transaction. `null` until the transaction is `completed` and the fee is processed. + Fee *string `json:"fee,omitempty"` + // Earnings: Total earnings for this transaction. This is the total minus the Paddle fee. `null` until the transaction is `completed` and the fee is processed. + Earnings *string `json:"earnings,omitempty"` + // CurrencyCode: Three-letter ISO 4217 currency code of the currency used for this transaction. + CurrencyCode string `json:"currency_code,omitempty"` +} + +// TransactionTotalsAdjusted: Breakdown of the payout totals for a transaction after adjustments. `null` until the transaction is `completed`. +type TransactionTotalsAdjusted struct { + // Subtotal: Subtotal before discount, tax, and deductions. If an item, unit price multiplied by quantity. + Subtotal string `json:"subtotal,omitempty"` + // Tax: Total tax on the subtotal. + Tax string `json:"tax,omitempty"` + // Total: Total after tax. + Total string `json:"total,omitempty"` + // GrandTotal: Total due after credits but before any payments. + GrandTotal string `json:"grand_total,omitempty"` + // Fee: Total fee taken by Paddle for this transaction. `null` until the transaction is `completed` and the fee is processed. + Fee *string `json:"fee,omitempty"` + /* + Earnings: Total earnings for this transaction. This is the total minus the Paddle fee. + `null` until the transaction is `completed` and the fee is processed. + */ + Earnings *string `json:"earnings,omitempty"` + // CurrencyCode: Three-letter ISO 4217 currency code of the currency used for this transaction. + CurrencyCode string `json:"currency_code,omitempty"` +} + +// TransactionPayoutTotals: Breakdown of the payout total for a transaction. `null` until the transaction is `completed`. Returned in your payout currency. +type TransactionPayoutTotals struct { + // Subtotal: Total before tax and fees. + Subtotal string `json:"subtotal,omitempty"` + /* + Discount: Total discount as a result of any discounts applied. + Except for percentage discounts, Paddle applies tax to discounts based on the line item `price.tax_mode`. If `price.tax_mode` for a line item is `internal`, Paddle removes tax from the discount applied. + */ + Discount string `json:"discount,omitempty"` + // Tax: Total tax on the subtotal. + Tax string `json:"tax,omitempty"` + // Total: Total after tax. + Total string `json:"total,omitempty"` + // Credit: Total credit applied to this transaction. This includes credits applied using a customer's credit balance and adjustments to a `billed` transaction. + Credit string `json:"credit,omitempty"` + // CreditToBalance: Additional credit generated from negative `details.line_items`. This credit is added to the customer balance. + CreditToBalance string `json:"credit_to_balance,omitempty"` + // Balance: Total due on a transaction after credits and any payments. + Balance string `json:"balance,omitempty"` + // GrandTotal: Total due on a transaction after credits but before any payments. + GrandTotal string `json:"grand_total,omitempty"` + // Fee: Total fee taken by Paddle for this payout. + Fee string `json:"fee,omitempty"` + // Earnings: Total earnings for this payout. This is the subtotal minus the Paddle fee. + Earnings string `json:"earnings,omitempty"` + // CurrencyCode: Three-letter ISO 4217 currency code used for the payout for this transaction. If your primary currency has changed, this reflects the primary currency at the time the transaction was billed. + CurrencyCode string `json:"currency_code,omitempty"` +} + +// TransactionPayoutTotalsAdjusted: Breakdown of the payout total for a transaction after adjustments. `null` until the transaction is `completed`. +type TransactionPayoutTotalsAdjusted struct { + // Subtotal: Total before tax and fees. + Subtotal string `json:"subtotal,omitempty"` + // Tax: Total tax on the subtotal. + Tax string `json:"tax,omitempty"` + // Total: Total after tax. + Total string `json:"total,omitempty"` + // Fee: Total fee taken by Paddle for this payout. + Fee string `json:"fee,omitempty"` + // ChargebackFee: Details of any chargeback fees incurred for this transaction. + ChargebackFee ChargebackFee `json:"chargeback_fee,omitempty"` + // Earnings: Total earnings for this payout. This is the subtotal minus the Paddle fee, excluding chargeback fees. + Earnings string `json:"earnings,omitempty"` + // CurrencyCode: Three-letter ISO 4217 currency code used for the payout for this transaction. If your primary currency has changed, this reflects the primary currency at the time the transaction was billed. + CurrencyCode string `json:"currency_code,omitempty"` +} + +// UnitTotals: Breakdown of the charge for one unit in the lowest denomination of a currency (e.g. cents for USD). +type UnitTotals struct { + // Subtotal: Unit price. + Subtotal string `json:"subtotal,omitempty"` + /* + Discount: Total discount as a result of any discounts applied. + Except for percentage discounts, Paddle applies tax to discounts based on the line item `price.tax_mode`. If `price.tax_mode` for a line item is `internal`, Paddle removes tax from the discount applied. + */ + Discount string `json:"discount,omitempty"` + // Tax: Total tax on the subtotal. + Tax string `json:"tax,omitempty"` + // Total: Total after discount and tax. + Total string `json:"total,omitempty"` +} + +// Product: Related product entity for this transaction line item price. +type Product struct { + // ID: Unique Paddle ID for this product, prefixed with `pro_`. + ID string `json:"id,omitempty"` + // Name: Name of this product. + Name string `json:"name,omitempty"` + // 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 string `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 string `json:"tax_category,omitempty"` + // ImageURL: Image for this product. Included in the checkout and on some customer documents. + ImageURL *string `json:"image_url,omitempty"` + // CustomData: Your own structured key-value data. + CustomData CustomData `json:"custom_data,omitempty"` + // Status: Whether this entity can be used in Paddle. + Status string `json:"status,omitempty"` + // ImportMeta: Import information for this entity. `null` if this entity is not imported. + ImportMeta *ImportMeta `json:"import_meta,omitempty"` + // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. + CreatedAt string `json:"created_at,omitempty"` + // UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle. + UpdatedAt string `json:"updated_at,omitempty"` +} + +// 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 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"` + // Quantity: Quantity of this transaction line item. + 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. + Proration *Proration `json:"proration,omitempty"` + // TaxRate: Rate used to calculate tax for this transaction line item. + TaxRate string `json:"tax_rate,omitempty"` + // UnitTotals: Breakdown of the charge for one unit in the lowest denomination of a currency (e.g. cents for USD). + UnitTotals UnitTotals `json:"unit_totals,omitempty"` + // Totals: Breakdown of a charge in the lowest denomination of a currency (e.g. cents for USD). + Totals Totals `json:"totals,omitempty"` + // Product: Related product entity for this transaction line item price. + Product Product `json:"product,omitempty"` +} + +// TransactionDetails: Calculated totals for a transaction, including proration, discounts, tax, and currency conversion. Considered the source of truth for totals on a transaction. +type TransactionDetails struct { + // TaxRatesUsed: List of tax rates applied for this transaction. + TaxRatesUsed []TaxRatesUsed `json:"tax_rates_used,omitempty"` + // Totals: Breakdown of the total for a transaction. These numbers can become negative when dealing with subscription updates that result in credit. + Totals TransactionTotals `json:"totals,omitempty"` + // AdjustedTotals: Breakdown of the payout totals for a transaction after adjustments. `null` until the transaction is `completed`. + AdjustedTotals TransactionTotalsAdjusted `json:"adjusted_totals,omitempty"` + // PayoutTotals: Breakdown of the payout total for a transaction. `null` until the transaction is `completed`. Returned in your payout currency. + PayoutTotals *TransactionPayoutTotals `json:"payout_totals,omitempty"` + // AdjustedPayoutTotals: Breakdown of the payout total for a transaction after adjustments. `null` until the transaction is `completed`. + AdjustedPayoutTotals *TransactionPayoutTotalsAdjusted `json:"adjusted_payout_totals,omitempty"` + // LineItems: 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. + LineItems []TransactionLineItem `json:"line_items,omitempty"` +} + +// PaymentAttemptStatus: Status of this payment attempt.. +type PaymentAttemptStatus string + +const ( + PaymentAttemptStatusAuthorized = "authorized" + PaymentAttemptStatusAuthorizedFlagged = "authorized_flagged" + PaymentAttemptStatusCanceled = "canceled" + PaymentAttemptStatusCaptured = "captured" + PaymentAttemptStatusError = "error" + PaymentAttemptStatusActionRequired = "action_required" + PaymentAttemptStatusPendingNoActionRequired = "pending_no_action_required" + PaymentAttemptStatusCreated = "created" + PaymentAttemptStatusUnknown = "unknown" + PaymentAttemptStatusDropped = "dropped" +) + +// ErrorCode: Reason why a payment attempt failed. Returns `null` if payment captured successfully.. +type ErrorCode *string + +const ( + ErrorCodeAlreadyCanceled = "already_canceled" + ErrorCodeAlreadyRefunded = "already_refunded" + ErrorCodeAuthenticationFailed = "authentication_failed" + ErrorCodeBlockedCard = "blocked_card" + ErrorCodeCanceled = "canceled" + ErrorCodeDeclined = "declined" + ErrorCodeDeclinedNotRetryable = "declined_not_retryable" + ErrorCodeExpiredCard = "expired_card" + ErrorCodeFraud = "fraud" + ErrorCodeInvalidAmount = "invalid_amount" + ErrorCodeInvalidPaymentDetails = "invalid_payment_details" + ErrorCodeIssuerUnavailable = "issuer_unavailable" + ErrorCodeNotEnoughBalance = "not_enough_balance" + ErrorCodePspError = "psp_error" + ErrorCodeRedactedPaymentMethod = "redacted_payment_method" + ErrorCodeSystemError = "system_error" + ErrorCodeTransactionNotPermitted = "transaction_not_permitted" + ErrorCodeUnknown = "unknown" +) + +// PaymentMethodType: Type of payment method used for this payment attempt.. +type PaymentMethodType string + +const ( + PaymentMethodTypeAlipay = "alipay" + PaymentMethodTypeApplePay = "apple_pay" + PaymentMethodTypeBancontact = "bancontact" + PaymentMethodTypeCard = "card" + PaymentMethodTypeGooglePay = "google_pay" + PaymentMethodTypeIdeal = "ideal" + PaymentMethodTypeOffline = "offline" + PaymentMethodTypePaypal = "paypal" + PaymentMethodTypeUnknown = "unknown" + PaymentMethodTypeWireTransfer = "wire_transfer" +) + +// CardType: Type of credit or debit card used to pay.. +type CardType string + +const ( + CardTypeAmericanExpress = "american_express" + CardTypeDinersClub = "diners_club" + CardTypeDiscover = "discover" + CardTypeJcb = "jcb" + CardTypeMada = "mada" + CardTypeMaestro = "maestro" + CardTypeMastercard = "mastercard" + CardTypeUnionPay = "union_pay" + CardTypeUnknown = "unknown" + CardTypeVisa = "visa" +) + +// Card: Information about the credit or debit card used to pay. `null` unless `type` is `card`. +type Card struct { + // Type: Type of credit or debit card used to pay. + Type string `json:"type,omitempty"` + // Last4: Last four digits of the card used to pay. + Last4 string `json:"last4,omitempty"` + // ExpiryMonth: Month of the expiry date of the card used to pay. + ExpiryMonth int `json:"expiry_month,omitempty"` + // ExpiryYear: Year of the expiry year of the card used to pay. + ExpiryYear int `json:"expiry_year,omitempty"` + // CardholderName: The name on the card used to pay. + CardholderName string `json:"cardholder_name,omitempty"` +} + +// MethodDetails: Information about the payment method used for a payment attempt. +type MethodDetails struct { + // Type: Type of payment method used for this payment attempt. + Type string `json:"type,omitempty"` + // Card: Information about the credit or debit card used to pay. `null` unless `type` is `card`. + Card *Card `json:"card,omitempty"` +} + +// TransactionPaymentAttempt: List of payment attempts for this transaction, including successful payments. Sorted by `created_at` in descending order, so most recent attempts are returned first. +type TransactionPaymentAttempt struct { + // PaymentAttemptID: UUID for this payment attempt. + PaymentAttemptID string `json:"payment_attempt_id,omitempty"` + // 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"` + // 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. + Status string `json:"status,omitempty"` + // ErrorCode: Reason why a payment attempt failed. Returns `null` if payment captured successfully. + ErrorCode *string `json:"error_code,omitempty"` + // MethodDetails: Information about the payment method used for a payment attempt. + MethodDetails MethodDetails `json:"method_details,omitempty"` + // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. + CreatedAt string `json:"created_at,omitempty"` + // CapturedAt: RFC 3339 datetime string of when this payment was captured. `null` if `status` is not `captured`. + CapturedAt *string `json:"captured_at,omitempty"` +} + +// Checkout: Paddle Checkout details for this transaction. Returned for automatically-collected transactions and where `billing_details.enable_checkout` is `true` for manually-collected transactions; `null` otherwise. +type Checkout struct { + // URL: Paddle Checkout URL for this transaction, composed of the URL passed in the request or your default payment URL + `_?txn=` and the Paddle ID for this transaction. + URL *string `json:"url,omitempty"` +} + +// TransactionNotification: New or changed entity. +type TransactionNotification struct { + // ID: Unique Paddle ID for this transaction entity, prefixed with `txn_`. + ID string `json:"id,omitempty"` + // Status: Status of this transaction. You may set a transaction to `billed` or `canceled`, other statuses are set automatically by Paddle. Automatically-collected transactions may return `completed` if payment is captured successfully, or `past_due` if payment failed. + Status string `json:"status,omitempty"` + // CustomerID: Paddle ID of the customer that this transaction is for, prefixed with `ctm_`. + CustomerID *string `json:"customer_id,omitempty"` + // AddressID: Paddle ID of the address that this transaction is for, prefixed with `add_`. + AddressID *string `json:"address_id,omitempty"` + // BusinessID: Paddle ID of the business that this transaction is for, prefixed with `biz_`. + BusinessID *string `json:"business_id,omitempty"` + // CustomData: Your own structured key-value data. + CustomData CustomData `json:"custom_data,omitempty"` + // CurrencyCode: Supported three-letter ISO 4217 currency code. Must be `USD`, `EUR`, or `GBP` if `collection_mode` is `manual`. + CurrencyCode string `json:"currency_code,omitempty"` + // Origin: Describes how this transaction was created. + Origin string `json:"origin,omitempty"` + // SubscriptionID: Paddle ID of the subscription that this transaction is for, prefixed with `sub_`. + SubscriptionID *string `json:"subscription_id,omitempty"` + // InvoiceID: Paddle ID of the invoice that this transaction is related to, prefixed with `inv_`. Used for compatibility with the Paddle Invoice API, which is now deprecated. This field is scheduled to be removed in the next version of the Paddle API. + InvoiceID *string `json:"invoice_id,omitempty"` + // InvoiceNumber: Invoice number for this transaction. Automatically generated by Paddle when you mark a transaction as `billed` where `collection_mode` is `manual`. + InvoiceNumber *string `json:"invoice_number,omitempty"` + // CollectionMode: How payment is collected for this transaction. `automatic` for checkout, `manual` for invoices. + CollectionMode string `json:"collection_mode,omitempty"` + // DiscountID: Paddle ID of the discount applied to this transaction, prefixed with `dsc_`. + DiscountID *string `json:"discount_id,omitempty"` + // BillingDetails: Details for invoicing. Required if `collection_mode` is `manual`. + BillingDetails *BillingDetails `json:"billing_details,omitempty"` + // BillingPeriod: Time period that this transaction is for. Set automatically by Paddle for subscription renewals to describe the period that charges are for. + BillingPeriod *TimePeriod `json:"billing_period,omitempty"` + // Items: List of items on this transaction. For calculated totals, use `details.line_items`. + Items []TransactionItem `json:"items,omitempty"` + // Details: Calculated totals for a transaction, including proration, discounts, tax, and currency conversion. Considered the source of truth for totals on a transaction. + Details TransactionDetails `json:"details,omitempty"` + // Payments: List of payment attempts for this transaction, including successful payments. Sorted by `created_at` in descending order, so most recent attempts are returned first. + Payments []TransactionPaymentAttempt `json:"payments,omitempty"` + // Checkout: Paddle Checkout details for this transaction. Returned for automatically-collected transactions and where `billing_details.enable_checkout` is `true` for manually-collected transactions; `null` otherwise. + Checkout *Checkout `json:"checkout,omitempty"` + // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. + CreatedAt string `json:"created_at,omitempty"` + // UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle. + UpdatedAt string `json:"updated_at,omitempty"` + // BilledAt: RFC 3339 datetime string of when this transaction was marked as `billed`. `null` for transactions that are not `billed` or `completed`. Set automatically by Paddle. + BilledAt *string `json:"billed_at,omitempty"` +} diff --git a/prices.go b/prices.go index 7552964..88bea92 100644 --- a/prices.go +++ b/prices.go @@ -43,8 +43,8 @@ var ErrPriceDuplicateCurrencyOverrideForCountry = &paddleerr.Error{ Type: paddleerr.ErrorTypeRequestError, } -// PriceIncludes: Represents a price entity with included entities. -type PriceIncludes struct { +// Price: Represents a price entity with included entities. +type Price struct { // ID: Unique Paddle ID for this price, prefixed with `pri_`. ID string `json:"id,omitempty"` // ProductID: Paddle ID for the product that this price is for, prefixed with `pro_`. @@ -127,7 +127,7 @@ type ListPricesRequest struct { } // ListPrices performs the GET operation on a Prices resource. -func (c *PricesClient) ListPrices(ctx context.Context, req *ListPricesRequest) (res *Collection[*PriceIncludes], err error) { +func (c *PricesClient) ListPrices(ctx context.Context, req *ListPricesRequest) (res *Collection[*Price], err error) { if err := c.doer.Do(ctx, "GET", "/prices", req, &res); err != nil { return nil, err } @@ -181,7 +181,7 @@ type GetPriceRequest struct { } // GetPrice performs the GET operation on a Prices resource. -func (c *PricesClient) GetPrice(ctx context.Context, req *GetPriceRequest) (res *PriceIncludes, err error) { +func (c *PricesClient) GetPrice(ctx context.Context, req *GetPriceRequest) (res *Price, err error) { if err := c.doer.Do(ctx, "GET", "/prices/{price_id}", req, &res); err != nil { return nil, err } diff --git a/products.go b/products.go index df10004..672155d 100644 --- a/products.go +++ b/products.go @@ -15,8 +15,8 @@ var ErrProductTaxCategoryNotApproved = &paddleerr.Error{ Type: paddleerr.ErrorTypeRequestError, } -// ProductWithIncludes: Represents a product entity with included entities. -type ProductWithIncludes struct { +// Product: Represents a product entity with included entities. +type Product struct { // ID: Unique Paddle ID for this product, prefixed with `pro_`. ID string `json:"id,omitempty"` // Name: Name of this product. @@ -86,7 +86,7 @@ type ListProductsRequest struct { } // ListProducts performs the GET operation on a Products resource. -func (c *ProductsClient) ListProducts(ctx context.Context, req *ListProductsRequest) (res *Collection[*ProductWithIncludes], err error) { +func (c *ProductsClient) ListProducts(ctx context.Context, req *ListProductsRequest) (res *Collection[*Product], err error) { if err := c.doer.Do(ctx, "GET", "/products", req, &res); err != nil { return nil, err } @@ -130,7 +130,7 @@ type GetProductRequest struct { } // GetProduct performs the GET operation on a Products resource. -func (c *ProductsClient) GetProduct(ctx context.Context, req *GetProductRequest) (res *ProductWithIncludes, err error) { +func (c *ProductsClient) GetProduct(ctx context.Context, req *GetProductRequest) (res *Product, err error) { if err := c.doer.Do(ctx, "GET", "/products/{product_id}", req, &res); err != nil { return nil, err } diff --git a/reports.go b/reports.go index 4f87642..5352d8d 100644 --- a/reports.go +++ b/reports.go @@ -37,6 +37,69 @@ var ErrReportFailed = &paddleerr.Error{ Type: paddleerr.ErrorTypeRequestError, } +/* +ReportStatus: Status of this report. Set automatically by Paddle. + +Reports are created as `pending` initially, then move to `ready` when they're available to download.. +*/ +type ReportStatus string + +const ( + ReportStatusPending = "pending" + ReportStatusReady = "ready" + ReportStatusFailed = "failed" + ReportStatusExpired = "expired" +) + +// ReportTypeTransactions: Type of report.. +type ReportTypeTransactions string + +const ( + ReportTypeTransactionsAdjustments = "adjustments" + ReportTypeTransactionsAdjustmentLineItems = "adjustment_line_items" + ReportTypeTransactionsTransactions = "transactions" + ReportTypeTransactionsTransactionLineItems = "transaction_line_items" + ReportTypeTransactionsProductsPrices = "products_prices" + ReportTypeTransactionsDiscounts = "discounts" +) + +// Name: Field name to filter by.. +type ReportsName string + +const ( + ReportsNameAction = "action" + ReportsNameCurrencyCode = "currency_code" + ReportsNameStatus = "status" + ReportsNameUpdatedAt = "updated_at" + ReportsNameCollectionMode = "collection_mode" + ReportsNameOrigin = "origin" + ReportsNameProductStatus = "product_status" + ReportsNamePriceStatus = "price_status" + ReportsNameProductType = "product_type" + ReportsNamePriceType = "price_type" + ReportsNameProductUpdatedAt = "product_updated_at" + ReportsNamePriceUpdatedAt = "price_updated_at" + ReportsNameType = "type" +) + +// Operator: Operator to use when filtering. Valid when filtering by `updated_at`, `null` otherwise.. +type ReportsOperator *string + +const ( + ReportsOperatorLt = "lt" + ReportsOperatorGte = "gte" +) + +// ReportFilters: List of filters applied to this report. +type ReportFilters struct { + // Name: Field name to filter by. + Name string `json:"name,omitempty"` + // Operator: Operator to use when filtering. Valid when filtering by `updated_at`, `null` otherwise. + Operator *string `json:"operator,omitempty"` + // Value: Value to filter by. Check the allowed values descriptions for the `name` field to see valid values for a field. + Value string `json:"value,omitempty"` +} + // Report: Represents a report entity. type Report struct { // ID: Unique Paddle ID for this report, prefixed with `rep_` @@ -105,6 +168,11 @@ type TransactionsReports struct { Filters []ReportsReportsReportFilters `json:"filters,omitempty"` } +// Type: Type of report to create.. +type Type string + +const TypeProductsPrices = "products_prices" + // ReportsReportsReportsReportFilters: Filter criteria for this report. If omitted, reports are filtered to include data updated in the last 30 days. This means `product_updated_at` and `price_updated_at` are greater than or equal to (`gte`) the date 30 days ago from the time the report was generated. type ReportsReportsReportsReportFilters struct { // Name: Field name to filter by. diff --git a/shared.go b/shared.go index d6eea01..a1652b5 100644 --- a/shared.go +++ b/shared.go @@ -519,42 +519,6 @@ type PriceQuantity struct { Maximum int `json:"maximum,omitempty"` } -// Price: Represents a price entity. -type Price struct { - // ID: Unique Paddle ID for this price, prefixed with `pri_`. - ID string `json:"id,omitempty"` - // ProductID: Paddle ID for the product that this price is for, prefixed with `pro_`. - ProductID string `json:"product_id,omitempty"` - // 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 string `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). - 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 string `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. - Quantity PriceQuantity `json:"quantity,omitempty"` - // Status: Whether this entity can be used in Paddle. - Status string `json:"status,omitempty"` - // CustomData: Your own structured key-value data. - 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"` - // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. - CreatedAt string `json:"created_at,omitempty"` - // UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle. - UpdatedAt string `json:"updated_at,omitempty"` -} - // Pagination: Keys used for working with paginated results. type Pagination struct { // PerPage: Number of entities per page for this response. May differ from the number requested if the requested number is greater than the maximum. @@ -575,32 +539,6 @@ type MetaPaginated struct { Pagination Pagination `json:"pagination,omitempty"` } -// Product: Represents a product entity. -type Product struct { - // ID: Unique Paddle ID for this product, prefixed with `pro_`. - ID string `json:"id,omitempty"` - // Name: Name of this product. - Name string `json:"name,omitempty"` - // 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 string `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 string `json:"tax_category,omitempty"` - // ImageURL: Image for this product. Included in the checkout and on some customer documents. - ImageURL *string `json:"image_url,omitempty"` - // CustomData: Your own structured key-value data. - CustomData CustomData `json:"custom_data,omitempty"` - // Status: Whether this entity can be used in Paddle. - Status string `json:"status,omitempty"` - // ImportMeta: Import information for this entity. `null` if this entity is not imported. - ImportMeta *ImportMeta `json:"import_meta,omitempty"` - // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. - CreatedAt string `json:"created_at,omitempty"` - // UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle. - UpdatedAt string `json:"updated_at,omitempty"` -} - // Meta: Information about this response. type Meta struct { // RequestID: Unique ID for the request relating to this response. Provide this when contacting Paddle support about a specific request. @@ -1250,33 +1188,6 @@ type Business struct { ImportMeta *ImportMeta `json:"import_meta,omitempty"` } -// Customer: Customer for this transaction. Returned when the `include` parameter is used with the `customer` value and the transaction has a `customer_id`. -type Customer struct { - // ID: Unique Paddle ID for this customer entity, prefixed with `ctm_`. - ID string `json:"id,omitempty"` - // Name: Full name of this customer. Required when creating transactions where `collection_mode` is `manual` (invoices). - Name *string `json:"name,omitempty"` - // Email: Email address for this customer. - Email string `json:"email,omitempty"` - /* - MarketingConsent: Whether this customer opted into marketing from you. - Set to `true` by Paddle where a customer checks the marketing consent box when using Paddle Checkout; `false` otherwise. - */ - MarketingConsent bool `json:"marketing_consent,omitempty"` - // Status: Whether this entity can be used in Paddle. - Status string `json:"status,omitempty"` - // CustomData: Your own structured key-value data. - CustomData CustomData `json:"custom_data,omitempty"` - // Locale: Valid IETF BCP 47 short form locale tag. If omitted, defaults to `en`. - Locale string `json:"locale,omitempty"` - // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. - CreatedAt string `json:"created_at,omitempty"` - // UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle. - UpdatedAt string `json:"updated_at,omitempty"` - // ImportMeta: Import information for this entity. `null` if this entity is not imported. - ImportMeta *ImportMeta `json:"import_meta,omitempty"` -} - // DiscountStatus: Whether this entity can be used in Paddle. `expired` and `used` are set automatically by Paddle.. type DiscountStatus string @@ -1381,144 +1292,4 @@ type EventType struct { // AvailableVersions: List of API versions that this event type supports. AvailableVersions []int `json:"available_versions,omitempty"` } - -// SubscriptionStatus: Status of this subscription. Set automatically by Paddle. Use the pause subscription or cancel subscription operations to change.. -type SubscriptionStatus string - -const ( - SubscriptionStatusActive = "active" - SubscriptionStatusCanceled = "canceled" - SubscriptionStatusPastDue = "past_due" - SubscriptionStatusPaused = "paused" - SubscriptionStatusTrialing = "trialing" -) - -// SubscriptionDiscount: Details of the discount applied to this subscription. -type SubscriptionDiscount struct { - // ID: Unique Paddle ID for this discount, prefixed with `dsc_`. - ID string `json:"id,omitempty"` - // StartsAt: RFC 3339 datetime string of when this discount was first applied. - StartsAt string `json:"starts_at,omitempty"` - // EndsAt: RFC 3339 datetime string of when this discount no longer applies. Where a discount has `maximum_recurring_intervals`, this is the date of the last billing period where this discount applies. `null` where a discount recurs forever. - EndsAt *string `json:"ends_at,omitempty"` -} - -// ScheduledChangeAction: Kind of change that's scheduled to be applied to this subscription.. -type ScheduledChangeAction string - -const ( - ScheduledChangeActionCancel = "cancel" - ScheduledChangeActionPause = "pause" - ScheduledChangeActionResume = "resume" -) - -// SubscriptionScheduledChange: Change that's scheduled to be applied to a subscription. Use the pause subscription, cancel subscription, and resume subscription operations to create scheduled changes. `null` if no scheduled changes. -type SubscriptionScheduledChange struct { - // Action: Kind of change that's scheduled to be applied to this subscription. - Action string `json:"action,omitempty"` - // EffectiveAt: RFC 3339 datetime string of when this scheduled change takes effect. - EffectiveAt string `json:"effective_at,omitempty"` - // ResumeAt: RFC 3339 datetime string of when a paused subscription should resume. Only used for `pause` scheduled changes. - ResumeAt *string `json:"resume_at,omitempty"` -} - -// SubscriptionItemStatus: Status of this subscription item. Set automatically by Paddle.. -type SubscriptionItemStatus string - -const ( - SubscriptionItemStatusActive = "active" - SubscriptionItemStatusInactive = "inactive" - SubscriptionItemStatusTrialing = "trialing" -) - -// SubscriptionItem: Represents a subscription item. -type SubscriptionItem struct { - // Status: Status of this subscription item. Set automatically by Paddle. - Status string `json:"status,omitempty"` - // Quantity: Quantity of this item on the subscription. - Quantity int `json:"quantity,omitempty"` - // Recurring: Whether this is a recurring item. `false` if one-time. - Recurring bool `json:"recurring,omitempty"` - // CreatedAt: RFC 3339 datetime string of when this item was added to this subscription. - CreatedAt string `json:"created_at,omitempty"` - // UpdatedAt: RFC 3339 datetime string of when this item was last updated on this subscription. - UpdatedAt string `json:"updated_at,omitempty"` - // PreviouslyBilledAt: RFC 3339 datetime string of when this item was last billed. - PreviouslyBilledAt *string `json:"previously_billed_at,omitempty"` - // NextBilledAt: RFC 3339 datetime string of when this item is next scheduled to be billed. - NextBilledAt *string `json:"next_billed_at,omitempty"` - // TrialDates: Trial dates for this item. - TrialDates *TimePeriod `json:"trial_dates,omitempty"` - // Price: Related price entity for this item. This reflects the price entity at the time it was added to the subscription. - Price Price `json:"price,omitempty"` -} - -/* -ReportStatus: Status of this report. Set automatically by Paddle. - -Reports are created as `pending` initially, then move to `ready` when they're available to download.. -*/ -type ReportStatus string - -const ( - ReportStatusPending = "pending" - ReportStatusReady = "ready" - ReportStatusFailed = "failed" - ReportStatusExpired = "expired" -) - -// ReportTypeTransactions: Type of report.. -type ReportTypeTransactions string - -const ( - ReportTypeTransactionsAdjustments = "adjustments" - ReportTypeTransactionsAdjustmentLineItems = "adjustment_line_items" - ReportTypeTransactionsTransactions = "transactions" - ReportTypeTransactionsTransactionLineItems = "transaction_line_items" - ReportTypeTransactionsProductsPrices = "products_prices" - ReportTypeTransactionsDiscounts = "discounts" -) - -// Name: Field name to filter by.. -type SharedName string - -const ( - SharedNameAction = "action" - SharedNameCurrencyCode = "currency_code" - SharedNameStatus = "status" - SharedNameUpdatedAt = "updated_at" - SharedNameCollectionMode = "collection_mode" - SharedNameOrigin = "origin" - SharedNameProductStatus = "product_status" - SharedNamePriceStatus = "price_status" - SharedNameProductType = "product_type" - SharedNamePriceType = "price_type" - SharedNameProductUpdatedAt = "product_updated_at" - SharedNamePriceUpdatedAt = "price_updated_at" - SharedNameType = "type" -) - -// Operator: Operator to use when filtering. Valid when filtering by `updated_at`, `null` otherwise.. -type SharedOperator *string - -const ( - SharedOperatorLt = "lt" - SharedOperatorGte = "gte" -) - -// ReportFilters: List of filters applied to this report. -type ReportFilters struct { - // Name: Field name to filter by. - Name string `json:"name,omitempty"` - // Operator: Operator to use when filtering. Valid when filtering by `updated_at`, `null` otherwise. - Operator *string `json:"operator,omitempty"` - // Value: Value to filter by. Check the allowed values descriptions for the `name` field to see valid values for a field. - Value string `json:"value,omitempty"` -} - -// Type: Type of report to create.. -type Type string - -const TypeProductsPrices = "products_prices" - type CustomData map[string]any diff --git a/subscriptions.go b/subscriptions.go index 4aa1760..84995b0 100644 --- a/subscriptions.go +++ b/subscriptions.go @@ -359,6 +359,46 @@ var ErrSubscriptionManualCollectionModeActivationNotAllowed = &paddleerr.Error{ Type: paddleerr.ErrorTypeRequestError, } +// SubscriptionStatus: Status of this subscription. Set automatically by Paddle. Use the pause subscription or cancel subscription operations to change.. +type SubscriptionStatus string + +const ( + SubscriptionStatusActive = "active" + SubscriptionStatusCanceled = "canceled" + SubscriptionStatusPastDue = "past_due" + SubscriptionStatusPaused = "paused" + SubscriptionStatusTrialing = "trialing" +) + +// SubscriptionDiscount: Details of the discount applied to this subscription. +type SubscriptionDiscount struct { + // ID: Unique Paddle ID for this discount, prefixed with `dsc_`. + ID string `json:"id,omitempty"` + // StartsAt: RFC 3339 datetime string of when this discount was first applied. + StartsAt string `json:"starts_at,omitempty"` + // EndsAt: RFC 3339 datetime string of when this discount no longer applies. Where a discount has `maximum_recurring_intervals`, this is the date of the last billing period where this discount applies. `null` where a discount recurs forever. + EndsAt *string `json:"ends_at,omitempty"` +} + +// ScheduledChangeAction: Kind of change that's scheduled to be applied to this subscription.. +type ScheduledChangeAction string + +const ( + ScheduledChangeActionCancel = "cancel" + ScheduledChangeActionPause = "pause" + ScheduledChangeActionResume = "resume" +) + +// SubscriptionScheduledChange: Change that's scheduled to be applied to a subscription. Use the pause subscription, cancel subscription, and resume subscription operations to create scheduled changes. `null` if no scheduled changes. +type SubscriptionScheduledChange struct { + // Action: Kind of change that's scheduled to be applied to this subscription. + Action string `json:"action,omitempty"` + // EffectiveAt: RFC 3339 datetime string of when this scheduled change takes effect. + EffectiveAt string `json:"effective_at,omitempty"` + // ResumeAt: RFC 3339 datetime string of when a paused subscription should resume. Only used for `pause` scheduled changes. + ResumeAt *string `json:"resume_at,omitempty"` +} + // SubscriptionManagementUrLs: Public URLs that customers can use to make changes to this subscription. For security, the `token` appended to each link is temporary. You shouldn't store these links. type SubscriptionManagementUrLs struct { // UpdatePaymentMethod: Public URL that lets customers update the payment method for this subscription. Creates or gets a transaction that can be used to update a payment method, then passes it to your default checkout page. @@ -367,6 +407,37 @@ type SubscriptionManagementUrLs struct { Cancel string `json:"cancel,omitempty"` } +// SubscriptionItemStatus: Status of this subscription item. Set automatically by Paddle.. +type SubscriptionItemStatus string + +const ( + SubscriptionItemStatusActive = "active" + SubscriptionItemStatusInactive = "inactive" + SubscriptionItemStatusTrialing = "trialing" +) + +// SubscriptionItem: Represents a subscription item. +type SubscriptionItem struct { + // Status: Status of this subscription item. Set automatically by Paddle. + Status string `json:"status,omitempty"` + // Quantity: Quantity of this item on the subscription. + Quantity int `json:"quantity,omitempty"` + // Recurring: Whether this is a recurring item. `false` if one-time. + Recurring bool `json:"recurring,omitempty"` + // CreatedAt: RFC 3339 datetime string of when this item was added to this subscription. + CreatedAt string `json:"created_at,omitempty"` + // UpdatedAt: RFC 3339 datetime string of when this item was last updated on this subscription. + UpdatedAt string `json:"updated_at,omitempty"` + // PreviouslyBilledAt: RFC 3339 datetime string of when this item was last billed. + PreviouslyBilledAt *string `json:"previously_billed_at,omitempty"` + // NextBilledAt: RFC 3339 datetime string of when this item is next scheduled to be billed. + NextBilledAt *string `json:"next_billed_at,omitempty"` + // TrialDates: Trial dates for this item. + TrialDates *TimePeriod `json:"trial_dates,omitempty"` + // Price: Related price entity for this item. This reflects the price entity at the time it was added to the subscription. + Price Price `json:"price,omitempty"` +} + // SubscriptionsTaxRatesUsed: List of tax rates applied to this transaction preview. type SubscriptionsTaxRatesUsed struct { // TaxRate: Rate used to calculate tax for this transaction preview. @@ -443,8 +514,8 @@ type NextTransaction struct { Adjustments []AdjustmentPreview `json:"adjustments,omitempty"` } -// SubscriptionIncludes: Represents a subscription entity with included entities. -type SubscriptionIncludes struct { +// Subscription: Represents a subscription entity with included entities. +type Subscription struct { // ID: Unique Paddle ID for this subscription entity, prefixed with `sub_`. ID string `json:"id,omitempty"` // Status: Status of this subscription. Set automatically by Paddle. Use the pause subscription or cancel subscription operations to change. @@ -546,56 +617,6 @@ const ( SubscriptionOnPaymentFailureApplyChange = "apply_change" ) -// Subscription: Represents a subscription entity. -type Subscription struct { - // ID: Unique Paddle ID for this subscription entity, prefixed with `sub_`. - ID string `json:"id,omitempty"` - // Status: Status of this subscription. Set automatically by Paddle. Use the pause subscription or cancel subscription operations to change. - Status string `json:"status,omitempty"` - // CustomerID: Paddle ID of the customer that this subscription is for, prefixed with `ctm_`. - CustomerID string `json:"customer_id,omitempty"` - // AddressID: Paddle ID of the address that this subscription is for, prefixed with `add_`. - AddressID string `json:"address_id,omitempty"` - // BusinessID: Paddle ID of the business that this subscription is for, prefixed with `biz_`. - BusinessID *string `json:"business_id,omitempty"` - // CurrencyCode: Supported three-letter ISO 4217 currency code. Transactions for this subscription are created in this currency. Must be `USD`, `EUR`, or `GBP` if `collection_mode` is `manual`. - CurrencyCode string `json:"currency_code,omitempty"` - // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. - CreatedAt string `json:"created_at,omitempty"` - // UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle. - UpdatedAt string `json:"updated_at,omitempty"` - // StartedAt: RFC 3339 datetime string of when this subscription started. This may be different from `first_billed_at` if the subscription started in trial. - StartedAt *string `json:"started_at,omitempty"` - // FirstBilledAt: RFC 3339 datetime string of when this subscription was first billed. This may be different from `started_at` if the subscription started in trial. - FirstBilledAt *string `json:"first_billed_at,omitempty"` - // NextBilledAt: RFC 3339 datetime string of when this subscription is next scheduled to be billed. - NextBilledAt *string `json:"next_billed_at,omitempty"` - // PausedAt: RFC 3339 datetime string of when this subscription was paused. Set automatically by Paddle when the pause subscription operation is used. `null` if not paused. - PausedAt *string `json:"paused_at,omitempty"` - // CanceledAt: RFC 3339 datetime string of when this subscription was canceled. Set automatically by Paddle when the cancel subscription operation is used. `null` if not canceled. - CanceledAt *string `json:"canceled_at,omitempty"` - // Discount: Details of the discount applied to this subscription. - Discount *SubscriptionDiscount `json:"discount,omitempty"` - // CollectionMode: How payment is collected for transactions created for this subscription. `automatic` for checkout, `manual` for invoices. - CollectionMode string `json:"collection_mode,omitempty"` - // BillingDetails: Details for invoicing. Required if `collection_mode` is `manual`. - BillingDetails *BillingDetails `json:"billing_details,omitempty"` - // CurrentBillingPeriod: Current billing period for this subscription. Set automatically by Paddle based on the billing cycle. `null` for `paused` and `canceled` subscriptions. - CurrentBillingPeriod *TimePeriod `json:"current_billing_period,omitempty"` - // BillingCycle: How often this subscription renews. Set automatically by Paddle based on the prices on this subscription. - BillingCycle Duration `json:"billing_cycle,omitempty"` - // ScheduledChange: Change that's scheduled to be applied to a subscription. Use the pause subscription, cancel subscription, and resume subscription operations to create scheduled changes. `null` if no scheduled changes. - ScheduledChange *SubscriptionScheduledChange `json:"scheduled_change,omitempty"` - // ManagementURLs: Public URLs that customers can use to make changes to this subscription. For security, the `token` appended to each link is temporary. You shouldn't store these links. - ManagementURLs SubscriptionManagementUrLs `json:"management_urls,omitempty"` - // Items: Represents a subscription item. - Items []SubscriptionItem `json:"items,omitempty"` - // CustomData: Your own structured key-value data. - 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"` -} - type ResumeOnASpecificDate struct { /* EffectiveFrom: When this scheduled change should take effect from. RFC 3339 datetime string of when the subscription should resume. @@ -616,64 +637,6 @@ type ResumeImmediately struct { EffectiveFrom *string `json:"effective_from,omitempty"` } -// Transaction: Represents a transaction entity. -type Transaction struct { - // ID: Unique Paddle ID for this transaction entity, prefixed with `txn_`. - ID string `json:"id,omitempty"` - // Status: Status of this transaction. You may set a transaction to `billed` or `canceled`, other statuses are set automatically by Paddle. Automatically-collected transactions may return `completed` if payment is captured successfully, or `past_due` if payment failed. - Status string `json:"status,omitempty"` - // CustomerID: Paddle ID of the customer that this transaction is for, prefixed with `ctm_`. - CustomerID *string `json:"customer_id,omitempty"` - // AddressID: Paddle ID of the address that this transaction is for, prefixed with `add_`. - AddressID *string `json:"address_id,omitempty"` - // BusinessID: Paddle ID of the business that this transaction is for, prefixed with `biz_`. - BusinessID *string `json:"business_id,omitempty"` - // CustomData: Your own structured key-value data. - CustomData CustomData `json:"custom_data,omitempty"` - // CurrencyCode: Supported three-letter ISO 4217 currency code. Must be `USD`, `EUR`, or `GBP` if `collection_mode` is `manual`. - CurrencyCode string `json:"currency_code,omitempty"` - // Origin: Describes how this transaction was created. - Origin string `json:"origin,omitempty"` - // SubscriptionID: Paddle ID of the subscription that this transaction is for, prefixed with `sub_`. - SubscriptionID *string `json:"subscription_id,omitempty"` - // InvoiceID: Paddle ID of the invoice that this transaction is related to, prefixed with `inv_`. Used for compatibility with the Paddle Invoice API, which is now deprecated. This field is scheduled to be removed in the next version of the Paddle API. - InvoiceID *string `json:"invoice_id,omitempty"` - // InvoiceNumber: Invoice number for this transaction. Automatically generated by Paddle when you mark a transaction as `billed` where `collection_mode` is `manual`. - InvoiceNumber *string `json:"invoice_number,omitempty"` - // CollectionMode: How payment is collected for this transaction. `automatic` for checkout, `manual` for invoices. - CollectionMode string `json:"collection_mode,omitempty"` - // DiscountID: Paddle ID of the discount applied to this transaction, prefixed with `dsc_`. - DiscountID *string `json:"discount_id,omitempty"` - // BillingDetails: Details for invoicing. Required if `collection_mode` is `manual`. - BillingDetails *BillingDetails `json:"billing_details,omitempty"` - // BillingPeriod: Time period that this transaction is for. Set automatically by Paddle for subscription renewals to describe the period that charges are for. - BillingPeriod *TimePeriod `json:"billing_period,omitempty"` - // Items: List of items on this transaction. For calculated totals, use `details.line_items`. - Items []TransactionItem `json:"items,omitempty"` - // Details: Calculated totals for a transaction, including proration, discounts, tax, and currency conversion. Considered the source of truth for totals on a transaction. - Details TransactionDetails `json:"details,omitempty"` - // Payments: List of payment attempts for this transaction, including successful payments. Sorted by `created_at` in descending order, so most recent attempts are returned first. - Payments []TransactionPaymentAttempt `json:"payments,omitempty"` - // Checkout: Paddle Checkout details for this transaction. Returned for automatically-collected transactions and where `billing_details.enable_checkout` is `true` for manually-collected transactions; `null` otherwise. - Checkout *Checkout `json:"checkout,omitempty"` - // CreatedAt: RFC 3339 datetime string of when this entity was created. Set automatically by Paddle. - CreatedAt string `json:"created_at,omitempty"` - // UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle. - UpdatedAt string `json:"updated_at,omitempty"` - // BilledAt: RFC 3339 datetime string of when this transaction was marked as `billed`. `null` for transactions that are not `billed` or `completed`. Set automatically by Paddle. - BilledAt *string `json:"billed_at,omitempty"` - // Customer: Related customer for this transaction. - Customer Customer `json:"customer,omitempty"` - // Address: Related address for this transaction. - Address Address `json:"address,omitempty"` - // Business: Only returned if a business exists for this transaction. - Business Business `json:"business,omitempty"` - // Discount: Only returned if a discount exists for this transaction. - Discount Discount `json:"discount,omitempty"` - // Adjustments: Represents an adjustment entity. - Adjustments []Adjustment `json:"adjustments,omitempty"` -} - // Credit: Details of any credit adjustments. Paddle creates adjustments against existing transactions when prorating. type Credit struct { // Amount: Total of any credit adjustments created for this update. @@ -858,7 +821,7 @@ type GetSubscriptionRequest struct { } // GetSubscription performs the GET operation on a Subscriptions resource. -func (c *SubscriptionsClient) GetSubscription(ctx context.Context, req *GetSubscriptionRequest) (res *SubscriptionIncludes, err error) { +func (c *SubscriptionsClient) GetSubscription(ctx context.Context, req *GetSubscriptionRequest) (res *Subscription, err error) { if err := c.doer.Do(ctx, "GET", "/subscriptions/{subscription_id}", req, &res); err != nil { return nil, err } diff --git a/transactions.go b/transactions.go index a1bb2a6..ef78c41 100644 --- a/transactions.go +++ b/transactions.go @@ -274,8 +274,8 @@ type AdjustmentsTotals struct { CurrencyCode string `json:"currency_code,omitempty"` } -// TransactionIncludes: Represents a transaction entity with included entities. -type TransactionIncludes struct { +// Transaction: Represents a transaction entity with included entities. +type Transaction struct { // ID: Unique Paddle ID for this transaction entity, prefixed with `txn_`. ID string `json:"id,omitempty"` // Status: Status of this transaction. You may set a transaction to `billed` or `canceled`, other statuses are set automatically by Paddle. Automatically-collected transactions may return `completed` if payment is captured successfully, or `past_due` if payment failed. @@ -835,6 +835,10 @@ type ListTransactionsRequest struct { // If set to true, will be included on the response. IncludeAdjustmentsTotals bool `in:"paddle_include=adjustments_totals" json:"-"` + // IncludeAvailablePaymentMethods allows requesting the available_payment_methods sub-resource as part of this request. + // If set to true, will be included on the response. + IncludeAvailablePaymentMethods bool `in:"paddle_include=available_payment_methods" json:"-"` + // IncludeBusiness allows requesting the business sub-resource as part of this request. // If set to true, will be included on the response. IncludeBusiness bool `in:"paddle_include=business" json:"-"` @@ -846,14 +850,10 @@ type ListTransactionsRequest struct { // IncludeDiscount allows requesting the discount sub-resource as part of this request. // If set to true, will be included on the response. IncludeDiscount bool `in:"paddle_include=discount" json:"-"` - - // IncludeAvailablePaymentMethods allows requesting the available_payment_methods sub-resource as part of this request. - // If set to true, will be included on the response. - IncludeAvailablePaymentMethods bool `in:"paddle_include=available_payment_methods" json:"-"` } // ListTransactions performs the GET operation on a Transactions resource. -func (c *TransactionsClient) ListTransactions(ctx context.Context, req *ListTransactionsRequest) (res *Collection[*TransactionIncludes], err error) { +func (c *TransactionsClient) ListTransactions(ctx context.Context, req *ListTransactionsRequest) (res *Collection[*Transaction], err error) { if err := c.doer.Do(ctx, "GET", "/transactions", req, &res); err != nil { return nil, err } @@ -961,6 +961,10 @@ type CreateTransactionRequest struct { // If set to true, will be included on the response. IncludeAdjustmentsTotals bool `in:"paddle_include=adjustments_totals" json:"-"` + // IncludeAvailablePaymentMethods allows requesting the available_payment_methods sub-resource as part of this request. + // If set to true, will be included on the response. + IncludeAvailablePaymentMethods bool `in:"paddle_include=available_payment_methods" json:"-"` + // IncludeBusiness allows requesting the business sub-resource as part of this request. // If set to true, will be included on the response. IncludeBusiness bool `in:"paddle_include=business" json:"-"` @@ -972,14 +976,10 @@ type CreateTransactionRequest struct { // IncludeDiscount allows requesting the discount sub-resource as part of this request. // If set to true, will be included on the response. IncludeDiscount bool `in:"paddle_include=discount" json:"-"` - - // IncludeAvailablePaymentMethods allows requesting the available_payment_methods sub-resource as part of this request. - // If set to true, will be included on the response. - IncludeAvailablePaymentMethods bool `in:"paddle_include=available_payment_methods" json:"-"` } // CreateTransaction performs the POST operation on a Transactions resource. -func (c *TransactionsClient) CreateTransaction(ctx context.Context, req *CreateTransactionRequest) (res *TransactionIncludes, err error) { +func (c *TransactionsClient) CreateTransaction(ctx context.Context, req *CreateTransactionRequest) (res *Transaction, err error) { if err := c.doer.Do(ctx, "POST", "/transactions", req, &res); err != nil { return nil, err } @@ -1065,6 +1065,10 @@ type GetTransactionRequest struct { // If set to true, will be included on the response. IncludeAdjustmentsTotals bool `in:"paddle_include=adjustments_totals" json:"-"` + // IncludeAvailablePaymentMethods allows requesting the available_payment_methods sub-resource as part of this request. + // If set to true, will be included on the response. + IncludeAvailablePaymentMethods bool `in:"paddle_include=available_payment_methods" json:"-"` + // IncludeBusiness allows requesting the business sub-resource as part of this request. // If set to true, will be included on the response. IncludeBusiness bool `in:"paddle_include=business" json:"-"` @@ -1076,14 +1080,10 @@ type GetTransactionRequest struct { // IncludeDiscount allows requesting the discount sub-resource as part of this request. // If set to true, will be included on the response. IncludeDiscount bool `in:"paddle_include=discount" json:"-"` - - // IncludeAvailablePaymentMethods allows requesting the available_payment_methods sub-resource as part of this request. - // If set to true, will be included on the response. - IncludeAvailablePaymentMethods bool `in:"paddle_include=available_payment_methods" json:"-"` } // GetTransaction performs the GET operation on a Transactions resource. -func (c *TransactionsClient) GetTransaction(ctx context.Context, req *GetTransactionRequest) (res *TransactionIncludes, err error) { +func (c *TransactionsClient) GetTransaction(ctx context.Context, req *GetTransactionRequest) (res *Transaction, err error) { if err := c.doer.Do(ctx, "GET", "/transactions/{transaction_id}", req, &res); err != nil { return nil, err } @@ -1190,6 +1190,10 @@ type UpdateTransactionRequest struct { // If set to true, will be included on the response. IncludeAdjustmentsTotals bool `in:"paddle_include=adjustments_totals" json:"-"` + // IncludeAvailablePaymentMethods allows requesting the available_payment_methods sub-resource as part of this request. + // If set to true, will be included on the response. + IncludeAvailablePaymentMethods bool `in:"paddle_include=available_payment_methods" json:"-"` + // IncludeBusiness allows requesting the business sub-resource as part of this request. // If set to true, will be included on the response. IncludeBusiness bool `in:"paddle_include=business" json:"-"` @@ -1201,14 +1205,10 @@ type UpdateTransactionRequest struct { // IncludeDiscount allows requesting the discount sub-resource as part of this request. // If set to true, will be included on the response. IncludeDiscount bool `in:"paddle_include=discount" json:"-"` - - // IncludeAvailablePaymentMethods allows requesting the available_payment_methods sub-resource as part of this request. - // If set to true, will be included on the response. - IncludeAvailablePaymentMethods bool `in:"paddle_include=available_payment_methods" json:"-"` } // UpdateTransaction performs the PATCH operation on a Transactions resource. -func (c *TransactionsClient) UpdateTransaction(ctx context.Context, req *UpdateTransactionRequest) (res *TransactionIncludes, err error) { +func (c *TransactionsClient) UpdateTransaction(ctx context.Context, req *UpdateTransactionRequest) (res *Transaction, err error) { if err := c.doer.Do(ctx, "PATCH", "/transactions/{transaction_id}", req, &res); err != nil { return nil, err }