From 7737791a15b1debadb41c4e2369a8417b22f93b4 Mon Sep 17 00:00:00 2001 From: Aleksey Kashapov Date: Tue, 8 Apr 2025 14:12:24 +0300 Subject: [PATCH 1/2] Allows to reopen all chargebacks (not only rejected ones) --- .github/workflows/erlang-checks.yaml | 4 +-- .../src/hg_invoice_payment_chargeback.erl | 8 ------ apps/hellgate/test/hg_invoice_tests_SUITE.erl | 26 ------------------- 3 files changed, 2 insertions(+), 36 deletions(-) diff --git a/.github/workflows/erlang-checks.yaml b/.github/workflows/erlang-checks.yaml index 72524dd7..605e3c22 100644 --- a/.github/workflows/erlang-checks.yaml +++ b/.github/workflows/erlang-checks.yaml @@ -18,7 +18,7 @@ jobs: thrift-version: ${{ steps.thrift-version.outputs.version }} steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - run: grep -v '^#' .env >> $GITHUB_ENV - id: otp-version run: echo "::set-output name=version::$OTP_VERSION" @@ -30,7 +30,7 @@ jobs: run: name: Run checks needs: setup - uses: valitydev/erlang-workflows/.github/workflows/erlang-parallel-build.yml@v1.0.17 + uses: valitydev/erlang-workflows/.github/workflows/erlang-parallel-build.yml@v1.0.18 with: otp-version: ${{ needs.setup.outputs.otp-version }} rebar-version: ${{ needs.setup.outputs.rebar-version }} diff --git a/apps/hellgate/src/hg_invoice_payment_chargeback.erl b/apps/hellgate/src/hg_invoice_payment_chargeback.erl index 629688f4..66c0bc5e 100644 --- a/apps/hellgate/src/hg_invoice_payment_chargeback.erl +++ b/apps/hellgate/src/hg_invoice_payment_chargeback.erl @@ -329,7 +329,6 @@ do_accept(State, PaymentState, AcceptParams = ?accept_params(Levy, Body)) -> -spec do_reopen(state(), payment_state(), reopen_params()) -> {ok, result()} | no_return(). do_reopen(State, PaymentState, ReopenParams = ?reopen_params(Levy, Body)) -> - _ = validate_chargeback_is_rejected(State), _ = validate_not_arbitration(State), _ = validate_currency(Body, hg_invoice_payment:get_payment(PaymentState)), _ = validate_currency(Levy, hg_invoice_payment:get_payment(PaymentState)), @@ -597,13 +596,6 @@ validate_not_arbitration(#domain_InvoicePaymentChargeback{stage = ?chargeback_st validate_not_arbitration(#domain_InvoicePaymentChargeback{}) -> ok. -validate_chargeback_is_rejected(#chargeback_st{chargeback = Chargeback}) -> - validate_chargeback_is_rejected(Chargeback); -validate_chargeback_is_rejected(#domain_InvoicePaymentChargeback{status = ?chargeback_status_rejected()}) -> - ok; -validate_chargeback_is_rejected(#domain_InvoicePaymentChargeback{status = Status}) -> - throw(#payproc_InvoicePaymentChargebackInvalidStatus{status = Status}). - validate_chargeback_is_pending(#chargeback_st{chargeback = Chargeback}) -> validate_chargeback_is_pending(Chargeback); validate_chargeback_is_pending(#domain_InvoicePaymentChargeback{status = ?chargeback_status_pending()}) -> diff --git a/apps/hellgate/test/hg_invoice_tests_SUITE.erl b/apps/hellgate/test/hg_invoice_tests_SUITE.erl index eb21b416..5680bf4b 100644 --- a/apps/hellgate/test/hg_invoice_tests_SUITE.erl +++ b/apps/hellgate/test/hg_invoice_tests_SUITE.erl @@ -128,7 +128,6 @@ -export([accept_payment_chargeback_twice/1]). -export([accept_payment_chargeback_new_body/1]). -export([accept_payment_chargeback_new_levy/1]). --export([reopen_accepted_payment_chargeback_fails/1]). -export([reopen_payment_chargeback_inconsistent/1]). -export([reopen_payment_chargeback_exceeded/1]). -export([reopen_payment_chargeback_cancel/1]). @@ -389,7 +388,6 @@ groups() -> accept_payment_chargeback_twice, accept_payment_chargeback_new_body, accept_payment_chargeback_new_levy, - reopen_accepted_payment_chargeback_fails, reopen_payment_chargeback_inconsistent, reopen_payment_chargeback_exceeded, reopen_payment_chargeback_cancel, @@ -4064,30 +4062,6 @@ accept_payment_chargeback_new_levy(C) -> ?assertEqual(Paid - Cost - NewLevyAmount, maps:get(min_available_amount, Settlement1)), ?assertEqual(Paid - Cost - NewLevyAmount, maps:get(max_available_amount, Settlement1)). --spec reopen_accepted_payment_chargeback_fails(config()) -> _ | no_return(). -reopen_accepted_payment_chargeback_fails(C) -> - Client = cfg(client, C), - Cost = 42000, - LevyAmount = 5000, - Levy = ?cash(LevyAmount, <<"RUB">>), - CBParams = make_chargeback_params(Levy), - {IID, PID, _SID, CB} = start_chargeback(C, Cost, CBParams, make_payment_params(?pmt_sys(<<"visa-ref">>))), - CBID = CB#domain_InvoicePaymentChargeback.id, - [ - ?payment_ev(PID, ?chargeback_ev(CBID, ?chargeback_created(CB))), - ?payment_ev(PID, ?chargeback_ev(CBID, ?chargeback_cash_flow_changed(_))) - ] = next_changes(IID, 2, Client), - AcceptParams = make_chargeback_accept_params(), - ok = hg_client_invoicing:accept_chargeback(IID, PID, CBID, AcceptParams, Client), - [ - ?payment_ev(PID, ?chargeback_ev(CBID, ?chargeback_target_status_changed(?chargeback_status_accepted()))), - ?payment_ev(PID, ?chargeback_ev(CBID, ?chargeback_status_changed(?chargeback_status_accepted()))), - ?payment_ev(PID, ?payment_status_changed(?charged_back())) - ] = next_changes(IID, 3, Client), - ReopenParams = make_chargeback_reopen_params(Levy), - Error = hg_client_invoicing:reopen_chargeback(IID, PID, CBID, ReopenParams, Client), - ?assertMatch(?invalid_chargeback_status(_), Error). - -spec reopen_payment_chargeback_inconsistent(config()) -> _ | no_return(). reopen_payment_chargeback_inconsistent(C) -> Client = cfg(client, C), From f8dafa8f527a9c8d66d75ce360f15b1bd8305c3a Mon Sep 17 00:00:00 2001 From: Aleksey Kashapov Date: Tue, 8 Apr 2025 14:24:15 +0300 Subject: [PATCH 2/2] Retires `iosetopts` --- rebar.config | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rebar.config b/rebar.config index 6b13ed2b..78b73b0a 100644 --- a/rebar.config +++ b/rebar.config @@ -77,12 +77,10 @@ % for introspection on production {recon, "2.5.2"}, {logger_logstash_formatter, - {git, "https://github.com/valitydev/logger_logstash_formatter.git", {ref, "08a66a6"}}}, - {iosetopts, {git, "https://github.com/valitydev/iosetopts.git", {ref, "edb445c"}}} + {git, "https://github.com/valitydev/logger_logstash_formatter.git", {ref, "08a66a6"}}} ]}, {relx, [ {release, {hellgate, "0.1"}, [ - iosetopts, {recon, load}, {runtime_tools, load}, {tools, load},