mirror of
https://github.com/valitydev/hellgate.git
synced 2024-11-06 02:45:20 +00:00
IMP-202: Add new pins (#122)
* IMP-202: Add new pins * Fix * Fix * Fix test * Fix specs and test * cleanup
This commit is contained in:
parent
5c02fe6ce0
commit
55899c876c
@ -767,15 +767,17 @@ gather_routes(PaymentInstitution, VS, Revision, St) ->
|
||||
Payment = get_payment(St),
|
||||
Predestination = choose_routing_predestination(Payment),
|
||||
#domain_Cash{currency = Currency} = get_payment_cost(Payment),
|
||||
PartyID = Payment#domain_InvoicePayment.owner_id,
|
||||
Payer = get_payment_payer(St),
|
||||
Payer = Payment#domain_InvoicePayment.payer,
|
||||
#domain_ContactInfo{email = Email} = get_contact_info(Payer),
|
||||
CardToken = get_payer_card_token(Payer),
|
||||
PaymentTool = get_payer_payment_tool(Payer),
|
||||
ClientIP = get_payer_client_ip(Payer),
|
||||
hg_routing:gather_routes(Predestination, PaymentInstitution, VS, Revision, #{
|
||||
currency => Currency,
|
||||
payment_tool => PaymentTool,
|
||||
party_id => PartyID,
|
||||
client_ip => ClientIP
|
||||
client_ip => ClientIP,
|
||||
email => Email,
|
||||
card_token => CardToken
|
||||
}).
|
||||
|
||||
-spec check_risk_score(risk_score()) -> ok | {error, risk_score_is_too_high}.
|
||||
@ -2915,6 +2917,18 @@ get_payer_payment_tool(?customer_payer(_CustomerID, _, _, PaymentTool, _)) ->
|
||||
get_payer_payment_tool(?recurrent_payer(PaymentTool, _, _)) ->
|
||||
PaymentTool.
|
||||
|
||||
get_payer_card_token(?payment_resource_payer(PaymentResource, _ContactInfo)) ->
|
||||
case get_resource_payment_tool(PaymentResource) of
|
||||
{bank_card, #domain_BankCard{token = Token}} ->
|
||||
Token;
|
||||
_ ->
|
||||
undefined
|
||||
end;
|
||||
get_payer_card_token(?customer_payer(_, _, _, _, _)) ->
|
||||
undefined;
|
||||
get_payer_card_token(?recurrent_payer(_, _, _)) ->
|
||||
undefined.
|
||||
|
||||
get_payer_client_ip(
|
||||
?payment_resource_payer(
|
||||
#domain_DisposablePaymentResource{
|
||||
|
@ -247,7 +247,6 @@ init(EncodedParams, #{id := RecPaymentToolID}) ->
|
||||
NonFailRatedRoutes = gather_routes(PaymentInstitution, VS1, Revision, #{
|
||||
currency => Currency,
|
||||
payment_tool => PaymentTool,
|
||||
party_id => Params#payproc_RecurrentPaymentToolParams.party_id,
|
||||
client_ip => get_client_info_ip(Params#payproc_RecurrentPaymentToolParams.payment_resource)
|
||||
}),
|
||||
{ChosenRoute, ChoiceContext} = hg_routing:choose_route(NonFailRatedRoutes),
|
||||
|
@ -232,7 +232,7 @@ mock_party_management(SupPid) ->
|
||||
?trm(1),
|
||||
0,
|
||||
0,
|
||||
?pin([currency, payment_tool, party_id, client_ip])
|
||||
?pin([currency, payment_tool, email, card_token, client_ip])
|
||||
),
|
||||
?candidate(<<"">>, {constant, true}, ?trm(2), 0, 0, ?pin([currency, payment_tool])),
|
||||
?candidate(<<"">>, {constant, true}, ?trm(3), 0, 0, ?pin([currency, payment_tool]))
|
||||
@ -454,7 +454,6 @@ no_route_found_for_payment(_C) ->
|
||||
Ctx0 = #{
|
||||
currency => Currency0,
|
||||
payment_tool => PaymentTool,
|
||||
party_id => ?dummy_party_id,
|
||||
client_ip => undefined
|
||||
},
|
||||
{ok, {[], RejectedRoutes1}} = unwrap_routing_context(
|
||||
@ -513,7 +512,6 @@ gather_route_success(_C) ->
|
||||
Ctx = #{
|
||||
currency => Currency,
|
||||
payment_tool => PaymentTool,
|
||||
party_id => ?dummy_party_id,
|
||||
client_ip => undefined
|
||||
},
|
||||
{ok, {[Route], RejectedRoutes}} = unwrap_routing_context(
|
||||
@ -556,7 +554,6 @@ rejected_by_table_prohibitions(_C) ->
|
||||
Ctx = #{
|
||||
currency => Currency,
|
||||
payment_tool => PaymentTool,
|
||||
party_id => ?dummy_party_id,
|
||||
client_ip => undefined
|
||||
},
|
||||
{ok, {[], RejectedRoutes}} = unwrap_routing_context(
|
||||
@ -598,7 +595,6 @@ empty_candidate_ok(_C) ->
|
||||
Ctx = #{
|
||||
currency => Currency,
|
||||
payment_tool => PaymentTool,
|
||||
party_id => ?dummy_party_id,
|
||||
client_ip => undefined
|
||||
},
|
||||
?assertMatch(
|
||||
@ -619,7 +615,6 @@ ruleset_misconfig(_C) ->
|
||||
Ctx = #{
|
||||
currency => ?cur(<<"RUB">>),
|
||||
payment_tool => {payment_terminal, #domain_PaymentTerminal{payment_service = ?pmt_srv(<<"euroset-ref">>)}},
|
||||
party_id => ?party_id_for_ruleset_w_no_delegates,
|
||||
client_ip => undefined
|
||||
},
|
||||
?assertMatch(
|
||||
@ -652,7 +647,6 @@ routes_selected_with_risk_score(_C, RiskScore, ProviderRefs) ->
|
||||
Ctx = #{
|
||||
currency => Currency,
|
||||
payment_tool => PaymentTool,
|
||||
party_id => ?dummy_party_id,
|
||||
client_ip => undefined
|
||||
},
|
||||
{ok, {Routes, _}} = unwrap_routing_context(
|
||||
@ -718,7 +712,6 @@ do_gather_routes(Revision, ExpectedRouteTerminal, ExpectedRejectedRoutes) ->
|
||||
Ctx = #{
|
||||
currency => Currency,
|
||||
payment_tool => PaymentTool,
|
||||
party_id => ?dummy_party_id,
|
||||
client_ip => undefined
|
||||
},
|
||||
{ok, {Routes, RejectedRoutes}} = unwrap_routing_context(
|
||||
@ -759,7 +752,6 @@ terminal_priority_for_shop(ShopID, _C) ->
|
||||
Ctx = #{
|
||||
currency => Currency,
|
||||
payment_tool => PaymentTool,
|
||||
party_id => ?dummy_party_id,
|
||||
client_ip => undefined
|
||||
},
|
||||
{ok, {Routes, _RejectedRoutes}} = unwrap_routing_context(
|
||||
@ -784,8 +776,9 @@ gather_pinned_route(_C) ->
|
||||
Ctx = #{
|
||||
currency => Currency,
|
||||
payment_tool => PaymentTool,
|
||||
party_id => ?dummy_party_id,
|
||||
client_ip => undefined
|
||||
client_ip => undefined,
|
||||
card_token => undefined,
|
||||
email => undefined
|
||||
},
|
||||
{ok, {Routes, _RejectedRoutes}} = unwrap_routing_context(
|
||||
hg_routing:gather_routes(payment, PaymentInstitution, VS, Revision, Ctx)
|
||||
@ -810,13 +803,11 @@ choose_pinned_route(_C) ->
|
||||
Pin1 = #{
|
||||
currency => Currency,
|
||||
payment_tool => PaymentTool,
|
||||
party_id => ?dummy_party_id,
|
||||
client_ip => undefined
|
||||
},
|
||||
Pin2 = #{
|
||||
currency => Currency,
|
||||
payment_tool => PaymentTool,
|
||||
party_id => ?dummy_party_id
|
||||
payment_tool => PaymentTool
|
||||
},
|
||||
Pin3 = #{
|
||||
currency => Currency,
|
||||
|
@ -41,14 +41,16 @@
|
||||
|
||||
-type currency() :: dmsl_domain_thrift:'CurrencyRef'().
|
||||
-type payment_tool() :: dmsl_domain_thrift:'PaymentTool'().
|
||||
-type party_id() :: dmsl_domain_thrift:'PartyID'().
|
||||
-type client_ip() :: dmsl_domain_thrift:'IPAddress'().
|
||||
-type email() :: binary().
|
||||
-type card_token() :: dmsl_domain_thrift:'Token'().
|
||||
|
||||
-type pin() :: #{
|
||||
currency => currency(),
|
||||
payment_tool => payment_tool(),
|
||||
party_id => party_id(),
|
||||
client_ip => client_ip() | undefined
|
||||
client_ip => client_ip() | undefined,
|
||||
email => email() | undefined,
|
||||
card_token => card_token() | undefined
|
||||
}.
|
||||
|
||||
-export_type([t/0]).
|
||||
|
@ -64,14 +64,16 @@
|
||||
|
||||
-type currency() :: dmsl_domain_thrift:'CurrencyRef'().
|
||||
-type payment_tool() :: dmsl_domain_thrift:'PaymentTool'().
|
||||
-type party_id() :: dmsl_domain_thrift:'PartyID'().
|
||||
-type client_ip() :: dmsl_domain_thrift:'IPAddress'().
|
||||
-type email() :: binary().
|
||||
-type card_token() :: dmsl_domain_thrift:'Token'().
|
||||
|
||||
-type gather_route_context() :: #{
|
||||
currency := currency(),
|
||||
payment_tool := payment_tool(),
|
||||
party_id := party_id(),
|
||||
client_ip := client_ip() | undefined
|
||||
client_ip := client_ip() | undefined,
|
||||
email => email() | undefined,
|
||||
card_token => card_token() | undefined
|
||||
}.
|
||||
|
||||
-type varset() :: hg_varset:varset().
|
||||
@ -269,7 +271,7 @@ gather_pin_info(#domain_RoutingPin{features = Features}, Ctx) ->
|
||||
FeaturesList = ordsets:to_list(Features),
|
||||
lists:foldl(
|
||||
fun(Feature, Acc) ->
|
||||
Acc#{Feature => maps:get(Feature, Ctx)}
|
||||
Acc#{Feature => maps:get(Feature, Ctx, undefined)}
|
||||
end,
|
||||
#{},
|
||||
FeaturesList
|
||||
|
@ -21,7 +21,7 @@
|
||||
{<<"ctx">>,{pkg,<<"ctx">>,<<"0.6.0">>},2},
|
||||
{<<"damsel">>,
|
||||
{git,"https://github.com/valitydev/damsel.git",
|
||||
{ref,"f8e56c683617eca4e2ecb2ea6a8eec97c6c1dac9"}},
|
||||
{ref,"781e19277224071639719f9fdfcfd46f9f03a832"}},
|
||||
0},
|
||||
{<<"dmt_client">>,
|
||||
{git,"https://github.com/valitydev/dmt-client.git",
|
||||
|
Loading…
Reference in New Issue
Block a user