diff --git a/apps/capi/src/capi_handler_utils.erl b/apps/capi/src/capi_handler_utils.erl index e9f9788..a770470 100644 --- a/apps/capi/src/capi_handler_utils.erl +++ b/apps/capi/src/capi_handler_utils.erl @@ -185,20 +185,25 @@ create_checkout_url(Invoice, AccessToken, Params0, ProcessingContext) -> #{<<"url">> => <>} end. +-define(CHECKOUT_BASE_URL(BaseUrl), #domain_CheckoutLocations{ + locations = [#domain_CheckoutLocation{base_url = BaseUrl} | _] +}). + get_base_url( #domain_Invoice{party_ref = #domain_PartyConfigRef{id = PartyID}, shop_ref = #domain_ShopConfigRef{id = ShopID}}, #{default_base_url := Default}, ProcessingContext ) -> case capi_party:get_shop(PartyID, ShopID, ProcessingContext) of - {ok, #domain_ShopConfig{ - checkout_location = #domain_ShopCheckoutLocation{ - locations = [#domain_CheckoutLocation{base_url = V} | _] - } - }} -> + {ok, #domain_ShopConfig{checkout_locations = ?CHECKOUT_BASE_URL(V)}} -> V; _ -> - Default + case capi_party:get_party(PartyID, ProcessingContext) of + {ok, #domain_PartyConfig{checkout_locations = ?CHECKOUT_BASE_URL(V)}} -> + V; + _ -> + Default + end end. -spec issue_access_token(token_source(), processing_context()) -> map(). diff --git a/apps/capi/test/capi_dummy_data.hrl b/apps/capi/test/capi_dummy_data.hrl index a5dad45..66c1c53 100644 --- a/apps/capi/test/capi_dummy_data.hrl +++ b/apps/capi/test/capi_dummy_data.hrl @@ -458,7 +458,7 @@ party_ref = #domain_PartyConfigRef{id = ?STRING}, location = ?SHOP_LOCATION, category = #domain_CategoryRef{id = ?INTEGER}, - checkout_location = #domain_ShopCheckoutLocation{ + checkout_locations = #domain_CheckoutLocations{ locations = [#domain_CheckoutLocation{base_url = ?CHECKOUT_URL}] } }). diff --git a/rebar.config b/rebar.config index 214b4a8..96325de 100644 --- a/rebar.config +++ b/rebar.config @@ -36,7 +36,7 @@ {cowboy_draining_server, {git, "https://github.com/valitydev/cowboy_draining_server.git", {branch, "master"}}}, {woody, {git, "https://github.com/valitydev/woody_erlang.git", {tag, "v1.1.0"}}}, {woody_user_identity, {git, "https://github.com/valitydev/woody_erlang_user_identity.git", {tag, "v1.1.0"}}}, - {damsel, {git, "https://github.com/valitydev/damsel.git", {tag, "v2.2.37"}}}, + {damsel, {git, "https://github.com/valitydev/damsel.git", {tag, "v2.2.39"}}}, {bender_proto, {git, "https://github.com/valitydev/bender-proto.git", {branch, "master"}}}, {bender_client, {git, "https://github.com/valitydev/bender-client-erlang.git", {tag, "v1.1.0"}}}, {dmt_client, {git, "https://github.com/valitydev/dmt_client.git", {tag, "v2.0.3"}}}, diff --git a/rebar.lock b/rebar.lock index 561f8bd..653552e 100644 --- a/rebar.lock +++ b/rebar.lock @@ -41,7 +41,7 @@ {<<"ctx">>,{pkg,<<"ctx">>,<<"0.6.0">>},2}, {<<"damsel">>, {git,"https://github.com/valitydev/damsel.git", - {ref,"dcd668277f5a2a144dd823bb0e6c9ba7b94428cc"}}, + {ref,"25e75a53bbdc2cdbda7da266d05ae626fa3fa69b"}}, 0}, {<<"dmt_client">>, {git,"https://github.com/valitydev/dmt_client.git",