fixed settlement flow

This commit is contained in:
Stephan D
2026-01-19 15:26:34 +01:00
parent 0b2a13feff
commit 069ff6b26b

View File

@@ -46,11 +46,33 @@ func (p *paymentExecutor) buildProviderSettlementTransferRequest(payment *model.
if strings.TrimSpace(metadata[providerSettlementMetaOutgoingLeg]) == "" {
metadata[providerSettlementMetaOutgoingLeg] = strings.ToLower(strings.TrimSpace(string(step.Rail)))
}
sourceWalletRef := ""
if payment.Intent.Source.ManagedWallet != nil {
sourceWalletRef = strings.TrimSpace(payment.Intent.Source.ManagedWallet.ManagedWalletRef)
}
if sourceWalletRef == "" {
return rail.TransferRequest{}, merrors.InvalidArgument("provider settlement: source managed wallet is required")
}
destRef := ""
if payment.Intent.Destination.Type == model.EndpointTypeCard {
if route, err := p.resolveCardRoute(payment.Intent); err == nil {
destRef = strings.TrimSpace(route.FundingAddress)
}
}
if destRef == "" {
destRef = paymentRef
}
return rail.TransferRequest{
OrganizationRef: payment.OrganizationRef.Hex(),
FromAccountID: sourceWalletRef,
ToAccountID: destRef,
Currency: strings.TrimSpace(amount.GetCurrency()),
Amount: strings.TrimSpace(amount.GetAmount()),
IdempotencyKey: requestID,
DestinationMemo: paymentRef,
Metadata: metadata,
ClientReference: paymentRef,
}, nil