-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(*): add transfer and payout creation
- Loading branch information
1 parent
3acdf8f
commit 635952a
Showing
102 changed files
with
6,294 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ coverage.out | |
dist/ | ||
.env | ||
payments | ||
tools/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
internal/api/services/payment_initiation_adjustments_get.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package services | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/formancehq/go-libs/bun/bunpaginate" | ||
"github.com/formancehq/payments/internal/models" | ||
"github.com/formancehq/payments/internal/storage" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
func (s *Service) PaymentInitiationAdjustmentsGetLast(ctx context.Context, id models.PaymentInitiationID) (*models.PaymentInitiationAdjustment, error) { | ||
q := storage.NewListPaymentInitiationAdjustmentsQuery( | ||
bunpaginate.NewPaginatedQueryOptions(storage.PaymentInitiationAdjustmentsQuery{}). | ||
WithPageSize(1), | ||
) | ||
|
||
cursor, err := s.storage.PaymentInitiationAdjustmentsList(ctx, id, q) | ||
if err != nil { | ||
return nil, newStorageError(err, "cannot list payment initiation's adjustments") | ||
} | ||
|
||
if len(cursor.Data) == 0 { | ||
return nil, errors.New("payment initiation's adjustments not found") | ||
} | ||
|
||
return &cursor.Data[0], nil | ||
} |
44 changes: 44 additions & 0 deletions
44
internal/api/services/payment_initiation_adjustments_list.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package services | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/formancehq/go-libs/bun/bunpaginate" | ||
"github.com/formancehq/payments/internal/models" | ||
"github.com/formancehq/payments/internal/storage" | ||
) | ||
|
||
func (s *Service) PaymentInitiationAdjustmentsList(ctx context.Context, id models.PaymentInitiationID, query storage.ListPaymentInitiationAdjustmentsQuery) (*bunpaginate.Cursor[models.PaymentInitiationAdjustment], error) { | ||
cursor, err := s.storage.PaymentInitiationAdjustmentsList(ctx, id, query) | ||
return cursor, newStorageError(err, "failed to list payment initiation adjustments") | ||
} | ||
|
||
func (s *Service) PaymentInitiationAdjustmentsListAll(ctx context.Context, id models.PaymentInitiationID) ([]models.PaymentInitiationAdjustment, error) { | ||
q := storage.NewListPaymentInitiationAdjustmentsQuery( | ||
bunpaginate.NewPaginatedQueryOptions(storage.PaymentInitiationAdjustmentsQuery{}). | ||
WithPageSize(50), | ||
) | ||
var next string | ||
adjustments := []models.PaymentInitiationAdjustment{} | ||
for { | ||
if next != "" { | ||
err := bunpaginate.UnmarshalCursor(next, &q) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
cursor, err := s.storage.PaymentInitiationAdjustmentsList(ctx, id, q) | ||
if err != nil { | ||
return nil, newStorageError(err, "cannot list payment initiation's adjustments") | ||
} | ||
|
||
adjustments = append(adjustments, cursor.Data...) | ||
|
||
if cursor.Next == "" { | ||
break | ||
} | ||
} | ||
|
||
return adjustments, nil | ||
} |
Oops, something went wrong.