mirror of
https://github.com/valitydev/party-management.git
synced 2024-11-06 09:15:18 +00:00
DC-127: Payment methods refactoring (#445)
* Use corresponding epic damsel branch * Bump dominant * Migrate to new bank_card payment method representation * Simplify guard clause Co-authored-by: Andrew Mayorov <a.mayorov@rbkmoney.com> * Delete invalid clauses in hg_payment_tool:get_method/1 * Remove marshaling that we don't use anymore * Correctly unmarshal tokenization_method * Revert "Correctly unmarshal tokenization_method" This reverts commit 6f14eefd003e3f80d087db97ca63c4ccc85152d8. * Do not unmarshal tokenization_method because it will never be there * Use old (_deprecated) payment methods * Replace has_cvv with is_cvv_empty * Upgrade damsel * Delete outdated comentaries * Return ordset of payment methods * Upgrade dominant * Upgrade damsel * Add tokenization_method to bank_card_deprecated * Rename function in hg_payment_tool, create function to test if payment method is supported * Simpilfy and rename payment methods matching * Export hg_payment_tool:get_possible_methods/1 * Upgrade damsel * Fix mising old bank card reference * Bump dominant * Fix construct_payment_method * Upgrade deps * Suffix with _derprecated payment methods * Bulk update deps * Mark deprecated pms introduced by merge Co-authored-by: Andrew Mayorov <a.mayorov@rbkmoney.com>
This commit is contained in:
parent
b85e9d3eb0
commit
a5d17b2b12
@ -17,7 +17,7 @@
|
||||
-spec create_from_method(method()) -> t().
|
||||
|
||||
%% TODO empty strings - ugly hack for dialyzar
|
||||
create_from_method(#domain_PaymentMethodRef{id = {empty_cvv_bank_card, PaymentSystem}}) ->
|
||||
create_from_method(#domain_PaymentMethodRef{id = {empty_cvv_bank_card_deprecated, PaymentSystem}}) ->
|
||||
{bank_card, #domain_BankCard{
|
||||
payment_system = PaymentSystem,
|
||||
token = <<"">>,
|
||||
@ -25,14 +25,14 @@ create_from_method(#domain_PaymentMethodRef{id = {empty_cvv_bank_card, PaymentSy
|
||||
last_digits = <<"">>,
|
||||
is_cvv_empty = true
|
||||
}};
|
||||
create_from_method(#domain_PaymentMethodRef{id = {bank_card, PaymentSystem}}) ->
|
||||
create_from_method(#domain_PaymentMethodRef{id = {bank_card_deprecated, PaymentSystem}}) ->
|
||||
{bank_card, #domain_BankCard{
|
||||
payment_system = PaymentSystem,
|
||||
token = <<"">>,
|
||||
bin = <<"">>,
|
||||
last_digits = <<"">>
|
||||
}};
|
||||
create_from_method(#domain_PaymentMethodRef{id = {tokenized_bank_card, #domain_TokenizedBankCard{
|
||||
create_from_method(#domain_PaymentMethodRef{id = {tokenized_bank_card_deprecated, #domain_TokenizedBankCard{
|
||||
payment_system = PaymentSystem,
|
||||
token_provider = TokenProvider,
|
||||
tokenization_method = TokenizationMethod
|
||||
@ -45,6 +45,21 @@ create_from_method(#domain_PaymentMethodRef{id = {tokenized_bank_card, #domain_T
|
||||
token_provider = TokenProvider,
|
||||
tokenization_method = TokenizationMethod
|
||||
}};
|
||||
create_from_method(#domain_PaymentMethodRef{id = {bank_card, #domain_BankCardPaymentMethod{
|
||||
payment_system = PaymentSystem,
|
||||
is_cvv_empty = IsCVVEmpty,
|
||||
token_provider = TokenProvider,
|
||||
tokenization_method = TokenizationMethod
|
||||
}}}) ->
|
||||
{bank_card, #domain_BankCard{
|
||||
payment_system = PaymentSystem,
|
||||
token = <<"">>,
|
||||
bin = <<"">>,
|
||||
last_digits = <<"">>,
|
||||
token_provider = TokenProvider,
|
||||
is_cvv_empty = IsCVVEmpty,
|
||||
tokenization_method = TokenizationMethod
|
||||
}};
|
||||
create_from_method(#domain_PaymentMethodRef{id = {payment_terminal, TerminalType}}) ->
|
||||
{payment_terminal, #domain_PaymentTerminal{terminal_type = TerminalType}};
|
||||
create_from_method(#domain_PaymentMethodRef{id = {digital_wallet, Provider}}) ->
|
||||
|
@ -558,7 +558,7 @@ construct_domain_fixture() ->
|
||||
?cat(3)
|
||||
])},
|
||||
payment_methods = {value, ordsets:from_list([
|
||||
?pmt(bank_card, visa)
|
||||
?pmt(bank_card_deprecated, visa)
|
||||
])}
|
||||
}
|
||||
},
|
||||
@ -630,11 +630,11 @@ construct_domain_fixture() ->
|
||||
pm_ct_fixture:construct_category(?cat(2), <<"Generic Store">>, live),
|
||||
pm_ct_fixture:construct_category(?cat(3), <<"Guns & Booze">>, live),
|
||||
|
||||
pm_ct_fixture:construct_payment_method(?pmt(bank_card, visa)),
|
||||
pm_ct_fixture:construct_payment_method(?pmt(bank_card, mastercard)),
|
||||
pm_ct_fixture:construct_payment_method(?pmt(bank_card, maestro)),
|
||||
pm_ct_fixture:construct_payment_method(?pmt(bank_card_deprecated, visa)),
|
||||
pm_ct_fixture:construct_payment_method(?pmt(bank_card_deprecated, mastercard)),
|
||||
pm_ct_fixture:construct_payment_method(?pmt(bank_card_deprecated, maestro)),
|
||||
pm_ct_fixture:construct_payment_method(?pmt(payment_terminal, euroset)),
|
||||
pm_ct_fixture:construct_payment_method(?pmt(empty_cvv_bank_card, visa)),
|
||||
pm_ct_fixture:construct_payment_method(?pmt(empty_cvv_bank_card_deprecated, visa)),
|
||||
|
||||
pm_ct_fixture:construct_payout_method(?pomt(russian_bank_account)),
|
||||
pm_ct_fixture:construct_payout_method(?pomt(international_bank_account)),
|
||||
@ -763,7 +763,7 @@ construct_domain_fixture() ->
|
||||
?cat(2)
|
||||
])},
|
||||
payment_methods = {value, ordsets:from_list([
|
||||
?pmt(bank_card, visa)
|
||||
?pmt(bank_card_deprecated, visa)
|
||||
])}
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,9 @@ construct_category(Ref, Name, Type) ->
|
||||
construct_payment_method(?pmt(_Type, ?tkz_bank_card(Name, _)) = Ref) when is_atom(Name) ->
|
||||
construct_payment_method(Name, Ref);
|
||||
construct_payment_method(?pmt(_Type, Name) = Ref) when is_atom(Name) ->
|
||||
construct_payment_method(Name, Ref).
|
||||
construct_payment_method(Name, Ref);
|
||||
construct_payment_method(?pmt(_Type, #domain_BankCardPaymentMethod{}) = Ref) ->
|
||||
construct_payment_method(Ref#domain_BankCardPaymentMethod.payment_system, Ref).
|
||||
|
||||
construct_payment_method(Name, Ref) ->
|
||||
Def = erlang:atom_to_binary(Name, unicode),
|
||||
|
@ -382,8 +382,11 @@ end_per_testcase(_Name, _C) ->
|
||||
-define(REAL_CONTRACTOR_ID, <<"CONTRACTOR1">>).
|
||||
-define(REAL_CONTRACT_ID, <<"CONTRACT1">>).
|
||||
-define(REAL_WALLET_ID, <<"WALLET1">>).
|
||||
-define(REAL_PARTY_PAYMENT_METHODS,
|
||||
[?pmt(bank_card, maestro), ?pmt(bank_card, mastercard), ?pmt(bank_card, visa)]).
|
||||
-define(REAL_PARTY_PAYMENT_METHODS, [
|
||||
?pmt(bank_card_deprecated, maestro),
|
||||
?pmt(bank_card_deprecated, mastercard),
|
||||
?pmt(bank_card_deprecated, visa)
|
||||
]).
|
||||
|
||||
-spec party_creation(config()) -> _ | no_return().
|
||||
-spec party_not_found_on_retrieval(config()) -> _ | no_return().
|
||||
@ -583,7 +586,7 @@ contract_terms_retrieval(C) ->
|
||||
ContractID, Timstamp1, {revision, PartyRevision}, DomainRevision1, Varset, Client
|
||||
),
|
||||
#domain_TermSet{payments = #domain_PaymentsServiceTerms{
|
||||
payment_methods = {value, [?pmt(bank_card, visa)]}
|
||||
payment_methods = {value, [?pmt(bank_card_deprecated, visa)]}
|
||||
}} = TermSet1,
|
||||
ok = pm_domain:update(construct_term_set_for_party(PartyID, undefined)),
|
||||
DomainRevision2 = pm_domain:head(),
|
||||
@ -816,7 +819,7 @@ compute_payment_institution_terms(C) ->
|
||||
),
|
||||
#domain_TermSet{} = T2 = pm_client_party:compute_payment_institution_terms(
|
||||
?pinst(2),
|
||||
#payproc_Varset{payment_method = ?pmt(bank_card, visa)},
|
||||
#payproc_Varset{payment_method = ?pmt(bank_card_deprecated, visa)},
|
||||
Client
|
||||
),
|
||||
T1 /= T2 orelse error({equal_term_sets, T1, T2}),
|
||||
@ -827,7 +830,7 @@ compute_payment_institution_terms(C) ->
|
||||
),
|
||||
#domain_TermSet{} = T4 = pm_client_party:compute_payment_institution_terms(
|
||||
?pinst(2),
|
||||
#payproc_Varset{payment_method = ?pmt(empty_cvv_bank_card, visa)},
|
||||
#payproc_Varset{payment_method = ?pmt(empty_cvv_bank_card_deprecated, visa)},
|
||||
Client
|
||||
),
|
||||
T1 /= T3 orelse error({equal_term_sets, T1, T3}),
|
||||
@ -970,7 +973,7 @@ shop_terms_retrieval(C) ->
|
||||
Timestamp = pm_datetime:format_now(),
|
||||
TermSet1 = pm_client_party:compute_shop_terms(ShopID, Timestamp, {timestamp, Timestamp}, Client),
|
||||
#domain_TermSet{payments = #domain_PaymentsServiceTerms{
|
||||
payment_methods = {value, [?pmt(bank_card, visa)]}
|
||||
payment_methods = {value, [?pmt(bank_card_deprecated, visa)]}
|
||||
}} = TermSet1,
|
||||
ok = pm_domain:update(construct_term_set_for_party(PartyID, {shop_is, ShopID})),
|
||||
TermSet2 = pm_client_party:compute_shop_terms(ShopID, pm_datetime:format_now(), {timestamp, Timestamp}, Client),
|
||||
@ -1542,7 +1545,7 @@ compute_provider_terminal_terms_ok(C) ->
|
||||
?share_with_rounding_method(5, 100, operation_amount, round_half_towards_zero)
|
||||
])}}
|
||||
),
|
||||
PaymentMethods = ?ordset([?pmt(bank_card, visa)]),
|
||||
PaymentMethods = ?ordset([?pmt(bank_card_deprecated, visa)]),
|
||||
#domain_ProvisionTermSet{
|
||||
payments = #domain_PaymentsProvisionTerms{
|
||||
cash_flow = {value, [CashFlow]},
|
||||
@ -1664,7 +1667,7 @@ compute_terms_w_criteria(C) ->
|
||||
ContractID, Timstamp, {revision, PartyRevision}, Revision,
|
||||
#payproc_Varset{
|
||||
currency = ?cur(<<"KZT">>),
|
||||
payment_method = ?pmt(bank_card, visa)
|
||||
payment_method = ?pmt(bank_card_deprecated, visa)
|
||||
},
|
||||
Client
|
||||
)
|
||||
@ -1677,7 +1680,7 @@ compute_terms_w_criteria(C) ->
|
||||
ContractID, Timstamp, {revision, PartyRevision}, Revision,
|
||||
#payproc_Varset{
|
||||
currency = ?cur(<<"KZT">>),
|
||||
payment_method = ?pmt(empty_cvv_bank_card, visa)
|
||||
payment_method = ?pmt(empty_cvv_bank_card_deprecated, visa)
|
||||
},
|
||||
Client
|
||||
)
|
||||
@ -1690,7 +1693,7 @@ compute_terms_w_criteria(C) ->
|
||||
ContractID, Timstamp, {revision, PartyRevision}, Revision,
|
||||
#payproc_Varset{
|
||||
currency = ?cur(<<"RUB">>),
|
||||
payment_method = ?pmt(bank_card, visa)
|
||||
payment_method = ?pmt(bank_card_deprecated, visa)
|
||||
},
|
||||
Client
|
||||
)
|
||||
@ -1783,7 +1786,7 @@ construct_term_set_for_party(PartyID, Def) ->
|
||||
#domain_PaymentMethodDecision{
|
||||
if_ = {constant, true},
|
||||
then_ = {value, ordsets:from_list([
|
||||
?pmt(bank_card, visa)
|
||||
?pmt(bank_card_deprecated, visa)
|
||||
])}
|
||||
}
|
||||
]}
|
||||
@ -1820,7 +1823,7 @@ construct_domain_fixture() ->
|
||||
?cat(3)
|
||||
])},
|
||||
payment_methods = {value, ordsets:from_list([
|
||||
?pmt(bank_card, visa)
|
||||
?pmt(bank_card_deprecated, visa)
|
||||
])}
|
||||
}
|
||||
},
|
||||
@ -2061,11 +2064,11 @@ construct_domain_fixture() ->
|
||||
pm_ct_fixture:construct_category(?cat(2), <<"Generic Store">>, live),
|
||||
pm_ct_fixture:construct_category(?cat(3), <<"Guns & Booze">>, live),
|
||||
|
||||
pm_ct_fixture:construct_payment_method(?pmt(bank_card, visa)),
|
||||
pm_ct_fixture:construct_payment_method(?pmt(bank_card, mastercard)),
|
||||
pm_ct_fixture:construct_payment_method(?pmt(bank_card, maestro)),
|
||||
pm_ct_fixture:construct_payment_method(?pmt(bank_card_deprecated, visa)),
|
||||
pm_ct_fixture:construct_payment_method(?pmt(bank_card_deprecated, mastercard)),
|
||||
pm_ct_fixture:construct_payment_method(?pmt(bank_card_deprecated, maestro)),
|
||||
pm_ct_fixture:construct_payment_method(?pmt(payment_terminal, euroset)),
|
||||
pm_ct_fixture:construct_payment_method(?pmt(empty_cvv_bank_card, visa)),
|
||||
pm_ct_fixture:construct_payment_method(?pmt(empty_cvv_bank_card_deprecated, visa)),
|
||||
|
||||
pm_ct_fixture:construct_payout_method(?pomt(russian_bank_account)),
|
||||
pm_ct_fixture:construct_payout_method(?pomt(international_bank_account)),
|
||||
@ -2163,7 +2166,7 @@ construct_domain_fixture() ->
|
||||
?cat(2)
|
||||
])},
|
||||
payment_methods = {value, ordsets:from_list([
|
||||
?pmt(bank_card, visa)
|
||||
?pmt(bank_card_deprecated, visa)
|
||||
])}
|
||||
}
|
||||
}
|
||||
@ -2294,8 +2297,8 @@ construct_domain_fixture() ->
|
||||
currencies = {value, ?ordset([?cur(<<"RUB">>)])},
|
||||
categories = {value, ?ordset([?cat(1)])},
|
||||
payment_methods = {value, ?ordset([
|
||||
?pmt(bank_card, visa),
|
||||
?pmt(bank_card, mastercard)
|
||||
?pmt(bank_card_deprecated, visa),
|
||||
?pmt(bank_card_deprecated, mastercard)
|
||||
])},
|
||||
cash_limit = {value, ?cashrng(
|
||||
{inclusive, ?cash( 1000, <<"RUB">>)},
|
||||
@ -2337,8 +2340,8 @@ construct_domain_fixture() ->
|
||||
recurrent_paytools = #domain_RecurrentPaytoolsProvisionTerms{
|
||||
categories = {value, ?ordset([?cat(1)])},
|
||||
payment_methods = {value, ?ordset([
|
||||
?pmt(bank_card, visa),
|
||||
?pmt(bank_card, mastercard)
|
||||
?pmt(bank_card_deprecated, visa),
|
||||
?pmt(bank_card_deprecated, mastercard)
|
||||
])},
|
||||
cash_value = {decisions, [
|
||||
#domain_CashValueDecision{
|
||||
@ -2363,7 +2366,7 @@ construct_domain_fixture() ->
|
||||
terms = #domain_ProvisionTermSet{
|
||||
payments = #domain_PaymentsProvisionTerms{
|
||||
payment_methods = {value, ?ordset([
|
||||
?pmt(bank_card, visa)
|
||||
?pmt(bank_card_deprecated, visa)
|
||||
])}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ services:
|
||||
mem_limit: 256M
|
||||
|
||||
dominant:
|
||||
image: dr2.rbkmoney.com/rbkmoney/dominant:d7d9d5c69e97c9436b26941b5a986fb70d0b7f1b
|
||||
image: dr2.rbkmoney.com/rbkmoney/dominant:6896d15357e87eb3de47d3e1aabcb1444e9c4f90
|
||||
command: /opt/dominant/bin/dominant foreground
|
||||
depends_on:
|
||||
machinegun:
|
||||
|
@ -10,7 +10,7 @@
|
||||
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.8.0">>},2},
|
||||
{<<"damsel">>,
|
||||
{git,"git@github.com:rbkmoney/damsel.git",
|
||||
{ref,"93687b644f4978751dcfa5ab1c03856d0be8a4bf"}},
|
||||
{ref,"735897b8b802e7d983bafada28cbc789049e7428"}},
|
||||
0},
|
||||
{<<"dmt_client">>,
|
||||
{git,"git@github.com:rbkmoney/dmt_client.git",
|
||||
|
Loading…
Reference in New Issue
Block a user