Skip to content

Commit

Permalink
fix(stripe): fix issues when making payouts and transfers using root …
Browse files Browse the repository at this point in the history
…account (#307)

* fix(stripe): use authenticated client when making payouts

* fix(stripe): allow nil account object for stripe transfers using implied root account
  • Loading branch information
laouji authored Feb 4, 2025
1 parent 4bb2363 commit 1fc4a78
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 1 addition & 2 deletions internal/connectors/plugins/public/stripe/client/payouts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/formancehq/payments/internal/connectors/metrics"
"github.com/stripe/stripe-go/v79"
"github.com/stripe/stripe-go/v79/payout"
)

type CreatePayoutRequest struct {
Expand Down Expand Up @@ -41,7 +40,7 @@ func (c *client) CreatePayout(ctx context.Context, createPayoutRequest *CreatePa
params.Description = stripe.String(createPayoutRequest.Description)
}

payoutResponse, err := payout.New(params)
payoutResponse, err := c.payoutClient.New(params)
if err != nil {
return nil, wrapSDKErr(err)
}
Expand Down
3 changes: 3 additions & 0 deletions internal/models/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ func FromPSPAccounts(from []PSPAccount, accountType AccountType, connectorID Con
}

func ToPSPAccount(from *Account) *PSPAccount {
if from == nil {
return nil
}
return &PSPAccount{
Reference: from.Reference,
CreatedAt: from.CreatedAt,
Expand Down
12 changes: 12 additions & 0 deletions internal/models/accounts_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package models

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestToPSPAccount(t *testing.T) {
assert.Nil(t, ToPSPAccount(nil))
assert.NotNil(t, ToPSPAccount(&Account{}))
}

0 comments on commit 1fc4a78

Please sign in to comment.