diff --git a/go.mod b/go.mod index 663e5c1..62031b9 100644 --- a/go.mod +++ b/go.mod @@ -12,13 +12,13 @@ require ( github.com/labstack/echo/v4 v4.13.4 github.com/labstack/gommon v0.4.2 github.com/rjNemo/underscore v0.8.0 + github.com/stripe/stripe-go/v83 v83.0.0 gorm.io/driver/postgres v1.6.0 gorm.io/gorm v1.31.0 ) require ( github.com/google/go-cmp v0.7.0 // indirect - github.com/stripe/stripe-go/v79 v79.12.0 // indirect github.com/tidwall/gjson v1.18.0 // indirect github.com/tidwall/match v1.2.0 // indirect github.com/tidwall/pretty v1.2.1 // indirect diff --git a/go.sum b/go.sum index e008838..e9355fd 100644 --- a/go.sum +++ b/go.sum @@ -60,8 +60,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/stripe/stripe-go/v79 v79.12.0 h1:HQs/kxNEB3gYA7FnkSFkp0kSOeez0fsmCWev6SxftYs= -github.com/stripe/stripe-go/v79 v79.12.0/go.mod h1:cuH6X0zC8peY6f1AubHwgJ/fJSn2dh5pfiCr6CjyKVU= +github.com/stripe/stripe-go/v83 v83.0.0 h1:00HYu/n80zH6ugy88bWI5sBLbJZ7WmhCXCRQ1N1tuqI= +github.com/stripe/stripe-go/v83 v83.0.0/go.mod h1:nRyDcLrJtwPPQUnKAFs9Bt1NnQvNhNiF6V19XHmPISE= github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= @@ -81,23 +81,17 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI= golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8= -golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I= golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY= golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= golang.org/x/time v0.13.0 h1:eUlYslOIt32DgYD6utsuUeHs4d7AsEYLuIAdg7FlYgI= golang.org/x/time v0.13.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/internal/driver/stripe/client.go b/internal/driver/stripe/client.go index 6b768ed..299cb17 100644 --- a/internal/driver/stripe/client.go +++ b/internal/driver/stripe/client.go @@ -8,8 +8,7 @@ import ( "strings" "time" - stripe "github.com/stripe/stripe-go/v79" - stripeclient "github.com/stripe/stripe-go/v79/client" + "github.com/stripe/stripe-go/v83" ) // Option configures a Client instance. @@ -25,7 +24,7 @@ func WithAccount(account string) Option { // Client wraps Stripe's SDK to expose the subset of functionality needed by the // application while keeping the rest of the codebase decoupled from the SDK. type Client struct { - api *stripeclient.API + api *stripe.Client account string } @@ -36,7 +35,7 @@ func New(secretKey string, opts ...Option) (*Client, error) { return nil, errors.New("stripe secret key is required") } - api := stripeclient.New(trimmed, nil) + api := stripe.NewClient(trimmed) client := &Client{api: api} for _, opt := range opts { opt(client) @@ -103,20 +102,24 @@ func (c *Client) ListPayments(ctx context.Context, params ListPaymentsParams) ([ listParams.SetStripeAccount(c.account) } - iter := c.api.PaymentIntents.List(listParams) + seq := c.api.V1PaymentIntents.List(ctx, listParams) payments := make([]Payment, 0) + var listErr error - for iter.Next() { - pi := iter.PaymentIntent() - if pi == nil { - continue + seq(func(pi *stripe.PaymentIntent, err error) bool { + if err != nil { + listErr = err + return false + } + if pi == nil { + return true } - payments = append(payments, NormalizePaymentIntent(pi)) - } + return true + }) - if err := iter.Err(); err != nil { - return nil, fmt.Errorf("stripe payment intents iteration failed: %w", err) + if listErr != nil { + return nil, fmt.Errorf("stripe payment intents iteration failed: %w", listErr) } return payments, nil diff --git a/internal/server/handle_stripe_webhook.go b/internal/server/handle_stripe_webhook.go index 6f6d160..b8fe9fc 100644 --- a/internal/server/handle_stripe_webhook.go +++ b/internal/server/handle_stripe_webhook.go @@ -7,8 +7,8 @@ import ( "net/http" "github.com/labstack/echo/v4" - stripe "github.com/stripe/stripe-go/v79" - "github.com/stripe/stripe-go/v79/webhook" + "github.com/stripe/stripe-go/v83" + "github.com/stripe/stripe-go/v83/webhook" ) type stripeEventService interface { diff --git a/internal/server/handle_stripe_webhook_test.go b/internal/server/handle_stripe_webhook_test.go index 28153aa..4831c4a 100644 --- a/internal/server/handle_stripe_webhook_test.go +++ b/internal/server/handle_stripe_webhook_test.go @@ -12,8 +12,8 @@ import ( "time" "github.com/labstack/echo/v4" - stripe "github.com/stripe/stripe-go/v79" - "github.com/stripe/stripe-go/v79/webhook" + "github.com/stripe/stripe-go/v83" + "github.com/stripe/stripe-go/v83/webhook" ) type stubStripeEventService struct { diff --git a/internal/service/booking/stripe_webhook.go b/internal/service/booking/stripe_webhook.go index e3d9dc4..6c30028 100644 --- a/internal/service/booking/stripe_webhook.go +++ b/internal/service/booking/stripe_webhook.go @@ -7,7 +7,7 @@ import ( "math" "strings" - stripe "github.com/stripe/stripe-go/v79" + "github.com/stripe/stripe-go/v83" "gorm.io/gorm" stripeclient "github.com/rjNemo/rentease/internal/driver/stripe" diff --git a/internal/service/booking/stripe_webhook_test.go b/internal/service/booking/stripe_webhook_test.go index 3b75a00..c9a89bc 100644 --- a/internal/service/booking/stripe_webhook_test.go +++ b/internal/service/booking/stripe_webhook_test.go @@ -6,7 +6,7 @@ import ( "log/slog" "testing" - stripe "github.com/stripe/stripe-go/v79" + "github.com/stripe/stripe-go/v83" "github.com/rjNemo/rentease/internal/config" ) diff --git a/thoughts/shared/plans/2025-10-03-stripe-payment-sync.md b/thoughts/shared/plans/2025-10-03-stripe-payment-sync.md index ff1102e..bff8ed4 100644 --- a/thoughts/shared/plans/2025-10-03-stripe-payment-sync.md +++ b/thoughts/shared/plans/2025-10-03-stripe-payment-sync.md @@ -95,7 +95,7 @@ Introduce Stripe SDK usage, configuration, and a service method to fetch payment ### Changes Required **File**: `go.mod` -**Changes**: Add `github.com/stripe/stripe-go/v79` dependency (or latest version) plus `go mod tidy`. +**Changes**: Add `github.com/stripe/stripe-go/v83` dependency (or latest version) plus `go mod tidy`. **File**: `internal/config/config.go` **Changes**: Add fields `StripeSecretKey`, `StripeWebhookSecret`, optional `StripeConnectAccount` (if needed). Update env tags and documentation. diff --git a/thoughts/shared/research/2025-10-03-stripe-payment-sync.md b/thoughts/shared/research/2025-10-03-stripe-payment-sync.md index 69b8909..1a80f01 100644 --- a/thoughts/shared/research/2025-10-03-stripe-payment-sync.md +++ b/thoughts/shared/research/2025-10-03-stripe-payment-sync.md @@ -30,7 +30,7 @@ background or on-demand sync routines, and unauthenticated webhook endpoints sec by Stripe signatures. Key integration hooks include the booking service (for upserting payments), the repository layer (for queries and uniqueness), the server router (to host webhooks), and the cron command (for scheduled backfills). -The implementation relies on `github.com/stripe/stripe-go/v79` (currently pinned at v79.12.0). +The implementation relies on `github.com/stripe/stripe-go/v83` (currently pinned at v83.0.0). ## Detailed Findings