fixed settlement flow #276

Merged
tech merged 1 commits from settlement-275 into main 2026-01-19 14:27:02 +00:00

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