Skip to content

Commit 7013bfc

Browse files
ttt161ttt161
andauthored
add trust_level condition (#204)
* add trust_level condition * fix dialyzer * bump damsel-2.2.33 * bump images for dominant, party-management --------- Co-authored-by: ttt161 <losto@nix>
1 parent ec717d3 commit 7013bfc

8 files changed

Lines changed: 32 additions & 21 deletions

File tree

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
# You SHOULD specify point releases here so that build time and run time Erlang/OTPs
33
# are the same. See: https://github.com/erlware/relx/pull/902
44
SERVICE_NAME=hellgate
5-
OTP_VERSION=27.3.4
6-
REBAR_VERSION=3.24
5+
OTP_VERSION=28.5.0
6+
REBAR_VERSION=3.26
77
THRIFT_VERSION=0.14.2.3

apps/hellgate/src/hg_invoice_payment.erl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
205205
-type session_change() :: hg_session:change().
206206
-type callback_response() :: dmsl_proxy_provider_thrift:'CallbackResponse'().
207207
-type make_recurrent() :: true | false.
208-
-type retry_strategy() :: hg_retry:strategy().
208+
209209
-type capture_data() :: dmsl_payproc_thrift:'InvoicePaymentCaptureData'().
210210
-type payment_session() :: dmsl_payproc_thrift:'InvoicePaymentSession'().
211211
-type failure() :: dmsl_domain_thrift:'OperationFailure'().
@@ -605,6 +605,13 @@ reconstruct_payment_flow(?invoice_payment_flow_hold(_OnHoldExpiration, HeldUntil
605605
Seconds = hg_datetime:parse_ts(HeldUntil) - hg_datetime:parse_ts(CreatedAt),
606606
VS#{flow => {hold, ?hold_lifetime(Seconds)}}.
607607

608+
add_trust_level(#domain_Invoice{client_info = undefined}, VS) ->
609+
VS;
610+
add_trust_level(#domain_Invoice{client_info = #domain_InvoiceClientInfo{trust_level = undefined}}, VS) ->
611+
VS;
612+
add_trust_level(#domain_Invoice{client_info = #domain_InvoiceClientInfo{trust_level = TrustLevel}}, VS) ->
613+
VS#{trust_level => TrustLevel}.
614+
608615
-spec get_predefined_route(payer()) -> {ok, route()} | undefined.
609616
get_predefined_route(?payment_resource_payer()) ->
610617
undefined;
@@ -2567,7 +2574,6 @@ get_actual_retry_strategy(Target, #st{retry_attempts = Attempts}) ->
25672574
AttemptNum = maps:get(get_target_type(Target), Attempts, 0),
25682575
hg_retry:skip_steps(get_initial_retry_strategy(get_target_type(Target)), AttemptNum).
25692576

2570-
-spec get_initial_retry_strategy(session_target_type()) -> retry_strategy().
25712577
get_initial_retry_strategy(TargetType) ->
25722578
PolicyConfig = genlib_app:env(hellgate, payment_retry_policy, #{}),
25732579
hg_retry:new_strategy(maps:get(TargetType, PolicyConfig, no_retry)).
@@ -3129,8 +3135,9 @@ get_varset(St, InitialValue) ->
31293135
Payment = get_payment(St),
31303136
Revision = get_payment_revision(St),
31313137
VS0 = reconstruct_payment_flow(Payment, InitialValue),
3132-
VS1 = collect_validation_varset(get_party_config_ref(Opts), get_shop_obj(Opts, Revision), Payment, VS0),
3133-
VS1.
3138+
VS1 = add_trust_level(get_invoice(Opts), VS0),
3139+
VS2 = collect_validation_varset(get_party_config_ref(Opts), get_shop_obj(Opts, Revision), Payment, VS1),
3140+
VS2.
31343141

31353142
%%
31363143

apps/hellgate/src/hg_retry.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ new_strategy({intervals, Array}) ->
3737
new_strategy({timecap, Timeout, Policy}) ->
3838
genlib_retry:timecap(Timeout, new_strategy(Policy));
3939
new_strategy(no_retry) ->
40-
finish;
40+
genlib_retry:timecap(0, genlib_retry:linear(1, 1));
4141
new_strategy(BadPolicy) ->
4242
erlang:error(badarg, [BadPolicy]).
4343

apps/hellgate/src/hg_varset.erl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
shop_id => dmsl_base_thrift:'ID'(),
1717
risk_score => hg_inspector:risk_score(),
1818
flow => instant | {hold, dmsl_domain_thrift:'HoldLifetime'()},
19-
wallet_id => dmsl_base_thrift:'ID'()
19+
wallet_id => dmsl_base_thrift:'ID'(),
20+
trust_level => dmsl_domain_thrift:'ClientTrustLevel'()
2021
}.
2122

2223
-spec prepare_varset(varset()) -> dmsl_payproc_thrift:'Varset'().
@@ -28,5 +29,6 @@ prepare_varset(Varset) ->
2829
wallet_id = genlib_map:get(wallet_id, Varset),
2930
payment_tool = genlib_map:get(payment_tool, Varset),
3031
party_ref = genlib_map:get(party_config_ref, Varset),
31-
shop_id = genlib_map:get(shop_id, Varset)
32+
shop_id = genlib_map:get(shop_id, Varset),
33+
trust_level = genlib_map:get(trust_level, Varset)
3234
}.

apps/hellgate/test/hg_ct_helper.erl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,8 @@ make_invoice_params(
841841
due = hg_datetime:format_ts(Due),
842842
cost = Cost,
843843
context = make_invoice_context(),
844-
allocation = AllocationPrototype
844+
allocation = AllocationPrototype,
845+
client_info = #domain_InvoiceClientInfo{trust_level = unknown}
845846
}.
846847

847848
-spec make_invoice_params_tpl(invoice_tpl_id()) -> invoice_params_tpl().

compose.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ services:
2929
command: /sbin/init
3030

3131
dmt:
32-
image: ghcr.io/valitydev/dominant-v2:sha-815385c
32+
image: ghcr.io/valitydev/dominant-v2:sha-c9430b5
3333
command: /opt/dmt/bin/dmt foreground
3434
volumes:
3535
- ./test/dmt/sys.config:/opt/dmt/releases/0.1/sys.config
@@ -109,7 +109,7 @@ services:
109109
retries: 20
110110

111111
party-management:
112-
image: ghcr.io/valitydev/party-management:sha-2296944
112+
image: ghcr.io/valitydev/party-management:sha-8a58cd5
113113
command: /opt/party-management/bin/party-management foreground
114114
volumes:
115115
- ./test/party-management/sys.config:/opt/party-management/releases/0.1/sys.config

rebar.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@
2626

2727
% Common project dependencies.
2828
{deps, [
29+
{cowboy, "2.12.0"},
2930
{recon, "2.5.2"},
3031
{cache, "2.3.3"},
3132
{gproc, "0.9.0"},
3233
{genlib, {git, "https://github.com/valitydev/genlib.git", {tag, "v1.1.0"}}},
3334
{woody, {git, "https://github.com/valitydev/woody_erlang.git", {tag, "v1.1.1"}}},
34-
{damsel, {git, "https://github.com/valitydev/damsel.git", {tag, "v2.2.32"}}},
35+
{damsel, {git, "https://github.com/valitydev/damsel.git", {tag, "v2.2.33"}}},
3536
{payproc_errors, {git, "https://github.com/valitydev/payproc-errors-erlang.git", {branch, "master"}}},
3637
{mg_proto, {git, "https://github.com/valitydev/machinegun-proto.git", {branch, "master"}}},
3738
{dmt_client, {git, "https://github.com/valitydev/dmt-client.git", {tag, "v2.0.3"}}},

rebar.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
{ref,"5a87a37694e42b6592d3b4164ae54e0e87e24e18"}},
2222
1},
2323
{<<"chatterbox">>,{pkg,<<"ts_chatterbox">>,<<"0.15.1">>},2},
24-
{<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.9.0">>},1},
25-
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.11.0">>},2},
24+
{<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.12.0">>},0},
25+
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.13.0">>},1},
2626
{<<"crc32cer">>,{pkg,<<"crc32cer">>,<<"0.1.11">>},3},
2727
{<<"ctx">>,{pkg,<<"ctx">>,<<"0.6.0">>},2},
2828
{<<"damsel">>,
2929
{git,"https://github.com/valitydev/damsel.git",
30-
{ref,"31495ce9d95c5d1b627b349c01d9937a5ef0231c"}},
30+
{ref,"e7a302a684deba1bb18a00d1056879329219d280"}},
3131
0},
3232
{<<"dmt_client">>,
3333
{git,"https://github.com/valitydev/dmt-client.git",
@@ -111,7 +111,7 @@
111111
{<<"prometheus_cowboy">>,{pkg,<<"prometheus_cowboy">>,<<"0.1.9">>},0},
112112
{<<"prometheus_httpd">>,{pkg,<<"prometheus_httpd">>,<<"2.1.15">>},1},
113113
{<<"quantile_estimator">>,{pkg,<<"quantile_estimator">>,<<"0.2.1">>},1},
114-
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.8.0">>},2},
114+
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.8.0">>},1},
115115
{<<"recon">>,{pkg,<<"recon">>,<<"2.5.2">>},0},
116116
{<<"scoper">>,
117117
{git,"https://github.com/valitydev/scoper.git",
@@ -142,8 +142,8 @@
142142
{<<"cache">>, <<"B23A5FE7095445A88412A6E614C933377E0137B44FFED77C9B3FEF1A731A20B2">>},
143143
{<<"certifi">>, <<"D4FB0A6BB20B7C9C3643E22507E42F356AC090A1DCEA9AB99E27E0376D695EBA">>},
144144
{<<"chatterbox">>, <<"5CAC4D15DD7AD61FC3C4415CE4826FC563D4643DEE897A558EC4EA0B1C835C9C">>},
145-
{<<"cowboy">>, <<"865DD8B6607E14CF03282E10E934023A1BD8BE6F6BACF921A7E2A96D800CD452">>},
146-
{<<"cowlib">>, <<"0B9FF9C346629256C42EBE1EEB769A83C6CB771A6EE5960BD110AB0B9B872063">>},
145+
{<<"cowboy">>, <<"F276D521A1FF88B2B9B4C54D0E753DA6C66DD7BE6C9FCA3D9418B561828A3731">>},
146+
{<<"cowlib">>, <<"DB8F7505D8332D98EF50A3EF34B34C1AFDDEC7506E4EE4DD4A3A266285D282CA">>},
147147
{<<"crc32cer">>, <<"B550DA6D615FEB72A882D15D020F8F7DEE72DFB2CB1BCDF3B1EE8DC2AFD68CFC">>},
148148
{<<"ctx">>, <<"8FF88B70E6400C4DF90142E7F130625B82086077A45364A78D208ED3ED53C7FE">>},
149149
{<<"erlydtl">>, <<"964B2DC84F8C17ACFAA69C59BA129EF26AC45D2BA898C3C6AD9B5BDC8BA13CED">>},
@@ -177,8 +177,8 @@
177177
{<<"cache">>, <<"44516CE6FA03594D3A2AF025DD3A87BFE711000EB730219E1DDEFC816E0AA2F4">>},
178178
{<<"certifi">>, <<"6AC7EFC1C6F8600B08D625292D4BBF584E14847CE1B6B5C44D983D273E1097EA">>},
179179
{<<"chatterbox">>, <<"4F75B91451338BC0DA5F52F3480FA6EF6E3A2AEECFC33686D6B3D0A0948F31AA">>},
180-
{<<"cowboy">>, <<"2C729F934B4E1AA149AFF882F57C6372C15399A20D54F65C8D67BEF583021BDE">>},
181-
{<<"cowlib">>, <<"2B3E9DA0B21C4565751A6D4901C20D1B4CC25CBB7FD50D91D2AB6DD287BC86A9">>},
180+
{<<"cowboy">>, <<"8A7ABE6D183372CEB21CAA2709BEC928AB2B72E18A3911AA1771639BEF82651E">>},
181+
{<<"cowlib">>, <<"E1E1284DC3FC030A64B1AD0D8382AE7E99DA46C3246B815318A4B848873800A4">>},
182182
{<<"crc32cer">>, <<"A39B8F0B1990AC1BF06C3A247FC6A178B740CDFC33C3B53688DC7DD6B1855942">>},
183183
{<<"ctx">>, <<"A14ED2D1B67723DBEBBE423B28D7615EB0BDCBA6FF28F2D1F1B0A7E1D4AA5FC2">>},
184184
{<<"erlydtl">>, <<"D80EC044CD8F58809C19D29AC5605BE09E955040911B644505E31E9DD8143431">>},

0 commit comments

Comments
 (0)