Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/hellgate/src/hg_invoice_payment.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2607,7 +2607,7 @@ hold_limit_routes(Routes0, VS, Iter, St) ->
{lists:reverse(Routes1), Rejected}.

do_reject_route(LimiterError, Route, TurnoverLimits, {LimitHeldRoutes, RejectedRoutes}) ->
LimitsIDs = [T#domain_TurnoverLimit.id || T <- TurnoverLimits],
LimitsIDs = [T#domain_TurnoverLimit.ref#domain_LimitConfigRef.id || T <- TurnoverLimits],
RejectedRoute = hg_route:to_rejected_route(Route, {'LimitHoldError', LimitsIDs, LimiterError}),
{LimitHeldRoutes, [RejectedRoute | RejectedRoutes]}.

Expand Down
306 changes: 47 additions & 259 deletions apps/hellgate/src/hg_limiter.erl

Large diffs are not rendered by default.

54 changes: 0 additions & 54 deletions apps/hellgate/src/hg_limiter_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
-include_lib("damsel/include/dmsl_base_thrift.hrl").
-include_lib("limiter_proto/include/limproto_limiter_thrift.hrl").

-export([get/4]).
-export([hold/3]).
-export([commit/3]).
-export([rollback/3]).

-export([get_values/2]).
-export([get_batch/2]).
-export([hold_batch/2]).
Expand All @@ -16,63 +11,14 @@

-type limit() :: limproto_limiter_thrift:'Limit'().
-type limit_id() :: limproto_limiter_thrift:'LimitID'().
-type limit_version() :: limproto_limiter_thrift:'Version'().
-type limit_change() :: limproto_limiter_thrift:'LimitChange'().
-type context() :: limproto_limiter_thrift:'LimitContext'().
-type clock() :: limproto_limiter_thrift:'Clock'().
-type request() :: limproto_limiter_thrift:'LimitRequest'().

-export_type([limit/0]).
-export_type([limit_id/0]).
-export_type([limit_change/0]).
-export_type([context/0]).
-export_type([clock/0]).

-spec get(limit_id(), limit_version() | undefined, clock(), context()) -> limit() | no_return().
get(LimitID, Version, Clock, Context) ->
Opts = hg_woody_wrapper:get_service_options(limiter),
Args = {LimitID, Version, Clock, Context},
case hg_woody_wrapper:call(limiter, 'GetVersioned', Args, Opts) of
{ok, Limit} ->
Limit;
{exception, #limiter_LimitNotFound{}} ->
error({not_found, LimitID});
{exception, #base_InvalidRequest{errors = Errors}} ->
error({invalid_request, Errors})
end.

-spec hold(limit_change(), clock(), context()) -> clock() | no_return().
hold(LimitChange, Clock, Context) ->
Opts = hg_woody_wrapper:get_service_options(limiter),
Args = {LimitChange, Clock, Context},
case hg_woody_wrapper:call(limiter, 'Hold', Args, Opts) of
{ok, ClockUpdated} ->
ClockUpdated;
{exception, Exception} ->
error(Exception)
end.

-spec commit(limit_change(), clock(), context()) -> clock() | no_return().
commit(LimitChange, Clock, Context) ->
Opts = hg_woody_wrapper:get_service_options(limiter),
Args = {LimitChange, Clock, Context},
case hg_woody_wrapper:call(limiter, 'Commit', Args, Opts) of
{ok, ClockUpdated} ->
ClockUpdated;
{exception, Exception} ->
error(Exception)
end.

-spec rollback(limit_change(), clock(), context()) -> clock() | no_return().
rollback(LimitChange, Clock, Context) ->
Opts = hg_woody_wrapper:get_service_options(limiter),
Args = {LimitChange, Clock, Context},
case hg_woody_wrapper:call(limiter, 'Rollback', Args, Opts) of
{ok, ClockUpdated} ->
ClockUpdated;
{exception, Exception} ->
error(Exception)
end.

-spec get_values(request(), context()) -> [limit()] | no_return().
get_values(Request, Context) ->
Expand Down
1 change: 1 addition & 0 deletions apps/hellgate/test/hg_ct_domain.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
-define(pmt(C, T), #domain_PaymentMethodRef{id = {C, T}}).
-define(pmt_sys(ID), #domain_PaymentSystemRef{id = ID}).
-define(pmt_srv(ID), #domain_PaymentServiceRef{id = ID}).
-define(lim(ID), #domain_LimitConfigRef{id = ID}).
-define(cat(ID), #domain_CategoryRef{id = ID}).
-define(prx(ID), #domain_ProxyRef{id = ID}).
-define(prv(ID), #domain_ProviderRef{id = ID}).
Expand Down
29 changes: 1 addition & 28 deletions apps/hellgate/test/hg_invoice_lite_tests_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
-export([payment_has_optional_fields/1]).
-export([payment_last_trx_correct/1]).

-export([payment_ok_hybrid_test/1]).

-type config() :: hg_ct_helper:config().
-type test_case_name() :: hg_ct_helper:test_case_name().
-type group_name() :: hg_ct_helper:group_name().
Expand All @@ -48,8 +46,7 @@ init([]) ->
-spec all() -> [test_case_name() | {group, group_name()}].
all() ->
[
{group, payments},
payment_ok_hybrid_test
{group, payments}
% {group, wrap_load}
].

Expand Down Expand Up @@ -501,30 +498,6 @@ payment_last_trx_correct(C) ->
PaymentID = await_payment_capture(InvoiceID, PaymentID, Client),
?payment_last_trx(TrxInfo0) = hg_client_invoicing:get_payment(InvoiceID, PaymentID, Client).

-spec payment_ok_hybrid_test(config()) -> test_return().
payment_ok_hybrid_test(C) ->
Client = cfg(client, C),
OriginalBackend = application:get_env(hellgate, backend, machinegun),
ok = application:set_env(hellgate, backend, machinegun),
InvoiceID = start_invoice(<<"rubberduck">>, make_due_date(10), 42000, C),
Context = #base_Content{
type = <<"application/x-erlang-binary">>,
data = erlang:term_to_binary({you, 643, "not", [<<"welcome">>, here]})
},
PayerSessionInfo = #domain_PayerSessionInfo{
redirect_url = <<"https://redirectly.io/merchant">>
},
PaymentParams = (make_payment_params(?pmt_sys(<<"visa-ref">>)))#payproc_InvoicePaymentParams{
payer_session_info = PayerSessionInfo,
context = Context
},
ok = application:set_env(hellgate, backend, hybrid),
PaymentID = process_payment(InvoiceID, PaymentParams, Client),
PaymentID = await_payment_capture(InvoiceID, PaymentID, Client),
#payproc_Invoice{} = hg_client_invoicing:get(InvoiceID, Client),
ok = application:set_env(hellgate, backend, OriginalBackend),
ok.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Internals
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down
Loading
Loading