From 9701fd5c331bd7c3ff7554034e49150ad535afb0 Mon Sep 17 00:00:00 2001 From: Aleksey Kashapov Date: Wed, 22 Jan 2025 12:37:06 +0300 Subject: [PATCH 1/4] EMP-228: Passes updated payment resource's `contact_info` to provider --- apps/hellgate/test/hg_ct_domain.hrl | 12 +++-- apps/hellgate/test/hg_dummy_provider.erl | 13 +++++ apps/hellgate/test/hg_invoice_tests_SUITE.erl | 52 ++++++++++++++++++- rebar.config | 2 +- rebar.lock | 2 +- 5 files changed, 74 insertions(+), 7 deletions(-) diff --git a/apps/hellgate/test/hg_ct_domain.hrl b/apps/hellgate/test/hg_ct_domain.hrl index 8357ddfd..9500a39b 100644 --- a/apps/hellgate/test/hg_ct_domain.hrl +++ b/apps/hellgate/test/hg_ct_domain.hrl @@ -85,10 +85,14 @@ ). -define(contact_info(EMail, Phone), - ?contact_info(EMail, Phone, undefined, undefined, undefined, undefined, undefined, undefined, undefined) + ?contact_info( + EMail, Phone, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined + ) ). --define(contact_info(EMail, Phone, FirstName, LastName, Country, State, City, Address, PostalCode), +-define(contact_info( + EMail, Phone, FirstName, LastName, Country, State, City, Address, PostalCode, DateOfBirth, DocumentId +), #domain_ContactInfo{ email = EMail, phone_number = Phone, @@ -98,7 +102,9 @@ state = State, city = City, address = Address, - postal_code = PostalCode + postal_code = PostalCode, + date_of_birth = DateOfBirth, + document_id = DocumentId } ). diff --git a/apps/hellgate/test/hg_dummy_provider.erl b/apps/hellgate/test/hg_dummy_provider.erl index 4a88b6da..e3a95dad 100644 --- a/apps/hellgate/test/hg_dummy_provider.erl +++ b/apps/hellgate/test/hg_dummy_provider.erl @@ -267,6 +267,15 @@ token_respond(Response, CallbackResult) -> % process_payment(?processed(), undefined, PaymentInfo, CtxOpts, _) -> case get_payment_info_scenario(PaymentInfo) of + {assert_contact_info, ContactInfo} -> + ProvidedContactInfo = + PaymentInfo#proxy_provider_PaymentInfo.payment#proxy_provider_InvoicePayment.contact_info, + case ContactInfo of + ProvidedContactInfo -> + maybe_fail(PaymentInfo, CtxOpts, result(?sleep(0), <<"sleeping">>)); + _ -> + error({contact_info_mismatch, ContactInfo, ProvidedContactInfo}) + end; {preauth_3ds, Timeout} -> Tag = generate_tag(<<"payment">>), Uri = get_callback_url(), @@ -684,6 +693,8 @@ get_payment_tool_scenario({'bank_card', #domain_BankCard{token = <<"unexpected_f get_payment_tool_scenario({'bank_card', #domain_BankCard{token = <<"scenario_", BinScenario/binary>>}}) -> Scenario = decode_failure_scenario(BinScenario), {temporary_unavailability, Scenario}; +get_payment_tool_scenario({'bank_card', #domain_BankCard{token = <<"assert_contact_info/", ContactInfoBin/binary>>}}) -> + {assert_contact_info, binary_to_term(ContactInfoBin)}; get_payment_tool_scenario( {'payment_terminal', #domain_PaymentTerminal{payment_service = #domain_PaymentServiceRef{id = <<"euroset-ref">>}}} ) -> @@ -753,6 +764,8 @@ make_payment_tool(Code, PSys) when Code =:= unexpected_failure_no_trx -> ?SESSION42(make_bank_card_payment_tool(atom_to_binary(Code, utf8), PSys)); +make_payment_tool({assert_contact_info, ContactInfo}, PSys) -> + ?SESSION42(make_bank_card_payment_tool(<<"assert_contact_info/", (term_to_binary(ContactInfo))/binary>>, PSys)); make_payment_tool(inspector_fail_first, PSys) -> ?SESSION42(make_bank_card_payment_tool(<<"inspector_fail_first">>, PSys)); make_payment_tool(inspector_fail_all, PSys) -> diff --git a/apps/hellgate/test/hg_invoice_tests_SUITE.erl b/apps/hellgate/test/hg_invoice_tests_SUITE.erl index b6602be6..eb21b416 100644 --- a/apps/hellgate/test/hg_invoice_tests_SUITE.erl +++ b/apps/hellgate/test/hg_invoice_tests_SUITE.erl @@ -208,6 +208,8 @@ -export([payment_cascade_fail_provider_error/1]). -export([payment_cascade_fail_ui/1]). +-export([payment_tool_contact_info_passed_to_provider/1]). + -export([route_not_found_provider_unavailable/1]). -export([payment_success_ruleset_provider_available/1]). -export([route_found_provider_lacking_conversion/1]). @@ -301,7 +303,9 @@ groups() -> {group, allocation}, - {group, route_cascading} + {group, route_cascading}, + + {group, proxy_provider_protocol} ]}, {base_payments, [], [ @@ -503,6 +507,9 @@ groups() -> payment_cascade_deadline_failures, payment_cascade_fail_provider_error, payment_cascade_fail_ui + ]}, + {proxy_provider_protocol, [parallel], [ + payment_tool_contact_info_passed_to_provider ]} ]. @@ -3328,7 +3335,9 @@ registered_payment_adjustment_success(C) -> payment_session_id = Session, client_info = #domain_ClientInfo{} }, - contact_info = ?contact_info(String, String, String, String, String, String, String, String, String) + contact_info = ?contact_info( + String, String, String, String, String, String, String, String, String, String, String + ) }}, route = Route, transaction_info = ?trx_info(<<"1">>, #{}) @@ -7871,6 +7880,45 @@ payment_cascade_deadline_failures(C) -> ?assertMatch(#domain_InvoicePayment{status = {failed, _}}, Payment), ?invoice_status_changed(?invoice_cancelled(<<"overdue">>)) = next_change(InvoiceID, Client). +%%============================================================================= +%% proxy_provider_protocol group + +-spec payment_tool_contact_info_passed_to_provider(config()) -> test_return(). +payment_tool_contact_info_passed_to_provider(C) -> + PartyID = cfg(party_id_big_merch, C), + RootUrl = cfg(root_url, C), + PartyClient = cfg(party_client, C), + Client = hg_client_invoicing:start_link(hg_ct_helper:create_client(RootUrl)), + ShopID = hg_ct_helper:create_shop(PartyID, ?cat(1), <<"RUB">>, ?tmpl(1), ?pinst(1), PartyClient), + InvoiceParams = make_invoice_params(PartyID, ShopID, <<"rubberduck">>, make_due_date(10), make_cash(42000)), + InvoiceID = create_invoice(InvoiceParams, Client), + ?invoice_created(?invoice_w_status(?invoice_unpaid())) = next_change(InvoiceID, Client), + PaymentID = process_payment( + InvoiceID, make_payment_params_with_contact_info_assertion(?pmt_sys(<<"visa-ref">>)), Client + ), + PaymentID = await_payment_capture(InvoiceID, PaymentID, Client), + ?invoice_state( + ?invoice_w_status(?invoice_paid()), + [?payment_state(Payment)] + ) = hg_client_invoicing:get(InvoiceID, Client), + ?payment_w_status(PaymentID, ?captured()) = Payment. + +make_payment_params_with_contact_info_assertion(PmtSys) -> + String = <<"STRING">>, + ContactInfo = ?contact_info(String, String, String, String, String, String, String, String, String, String, String), + {PaymentTool, Session} = hg_dummy_provider:make_payment_tool({assert_contact_info, ContactInfo}, PmtSys), + #payproc_InvoicePaymentParams{ + payer = + {payment_resource, #payproc_PaymentResourcePayerParams{ + resource = #domain_DisposablePaymentResource{ + payment_tool = PaymentTool, + payment_session_id = Session, + client_info = #domain_ClientInfo{} + }, + contact_info = ContactInfo + }}, + flow = {instant, #payproc_InvoicePaymentParamsFlowInstant{}} + }. %% await_cascade_triggering(InvoiceID, PaymentID, Client) -> diff --git a/rebar.config b/rebar.config index 6b13ed2b..d987c48a 100644 --- a/rebar.config +++ b/rebar.config @@ -30,7 +30,7 @@ {gproc, "0.9.0"}, {genlib, {git, "https://github.com/valitydev/genlib.git", {branch, "master"}}}, {woody, {git, "https://github.com/valitydev/woody_erlang.git", {branch, "master"}}}, - {damsel, {git, "https://github.com/valitydev/damsel.git", {branch, "master"}}}, + {damsel, {git, "https://github.com/valitydev/damsel.git", {branch, "EMP-228/ft/additional-contact-info-fields"}}}, {payproc_errors, {git, "https://github.com/valitydev/payproc-errors-erlang.git", {branch, "master"}}}, {mg_proto, {git, "https://github.com/valitydev/machinegun-proto.git", {branch, "master"}}}, {dmt_client, {git, "https://github.com/valitydev/dmt-client.git", {branch, "master"}}}, diff --git a/rebar.lock b/rebar.lock index 6fa99ca7..b3b1f74b 100644 --- a/rebar.lock +++ b/rebar.lock @@ -21,7 +21,7 @@ {<<"ctx">>,{pkg,<<"ctx">>,<<"0.6.0">>},2}, {<<"damsel">>, {git,"https://github.com/valitydev/damsel.git", - {ref,"81d1edce2043500e4581867da3f5f4c31e682f44"}}, + {ref,"f20444d7d091c0703220ed0c859df38e7f832295"}}, 0}, {<<"dmt_client">>, {git,"https://github.com/valitydev/dmt-client.git", From d9f062eac1ea25254bee374f529df6e8106e059b Mon Sep 17 00:00:00 2001 From: Aleksey Kashapov Date: Wed, 22 Jan 2025 14:35:49 +0300 Subject: [PATCH 2/4] Bumps CI --- .github/workflows/erlang-checks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/erlang-checks.yaml b/.github/workflows/erlang-checks.yaml index 9a30e05c..cc8a93e6 100644 --- a/.github/workflows/erlang-checks.yaml +++ b/.github/workflows/erlang-checks.yaml @@ -30,7 +30,7 @@ jobs: run: name: Run checks needs: setup - uses: valitydev/erlang-workflows/.github/workflows/erlang-parallel-build.yml@v1.0.15 + uses: valitydev/erlang-workflows/.github/workflows/erlang-parallel-build.yml@v1.0.16 with: otp-version: ${{ needs.setup.outputs.otp-version }} rebar-version: ${{ needs.setup.outputs.rebar-version }} From 35e2d94e5ac7fd5c41ae956d9700cddac06ede5f Mon Sep 17 00:00:00 2001 From: Aleksey Kashapov Date: Wed, 22 Jan 2025 15:27:58 +0300 Subject: [PATCH 3/4] Fixes dialyzer error --- apps/hellgate/test/hg_dummy_provider.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/hellgate/test/hg_dummy_provider.erl b/apps/hellgate/test/hg_dummy_provider.erl index e3a95dad..35e611d2 100644 --- a/apps/hellgate/test/hg_dummy_provider.erl +++ b/apps/hellgate/test/hg_dummy_provider.erl @@ -744,7 +744,8 @@ get_payment_tool_scenario( | empty_cvv | {scenario, failure_scenario()} | {preauth_3ds, integer()} - | {preauth_3ds_sleep, integer()}. + | {preauth_3ds_sleep, integer()} + | {assert_contact_info, dmsl_domain_thrift:'ContactInfo'()}. -type tag() :: dmsl_proxy_provider_thrift:'CallbackTag'(). -type session_change() :: dmsl_proxy_provider_thrift:'PaymentSessionChange'(). From 42ec99d43cabfffef7b32b57d912fc638274c51a Mon Sep 17 00:00:00 2001 From: Aleksey Kashapov Date: Thu, 23 Jan 2025 19:06:23 +0300 Subject: [PATCH 4/4] Bumps damsel --- .github/workflows/erlang-checks.yaml | 2 +- rebar.config | 2 +- rebar.lock | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/erlang-checks.yaml b/.github/workflows/erlang-checks.yaml index cc8a93e6..72524dd7 100644 --- a/.github/workflows/erlang-checks.yaml +++ b/.github/workflows/erlang-checks.yaml @@ -30,7 +30,7 @@ jobs: run: name: Run checks needs: setup - uses: valitydev/erlang-workflows/.github/workflows/erlang-parallel-build.yml@v1.0.16 + uses: valitydev/erlang-workflows/.github/workflows/erlang-parallel-build.yml@v1.0.17 with: otp-version: ${{ needs.setup.outputs.otp-version }} rebar-version: ${{ needs.setup.outputs.rebar-version }} diff --git a/rebar.config b/rebar.config index d987c48a..6b13ed2b 100644 --- a/rebar.config +++ b/rebar.config @@ -30,7 +30,7 @@ {gproc, "0.9.0"}, {genlib, {git, "https://github.com/valitydev/genlib.git", {branch, "master"}}}, {woody, {git, "https://github.com/valitydev/woody_erlang.git", {branch, "master"}}}, - {damsel, {git, "https://github.com/valitydev/damsel.git", {branch, "EMP-228/ft/additional-contact-info-fields"}}}, + {damsel, {git, "https://github.com/valitydev/damsel.git", {branch, "master"}}}, {payproc_errors, {git, "https://github.com/valitydev/payproc-errors-erlang.git", {branch, "master"}}}, {mg_proto, {git, "https://github.com/valitydev/machinegun-proto.git", {branch, "master"}}}, {dmt_client, {git, "https://github.com/valitydev/dmt-client.git", {branch, "master"}}}, diff --git a/rebar.lock b/rebar.lock index b3b1f74b..0ba51399 100644 --- a/rebar.lock +++ b/rebar.lock @@ -21,7 +21,7 @@ {<<"ctx">>,{pkg,<<"ctx">>,<<"0.6.0">>},2}, {<<"damsel">>, {git,"https://github.com/valitydev/damsel.git", - {ref,"f20444d7d091c0703220ed0c859df38e7f832295"}}, + {ref,"24932cdc557a75bfb3a4aeb1738638366003aba4"}}, 0}, {<<"dmt_client">>, {git,"https://github.com/valitydev/dmt-client.git",