diff --git a/CHANGELOG.md b/CHANGELOG.md index aaff24d..8420400 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx&utm_medium=paddle-go-sdk) for information about changes to the Paddle Billing platform, the Paddle API, and other developer tools. +## 0.3.0 - 2024-05-27 + +### Breaking changes + +- `Event` and `NotificationsEvent` are now an interfaces. +- `NotificationsEvent` has moved package to `paddlenotification`. + +### Added + +- New `paddlenotification` package. +- Support for `/events` and `/notifications` endpoints. + + ## 0.1.0 - 2024-05-07 ### Added diff --git a/README.md b/README.md index e5255bf..8db59b4 100644 --- a/README.md +++ b/README.md @@ -168,84 +168,84 @@ While in early access, not all operations in the Paddle API are available in our This table shows which operations are available as of the latest release. -| Paddle API operation | Support | -|----------------------------------------------|:-----------:| -| **Products** | **Full** | -| List products | ✅ | -| Create a product | ✅ | -| Get a product | ✅ | -| Update a product | ✅ | -| **Prices** | **Full** | -| List prices | ✅ | -| Create a price | ✅ | -| Get a price | ✅ | -| Update a price | ✅ | -| **Discounts** | **Full** | -| List discounts | ✅ | -| Create a discount | ✅ | -| Get a discount | ✅ | -| Update a discount | ✅ | -| **Customers** | **Full** | -| List customers | ✅ | -| Create a customer | ✅ | -| Get a customer | ✅ | -| Update a customer | ✅ | -| List credit balances for a customer | ✅ | -| **Addresses** | **Full** | -| List addresses for a customer | ✅ | -| Create an addresses for a customer | ✅ | -| Get an address for a customer | ✅ | -| Update an address for a customer | ✅ | -| **Businesses** | ✅ | -| List businesses for a customer | ✅ | -| Create a business for a customer | ✅ | -| Get a business for a customer | ✅ | -| Update a business for a customer | ✅ | -| **Transactions** | **Full** | -| List transactions | ✅ | -| Create a transaction | ✅ | -| Get a transaction | ✅ | -| Update a transaction | ✅ | -| Preview a transaction | ✅ | -| Get a PDF invoice for a transaction | ✅ | -| **Subscriptions** | **Full** | -| List subscriptions | ✅ | -| Get a subscription | ✅ | -| Preview an update to a subscription | ✅ | -| Update a subscription | ✅ | -| Get a transaction to update payment method | ✅ | -| Preview a one-time charge for a subscription | ✅ | -| Create a one-time charge for a subscription | ✅ | -| Activate a trialing subscription | ✅ | -| Pause a subscription | ✅ | -| Resume a paused subscription | ✅ | -| Cancel a subscription | ✅ | -| **Adjustments** | **Full** | -| List adjustments | ✅ | -| Create an adjustment | ✅ | -| **Pricing preview** | **Full** | -| Preview prices | ✅ | -| **Reports** | **Full** | -| List reports | ✅ | -| Create a report | ✅ | -| Get a report | ✅ | -| Get a CSV file for a report | ✅ | -| **Notification settings** | **Full** | -| List notification settings | ✅ | -| Create a notification setting | ✅ | -| Get a notification setting | ✅ | -| Update a notification setting | ✅ | -| Delete a notification setting | ✅ | -| **Event types** | **Full** | -| List event types | ✅ | -| **Events** | **-** | -| List events | - | -| **Notifications** | **Partial** | -| List notifications | - | -| Get a notification | - | -| Replay a notification | ✅ | -| **Notification logs** | **Full** | -| List logs for a notification | ✅ | +| Paddle API operation | Support | +|----------------------------------------------|:--------:| +| **Products** | **Full** | +| List products | ✅ | +| Create a product | ✅ | +| Get a product | ✅ | +| Update a product | ✅ | +| **Prices** | **Full** | +| List prices | ✅ | +| Create a price | ✅ | +| Get a price | ✅ | +| Update a price | ✅ | +| **Discounts** | **Full** | +| List discounts | ✅ | +| Create a discount | ✅ | +| Get a discount | ✅ | +| Update a discount | ✅ | +| **Customers** | **Full** | +| List customers | ✅ | +| Create a customer | ✅ | +| Get a customer | ✅ | +| Update a customer | ✅ | +| List credit balances for a customer | ✅ | +| **Addresses** | **Full** | +| List addresses for a customer | ✅ | +| Create an addresses for a customer | ✅ | +| Get an address for a customer | ✅ | +| Update an address for a customer | ✅ | +| **Businesses** | ✅ | +| List businesses for a customer | ✅ | +| Create a business for a customer | ✅ | +| Get a business for a customer | ✅ | +| Update a business for a customer | ✅ | +| **Transactions** | **Full** | +| List transactions | ✅ | +| Create a transaction | ✅ | +| Get a transaction | ✅ | +| Update a transaction | ✅ | +| Preview a transaction | ✅ | +| Get a PDF invoice for a transaction | ✅ | +| **Subscriptions** | **Full** | +| List subscriptions | ✅ | +| Get a subscription | ✅ | +| Preview an update to a subscription | ✅ | +| Update a subscription | ✅ | +| Get a transaction to update payment method | ✅ | +| Preview a one-time charge for a subscription | ✅ | +| Create a one-time charge for a subscription | ✅ | +| Activate a trialing subscription | ✅ | +| Pause a subscription | ✅ | +| Resume a paused subscription | ✅ | +| Cancel a subscription | ✅ | +| **Adjustments** | **Full** | +| List adjustments | ✅ | +| Create an adjustment | ✅ | +| **Pricing preview** | **Full** | +| Preview prices | ✅ | +| **Reports** | **Full** | +| List reports | ✅ | +| Create a report | ✅ | +| Get a report | ✅ | +| Get a CSV file for a report | ✅ | +| **Notification settings** | **Full** | +| List notification settings | ✅ | +| Create a notification setting | ✅ | +| Get a notification setting | ✅ | +| Update a notification setting | ✅ | +| Delete a notification setting | ✅ | +| **Event types** | **Full** | +| List event types | ✅ | +| **Events** | **Full** | +| List events | ✅ | +| **Notifications** | **Full** | +| List notifications | ✅ | +| Get a notification | ✅ | +| Replay a notification | ✅ | +| **Notification logs** | **Full** | +| List logs for a notification | ✅ | ## Learn more diff --git a/collection.go b/collection.go index 80a515e..e02b9ec 100644 --- a/collection.go +++ b/collection.go @@ -163,8 +163,8 @@ func (c *Collection[T]) UnmarshalJSON(b []byte) error { return nil } - // Unmarshal into an intermediary struct that matches the API response. - var res response.Response[[]T] + // Unmarshal into an intermediary struct with delayed decoding + var res response.Response[[]json.RawMessage] if err := json.Unmarshal(b, &res); err != nil { return err @@ -175,7 +175,22 @@ func (c *Collection[T]) UnmarshalJSON(b []byte) error { c.pos = 0 for _, item := range res.Data { - c.results = append(c.results, &Res[T]{value: item}) + switch any(c).(type) { + case *Collection[Event]: + e, err := unmarshalEvent(item) + if err != nil { + return err + } + + c.results = append(c.results, &Res[T]{value: any(e).(T)}) //nolint:forcetypeassert // we know the type is correct. + default: + var t T + if err := json.Unmarshal(item, &t); err != nil { + return err + } + + c.results = append(c.results, &Res[T]{value: t}) //nolint:forcetypeassert // we know the type is correct. + } } nextURL, err := url.Parse(res.Meta.Pagination.Next) diff --git a/events.go b/events.go index 33043d9..18435a3 100644 --- a/events.go +++ b/events.go @@ -2,10 +2,18 @@ package paddle -import "context" +import ( + "context" + "encoding/json" + paddlenotification "github.com/PaddleHQ/paddle-go-sdk/pkg/paddlenotification" +) // Event: Represents an event entity. -type Event struct { +type Event interface{} + +// GenericEvent is an generic implementation for Event +type GenericEvent struct { + Event // EventID: Unique Paddle ID for this event, prefixed with `evt_`. EventID string `json:"event_id,omitempty"` // EventType: Type of event sent by Paddle, in the format `entity.event_type`. @@ -16,6 +24,363 @@ type Event struct { Data any `json:"data,omitempty"` } +// AddressCreatedEvent represents an Event implementation for address.created event. +type AddressCreatedEvent struct { + GenericEvent + Data paddlenotification.AddressNotification `json:"data"` +} + +// AddressImportedEvent represents an Event implementation for address.imported event. +type AddressImportedEvent struct { + GenericEvent + Data paddlenotification.AddressNotification `json:"data"` +} + +// AddressUpdatedEvent represents an Event implementation for address.updated event. +type AddressUpdatedEvent struct { + GenericEvent + Data paddlenotification.AddressNotification `json:"data"` +} + +// AdjustmentCreatedEvent represents an Event implementation for adjustment.created event. +type AdjustmentCreatedEvent struct { + GenericEvent + Data paddlenotification.AdjustmentNotification `json:"data"` +} + +// AdjustmentUpdatedEvent represents an Event implementation for adjustment.updated event. +type AdjustmentUpdatedEvent struct { + GenericEvent + Data paddlenotification.AdjustmentNotification `json:"data"` +} + +// BusinessCreatedEvent represents an Event implementation for business.created event. +type BusinessCreatedEvent struct { + GenericEvent + Data paddlenotification.BusinessNotification `json:"data"` +} + +// BusinessImportedEvent represents an Event implementation for business.imported event. +type BusinessImportedEvent struct { + GenericEvent + Data paddlenotification.BusinessNotification `json:"data"` +} + +// BusinessUpdatedEvent represents an Event implementation for business.updated event. +type BusinessUpdatedEvent struct { + GenericEvent + Data paddlenotification.BusinessNotification `json:"data"` +} + +// CustomerCreatedEvent represents an Event implementation for customer.created event. +type CustomerCreatedEvent struct { + GenericEvent + Data paddlenotification.CustomerNotification `json:"data"` +} + +// CustomerImportedEvent represents an Event implementation for customer.imported event. +type CustomerImportedEvent struct { + GenericEvent + Data paddlenotification.CustomerNotification `json:"data"` +} + +// CustomerUpdatedEvent represents an Event implementation for customer.updated event. +type CustomerUpdatedEvent struct { + GenericEvent + Data paddlenotification.CustomerNotification `json:"data"` +} + +// DiscountCreatedEvent represents an Event implementation for discount.created event. +type DiscountCreatedEvent struct { + GenericEvent + Data paddlenotification.DiscountNotification `json:"data"` +} + +// DiscountImportedEvent represents an Event implementation for discount.imported event. +type DiscountImportedEvent struct { + GenericEvent + Data paddlenotification.DiscountNotification `json:"data"` +} + +// DiscountUpdatedEvent represents an Event implementation for discount.updated event. +type DiscountUpdatedEvent struct { + GenericEvent + Data paddlenotification.DiscountNotification `json:"data"` +} + +// PayoutCreatedEvent represents an Event implementation for payout.created event. +type PayoutCreatedEvent struct { + GenericEvent + Data paddlenotification.PayoutNotification `json:"data"` +} + +// PayoutPaidEvent represents an Event implementation for payout.paid event. +type PayoutPaidEvent struct { + GenericEvent + Data paddlenotification.PayoutNotification `json:"data"` +} + +// PriceCreatedEvent represents an Event implementation for price.created event. +type PriceCreatedEvent struct { + GenericEvent + Data paddlenotification.PriceNotification `json:"data"` +} + +// PriceImportedEvent represents an Event implementation for price.imported event. +type PriceImportedEvent struct { + GenericEvent + Data paddlenotification.PriceNotification `json:"data"` +} + +// PriceUpdatedEvent represents an Event implementation for price.updated event. +type PriceUpdatedEvent struct { + GenericEvent + Data paddlenotification.PriceNotification `json:"data"` +} + +// ProductCreatedEvent represents an Event implementation for product.created event. +type ProductCreatedEvent struct { + GenericEvent + Data paddlenotification.ProductNotification `json:"data"` +} + +// ProductImportedEvent represents an Event implementation for product.imported event. +type ProductImportedEvent struct { + GenericEvent + Data paddlenotification.ProductNotification `json:"data"` +} + +// ProductUpdatedEvent represents an Event implementation for product.updated event. +type ProductUpdatedEvent struct { + GenericEvent + Data paddlenotification.ProductNotification `json:"data"` +} + +// ReportCreatedEvent represents an Event implementation for report.created event. +type ReportCreatedEvent struct { + GenericEvent + Data paddlenotification.ReportNotification `json:"data"` +} + +// ReportUpdatedEvent represents an Event implementation for report.updated event. +type ReportUpdatedEvent struct { + GenericEvent + Data paddlenotification.ReportNotification `json:"data"` +} + +// SubscriptionActivatedEvent represents an Event implementation for subscription.activated event. +type SubscriptionActivatedEvent struct { + GenericEvent + Data paddlenotification.SubscriptionNotification `json:"data"` +} + +// SubscriptionCanceledEvent represents an Event implementation for subscription.canceled event. +type SubscriptionCanceledEvent struct { + GenericEvent + Data paddlenotification.SubscriptionNotification `json:"data"` +} + +// SubscriptionCreatedEvent represents an Event implementation for subscription.created event. +type SubscriptionCreatedEvent struct { + GenericEvent + Data paddlenotification.SubscriptionCreatedNotification `json:"data"` +} + +// SubscriptionPastDueEvent represents an Event implementation for subscription.past_due event. +type SubscriptionPastDueEvent struct { + GenericEvent + Data paddlenotification.SubscriptionNotification `json:"data"` +} + +// SubscriptionImportedEvent represents an Event implementation for subscription.imported event. +type SubscriptionImportedEvent struct { + GenericEvent + Data paddlenotification.SubscriptionNotification `json:"data"` +} + +// SubscriptionPausedEvent represents an Event implementation for subscription.paused event. +type SubscriptionPausedEvent struct { + GenericEvent + Data paddlenotification.SubscriptionNotification `json:"data"` +} + +// SubscriptionResumedEvent represents an Event implementation for subscription.resumed event. +type SubscriptionResumedEvent struct { + GenericEvent + Data paddlenotification.SubscriptionNotification `json:"data"` +} + +// SubscriptionTrialingEvent represents an Event implementation for subscription.trialing event. +type SubscriptionTrialingEvent struct { + GenericEvent + Data paddlenotification.SubscriptionNotification `json:"data"` +} + +// SubscriptionUpdatedEvent represents an Event implementation for subscription.updated event. +type SubscriptionUpdatedEvent struct { + GenericEvent + Data paddlenotification.SubscriptionNotification `json:"data"` +} + +// TransactionBilledEvent represents an Event implementation for transaction.billed event. +type TransactionBilledEvent struct { + GenericEvent + Data paddlenotification.TransactionNotification `json:"data"` +} + +// TransactionCanceledEvent represents an Event implementation for transaction.canceled event. +type TransactionCanceledEvent struct { + GenericEvent + Data paddlenotification.TransactionNotification `json:"data"` +} + +// TransactionCompletedEvent represents an Event implementation for transaction.completed event. +type TransactionCompletedEvent struct { + GenericEvent + Data paddlenotification.TransactionNotification `json:"data"` +} + +// TransactionCreatedEvent represents an Event implementation for transaction.created event. +type TransactionCreatedEvent struct { + GenericEvent + Data paddlenotification.TransactionNotification `json:"data"` +} + +// TransactionPaidEvent represents an Event implementation for transaction.paid event. +type TransactionPaidEvent struct { + GenericEvent + Data paddlenotification.TransactionNotification `json:"data"` +} + +// TransactionPastDueEvent represents an Event implementation for transaction.past_due event. +type TransactionPastDueEvent struct { + GenericEvent + Data paddlenotification.TransactionNotification `json:"data"` +} + +// TransactionPaymentFailedEvent represents an Event implementation for transaction.payment_failed event. +type TransactionPaymentFailedEvent struct { + GenericEvent + Data paddlenotification.TransactionNotification `json:"data"` +} + +// TransactionReadyEvent represents an Event implementation for transaction.ready event. +type TransactionReadyEvent struct { + GenericEvent + Data paddlenotification.TransactionNotification `json:"data"` +} + +// TransactionUpdatedEvent represents an Event implementation for transaction.updated event. +type TransactionUpdatedEvent struct { + GenericEvent + Data paddlenotification.TransactionNotification `json:"data"` +} + +// unmarshalEvent unmarshals JSON data to the correct Event implementation +func unmarshalEvent(data []byte) (Event, error) { + e := &GenericEvent{} + if err := json.Unmarshal(data, e); err != nil { + return nil, err + } + + var t Event + switch e.EventType { + case "address.created": + t = &AddressCreatedEvent{} + case "address.imported": + t = &AddressImportedEvent{} + case "address.updated": + t = &AddressUpdatedEvent{} + case "adjustment.created": + t = &AdjustmentCreatedEvent{} + case "adjustment.updated": + t = &AdjustmentUpdatedEvent{} + case "business.created": + t = &BusinessCreatedEvent{} + case "business.imported": + t = &BusinessImportedEvent{} + case "business.updated": + t = &BusinessUpdatedEvent{} + case "customer.created": + t = &CustomerCreatedEvent{} + case "customer.imported": + t = &CustomerImportedEvent{} + case "customer.updated": + t = &CustomerUpdatedEvent{} + case "discount.created": + t = &DiscountCreatedEvent{} + case "discount.imported": + t = &DiscountImportedEvent{} + case "discount.updated": + t = &DiscountUpdatedEvent{} + case "payout.created": + t = &PayoutCreatedEvent{} + case "payout.paid": + t = &PayoutPaidEvent{} + case "price.created": + t = &PriceCreatedEvent{} + case "price.imported": + t = &PriceImportedEvent{} + case "price.updated": + t = &PriceUpdatedEvent{} + case "product.created": + t = &ProductCreatedEvent{} + case "product.imported": + t = &ProductImportedEvent{} + case "product.updated": + t = &ProductUpdatedEvent{} + case "report.created": + t = &ReportCreatedEvent{} + case "report.updated": + t = &ReportUpdatedEvent{} + case "subscription.activated": + t = &SubscriptionActivatedEvent{} + case "subscription.canceled": + t = &SubscriptionCanceledEvent{} + case "subscription.created": + t = &SubscriptionCreatedEvent{} + case "subscription.past_due": + t = &SubscriptionPastDueEvent{} + case "subscription.imported": + t = &SubscriptionImportedEvent{} + case "subscription.paused": + t = &SubscriptionPausedEvent{} + case "subscription.resumed": + t = &SubscriptionResumedEvent{} + case "subscription.trialing": + t = &SubscriptionTrialingEvent{} + case "subscription.updated": + t = &SubscriptionUpdatedEvent{} + case "transaction.billed": + t = &TransactionBilledEvent{} + case "transaction.canceled": + t = &TransactionCanceledEvent{} + case "transaction.completed": + t = &TransactionCompletedEvent{} + case "transaction.created": + t = &TransactionCreatedEvent{} + case "transaction.paid": + t = &TransactionPaidEvent{} + case "transaction.past_due": + t = &TransactionPastDueEvent{} + case "transaction.payment_failed": + t = &TransactionPaymentFailedEvent{} + case "transaction.ready": + t = &TransactionReadyEvent{} + case "transaction.updated": + t = &TransactionUpdatedEvent{} + default: + return e, nil + } + + err := json.Unmarshal(data, t) + if err != nil { + return nil, err + } + + return t, nil +} + // EventsClient is a client for the Events resource. type EventsClient struct { doer Doer @@ -43,7 +408,7 @@ type ListEventsRequest struct { } // ListEvents performs the GET operation on a Events resource. -func (c *EventsClient) ListEvents(ctx context.Context, req *ListEventsRequest) (res *Collection[*Event], err error) { +func (c *EventsClient) ListEvents(ctx context.Context, req *ListEventsRequest) (res *Collection[Event], err error) { if err := c.doer.Do(ctx, "GET", "/events", req, &res); err != nil { return nil, err } diff --git a/example_list_events_test.go b/example_list_events_test.go new file mode 100644 index 0000000..71b7828 --- /dev/null +++ b/example_list_events_test.go @@ -0,0 +1,81 @@ +package paddle_test + +import ( + "context" + "encoding/json" + "fmt" + "os" + + paddle "github.com/PaddleHQ/paddle-go-sdk" +) + +// Demonstrates how to fetch a list of events and iterate over the provided results. +func Example_listEvents() { + // Create a mock HTTP server for this example - skip over this bit! + s := mockServerForExample(mockServerResponse{stub: &stub{paths: []stubPath{events}}}) + + // Create a new Paddle client. + client, err := paddle.New( + os.Getenv("PADDLE_API_KEY"), + paddle.WithBaseURL(s.URL), // Uses the mock server, you will not need this in your integration. + ) + + if err != nil { + fmt.Println(err) + return + } + + ctx := context.Background() + + // Optionally set a transit ID on the context. This is useful to link your + // own request IDs to Paddle API requests. + ctx = paddle.ContextWithTransitID(ctx, "sdk-testing-request-1") + + // Get a collection of events. + res, err := client.ListEvents(ctx, &paddle.ListEventsRequest{}) + + // Iterate the events. + err = res.Iter(ctx, func(e paddle.Event) (bool, error) { + switch v := e.(type) { + case *paddle.TransactionCompletedEvent: + // here v could be used as concrete type TransactionCompletedEvent + fmt.Println(v.EventID) + fmt.Println(v.Data.ID) + case *paddle.TransactionUpdatedEvent: + // here v could be used as concrete type TransactionUpdatedEvent + fmt.Println(v.EventID) + fmt.Println(v.Data.ID) + default: + // Unhandled event, we could log and error or covert to GenericEvent + ge, err := toGenericEvent(v) + if err != nil { + return false, err + } + fmt.Println(ge.EventID) + } + + return true, nil + }) + fmt.Println(err) + + // Output: + //evt_01hywqk7y8qfzj69z3pdvz34qt + //txn_01hywqfe6yxhxcsfb4ays8mqt3 + //evt_01hywqfn8b1na40vyarxaxqa9t + //txn_01hywqfervkjg6hkk035wy24gt + //evt_01hv9771tccgcm4y810d8zbceh + // +} + +func toGenericEvent(e paddle.Event) (ge *paddle.GenericEvent, err error) { + t, err := json.Marshal(e) + if err != nil { + return nil, err + } + err = json.Unmarshal(t, &ge) + if err != nil { + return nil, err + } + + return ge, nil +} diff --git a/example_test.go b/example_test.go index 6e2eb56..9fc4ea2 100644 --- a/example_test.go +++ b/example_test.go @@ -9,6 +9,7 @@ import ( type stubPath string const ( + events stubPath = "testdata/events.json" transaction stubPath = "testdata/transaction.json" transactions stubPath = "testdata/transactions.json" transactionsPaginatedPg1 stubPath = "testdata/transactions_paginated_pg1.json" diff --git a/notifications.go b/notifications.go index a1923eb..98f8dab 100644 --- a/notifications.go +++ b/notifications.go @@ -4,7 +4,9 @@ package paddle import ( "context" + "encoding/json" paddleerr "github.com/PaddleHQ/paddle-go-sdk/pkg/paddleerr" + paddlenotification "github.com/PaddleHQ/paddle-go-sdk/pkg/paddlenotification" ) // ErrNotificationMaximumActiveSettingsReached represents a `notification_maximum_active_settings_reached` error. @@ -52,20 +54,6 @@ const ( NotificationStatusFailed = "failed" ) -// NotificationsEvent: Notification payload. Includes the new or changed event. -type NotificationsEvent struct { - // EventID: Unique Paddle ID for this event, prefixed with `evt_`. - EventID string `json:"event_id,omitempty"` - // EventType: Type of event sent by Paddle, in the format `entity.event_type`. - EventType string `json:"event_type,omitempty"` - // OccurredAt: RFC 3339 datetime string of when this event occurred. - OccurredAt string `json:"occurred_at,omitempty"` - // Data: New or changed entity. - Data any `json:"data,omitempty"` - // NotificationID: Unique Paddle ID for this notification, prefixed with `ntf_`. - NotificationID string `json:"notification_id,omitempty"` -} - // Origin: Describes how this notification was created.. type Origin string @@ -83,7 +71,7 @@ type Notification struct { // Status: Status of this notification. Status string `json:"status,omitempty"` // Payload: Notification payload. Includes the new or changed event. - Payload NotificationsEvent `json:"payload,omitempty"` + Payload paddlenotification.NotificationsEvent `json:"payload,omitempty"` // OccurredAt: RFC 3339 datetime string of when this notification occurred. OccurredAt string `json:"occurred_at,omitempty"` // DeliveredAt: RFC 3339 datetime string of when this notification was delivered. `null` if not yet delivered successfully. @@ -102,6 +90,117 @@ type Notification struct { NotificationSettingID string `json:"notification_setting_id,omitempty"` } +// UnmarshalJSON implements the json.Unmarshaler interface for Notification +func (n *Notification) UnmarshalJSON(data []byte) error { + type alias Notification + if err := json.Unmarshal(data, (*alias)(n)); err != nil { + return err + } + + var t paddlenotification.NotificationsEvent + switch n.Type { + case "address.created": + t = &paddlenotification.AddressCreated{} + case "address.imported": + t = &paddlenotification.AddressImported{} + case "address.updated": + t = &paddlenotification.AddressUpdated{} + case "adjustment.created": + t = &paddlenotification.AdjustmentCreated{} + case "adjustment.updated": + t = &paddlenotification.AdjustmentUpdated{} + case "business.created": + t = &paddlenotification.BusinessCreated{} + case "business.imported": + t = &paddlenotification.BusinessImported{} + case "business.updated": + t = &paddlenotification.BusinessUpdated{} + case "customer.created": + t = &paddlenotification.CustomerCreated{} + case "customer.imported": + t = &paddlenotification.CustomerImported{} + case "customer.updated": + t = &paddlenotification.CustomerUpdated{} + case "discount.created": + t = &paddlenotification.DiscountCreated{} + case "discount.imported": + t = &paddlenotification.DiscountImported{} + case "discount.updated": + t = &paddlenotification.DiscountUpdated{} + case "payout.created": + t = &paddlenotification.PayoutCreated{} + case "payout.paid": + t = &paddlenotification.PayoutPaid{} + case "price.created": + t = &paddlenotification.PriceCreated{} + case "price.imported": + t = &paddlenotification.PriceImported{} + case "price.updated": + t = &paddlenotification.PriceUpdated{} + case "product.created": + t = &paddlenotification.ProductCreated{} + case "product.imported": + t = &paddlenotification.ProductImported{} + case "product.updated": + t = &paddlenotification.ProductUpdated{} + case "report.created": + t = &paddlenotification.ReportCreated{} + case "report.updated": + t = &paddlenotification.ReportUpdated{} + case "subscription.activated": + t = &paddlenotification.SubscriptionActivated{} + case "subscription.canceled": + t = &paddlenotification.SubscriptionCanceled{} + case "subscription.created": + t = &paddlenotification.SubscriptionCreated{} + case "subscription.past_due": + t = &paddlenotification.SubscriptionPastDue{} + case "subscription.imported": + t = &paddlenotification.SubscriptionImported{} + case "subscription.paused": + t = &paddlenotification.SubscriptionPaused{} + case "subscription.resumed": + t = &paddlenotification.SubscriptionResumed{} + case "subscription.trialing": + t = &paddlenotification.SubscriptionTrialing{} + case "subscription.updated": + t = &paddlenotification.SubscriptionUpdated{} + case "transaction.billed": + t = &paddlenotification.TransactionBilled{} + case "transaction.canceled": + t = &paddlenotification.TransactionCanceled{} + case "transaction.completed": + t = &paddlenotification.TransactionCompleted{} + case "transaction.created": + t = &paddlenotification.TransactionCreated{} + case "transaction.paid": + t = &paddlenotification.TransactionPaid{} + case "transaction.past_due": + t = &paddlenotification.TransactionPastDue{} + case "transaction.payment_failed": + t = &paddlenotification.TransactionPaymentFailed{} + case "transaction.ready": + t = &paddlenotification.TransactionReady{} + case "transaction.updated": + t = &paddlenotification.TransactionUpdated{} + default: + t = &paddlenotification.GenericNotificationsEvent{} + } + + rawT, err := json.Marshal(n.Payload) + if err != nil { + return err + } + + if err := json.Unmarshal(rawT, t); err != nil { + return err + } + + n.Payload = t + + return nil +} + // NotificationsClient is a client for the Notifications resource. type NotificationsClient struct { doer Doer diff --git a/pkg/paddlenotification/address.go b/pkg/paddlenotification/address.go new file mode 100644 index 0000000..238ecd8 --- /dev/null +++ b/pkg/paddlenotification/address.go @@ -0,0 +1,56 @@ +// Code generated by the Paddle SDK Generator; DO NOT EDIT. + +package paddlenotification + +// AddressCreated represents a address webhook notification entity. +// 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. +// 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. +// See https://developer.paddle.com/webhooks/overview for more information. +type AddressUpdated struct { + GenericNotificationsEvent + Data AddressNotification `json:"data"` +} + +// AddressNotification: New or changed entity. +type AddressNotification 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"` +} diff --git a/pkg/paddlenotification/adjustment.go b/pkg/paddlenotification/adjustment.go new file mode 100644 index 0000000..f9c770f --- /dev/null +++ b/pkg/paddlenotification/adjustment.go @@ -0,0 +1,68 @@ +// 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/business.go b/pkg/paddlenotification/business.go new file mode 100644 index 0000000..ce1e33c --- /dev/null +++ b/pkg/paddlenotification/business.go @@ -0,0 +1,50 @@ +// Code generated by the Paddle SDK Generator; DO NOT EDIT. + +package paddlenotification + +// BusinessCreated represents a business webhook notification entity. +// 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. +// 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. +// See https://developer.paddle.com/webhooks/overview for more information. +type BusinessUpdated struct { + GenericNotificationsEvent + Data BusinessNotification `json:"data"` +} + +// BusinessNotification: New or changed entity. +type BusinessNotification 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"` +} diff --git a/pkg/paddlenotification/customer.go b/pkg/paddlenotification/customer.go new file mode 100644 index 0000000..b7ba2c9 --- /dev/null +++ b/pkg/paddlenotification/customer.go @@ -0,0 +1,51 @@ +// Code generated by the Paddle SDK Generator; DO NOT EDIT. + +package paddlenotification + +// CustomerCreated represents a customer webhook notification entity. +// 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. +// 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. +// See https://developer.paddle.com/webhooks/overview for more information. +type CustomerUpdated struct { + GenericNotificationsEvent + Data CustomerNotification `json:"data"` +} + +// CustomerNotification: New or changed entity. +type CustomerNotification 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"` +} diff --git a/pkg/paddlenotification/discount.go b/pkg/paddlenotification/discount.go new file mode 100644 index 0000000..b2c4a5e --- /dev/null +++ b/pkg/paddlenotification/discount.go @@ -0,0 +1,62 @@ +// Code generated by the Paddle SDK Generator; DO NOT EDIT. + +package paddlenotification + +// DiscountCreated represents a discount webhook notification entity. +// 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. +// 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. +// See https://developer.paddle.com/webhooks/overview for more information. +type DiscountUpdated struct { + GenericNotificationsEvent + Data DiscountNotification `json:"data"` +} + +// DiscountNotification: New or changed entity. +type DiscountNotification 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"` + // 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"` + // 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"` + // 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/notification.go b/pkg/paddlenotification/notification.go new file mode 100644 index 0000000..503ebc2 --- /dev/null +++ b/pkg/paddlenotification/notification.go @@ -0,0 +1,21 @@ +// Code generated by the Paddle SDK Generator; DO NOT EDIT. + +package paddlenotification + +type NotificationsEvent interface{} + +// GenericNotificationsEvent: Notification payload. Includes the new or changed event. +type GenericNotificationsEvent struct { + NotificationsEvent + + // EventID: Unique Paddle ID for this event, prefixed with `evt_`. + EventID string `json:"event_id,omitempty"` + // EventType: Type of event sent by Paddle, in the format `entity.event_type`. + EventType string `json:"event_type,omitempty"` + // OccurredAt: RFC 3339 datetime string of when this event occurred. + OccurredAt string `json:"occurred_at,omitempty"` + // Data: New or changed entity. + Data any `json:"data,omitempty"` + // NotificationID: Unique Paddle ID for this notification, prefixed with `ntf_`. + NotificationID string `json:"notification_id,omitempty"` +} diff --git a/pkg/paddlenotification/payout.go b/pkg/paddlenotification/payout.go new file mode 100644 index 0000000..a5ba556 --- /dev/null +++ b/pkg/paddlenotification/payout.go @@ -0,0 +1,29 @@ +// Code generated by the Paddle SDK Generator; DO NOT EDIT. + +package paddlenotification + +// PayoutCreated represents a payout webhook notification entity. +// 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. +// See https://developer.paddle.com/webhooks/overview for more information. +type PayoutPaid struct { + GenericNotificationsEvent + Data PayoutNotification `json:"data"` +} + +// PayoutNotification: New or changed entity. +type PayoutNotification struct { + // ID: ID for this payout. + ID string `json:"id,omitempty"` + // Status: Status of this payout. + Status string `json:"status,omitempty"` + // Amount: Amount paid, or scheduled to be paid, for this payout. + Amount string `json:"amount,omitempty"` + // CurrencyCode: Three-letter ISO 4217 currency code for this payout. + CurrencyCode string `json:"currency_code,omitempty"` +} diff --git a/pkg/paddlenotification/price.go b/pkg/paddlenotification/price.go new file mode 100644 index 0000000..e3d156d --- /dev/null +++ b/pkg/paddlenotification/price.go @@ -0,0 +1,60 @@ +// Code generated by the Paddle SDK Generator; DO NOT EDIT. + +package paddlenotification + +// PriceCreated represents a price webhook notification entity. +// 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. +// 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. +// See https://developer.paddle.com/webhooks/overview for more information. +type PriceUpdated struct { + GenericNotificationsEvent + Data PriceNotification `json:"data"` +} + +// PriceNotification: Represents a price entity. +type PriceNotification 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"` +} diff --git a/pkg/paddlenotification/product.go b/pkg/paddlenotification/product.go new file mode 100644 index 0000000..44538a6 --- /dev/null +++ b/pkg/paddlenotification/product.go @@ -0,0 +1,50 @@ +// Code generated by the Paddle SDK Generator; DO NOT EDIT. + +package paddlenotification + +// ProductCreated represents a product webhook notification entity. +// 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. +// 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. +// See https://developer.paddle.com/webhooks/overview for more information. +type ProductUpdated struct { + GenericNotificationsEvent + Data ProductNotification `json:"data"` +} + +// ProductNotification: Represents a product entity. +type ProductNotification 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"` +} diff --git a/pkg/paddlenotification/report.go b/pkg/paddlenotification/report.go new file mode 100644 index 0000000..6983d9f --- /dev/null +++ b/pkg/paddlenotification/report.go @@ -0,0 +1,41 @@ +// 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/shared.go b/pkg/paddlenotification/shared.go new file mode 100644 index 0000000..4feda21 --- /dev/null +++ b/pkg/paddlenotification/shared.go @@ -0,0 +1,1414 @@ +// Code generated by the Paddle SDK Generator; DO NOT EDIT. + +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.. +type CountryCode string + +const ( + CountryCodeAD = "AD" + CountryCodeAE = "AE" + CountryCodeAG = "AG" + CountryCodeAI = "AI" + CountryCodeAL = "AL" + CountryCodeAM = "AM" + CountryCodeAO = "AO" + CountryCodeAR = "AR" + CountryCodeAS = "AS" + CountryCodeAT = "AT" + CountryCodeAU = "AU" + CountryCodeAW = "AW" + CountryCodeAX = "AX" + CountryCodeAZ = "AZ" + CountryCodeBA = "BA" + CountryCodeBB = "BB" + CountryCodeBD = "BD" + CountryCodeBE = "BE" + CountryCodeBF = "BF" + CountryCodeBG = "BG" + CountryCodeBH = "BH" + CountryCodeBI = "BI" + CountryCodeBJ = "BJ" + CountryCodeBL = "BL" + CountryCodeBM = "BM" + CountryCodeBN = "BN" + CountryCodeBO = "BO" + CountryCodeBQ = "BQ" + CountryCodeBR = "BR" + CountryCodeBS = "BS" + CountryCodeBT = "BT" + CountryCodeBV = "BV" + CountryCodeBW = "BW" + CountryCodeBZ = "BZ" + CountryCodeCA = "CA" + CountryCodeCC = "CC" + CountryCodeCG = "CG" + CountryCodeCH = "CH" + CountryCodeCI = "CI" + CountryCodeCK = "CK" + CountryCodeCL = "CL" + CountryCodeCM = "CM" + CountryCodeCN = "CN" + CountryCodeCO = "CO" + CountryCodeCR = "CR" + CountryCodeCV = "CV" + CountryCodeCW = "CW" + CountryCodeCX = "CX" + CountryCodeCY = "CY" + CountryCodeCZ = "CZ" + CountryCodeDE = "DE" + CountryCodeDJ = "DJ" + CountryCodeDK = "DK" + CountryCodeDM = "DM" + CountryCodeDO = "DO" + CountryCodeDZ = "DZ" + CountryCodeEC = "EC" + CountryCodeEE = "EE" + CountryCodeEG = "EG" + CountryCodeEH = "EH" + CountryCodeER = "ER" + CountryCodeES = "ES" + CountryCodeET = "ET" + CountryCodeFI = "FI" + CountryCodeFJ = "FJ" + CountryCodeFK = "FK" + CountryCodeFM = "FM" + CountryCodeFO = "FO" + CountryCodeFR = "FR" + CountryCodeGA = "GA" + CountryCodeGB = "GB" + CountryCodeGD = "GD" + CountryCodeGE = "GE" + CountryCodeGF = "GF" + CountryCodeGG = "GG" + CountryCodeGH = "GH" + CountryCodeGI = "GI" + CountryCodeGL = "GL" + CountryCodeGM = "GM" + CountryCodeGN = "GN" + CountryCodeGP = "GP" + CountryCodeGQ = "GQ" + CountryCodeGR = "GR" + CountryCodeGS = "GS" + CountryCodeGT = "GT" + CountryCodeGU = "GU" + CountryCodeGW = "GW" + CountryCodeGY = "GY" + CountryCodeHK = "HK" + CountryCodeHM = "HM" + CountryCodeHN = "HN" + CountryCodeHR = "HR" + CountryCodeHU = "HU" + CountryCodeID = "ID" + CountryCodeIE = "IE" + CountryCodeIL = "IL" + CountryCodeIM = "IM" + CountryCodeIN = "IN" + CountryCodeIO = "IO" + CountryCodeIQ = "IQ" + CountryCodeIS = "IS" + CountryCodeIT = "IT" + CountryCodeJE = "JE" + CountryCodeJM = "JM" + CountryCodeJO = "JO" + CountryCodeJP = "JP" + CountryCodeKE = "KE" + CountryCodeKG = "KG" + CountryCodeKH = "KH" + CountryCodeKI = "KI" + CountryCodeKM = "KM" + CountryCodeKN = "KN" + CountryCodeKR = "KR" + CountryCodeKW = "KW" + CountryCodeKY = "KY" + CountryCodeKZ = "KZ" + CountryCodeLA = "LA" + CountryCodeLB = "LB" + CountryCodeLC = "LC" + CountryCodeLI = "LI" + CountryCodeLK = "LK" + CountryCodeLR = "LR" + CountryCodeLS = "LS" + CountryCodeLT = "LT" + CountryCodeLU = "LU" + CountryCodeLV = "LV" + CountryCodeMA = "MA" + CountryCodeMC = "MC" + CountryCodeMD = "MD" + CountryCodeME = "ME" + CountryCodeMF = "MF" + CountryCodeMG = "MG" + CountryCodeMH = "MH" + CountryCodeMK = "MK" + CountryCodeMN = "MN" + CountryCodeMO = "MO" + CountryCodeMP = "MP" + CountryCodeMQ = "MQ" + CountryCodeMR = "MR" + CountryCodeMS = "MS" + CountryCodeMT = "MT" + CountryCodeMU = "MU" + CountryCodeMV = "MV" + CountryCodeMW = "MW" + CountryCodeMX = "MX" + CountryCodeMY = "MY" + CountryCodeMZ = "MZ" + CountryCodeNA = "NA" + CountryCodeNC = "NC" + CountryCodeNE = "NE" + CountryCodeNF = "NF" + CountryCodeNG = "NG" + CountryCodeNL = "NL" + CountryCodeNO = "NO" + CountryCodeNP = "NP" + CountryCodeNR = "NR" + CountryCodeNU = "NU" + CountryCodeNZ = "NZ" + CountryCodeOM = "OM" + CountryCodePA = "PA" + CountryCodePE = "PE" + CountryCodePF = "PF" + CountryCodePG = "PG" + CountryCodePH = "PH" + CountryCodePK = "PK" + CountryCodePL = "PL" + CountryCodePM = "PM" + CountryCodePN = "PN" + CountryCodePR = "PR" + CountryCodePS = "PS" + CountryCodePT = "PT" + CountryCodePW = "PW" + CountryCodePY = "PY" + CountryCodeQA = "QA" + CountryCodeRE = "RE" + CountryCodeRO = "RO" + CountryCodeRS = "RS" + CountryCodeRW = "RW" + CountryCodeSA = "SA" + CountryCodeSB = "SB" + CountryCodeSC = "SC" + CountryCodeSE = "SE" + CountryCodeSG = "SG" + CountryCodeSH = "SH" + CountryCodeSI = "SI" + CountryCodeSJ = "SJ" + CountryCodeSK = "SK" + CountryCodeSL = "SL" + CountryCodeSM = "SM" + CountryCodeSN = "SN" + CountryCodeSR = "SR" + CountryCodeST = "ST" + CountryCodeSV = "SV" + CountryCodeSX = "SX" + CountryCodeSZ = "SZ" + CountryCodeTC = "TC" + CountryCodeTD = "TD" + CountryCodeTF = "TF" + CountryCodeTG = "TG" + CountryCodeTH = "TH" + CountryCodeTJ = "TJ" + CountryCodeTK = "TK" + CountryCodeTL = "TL" + CountryCodeTM = "TM" + CountryCodeTN = "TN" + CountryCodeTO = "TO" + CountryCodeTR = "TR" + CountryCodeTT = "TT" + CountryCodeTV = "TV" + CountryCodeTW = "TW" + CountryCodeTZ = "TZ" + CountryCodeUA = "UA" + CountryCodeUG = "UG" + CountryCodeUM = "UM" + CountryCodeUS = "US" + CountryCodeUY = "UY" + CountryCodeUZ = "UZ" + CountryCodeVA = "VA" + CountryCodeVC = "VC" + CountryCodeVG = "VG" + CountryCodeVI = "VI" + CountryCodeVN = "VN" + CountryCodeVU = "VU" + CountryCodeWF = "WF" + CountryCodeWS = "WS" + CountryCodeXK = "XK" + CountryCodeYT = "YT" + CountryCodeZA = "ZA" + 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 + +const ( + CollectionModeAutomatic = "automatic" + CollectionModeManual = "manual" +) + +// 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" +) + +// 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. +type TimePeriod struct { + // StartsAt: RFC 3339 datetime string of when this period starts. + StartsAt string `json:"starts_at,omitempty"` + // EndsAt: RFC 3339 datetime string of when this period ends. + 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. +type Proration struct { + // Rate: Rate used to calculate proration. + Rate string `json:"rate,omitempty"` + // BillingPeriod: Billing period that proration is based on. + 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"` +} + +// 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"` +} + +// 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.. +type CurrencyCodePayouts string + +const ( + CurrencyCodePayoutsAUD = "AUD" + CurrencyCodePayoutsCAD = "CAD" + CurrencyCodePayoutsCHF = "CHF" + CurrencyCodePayoutsCNY = "CNY" + CurrencyCodePayoutsCZK = "CZK" + CurrencyCodePayoutsDKK = "DKK" + CurrencyCodePayoutsEUR = "EUR" + CurrencyCodePayoutsGBP = "GBP" + CurrencyCodePayoutsHUF = "HUF" + CurrencyCodePayoutsPLN = "PLN" + CurrencyCodePayoutsSEK = "SEK" + CurrencyCodePayoutsUSD = "USD" + 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 ( + 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 + +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"` +} + +// 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"` +} + +// 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"` +} + +// 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. + 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"` +} + +// 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 + +const ( + DiscountStatusActive = "active" + DiscountStatusArchived = "archived" + DiscountStatusExpired = "expired" + DiscountStatusUsed = "used" +) + +// DiscountType: Type of discount.. +type DiscountType string + +const ( + DiscountTypeFlat = "flat" + DiscountTypeFlatPerSeat = "flat_per_seat" + DiscountTypePercentage = "percentage" +) + +// 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"` +} + +// TransactionSubscriptionPriceCreateWithProductID: Price object for a non-catalog item to charge for. Include a `product_id` to relate this non-catalog price to an existing catalog price. +type TransactionSubscriptionPriceCreateWithProductID struct { + // Description: Internal description for this price, not shown to customers. Typically notes for your team. + Description string `json:"description,omitempty"` + // Name: Name of this price, shown to customers at checkout and on invoices. Typically describes how often the related product bills. + Name *string `json:"name,omitempty"` + // BillingCycle: How often this price should be charged. `null` if price is non-recurring (one-time). + BillingCycle *Duration `json:"billing_cycle,omitempty"` + // TrialPeriod: Trial period for the product related to this price. The billing cycle begins once the trial period is over. `null` for no trial period. Requires `billing_cycle`. + TrialPeriod *Duration `json:"trial_period,omitempty"` + // TaxMode: How tax is calculated for this price. + TaxMode 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. If omitted, defaults to 1-100. + Quantity PriceQuantity `json:"quantity,omitempty"` + // CustomData: Your own structured key-value data. + CustomData CustomData `json:"custom_data,omitempty"` + // ProductID: Paddle ID for the product that this price is for, prefixed with `pro_`. + ProductID string `json:"product_id,omitempty"` +} + +// TransactionSubscriptionProductCreate: Product object for a non-catalog item to charge for. +type TransactionSubscriptionProductCreate struct { + // Name: Name of this product. + 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"` +} + +// TransactionSubscriptionPriceCreateWithProduct: Price object for a non-catalog item to charge for. Include a `product` object to create a non-catalog product for this non-catalog price. +type TransactionSubscriptionPriceCreateWithProduct struct { + // Description: Internal description for this price, not shown to customers. Typically notes for your team. + Description string `json:"description,omitempty"` + // Name: Name of this price, shown to customers at checkout and on invoices. Typically describes how often the related product bills. + Name *string `json:"name,omitempty"` + // BillingCycle: How often this price should be charged. `null` if price is non-recurring (one-time). + BillingCycle *Duration `json:"billing_cycle,omitempty"` + // TrialPeriod: Trial period for the product related to this price. The billing cycle begins once the trial period is over. `null` for no trial period. Requires `billing_cycle`. + TrialPeriod *Duration `json:"trial_period,omitempty"` + // TaxMode: How tax is calculated for this price. + TaxMode 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. If omitted, defaults to 1-100. + Quantity PriceQuantity `json:"quantity,omitempty"` + // CustomData: Your own structured key-value data. + CustomData CustomData `json:"custom_data,omitempty"` + // Product: Product object for a non-catalog item to charge for. + Product TransactionSubscriptionProductCreate `json:"product,omitempty"` +} + +// AddressPreview: Address for this preview. Send one of `address_id`, `customer_ip_address`, or the `address` object when previewing. +type AddressPreview struct { + // PostalCode: ZIP or postal code of this address. Include for more accurate tax calculations. + 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 { + // 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"` +} + +// 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_`. + 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" +) + +// 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/subscription.go new file mode 100644 index 0000000..446c98c --- /dev/null +++ b/pkg/paddlenotification/subscription.go @@ -0,0 +1,164 @@ +// Code generated by the Paddle SDK Generator; DO NOT EDIT. + +package paddlenotification + +// SubscriptionActivated represents a subscription webhook notification entity. +// 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. +// 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. +// 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. +// 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. +// 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. +// 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. +// 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. +// 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. +// See https://developer.paddle.com/webhooks/overview for more information. +type SubscriptionUpdated struct { + GenericNotificationsEvent + Data SubscriptionNotification `json:"data"` +} + +// SubscriptionNotification: New or changed entity. +type SubscriptionNotification 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. + 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"` + // 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"` +} + +// SubscriptionCreatedNotification: New or changed entity. +type SubscriptionCreatedNotification struct { + // ID: Unique Paddle ID for this subscription entity, prefixed with `sub_`. + ID string `json:"id,omitempty"` + // TransactionID: Paddle ID for the transaction entity that resulted in this subscription being created, prefixed with `txn_`. + TransactionID string `json:"transaction_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. + 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"` + // 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"` +} diff --git a/pkg/paddlenotification/transaction.go b/pkg/paddlenotification/transaction.go new file mode 100644 index 0000000..16c9529 --- /dev/null +++ b/pkg/paddlenotification/transaction.go @@ -0,0 +1,114 @@ +// 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/testdata/events.json b/testdata/events.json new file mode 100644 index 0000000..d9b29f6 --- /dev/null +++ b/testdata/events.json @@ -0,0 +1,481 @@ +{ + "data": [ + { + "event_id": "evt_01hywqk7y8qfzj69z3pdvz34qt", + "event_type": "transaction.completed", + "occurred_at": "2024-05-27T09:55:06.825325Z", + "data": { + "id": "txn_01hywqfe6yxhxcsfb4ays8mqt3", + "status": "completed", + "customer_id": "ctm_01hszn72m8kqyqm8g1jxwxc3t3", + "address_id": "add_01hszn72tmh4f90m0940t0vext", + "business_id": null, + "custom_data": null, + "currency_code": "GBP", + "origin": "subscription_recurring", + "subscription_id": "sub_01hszn787vc5vkkdah3rtd4nft", + "invoice_id": "inv_01hywqfhy0nvwg65mdzvc2c9vt", + "invoice_number": "296-173553", + "collection_mode": "automatic", + "discount_id": null, + "billing_details": null, + "billing_period": { + "ends_at": "2024-06-27T09:52:50.189382Z", + "starts_at": "2024-05-27T09:52:50.189382Z" + }, + "items": [ + { + "price": { + "id": "pri_01hszn72dfz9mef1n7f9atmt14", + "name": null, + "type": "standard", + "status": "active", + "quantity": { + "maximum": 100, + "minimum": 1 + }, + "tax_mode": "external", + "created_at": "2024-03-27T09:52:44.975316Z", + "product_id": "pro_01hszn726kxbk7y5mt6trc6at6", + "unit_price": { + "amount": "1000", + "currency_code": "USD" + }, + "updated_at": "2024-03-27T09:52:44.975316Z", + "custom_data": null, + "description": "Monthly price for Product 1", + "trial_period": null, + "billing_cycle": { + "interval": "month", + "frequency": 1 + }, + "unit_price_overrides": [] + }, + "price_id": "pri_01hszn72dfz9mef1n7f9atmt14", + "quantity": 1, + "proration": { + "rate": "1", + "billing_period": { + "ends_at": "2024-06-27T09:52:50.189382Z", + "starts_at": "2024-05-27T09:52:50.189382Z" + } + } + } + ], + "details": { + "totals": { + "fee": "87", + "tax": "158", + "total": "950", + "credit": "0", + "balance": "0", + "discount": "0", + "earnings": "705", + "subtotal": "792", + "grand_total": "950", + "currency_code": "GBP", + "credit_to_balance": "0" + }, + "line_items": [ + { + "id": "txnitm_01hywqfeb1qsrggw6pbg4r8hjt", + "totals": { + "tax": "158", + "total": "950", + "discount": "0", + "subtotal": "792" + }, + "item_id": null, + "product": { + "id": "pro_01hszn726kxbk7y5mt6trc6at6", + "name": "Luxurious Plastic Tuna", + "type": "standard", + "status": "active", + "image_url": "https://via.placeholder.com/100x100/a5afa3/e3bcfb.webp?text=audacia%20conculco%20cimentarius", + "created_at": "2024-03-27T09:52:44.755Z", + "updated_at": "2024-03-27T09:52:44.755Z", + "custom_data": { + "random_key": { + "nested_inside": "value" + } + }, + "description": "The slim & simple Maple Gaming Keyboard from Dev Byte comes with a sleek body and 7- Color RGB LED Back-lighting for smart functionality", + "tax_category": "standard" + }, + "price_id": "pri_01hszn72dfz9mef1n7f9atmt14", + "quantity": 1, + "tax_rate": "0.2", + "proration": { + "rate": "1", + "billing_period": { + "ends_at": "2024-06-27T09:52:50.189382Z", + "starts_at": "2024-05-27T09:52:50.189382Z" + } + }, + "unit_totals": { + "tax": "158", + "total": "950", + "discount": "0", + "subtotal": "792" + } + } + ], + "payout_totals": { + "fee": "87", + "tax": "158", + "total": "950", + "credit": "0", + "balance": "0", + "discount": "0", + "earnings": "705", + "fee_rate": "0.05", + "subtotal": "792", + "grand_total": "950", + "currency_code": "GBP", + "exchange_rate": "1", + "credit_to_balance": "0" + }, + "tax_rates_used": [ + { + "totals": { + "tax": "158", + "total": "950", + "discount": "0", + "subtotal": "792" + }, + "tax_rate": "0.2" + } + ], + "adjusted_totals": { + "fee": "87", + "tax": "158", + "total": "950", + "earnings": "705", + "subtotal": "792", + "grand_total": "950", + "currency_code": "GBP" + } + }, + "payments": [ + { + "amount": "950", + "status": "captured", + "created_at": "2024-05-27T09:53:02.547745Z", + "error_code": null, + "captured_at": "2024-05-27T09:53:04.956177Z", + "method_details": { + "card": { + "type": "visa", + "last4": "4242", + "expiry_year": 2025, + "expiry_month": 3, + "cardholder_name": "Opal Emmerich I" + }, + "type": "card" + }, + "payment_method_id": "paymtd_01hszn74f707vp9q79zc0sgmqt", + "payment_attempt_id": "fa0457ab-71ce-402d-8c3b-417fe5064029", + "stored_payment_method_id": "de368e4d-1b24-4d6e-8a9f-235288aea032" + } + ], + "checkout": { + "url": "https://aeroedit.com/pay?_ptxn=txn_01hywqfe6yxhxcsfb4ays8mqt3" + }, + "created_at": "2024-05-27T09:53:02.392025Z", + "updated_at": "2024-05-27T09:55:06.105983101Z", + "billed_at": "2024-05-27T09:53:02.174288Z", + "receipt_data": null + } + }, + { + "event_id": "evt_01hywqfn8b1na40vyarxaxqa9t", + "event_type": "transaction.updated", + "occurred_at": "2024-05-27T09:53:09.387526Z", + "data": { + "id": "txn_01hywqfervkjg6hkk035wy24gt", + "status": "completed", + "customer_id": "ctm_01hszn65emk81yejv674418f5t", + "address_id": "add_01hszn65ngcse4z4qy3xj9z7at", + "business_id": null, + "custom_data": null, + "currency_code": "GBP", + "origin": "subscription_recurring", + "subscription_id": "sub_01hszn67g1m6xsmv62fdypf6t3", + "invoice_id": "inv_01hywqffqy4bzfs0sdkgxnrbt7", + "invoice_number": "296-173550", + "collection_mode": "manual", + "discount_id": "dsc_01hszn66dvmdaatbhxd7fqbht3", + "billing_details": { + "payment_terms": { + "interval": "day", + "frequency": 1 + }, + "enable_checkout": false, + "purchase_order_number": "ON123", + "additional_information": "foobar" + }, + "billing_period": { + "ends_at": "2024-06-27T09:52:16.382Z", + "starts_at": "2024-05-27T09:52:16.382Z" + }, + "items": [ + { + "price": { + "id": "pri_01hszn667p2p24p7a7ha93cz5t", + "name": null, + "type": "standard", + "status": "active", + "quantity": { + "maximum": 100, + "minimum": 1 + }, + "tax_mode": "external", + "created_at": "2024-03-27T09:52:16.118256Z", + "product_id": "pro_01hszn6612hr6k15wq9zvwhgrt", + "unit_price": { + "amount": "1000", + "currency_code": "USD" + }, + "updated_at": "2024-03-27T09:52:16.118256Z", + "custom_data": null, + "description": "Monthly price for Product 1", + "trial_period": null, + "billing_cycle": { + "interval": "month", + "frequency": 1 + }, + "unit_price_overrides": [] + }, + "price_id": "pri_01hszn667p2p24p7a7ha93cz5t", + "quantity": 1, + "proration": { + "rate": "1", + "billing_period": { + "ends_at": "2024-06-27T09:52:16.382Z", + "starts_at": "2024-05-27T09:52:16.382Z" + } + } + } + ], + "details": { + "totals": { + "fee": "0", + "tax": "0", + "total": "0", + "credit": "0", + "balance": "0", + "discount": "792", + "earnings": "0", + "subtotal": "792", + "grand_total": "0", + "currency_code": "GBP", + "credit_to_balance": "0" + }, + "line_items": [ + { + "id": "txnitm_01hywqff74qe36jtt5cr1q3w83", + "totals": { + "tax": "0", + "total": "0", + "discount": "792", + "subtotal": "792" + }, + "item_id": null, + "product": { + "id": "pro_01hszn6612hr6k15wq9zvwhgrt", + "name": "Recycled Bronze Bike", + "type": "standard", + "status": "active", + "image_url": "https://via.placeholder.com/100x100/bed28f/f295c0.gif?text=tempus%20cultura%20viriliter", + "created_at": "2024-03-27T09:52:15.906Z", + "updated_at": "2024-03-27T09:52:15.906Z", + "custom_data": null, + "description": "New range of formal shirts are designed keeping you in mind. With fits and styling that will make you stand apart", + "tax_category": "standard" + }, + "price_id": "pri_01hszn667p2p24p7a7ha93cz5x", + "quantity": 1, + "tax_rate": "0", + "proration": { + "rate": "1", + "billing_period": { + "ends_at": "2024-06-27T09:52:16.382Z", + "starts_at": "2024-05-27T09:52:16.382Z" + } + }, + "unit_totals": { + "tax": "0", + "total": "0", + "discount": "792", + "subtotal": "792" + } + } + ], + "payout_totals": { + "fee": "0", + "tax": "0", + "total": "0", + "credit": "0", + "balance": "0", + "discount": "792", + "earnings": "0", + "fee_rate": "0", + "subtotal": "792", + "grand_total": "0", + "currency_code": "GBP", + "exchange_rate": "1", + "credit_to_balance": "0" + }, + "tax_rates_used": [ + { + "totals": { + "tax": "0", + "total": "0", + "discount": "792", + "subtotal": "792" + }, + "tax_rate": "0" + } + ], + "adjusted_totals": { + "fee": "0", + "tax": "0", + "total": "0", + "earnings": "0", + "subtotal": "0", + "grand_total": "0", + "currency_code": "GBP" + } + }, + "payments": [], + "checkout": { + "url": null + }, + "created_at": "2024-05-27T09:53:03.234999Z", + "updated_at": "2024-05-27T09:53:08.230133624Z", + "billed_at": "2024-05-27T09:53:02.747946Z", + "receipt_data": null + } + }, + { + "event_id": "evt_01hv9771tccgcm4y810d8zbceh", + "event_type": "subscription.created", + "occurred_at": "2024-04-12T13:16:10.444253Z", + "data": { + "id": "sub_01hv9770y40xzc823155s0z4zz", + "status": "active", + "customer_id": "ctm_01hv976dcgq4wmyrp8yq7asfmj", + "address_id": "add_01hv976dczs1h4a7zym0dn7qam", + "business_id": null, + "currency_code": "USD", + "created_at": "2024-04-12T13:16:09.54Z", + "updated_at": "2024-04-12T13:16:09.54Z", + "started_at": "2024-04-12T13:16:08.821891Z", + "first_billed_at": "2024-04-12T13:16:08.821891Z", + "next_billed_at": "2024-05-12T13:16:08.821891Z", + "paused_at": null, + "canceled_at": null, + "discount": null, + "collection_mode": "automatic", + "billing_details": null, + "current_billing_period": { + "ends_at": "2024-05-12T13:16:08.821891Z", + "starts_at": "2024-04-12T13:16:08.821891Z" + }, + "billing_cycle": { + "interval": "month", + "frequency": 1 + }, + "scheduled_change": null, + "items": [ + { + "price": { + "id": "pri_01gsz8x8sawmvhz1pv30nge1ke", + "name": "Monthly (per seat)", + "type": "standard", + "status": "active", + "quantity": { + "maximum": 999, + "minimum": 1 + }, + "tax_mode": "account_setting", + "created_at": "2023-02-23T13:55:22.538367Z", + "product_id": "pro_01gsz4t5hdjse780zja8vvr7jg", + "unit_price": { + "amount": "3000", + "currency_code": "USD" + }, + "updated_at": "2024-04-11T13:54:52.254748Z", + "custom_data": null, + "description": "Monthly", + "import_meta": null, + "trial_period": null, + "billing_cycle": { + "interval": "month", + "frequency": 1 + }, + "unit_price_overrides": [] + }, + "status": "active", + "quantity": 10, + "recurring": true, + "created_at": "2024-04-12T13:16:09.54Z", + "updated_at": "2024-04-12T13:16:09.54Z", + "trial_dates": null, + "next_billed_at": "2024-05-12T13:16:08.821891Z", + "previously_billed_at": "2024-04-12T13:16:08.821891Z" + }, + { + "price": { + "id": "pri_01h1vjfevh5etwq3rb416a23h2", + "name": "Monthly (recurring addon)", + "type": "standard", + "status": "active", + "quantity": { + "maximum": 100, + "minimum": 1 + }, + "tax_mode": "account_setting", + "created_at": "2023-06-01T13:31:12.625056Z", + "product_id": "pro_01h1vjes1y163xfj1rh1tkfb65", + "unit_price": { + "amount": "10000", + "currency_code": "USD" + }, + "updated_at": "2024-04-12T10:42:45.476453Z", + "custom_data": null, + "description": "Monthly", + "import_meta": null, + "trial_period": null, + "billing_cycle": { + "interval": "month", + "frequency": 1 + }, + "unit_price_overrides": [] + }, + "status": "active", + "quantity": 1, + "recurring": true, + "created_at": "2024-04-12T13:16:09.54Z", + "updated_at": "2024-04-12T13:16:09.54Z", + "trial_dates": null, + "next_billed_at": "2024-05-12T13:16:08.821891Z", + "previously_billed_at": "2024-04-12T13:16:08.821891Z" + } + ], + "custom_data": null, + "transaction_id": "txn_01hv975mbh902hcyb7mks5kt0n", + "import_meta": null + } + } + ], + "meta": { + "request_id": "b93d9c94-c28f-4e5d-af2e-044854d7afe8", + "pagination": { + "per_page": 30, + "next": "https://api.paddle.com/events?after=evt_01hv9771tccgcm4y810d8zbceh", + "has_more": false, + "estimated_total": 3 + } + } +} \ No newline at end of file