Files
payments/internal/models/plugin_psp.go
Paul NicolasandGitHub d66040c0eb feat(*): add plaid bank bridge connector and boilerplate (#499)
* feat(models): add bank bridge models

* feat(storage): add bank bridge migrations and functions

* feat(engine): add bank bridge workflows

* feat(connectors): add plaid bank bridge connector

* feat(events): add bank bridge events

* feat(api): add bank bridge router

* feat(*): bank bridge boilerplate

* fix nil pointer crash

* add more check when getting link attempts + change enum

* fix tests

* remove print

* fixes after reviews

* add specific table for access tokens

* fixes after reviews

* fix go mod tidy

* remove indexes + null default

* plaid: add tests

* *: add more tests

* fix after rebase
2025-07-30 13:44:31 +00:00

163 lines
4.5 KiB
Go

package models
import (
"context"
"encoding/json"
)
type PSPPlugin interface {
FetchNextAccounts(context.Context, FetchNextAccountsRequest) (FetchNextAccountsResponse, error)
FetchNextPayments(context.Context, FetchNextPaymentsRequest) (FetchNextPaymentsResponse, error)
FetchNextBalances(context.Context, FetchNextBalancesRequest) (FetchNextBalancesResponse, error)
FetchNextExternalAccounts(context.Context, FetchNextExternalAccountsRequest) (FetchNextExternalAccountsResponse, error)
FetchNextOthers(context.Context, FetchNextOthersRequest) (FetchNextOthersResponse, error)
CreateBankAccount(context.Context, CreateBankAccountRequest) (CreateBankAccountResponse, error)
CreateTransfer(context.Context, CreateTransferRequest) (CreateTransferResponse, error)
ReverseTransfer(context.Context, ReverseTransferRequest) (ReverseTransferResponse, error)
PollTransferStatus(context.Context, PollTransferStatusRequest) (PollTransferStatusResponse, error)
CreatePayout(context.Context, CreatePayoutRequest) (CreatePayoutResponse, error)
ReversePayout(context.Context, ReversePayoutRequest) (ReversePayoutResponse, error)
PollPayoutStatus(context.Context, PollPayoutStatusRequest) (PollPayoutStatusResponse, error)
}
type FetchNextAccountsRequest struct {
FromPayload json.RawMessage
State json.RawMessage
PageSize int
}
type FetchNextAccountsResponse struct {
Accounts []PSPAccount
NewState json.RawMessage
HasMore bool
}
type FetchNextExternalAccountsRequest struct {
FromPayload json.RawMessage
State json.RawMessage
PageSize int
}
type FetchNextExternalAccountsResponse struct {
ExternalAccounts []PSPAccount
NewState json.RawMessage
HasMore bool
}
type FetchNextPaymentsRequest struct {
FromPayload json.RawMessage
State json.RawMessage
PageSize int
}
type FetchNextPaymentsResponse struct {
Payments []PSPPayment
PaymentsToDelete []PSPPaymentsToDelete
NewState json.RawMessage
HasMore bool
}
type FetchNextOthersRequest struct {
Name string
FromPayload json.RawMessage
State json.RawMessage
PageSize int
}
type FetchNextOthersResponse struct {
Others []PSPOther
NewState json.RawMessage
HasMore bool
}
type FetchNextBalancesRequest struct {
FromPayload json.RawMessage
State json.RawMessage
PageSize int
}
type FetchNextBalancesResponse struct {
Balances []PSPBalance
NewState json.RawMessage
HasMore bool
}
type CreateBankAccountRequest struct {
BankAccount BankAccount
}
type CreateBankAccountResponse struct {
RelatedAccount PSPAccount
}
type CreateTransferRequest struct {
PaymentInitiation PSPPaymentInitiation
}
type CreateTransferResponse struct {
// If payment is immediately available, it will be return here and
// the workflow will be terminated
Payment *PSPPayment
// Otherwise, the payment will be nil and the transfer ID will be returned
// to be polled regularly until the payment is available
PollingTransferID *string
}
type ReverseTransferRequest struct {
PaymentInitiationReversal PSPPaymentInitiationReversal
}
type ReverseTransferResponse struct {
Payment PSPPayment
}
type PollTransferStatusRequest struct {
TransferID string
}
type PollTransferStatusResponse struct {
// If nil, the payment is not yet available and the function will be called
// again later
// If not, the payment is available and the workflow will be terminated
Payment *PSPPayment
// If not nil, it means that the transfer failed, the payment initiation
// will be marked as fail and the workflow will be terminated
Error *string
}
type CreatePayoutRequest struct {
PaymentInitiation PSPPaymentInitiation
}
type CreatePayoutResponse struct {
// If payment is immediately available, it will be return here and
// the workflow will be terminated
Payment *PSPPayment
// Otherwise, the payment will be nil and the payout ID will be returned
// to be polled regularly until the payment is available
PollingPayoutID *string
}
type ReversePayoutRequest struct {
PaymentInitiationReversal PSPPaymentInitiationReversal
}
type ReversePayoutResponse struct {
Payment PSPPayment
}
type PollPayoutStatusRequest struct {
PayoutID string
}
type PollPayoutStatusResponse struct {
// If nil, the payment is not yet available and the function will be called
// again later
// If not, the payment is available and the workflow will be terminated
Payment *PSPPayment
// If not nil, it means that the payout failed, the payment initiation
// will be marked as fail and the workflow will be terminated
Error *string
}