TD-933: Fixes response serialization w/ randomized invoice amount (#50)

This commit is contained in:
Aleksey Kashapov 2024-07-08 12:54:47 +03:00 committed by GitHub
parent 85b19cb5f3
commit ea4e74b3c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View File

@ -67,7 +67,7 @@ decode_invoice_amount_mutation(Mutations) when is_list(Mutations) ->
({amount, #domain_InvoiceAmountMutation{original = Original, mutated = Mutated}}, _) ->
#{
<<"original">> => Original,
<<"mutated">> => Mutated
<<"randomized">> => Mutated
};
(_, AmountRandomized) ->
AmountRandomized

View File

@ -24,6 +24,7 @@
-export([
create_invoice_ok_test/1,
create_invoice_rand_amount_ok_test/1,
create_invoice_autorization_error_test/1,
get_invoice_by_external_id/1,
get_invoice_by_external_id_for_party/1,
@ -153,6 +154,7 @@ groups() ->
create_customer_access_token_ok_test,
create_invoice_ok_test,
create_invoice_rand_amount_ok_test,
create_invoice_autorization_error_test,
get_invoice_by_external_id,
get_invoice_by_external_id_for_party,
@ -307,6 +309,27 @@ create_invoice_ok_test(Config) ->
_ = capi_ct_helper_bouncer:mock_assert_shop_op_ctx(<<"CreateInvoice">>, ?STRING, ?STRING, Config),
{ok, _} = capi_client_invoices:create_invoice(?config(context, Config), ?INVOICE_PARAMS).
-spec create_invoice_rand_amount_ok_test(config()) -> _.
create_invoice_rand_amount_ok_test(Config) ->
RandomizedAmount = ?INTEGER + ?SMALLER_INTEGER,
ExpectedInvoice = ?INVOICE#domain_Invoice{
cost = ?CASH(RandomizedAmount),
mutations = [{amount, #domain_InvoiceAmountMutation{original = ?INTEGER, mutated = RandomizedAmount}}]
},
_ = capi_ct_helper:mock_services(
[
{invoicing, fun('Create', _) -> {ok, ?PAYPROC_INVOICE(ExpectedInvoice, [])} end},
{generator, fun('GenerateID', _) -> capi_ct_helper_bender:generate_id(<<"bender_key">>) end}
],
Config
),
_ = capi_ct_helper_bouncer:mock_assert_shop_op_ctx(<<"CreateInvoice">>, ?STRING, ?STRING, Config),
{ok, _} = capi_client_invoices:create_invoice(?config(context, Config), ?INVOICE_PARAMS#{
<<"randomizeAmount">> => #{
<<"deviation">> => ?SMALLER_INTEGER
}
}).
-spec create_invoice_autorization_error_test(config()) -> _.
create_invoice_autorization_error_test(Config) ->
_ = capi_ct_helper:mock_services(