fixed settlement flow #276
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user