Skip to content

Commit 696c887

Browse files
committed
fixed after merge
1 parent cdd3280 commit 696c887

2 files changed

Lines changed: 23 additions & 13 deletions

File tree

apps/hellgate/src/hg_invoice_payment.erl

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,6 +1963,7 @@ process_routing(Action, St) ->
19631963
%% accounted for in `St`.
19641964
NewIter = get_iter(St) + 1,
19651965
FilterFuns = [
1966+
fun(Result) -> filter_routes_by_recurrent_tokens(Result, St) end,
19661967
fun(Result) -> filter_attempted_routes(Result, St) end,
19671968
fun(Result) -> filter_routes_with_limit_hold(Result, VS, NewIter, St) end,
19681969
fun(Result) -> filter_routes_by_limit_overflow(Result, VS, NewIter, St) end,
@@ -2038,6 +2039,10 @@ route_args(St) ->
20382039
PaymentInstitution = hg_payment_institution:compute_payment_institution(PaymentInstitutionRef, VS1, Revision),
20392040
{PaymentInstitution, VS3, Revision}.
20402041

2042+
get_routes(PaymentInstitution, VS, Revision, #st{cascade_recurrent_tokens = CascadeTokens} = St) when
2043+
CascadeTokens =/= undefined
2044+
->
2045+
get_routes_(PaymentInstitution, VS, Revision, St);
20412046
get_routes(PaymentInstitution, VS, Revision, St) ->
20422047
Payer = get_payment_payer(St),
20432048
case get_predefined_route(Payer) of
@@ -2066,26 +2071,28 @@ filter_attempted_routes(Result, #st{routes = AttemptedRoutes}) ->
20662071
),
20672072
hg_routing_ctx:append_rejected_routes(already_attempted, AcceptedRoutes, RejectedRoutes, Result).
20682073

2069-
filter_routes_by_recurrent_tokens(Ctx, #st{cascade_recurrent_tokens = undefined}) ->
2070-
Ctx;
2071-
filter_routes_by_recurrent_tokens(Ctx, #st{cascade_recurrent_tokens = Tokens}) ->
2072-
lists:foldl(
2073-
fun(Route, C) ->
2074+
filter_routes_by_recurrent_tokens(Result0, #st{cascade_recurrent_tokens = undefined}) ->
2075+
Result0;
2076+
filter_routes_by_recurrent_tokens(Result0, #st{cascade_recurrent_tokens = Tokens}) ->
2077+
Routes = hg_routing_ctx:candidates(Result0),
2078+
{AcceptedRoutes, RejectedRoutes} = lists:foldr(
2079+
fun(Route, {AcceptedAcc, RejectedAcc}) ->
20742080
Key = #customer_ProviderTerminalKey{
20752081
provider_ref = hg_route:provider_ref(Route),
20762082
terminal_ref = hg_route:terminal_ref(Route)
20772083
},
20782084
case maps:is_key(Key, Tokens) of
20792085
true ->
2080-
C;
2086+
{[Route | AcceptedAcc], RejectedAcc};
20812087
false ->
2082-
RejectedRoute = hg_route:to_rejected_route(Route, {recurrent_token_missing, undefined}),
2083-
hg_routing_ctx:reject(recurrent_token_missing, RejectedRoute, C)
2088+
RejectedRoute = hg_route:set_rejection_reason({recurrent_token_missing, undefined}, Route),
2089+
{AcceptedAcc, [RejectedRoute | RejectedAcc]}
20842090
end
20852091
end,
2086-
Ctx,
2087-
hg_routing_ctx:candidates(Ctx)
2088-
).
2092+
{[], []},
2093+
Routes
2094+
),
2095+
hg_routing_ctx:append_rejected_routes(recurrent_token_missing, AcceptedRoutes, RejectedRoutes, Result0).
20892096

20902097
handle_choose_route_error(Error, Events, St, Action) ->
20912098
Failure = construct_routing_failure(Error),
@@ -3685,7 +3692,10 @@ get_limit_values(St, Opts) ->
36853692

36863693
get_limit_values_(St, Mode) ->
36873694
{PaymentInstitution, VS, Revision} = route_args(St),
3688-
#{routes := Routes} = get_routes(PaymentInstitution, VS, Revision, St),
3695+
#{routes := Routes0} = get_routes(PaymentInstitution, VS, Revision, St),
3696+
Routes = hg_routing_ctx:candidates(
3697+
filter_routes_by_recurrent_tokens(hg_routing_ctx:new(Routes0), St)
3698+
),
36893699
Session = get_activity_session(St),
36903700
Payment = get_payment(St),
36913701
Invoice = get_invoice(get_opts(St)),

apps/routing/src/hg_route_collector.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
fill_blacklist(_BlCtx, []) ->
5959
[];
6060
fill_blacklist(BlCtx, [Route]) ->
61-
hg_inspector:fill_blacklist(Route, BlCtx);
61+
[hg_inspector:fill_blacklist(Route, BlCtx)];
6262
fill_blacklist(BlCtx, Routes) ->
6363
HgContext = hg_context:load(),
6464
try

0 commit comments

Comments
 (0)