diff --git a/apps/hellgate/include/hg_invoice.hrl b/apps/hellgate/include/hg_invoice.hrl index 211febd4..dfdbaf36 100644 --- a/apps/hellgate/include/hg_invoice.hrl +++ b/apps/hellgate/include/hg_invoice.hrl @@ -5,7 +5,8 @@ activity :: undefined | hg_invoice:activity(), invoice :: undefined | hg_invoice:invoice(), payments = [] :: [{hg_invoice:payment_id(), hg_invoice:payment_st()}], - party :: undefined | hg_invoice:party() + party :: undefined | hg_invoice:party(), + party_id :: undefined | hg_invoice:party_id() }). -endif. diff --git a/apps/hellgate/src/hg_accounting.erl b/apps/hellgate/src/hg_accounting.erl index 3de3d053..b4d1b8af 100644 --- a/apps/hellgate/src/hg_accounting.erl +++ b/apps/hellgate/src/hg_accounting.erl @@ -12,7 +12,7 @@ -export([create_account/1]). -export([create_account/2]). -export([collect_account_map/1]). --export([collect_merchant_account_map/4]). +-export([collect_merchant_account_map/3]). -export([collect_provider_account_map/4]). -export([collect_system_account_map/4]). -export([collect_external_account_map/4]). @@ -27,7 +27,6 @@ -include_lib("damsel/include/dmsl_accounter_thrift.hrl"). -type amount() :: dmsl_domain_thrift:'Amount'(). --type currency() :: dmsl_domain_thrift:'CurrencyRef'(). -type currency_code() :: dmsl_domain_thrift:'CurrencySymbolicCode'(). -type account_id() :: dmsl_accounter_thrift:'AccountID'(). -type plan_id() :: dmsl_accounter_thrift:'PlanID'(). @@ -38,8 +37,9 @@ -type thrift_account() :: dmsl_accounter_thrift:'Account'(). -type payment() :: dmsl_domain_thrift:'InvoicePayment'(). --type party() :: dmsl_domain_thrift:'PartyConfig'(). +-type party_id() :: dmsl_domain_thrift:'PartyID'(). -type shop() :: dmsl_domain_thrift:'ShopConfig'(). +-type shop_id() :: dmsl_domain_thrift:'ShopConfigID'(). -type route() :: hg_route:payment_route(). -type payment_institution() :: dmsl_domain_thrift:'PaymentInstitution'(). -type provider() :: dmsl_domain_thrift:'Provider'(). @@ -48,8 +48,8 @@ -type collect_account_context() :: #{ payment := payment(), - party := party(), - shop := shop(), + party_id := party_id(), + shop := {shop_id(), shop()}, route := route(), payment_institution := payment_institution(), provider := provider(), @@ -100,29 +100,26 @@ create_account(CurrencyCode, Description) -> -spec collect_account_map(collect_account_context()) -> map(). collect_account_map(#{ - payment := #domain_InvoicePayment{cost = #domain_Cash{currency = Currency}} = Payment, - party := Party, - shop := Shop, + payment := Payment, + party_id := PartyID, + shop := ShopObj, route := Route, payment_institution := PaymentInstitution, provider := Provider, varset := VS, revision := Revision }) -> - Map0 = collect_merchant_account_map(Currency, Party, Shop, #{}), + Map0 = collect_merchant_account_map(PartyID, ShopObj, #{}), Map1 = collect_provider_account_map(Payment, Provider, Route, Map0), Map2 = collect_system_account_map(Payment, PaymentInstitution, Revision, Map1), collect_external_account_map(Payment, VS, Revision, Map2). --spec collect_merchant_account_map(currency(), party(), shop(), map()) -> map(). -collect_merchant_account_map( - Currency, #domain_PartyConfig{id = PartyID}, #domain_ShopConfig{id = ShopID, currency_configs = Configs}, Acc -) -> - #{Currency := Config} = Configs, +-spec collect_merchant_account_map(party_id(), {shop_id(), shop()}, map()) -> map(). +collect_merchant_account_map(PartyID, {ShopID, #domain_ShopConfig{account = Account}}, Acc) -> Acc#{ merchant => {PartyID, ShopID}, - {merchant, settlement} => Config#domain_ShopCurrencyConfig.settlement, - {merchant, guarantee} => Config#domain_ShopCurrencyConfig.guarantee + {merchant, settlement} => Account#domain_ShopAccount.settlement, + {merchant, guarantee} => Account#domain_ShopAccount.guarantee }. -spec collect_provider_account_map(payment(), provider(), route(), map()) -> map(). diff --git a/apps/hellgate/src/hg_cashflow_utils.erl b/apps/hellgate/src/hg_cashflow_utils.erl index 4149e938..119b02c2 100644 --- a/apps/hellgate/src/hg_cashflow_utils.erl +++ b/apps/hellgate/src/hg_cashflow_utils.erl @@ -10,8 +10,8 @@ -type cash_flow_context() :: #{ operation := refund | payment, provision_terms := dmsl_domain_thrift:'PaymentsProvisionTerms'(), - party := party(), - shop := shop(), + party := {party_id(), party()}, + shop := {shop_id(), shop()}, route := route(), payment := payment(), provider := provider(), @@ -29,7 +29,9 @@ -export([collect_cashflow/2]). -type party() :: dmsl_domain_thrift:'PartyConfig'(). +-type party_id() :: dmsl_domain_thrift:'PartyID'(). -type shop() :: dmsl_domain_thrift:'ShopConfig'(). +-type shop_id() :: dmsl_domain_thrift:'ShopConfigID'(). -type route() :: dmsl_domain_thrift:'PaymentRoute'(). -type payment() :: dmsl_domain_thrift:'InvoicePayment'(). -type refund() :: dmsl_domain_thrift:'InvoicePaymentRefund'(). @@ -39,8 +41,8 @@ -type final_cash_flow() :: hg_cashflow:final_cash_flow(). -spec collect_cashflow(cash_flow_context()) -> final_cash_flow(). -collect_cashflow(#{party := Party, shop := Shop, varset := VS, revision := Revision} = Context) -> - PaymentInstitution = get_cashflow_payment_institution(Party, Shop, VS, Revision), +collect_cashflow(#{shop := {_, Shop}, varset := VS, revision := Revision} = Context) -> + PaymentInstitution = get_cashflow_payment_institution(Shop, VS, Revision), collect_cashflow(PaymentInstitution, Context). -spec collect_cashflow(payment_institution(), cash_flow_context()) -> final_cash_flow(). @@ -62,27 +64,26 @@ collect_allocation_cash_flow( Transactions, Context = #{ revision := Revision, - party := Party, - shop := Shop, + shop := {_, Shop}, varset := VS0 } ) -> lists:foldl( fun(?allocation_trx(_ID, Target, Amount), Acc) -> ?allocation_trx_target_shop(PartyID, ShopID) = Target, - TargetParty = hg_party:get_party(PartyID), - TargetShop = hg_party:get_shop(ShopID, TargetParty, Revision), + {PartyID, TargetParty} = hg_party:get_party(PartyID), + {ShopID, TargetShop} = hg_party:get_shop(ShopID, TargetParty, Revision), VS1 = VS0#{ - party_id => Party#domain_PartyConfig.id, - shop_id => Shop#domain_ShopConfig.id, + party_id => PartyID, + shop_id => ShopID, cost => Amount }, AllocationPaymentInstitution = - get_cashflow_payment_institution(Party, Shop, VS1, Revision), + get_cashflow_payment_institution(Shop, VS1, Revision), construct_transaction_cashflow( Amount, AllocationPaymentInstitution, - Context#{party => TargetParty, shop => TargetShop} + Context#{party => {PartyID, TargetParty}, shop => {ShopID, TargetShop}} ) ++ Acc end, [], @@ -95,7 +96,7 @@ construct_transaction_cashflow( Context = #{ revision := Revision, operation := OpType, - shop := Shop, + shop := {_, Shop}, varset := VS } ) -> @@ -122,7 +123,6 @@ construct_final_cashflow(Cashflow, Context, AccountMap) -> hg_cashflow:finalize(Cashflow, Context, AccountMap). get_cashflow_payment_institution( - _Party, #domain_ShopConfig{payment_institution = PaymentInstitutionRef}, VS, Revision @@ -161,7 +161,7 @@ get_selector_value(Name, Selector) -> hg_accounting:collect_account_context(). make_collect_account_context(PaymentInstitution, #{ payment := Payment, - party := Party, + party := {PartyID, _}, shop := Shop, route := Route, provider := Provider, @@ -170,7 +170,7 @@ make_collect_account_context(PaymentInstitution, #{ }) -> #{ payment => Payment, - party => Party, + party_id => PartyID, shop => Shop, route => Route, payment_institution => PaymentInstitution, diff --git a/apps/hellgate/src/hg_inspector.erl b/apps/hellgate/src/hg_inspector.erl index 8a837a21..e980abd9 100644 --- a/apps/hellgate/src/hg_inspector.erl +++ b/apps/hellgate/src/hg_inspector.erl @@ -100,14 +100,13 @@ inspect( RiskScore. get_payment_info( - #domain_ShopConfig{ - id = ShopID, + Shop = #domain_ShopConfig{ category = CategoryRef, - details = ShopDetails, location = Location }, #domain_Invoice{ owner_id = PartyID, + shop_id = ShopID, id = InvoiceID, created_at = InvoiceCreatedAt, due = InvoiceDue, @@ -133,10 +132,8 @@ get_payment_info( ProxyShop = #proxy_inspector_Shop{ id = ShopID, category = ShopCategory, - details = #domain_ShopDetails{ - name = ShopDetails#domain_Details.name, - description = ShopDetails#domain_Details.description - }, + name = Shop#domain_ShopConfig.name, + description = Shop#domain_ShopConfig.description, location = Location }, ProxyInvoice = #proxy_inspector_Invoice{ diff --git a/apps/hellgate/src/hg_invoice.erl b/apps/hellgate/src/hg_invoice.erl index 207efdcc..d199ddec 100644 --- a/apps/hellgate/src/hg_invoice.erl +++ b/apps/hellgate/src/hg_invoice.erl @@ -31,13 +31,14 @@ -export_type([payment_id/0]). -export_type([payment_st/0]). -export_type([party/0]). +-export_type([party_id/0]). %% Public interface -export([get/1]). -export([get_payment/2]). -export([get_payment_opts/1]). --export([create/5]). +-export([create/6]). -export([marshal_invoice/1]). -export([unmarshal_history/1]). -export([collapse_history/1]). @@ -76,6 +77,8 @@ -type invoice() :: dmsl_domain_thrift:'Invoice'(). -type allocation() :: dmsl_domain_thrift:'Allocation'(). -type party() :: dmsl_domain_thrift:'PartyConfig'(). +-type party_id() :: dmsl_domain_thrift:'PartyID'(). +-type revision() :: dmt_client:vsn(). -type payment_id() :: dmsl_domain_thrift:'InvoicePaymentID'(). -type payment_st() :: hg_invoice_payment:st(). @@ -106,14 +109,17 @@ get_payment(PaymentID, St) -> -spec get_payment_opts(st()) -> hg_invoice_payment:opts(). get_payment_opts(St = #st{invoice = Invoice, party = undefined}) -> + {PartyID, Party} = hg_party:get_party(get_party_id(St)), #{ - party => hg_party:get_party(get_party_id(St)), + party => Party, + party_id => PartyID, invoice => Invoice, timestamp => hg_datetime:format_now() }; -get_payment_opts(#st{invoice = Invoice, party = Party}) -> +get_payment_opts(#st{invoice = Invoice, party = Party, party_id = PartyID}) -> #{ party => Party, + party_id => PartyID, invoice => Invoice, timestamp => hg_datetime:format_now() }. @@ -121,8 +127,10 @@ get_payment_opts(#st{invoice = Invoice, party = Party}) -> -spec get_payment_opts(hg_domain:revision(), st()) -> hg_invoice_payment:opts(). get_payment_opts(Revision, St = #st{invoice = Invoice}) -> + {PartyID, Party} = hg_party:checkout(get_party_id(St), Revision), #{ - party => hg_party:checkout(get_party_id(St), Revision), + party => Party, + party_id => PartyID, invoice => Invoice, timestamp => hg_datetime:format_now() }. @@ -132,10 +140,11 @@ get_payment_opts(Revision, St = #st{invoice = Invoice}) -> undefined | hg_machine:id(), invoice_params(), undefined | allocation(), - [hg_invoice_mutation:mutation()] + [hg_invoice_mutation:mutation()], + revision() ) -> invoice(). -create(ID, InvoiceTplID, V = #payproc_InvoiceParams{}, _Allocation, Mutations) -> +create(ID, InvoiceTplID, V = #payproc_InvoiceParams{}, _Allocation, Mutations, DomainRevision) -> OwnerID = V#payproc_InvoiceParams.party_id, ShopID = V#payproc_InvoiceParams.shop_id, Cost = V#payproc_InvoiceParams.cost, @@ -146,6 +155,7 @@ create(ID, InvoiceTplID, V = #payproc_InvoiceParams{}, _Allocation, Mutations) - created_at = hg_datetime:format_now(), status = ?invoice_unpaid(), cost = Cost, + domain_revision = DomainRevision, due = V#payproc_InvoiceParams.due, details = V#payproc_InvoiceParams.details, context = V#payproc_InvoiceParams.context, @@ -174,12 +184,12 @@ assert_invoice({status, Status}, #st{invoice = #domain_Invoice{status = {Status, assert_invoice({status, _Status}, #st{invoice = #domain_Invoice{status = Invalid}}) -> throw(?invalid_invoice_status(Invalid)). -assert_party_shop_operable(Shop, Party) -> +assert_party_shop_operable({_ShopID, Shop}, Party) -> _ = assert_party_operable(Party), _ = assert_shop_operable(Shop), ok. -assert_party_shop_unblocked(Shop, Party) -> +assert_party_shop_unblocked({_ShopID, Shop}, Party) -> _ = assert_party_unblocked(Party), _ = assert_shop_unblocked(Shop), ok. @@ -381,15 +391,15 @@ process_call(Call, #{history := History}) -> -spec handle_call(call(), st()) -> call_result(). handle_call({{'Invoicing', 'StartPayment'}, {_InvoiceID, PaymentParams}}, St0) -> - St = St0#st{party = hg_party:get_party(get_party_id(St0))}, + St = add_party_to_st(St0), _ = assert_invoice(operable, St), start_payment(PaymentParams, St); handle_call({{'Invoicing', 'RegisterPayment'}, {_InvoiceID, PaymentParams}}, St0) -> - St = St0#st{party = hg_party:get_party(get_party_id(St0))}, + St = add_party_to_st(St0), _ = assert_invoice(unblocked, St), register_payment(PaymentParams, St); handle_call({{'Invoicing', 'CapturePayment'}, {_InvoiceID, PaymentID, Params}}, St0) -> - St = St0#st{party = hg_party:get_party(get_party_id(St0))}, + St = add_party_to_st(St0), _ = assert_invoice(operable, St), #payproc_InvoicePaymentCaptureParams{ reason = Reason, @@ -406,7 +416,7 @@ handle_call({{'Invoicing', 'CapturePayment'}, {_InvoiceID, PaymentID, Params}}, state => St }; handle_call({{'Invoicing', 'CancelPayment'}, {_InvoiceID, PaymentID, Reason}}, St0) -> - St = St0#st{party = hg_party:get_party(get_party_id(St0))}, + St = add_party_to_st(St0), _ = assert_invoice(operable, St), PaymentSession = get_payment_session(PaymentID, St), {ok, {Changes, Action}} = hg_invoice_payment:cancel(PaymentSession, Reason), @@ -417,7 +427,7 @@ handle_call({{'Invoicing', 'CancelPayment'}, {_InvoiceID, PaymentID, Reason}}, S state => St }; handle_call({{'Invoicing', 'Fulfill'}, {_InvoiceID, Reason}}, St0) -> - St = St0#st{party = hg_party:get_party(get_party_id(St0))}, + St = add_party_to_st(St0), _ = assert_invoice([operable, {status, paid}], St), #{ response => ok, @@ -425,7 +435,7 @@ handle_call({{'Invoicing', 'Fulfill'}, {_InvoiceID, Reason}}, St0) -> state => St }; handle_call({{'Invoicing', 'Rescind'}, {_InvoiceID, Reason}}, St0) -> - St = St0#st{party = hg_party:get_party(get_party_id(St0))}, + St = add_party_to_st(St0), _ = assert_invoice([operable, {status, unpaid}], St), _ = assert_no_pending_payment(St), #{ @@ -435,12 +445,12 @@ handle_call({{'Invoicing', 'Rescind'}, {_InvoiceID, Reason}}, St0) -> state => St }; handle_call({{'Invoicing', 'RefundPayment'}, {_InvoiceID, PaymentID, Params}}, St0) -> - St = St0#st{party = hg_party:get_party(get_party_id(St0))}, + St = add_party_to_st(St0), _ = assert_invoice(operable, St), PaymentSession = get_payment_session(PaymentID, St), start_refund(refund, Params, PaymentID, PaymentSession, St); handle_call({{'Invoicing', 'CreateManualRefund'}, {_InvoiceID, PaymentID, Params}}, St0) -> - St = St0#st{party = hg_party:get_party(get_party_id(St0))}, + St = add_party_to_st(St0), _ = assert_invoice(operable, St), PaymentSession = get_payment_session(PaymentID, St), start_refund(manual_refund, Params, PaymentID, PaymentSession, St); @@ -887,6 +897,10 @@ check_non_idle_payments_([{PaymentID, PaymentSession} | Rest], St) -> check_non_idle_payments_(Rest, St) end. +add_party_to_st(St) -> + {PartyID, Party} = hg_party:get_party(get_party_id(St)), + St#st{party = Party, party_id = PartyID}. + get_party_id(#st{invoice = #domain_Invoice{owner_id = PartyID}}) -> PartyID. diff --git a/apps/hellgate/src/hg_invoice_handler.erl b/apps/hellgate/src/hg_invoice_handler.erl index 4309dc60..cda145ca 100644 --- a/apps/hellgate/src/hg_invoice_handler.erl +++ b/apps/hellgate/src/hg_invoice_handler.erl @@ -37,34 +37,34 @@ handle_function_('Create', {InvoiceParams}, _Opts) -> _ = set_invoicing_meta(InvoiceID), PartyID = InvoiceParams#payproc_InvoiceParams.party_id, ShopID = InvoiceParams#payproc_InvoiceParams.shop_id, - Party = hg_party:get_party(PartyID), - Shop = hg_party:get_shop(ShopID, Party, DomainRevision), + {PartyID, Party} = hg_party:get_party(PartyID), + {ShopID, Shop} = assert_shop_exists(hg_party:get_shop(ShopID, Party, DomainRevision)), _ = assert_party_shop_operable(Shop, Party), ok = validate_invoice_mutations(InvoiceParams), {Cost, Mutations} = maybe_make_mutations(InvoiceParams), VS = #{ cost => Cost, - shop_id => Shop#domain_ShopConfig.id + shop_id => ShopID }, MerchantTerms = hg_invoice_utils:compute_shop_terms(DomainRevision, Shop, VS), ok = validate_invoice_params(InvoiceParams, Shop, MerchantTerms), - ok = ensure_started(InvoiceID, undefined, InvoiceParams, undefined, Mutations), + ok = ensure_started(InvoiceID, undefined, InvoiceParams, undefined, Mutations, DomainRevision), get_invoice_state(get_state(InvoiceID)); handle_function_('CreateWithTemplate', {Params}, _Opts) -> DomainRevision = hg_domain:head(), InvoiceID = Params#payproc_InvoiceWithTemplateParams.id, _ = set_invoicing_meta(InvoiceID), TplID = Params#payproc_InvoiceWithTemplateParams.template_id, - {_Party, Shop, InvoiceParams} = make_invoice_params(Params), + {_Party, {ShopID, Shop}, InvoiceParams} = make_invoice_params(Params), ok = validate_invoice_mutations(InvoiceParams), {Cost, Mutations} = maybe_make_mutations(InvoiceParams), VS = #{ cost => Cost, - shop_id => Shop#domain_ShopConfig.id + shop_id => ShopID }, MerchantTerms = hg_invoice_utils:compute_shop_terms(DomainRevision, Shop, VS), ok = validate_invoice_params(InvoiceParams, Shop, MerchantTerms), - ok = ensure_started(InvoiceID, TplID, InvoiceParams, undefined, Mutations), + ok = ensure_started(InvoiceID, TplID, InvoiceParams, undefined, Mutations, DomainRevision), get_invoice_state(get_state(InvoiceID)); handle_function_('CapturePaymentNew', Args, Opts) -> handle_function_('CapturePayment', Args, Opts); @@ -100,13 +100,13 @@ handle_function_('ComputeTerms', {InvoiceID}, _Opts) -> _ = set_invoicing_meta(InvoiceID), St = get_state(InvoiceID), DomainRevision = hg_domain:head(), - Party = hg_party:get_party(get_party_id(St)), - Shop = assert_shop_exists(hg_party:get_shop(get_shop_id(St), Party, DomainRevision)), + {PartyID, Party} = hg_party:get_party(get_party_id(St)), + {ShopID, Shop} = assert_shop_exists(hg_party:get_shop(get_shop_id(St), Party, DomainRevision)), _ = assert_party_shop_operable(Shop, Party), VS = #{ cost => get_cost(St), - shop_id => Shop#domain_ShopConfig.id, - party_id => Party#domain_PartyConfig.id, + shop_id => ShopID, + party_id => PartyID, category => Shop#domain_ShopConfig.category, currency => hg_invoice_utils:get_shop_currency(Shop) }, @@ -145,8 +145,8 @@ handle_function_('ExplainRoute', {InvoiceID, PaymentID}, _Opts) -> St = get_state(InvoiceID), hg_routing_explanation:get_explanation(get_payment_session(PaymentID, St), hg_invoice:get_payment_opts(St)). -ensure_started(ID, TemplateID, Params, Allocation, Mutations) -> - Invoice = hg_invoice:create(ID, TemplateID, Params, Allocation, Mutations), +ensure_started(ID, TemplateID, Params, Allocation, Mutations, DomainRevision) -> + Invoice = hg_invoice:create(ID, TemplateID, Params, Allocation, Mutations, DomainRevision), case hg_machine:start(hg_invoice:namespace(), ID, hg_invoice:marshal_invoice(Invoice)) of {ok, _} -> ok; {error, exists} -> ok; @@ -294,8 +294,8 @@ make_invoice_params(Params) -> mutations = MutationsParams } = hg_invoice_template:get(TplID), DomainRevision = hg_domain:head(), - Party = hg_party:get_party(PartyID), - Shop = assert_shop_exists(hg_party:get_shop(ShopID, Party, DomainRevision)), + {PartyID, Party} = hg_party:get_party(PartyID), + {ShopID, Shop} = assert_shop_exists(hg_party:get_shop(ShopID, Party, DomainRevision)), _ = assert_party_shop_operable(Shop, Party), Cart = make_invoice_cart(Cost, TplDetails, Shop), InvoiceDetails = #domain_InvoiceDetails{ @@ -317,7 +317,7 @@ make_invoice_params(Params) -> external_id = ExternalID, mutations = MutationsParams }, - {Party, Shop, InvoiceParams}. + {{PartyID, Party}, {ShopID, Shop}, InvoiceParams}. validate_invoice_params(#payproc_InvoiceParams{cost = Cost}, Shop, MerchantTerms) -> ok = validate_invoice_cost(Cost, Shop, MerchantTerms), diff --git a/apps/hellgate/src/hg_invoice_mutation.erl b/apps/hellgate/src/hg_invoice_mutation.erl index 815e3562..7c66d49d 100644 --- a/apps/hellgate/src/hg_invoice_mutation.erl +++ b/apps/hellgate/src/hg_invoice_mutation.erl @@ -167,6 +167,7 @@ calc_deviation(MaxDeviation, PrecisionFactor) -> shop_id = <<"shop_id">>, owner_id = <<"owner_id">>, created_at = <<"1970-01-01T00:00:00Z">>, + domain_revision = 1223, status = {unpaid, #domain_InvoiceUnpaid{}}, cost = ?cash(Amount), due = <<"1970-01-01T00:00:00Z">>, diff --git a/apps/hellgate/src/hg_invoice_payment.erl b/apps/hellgate/src/hg_invoice_payment.erl index 86e92a8b..4ee61fc7 100644 --- a/apps/hellgate/src/hg_invoice_payment.erl +++ b/apps/hellgate/src/hg_invoice_payment.erl @@ -97,7 +97,7 @@ -export([get_log_params/2]). -export([validate_transition/4]). --export([construct_payer/2]). +-export([construct_payer/1]). -export([construct_payment_plan_id/1]). -export([construct_payment_plan_id/2]). @@ -172,6 +172,7 @@ -type cash() :: dmsl_domain_thrift:'Cash'(). -type cart() :: dmsl_domain_thrift:'InvoiceCart'(). -type party() :: dmsl_domain_thrift:'PartyConfig'(). +-type party_id() :: dmsl_domain_thrift:'PartyID'(). -type payer() :: dmsl_domain_thrift:'Payer'(). -type payer_params() :: dmsl_payproc_thrift:'PayerParams'(). -type invoice() :: dmsl_domain_thrift:'Invoice'(). @@ -208,6 +209,7 @@ -type payment_session() :: dmsl_payproc_thrift:'InvoicePaymentSession'(). -type failure() :: dmsl_domain_thrift:'OperationFailure'(). -type shop() :: dmsl_domain_thrift:'ShopConfig'(). +-type shop_id() :: dmsl_domain_thrift:'ShopConfigID'(). -type payment_tool() :: dmsl_domain_thrift:'PaymentTool'(). -type recurrent_paytool_service_terms() :: dmsl_domain_thrift:'RecurrentPaytoolsServiceTerms'(). -type session() :: hg_session:t(). @@ -216,6 +218,7 @@ -type opts() :: #{ party => party(), + party_id => party_id(), invoice => invoice(), timestamp => hg_datetime:timestamp() }. @@ -413,20 +416,20 @@ init_(PaymentID, Params, Opts = #{timestamp := CreatedAt}) -> processing_deadline = Deadline } = Params, Revision = hg_domain:head(), - Party = get_party(Opts), - Shop = get_shop(Opts, Revision), + PartyID = get_party_id(Opts), + ShopObj = get_shop_obj(Opts, Revision), Invoice = get_invoice(Opts), Cost = #domain_Cash{currency = Currency} = get_invoice_cost(Invoice), - {ok, Payer, VS0} = construct_payer(PayerParams, Shop), - VS1 = collect_validation_varset_(Party, Shop, Currency, VS0), + {ok, Payer, VS0} = construct_payer(PayerParams), + VS1 = collect_validation_varset_(PartyID, ShopObj, Currency, VS0), Payment1 = construct_payment( PaymentID, CreatedAt, Cost, Payer, FlowParams, - Party, - Shop, + PartyID, + ShopObj, VS1, Revision, genlib:define(MakeRecurrent, false) @@ -460,21 +463,19 @@ get_provider_terminal_terms(?route(ProviderRef, TerminalRef), VS, Revision) -> ), TermsSet#domain_ProvisionTermSet.payments. --spec construct_payer(payer_params(), shop()) -> {ok, payer(), map()}. +-spec construct_payer(payer_params()) -> {ok, payer(), map()}. construct_payer( {payment_resource, #payproc_PaymentResourcePayerParams{ resource = Resource, contact_info = ContactInfo - }}, - _ + }} ) -> {ok, ?payment_resource_payer(Resource, ContactInfo), #{}}; construct_payer( {recurrent, #payproc_RecurrentPayerParams{ recurrent_parent = Parent, contact_info = ContactInfo - }}, - _ + }} ) -> ?recurrent_parent(InvoiceID, PaymentID) = Parent, ParentPayment = @@ -496,8 +497,8 @@ construct_payment( Cost, Payer, FlowParams, - Party, - Shop, + PartyID, + {ShopID, Shop} = ShopObj, VS0, Revision, MakeRecurrent @@ -524,12 +525,12 @@ construct_payment( PaymentTool ), ParentPayment = maps:get(parent_payment, VS1, undefined), - ok = validate_recurrent_intention(Payer, RecurrentTerms, PaymentTool, Shop, ParentPayment, MakeRecurrent), + ok = validate_recurrent_intention(Payer, RecurrentTerms, PaymentTool, ShopObj, ParentPayment, MakeRecurrent), #domain_InvoicePayment{ id = PaymentID, created_at = CreatedAt, - owner_id = Party#domain_PartyConfig.id, - shop_id = Shop#domain_ShopConfig.id, + owner_id = PartyID, + shop_id = ShopID, domain_revision = Revision, status = ?pending(), cost = Cost, @@ -587,7 +588,7 @@ validate_hold_lifetime(undefined, _PaymentTool) -> payer(), recurrent_paytool_service_terms(), payment_tool(), - shop(), + {shop_id(), shop()}, payment(), make_recurrent() ) -> ok | no_return(). @@ -595,13 +596,13 @@ validate_recurrent_intention( ?recurrent_payer() = Payer, RecurrentTerms, PaymentTool, - Shop, + ShopObj, ParentPayment, MakeRecurrent ) -> ok = validate_recurrent_terms(RecurrentTerms, PaymentTool), ok = validate_recurrent_payer(Payer, MakeRecurrent), - ok = validate_recurrent_parent(Shop, ParentPayment); + ok = validate_recurrent_parent(ShopObj, ParentPayment); validate_recurrent_intention(Payer, RecurrentTerms, PaymentTool, _Shop, _ParentPayment, true = MakeRecurrent) -> ok = validate_recurrent_terms(RecurrentTerms, PaymentTool), ok = validate_recurrent_payer(Payer, MakeRecurrent); @@ -630,10 +631,10 @@ validate_recurrent_terms(RecurrentTerms, PaymentTool) -> end, ok. --spec validate_recurrent_parent(shop(), st()) -> ok | no_return(). -validate_recurrent_parent(Shop, ParentPayment) -> +-spec validate_recurrent_parent({shop_id(), shop()}, st()) -> ok | no_return(). +validate_recurrent_parent(ShopObj, ParentPayment) -> ok = validate_recurrent_token_present(ParentPayment), - ok = validate_recurrent_parent_shop(Shop, ParentPayment), + ok = validate_recurrent_parent_shop(ShopObj, ParentPayment), ok = validate_recurrent_parent_status(ParentPayment). -spec validate_recurrent_token_present(st()) -> ok | no_return(). @@ -645,13 +646,13 @@ validate_recurrent_token_present(PaymentState) -> throw_invalid_recurrent_parent(<<"Parent payment has no recurrent token">>) end. --spec validate_recurrent_parent_shop(shop(), st()) -> ok | no_return(). -validate_recurrent_parent_shop(Shop, PaymentState) -> +-spec validate_recurrent_parent_shop({shop_id(), shop()}, st()) -> ok | no_return(). +validate_recurrent_parent_shop({ShopID, _}, PaymentState) -> PaymentShopID = get_payment_shop_id(get_payment(PaymentState)), - case Shop of - #domain_ShopConfig{id = ShopID} when ShopID =:= PaymentShopID -> + case ShopID =:= PaymentShopID of + true -> ok; - _Other -> + false -> throw_invalid_recurrent_parent(<<"Parent payment refer to another shop">>) end. @@ -814,20 +815,18 @@ collect_partial_refund_varset(undefined) -> collect_validation_varset(St, Opts) -> Revision = get_payment_revision(St), - collect_validation_varset(get_party(Opts), get_shop(Opts, Revision), get_payment(St), #{}). + collect_validation_varset(get_party_id(Opts), get_shop_obj(Opts, Revision), get_payment(St), #{}). -collect_validation_varset(Party, Shop, Payment, VS) -> +collect_validation_varset(PartyID, ShopObj, Payment, VS) -> Cost = #domain_Cash{currency = Currency} = get_payment_cost(Payment), - VS0 = collect_validation_varset_(Party, Shop, Currency, VS), + VS0 = collect_validation_varset_(PartyID, ShopObj, Currency, VS), VS0#{ cost => Cost, payment_tool => get_payment_tool(Payment) }. -collect_validation_varset_(Party, Shop, Currency, VS) -> - #domain_PartyConfig{id = PartyID} = Party, +collect_validation_varset_(PartyID, {ShopID, Shop}, Currency, VS) -> #domain_ShopConfig{ - id = ShopID, category = Category } = Shop, VS#{ @@ -1156,8 +1155,8 @@ make_refund_cashflow(Refund, Payment, Revision, St, Opts, MerchantTerms, VS, Tim operation => refund, provision_terms => get_provider_refunds_terms(ProviderPaymentsTerms, Refund, Payment), merchant_terms => MerchantTerms, - party => get_party(Opts), - shop => get_shop(Opts, Revision), + party => get_party_obj(Opts), + shop => get_shop_obj(Opts, Revision), route => Route, payment => Payment, provider => get_route_provider(Route, Revision), @@ -1521,8 +1520,8 @@ get_cash_flow_for_target_status({failed, _}, _St, _Opts) -> calculate_cashflow(Context = #{route := Route, revision := Revision}, Opts) -> CollectCashflowContext = genlib_map:compact(Context#{ operation => payment, - party => get_party(Opts), - shop => get_shop(Opts, Revision), + party => get_party_obj(Opts), + shop => get_shop_obj(Opts, Revision), provider => get_route_provider(Route, Revision) }), hg_cashflow_utils:collect_cashflow(CollectCashflowContext). @@ -1531,8 +1530,8 @@ calculate_cashflow(Context = #{route := Route, revision := Revision}, Opts) -> calculate_cashflow(PaymentInstitution, Context = #{route := Route, revision := Revision}, Opts) -> CollectCashflowContext = genlib_map:compact(Context#{ operation => payment, - party => get_party(Opts), - shop => get_shop(Opts, Revision), + party => get_party_obj(Opts), + shop => get_shop_obj(Opts, Revision), provider => get_route_provider(Route, Revision) }), hg_cashflow_utils:collect_cashflow(PaymentInstitution, CollectCashflowContext). @@ -2054,7 +2053,7 @@ process_cash_flow_building(Action, St) -> Payment = get_payment(St), Timestamp = get_payment_created_at(Payment), VS0 = reconstruct_payment_flow(Payment, #{}), - VS1 = collect_validation_varset(get_party(Opts), get_shop(Opts, Revision), Payment, VS0), + VS1 = collect_validation_varset(get_party_id(Opts), get_shop_obj(Opts, Revision), Payment, VS0), ProviderTerms = get_provider_terminal_terms(Route, VS1, Revision), Allocation = get_allocation(St), Context = #{ @@ -2484,7 +2483,7 @@ get_provider_terms(St, Revision) -> Route = get_route(St), Payment = get_payment(St), VS0 = reconstruct_payment_flow(Payment, #{}), - VS1 = collect_validation_varset(get_party(Opts), get_shop(Opts, Revision), Payment, VS0), + VS1 = collect_validation_varset(get_party_id(Opts), get_shop_obj(Opts, Revision), Payment, VS0), hg_routing:get_payment_terms(Route, VS1, Revision). filter_routes_with_limit_hold(Ctx0, VS, Iter, St) -> @@ -2532,40 +2531,40 @@ hold_shop_limits(Opts, St) -> Payment = get_payment(St), Revision = get_payment_revision(St), Invoice = get_invoice(Opts), - Party = get_party(Opts), - Shop = get_shop(Opts, Revision), + PartyID = get_party_id(Opts), + {ShopID, Shop} = get_shop_obj(Opts, Revision), TurnoverLimits = get_shop_turnover_limits(Shop), - ok = hg_limiter:hold_shop_limits(TurnoverLimits, Party, Shop, Invoice, Payment). + ok = hg_limiter:hold_shop_limits(TurnoverLimits, PartyID, ShopID, Invoice, Payment). commit_shop_limits(Opts, St) -> Payment = get_payment(St), Revision = get_payment_revision(St), Invoice = get_invoice(Opts), - Party = get_party(Opts), - Shop = get_shop(Opts, Revision), + PartyID = get_party_id(Opts), + {ShopID, Shop} = get_shop_obj(Opts, Revision), TurnoverLimits = get_shop_turnover_limits(Shop), - ok = hg_limiter:commit_shop_limits(TurnoverLimits, Party, Shop, Invoice, Payment). + ok = hg_limiter:commit_shop_limits(TurnoverLimits, PartyID, ShopID, Invoice, Payment). check_shop_limits(Opts, St) -> Payment = get_payment(St), Revision = get_payment_revision(St), Invoice = get_invoice(Opts), - Party = get_party(Opts), - Shop = get_shop(Opts, Revision), - TurnoverLimits = get_shop_turnover_limits(get_shop(Opts, Revision)), - hg_limiter:check_shop_limits(TurnoverLimits, Party, Shop, Invoice, Payment). + PartyID = get_party_id(Opts), + {ShopID, Shop} = get_shop_obj(Opts, Revision), + TurnoverLimits = get_shop_turnover_limits(Shop), + hg_limiter:check_shop_limits(TurnoverLimits, PartyID, ShopID, Invoice, Payment). rollback_shop_limits(Opts, St, Flags) -> Payment = get_payment(St), Revision = get_payment_revision(St), Invoice = get_invoice(Opts), - Party = get_party(Opts), - Shop = get_shop(Opts, Revision), + PartyID = get_party_id(Opts), + {ShopID, Shop} = get_shop_obj(Opts, Revision), TurnoverLimits = get_shop_turnover_limits(Shop), ok = hg_limiter:rollback_shop_limits( TurnoverLimits, - Party, - Shop, + PartyID, + ShopID, Invoice, Payment, Flags @@ -2760,7 +2759,7 @@ construct_payment_info(St, Opts) -> get_target(St), St, #proxy_provider_PaymentInfo{ - shop = construct_proxy_shop(get_shop(Opts, Revision)), + shop = construct_proxy_shop(get_shop_obj(Opts, Revision)), invoice = construct_proxy_invoice(get_invoice(Opts)), payment = construct_proxy_payment(Payment, get_trx(St)) } @@ -2843,21 +2842,18 @@ construct_proxy_invoice( }. construct_proxy_shop( - #domain_ShopConfig{ - id = ShopID, - details = ShopDetails, - location = Location, - category = ShopCategoryRef - } + {ShopID, + Shop = #domain_ShopConfig{ + location = Location, + category = ShopCategoryRef + }} ) -> ShopCategory = hg_domain:get({category, ShopCategoryRef}), #proxy_provider_Shop{ id = ShopID, category = ShopCategory, - details = #domain_ShopDetails{ - name = ShopDetails#domain_Details.name, - description = ShopDetails#domain_Details.description - }, + name = Shop#domain_ShopConfig.name, + description = Shop#domain_ShopConfig.description, location = Location }. @@ -2877,10 +2873,20 @@ construct_proxy_capture(?captured(_, Cost)) -> %% +get_party_obj(#{party := Party, party_id := PartyID}) -> + {PartyID, Party}. + get_party(#{party := Party}) -> Party. +get_party_id(#{party_id := PartyID}) -> + PartyID. + get_shop(#{party := Party, invoice := Invoice}, Revision) -> + {_, Shop} = hg_party:get_shop(get_invoice_shop_id(Invoice), Party, Revision), + Shop. + +get_shop_obj(#{party := Party, invoice := Invoice}, Revision) -> hg_party:get_shop(get_invoice_shop_id(Invoice), Party, Revision). get_payment_institution_ref(Opts, Revision) -> @@ -2958,7 +2964,7 @@ get_varset(St, InitialValue) -> Payment = get_payment(St), Revision = get_payment_revision(St), VS0 = reconstruct_payment_flow(Payment, InitialValue), - VS1 = collect_validation_varset(get_party(Opts), get_shop(Opts, Revision), Payment, VS0), + VS1 = collect_validation_varset(get_party_id(Opts), get_shop_obj(Opts, Revision), Payment, VS0), VS1. %% @@ -3356,9 +3362,9 @@ get_routing_attempt_limit( } } ) -> - Party = hg_party:checkout(PartyID, Revision), - Shop = hg_party:get_shop(ShopID, Party, Revision), - VS = collect_validation_varset(Party, Shop, get_payment(St), #{}), + {PartyID, Party} = hg_party:checkout(PartyID, Revision), + ShopObj = {_, Shop} = hg_party:get_shop(ShopID, Party, Revision), + VS = collect_validation_varset(PartyID, ShopObj, get_payment(St), #{}), Terms = hg_invoice_utils:compute_shop_terms(Revision, Shop, VS), #domain_TermSet{payments = PaymentTerms} = Terms, log_cascade_attempt_context(PaymentTerms, St), diff --git a/apps/hellgate/src/hg_invoice_payment_chargeback.erl b/apps/hellgate/src/hg_invoice_payment_chargeback.erl index 9ec8b438..203bca34 100644 --- a/apps/hellgate/src/hg_invoice_payment_chargeback.erl +++ b/apps/hellgate/src/hg_invoice_payment_chargeback.erl @@ -71,6 +71,8 @@ }. -type opts() :: #{ + party => party(), + party_id => party_id(), payment_state := payment_state(), party := party(), invoice := invoice() @@ -82,6 +84,9 @@ -type party() :: dmsl_domain_thrift:'PartyConfig'(). +-type party_id() :: + dmsl_domain_thrift:'PartyID'(). + -type invoice() :: dmsl_domain_thrift:'Invoice'(). @@ -280,11 +285,12 @@ do_create(Opts, CreateParams = ?chargeback_params(Levy, Body, _Reason)) -> CreatedAt = hg_datetime:format_now(), Invoice = get_opts_invoice(Opts), Party = get_opts_party(Opts), + PartyID = get_opts_party_id(Opts), Route = get_opts_route(Opts), Payment = get_opts_payment(Opts), ShopID = get_invoice_shop_id(Invoice), - Shop = hg_party:get_shop(ShopID, Party, Revision), - VS = collect_validation_varset(Party, Shop, Payment, Body), + ShopObj = {_, Shop} = hg_party:get_shop(ShopID, Party, Revision), + VS = collect_validation_varset(PartyID, ShopObj, Payment, Body), PaymentsTerms = hg_routing:get_payment_terms(Route, VS, Revision), ProviderTerms = get_provider_chargeback_terms(PaymentsTerms, Payment), ServiceTerms = get_merchant_chargeback_terms(Party, Shop, VS, Revision, CreatedAt), @@ -416,9 +422,10 @@ build_chargeback_final_cash_flow(State, Opts) -> Invoice = get_opts_invoice(Opts), Route = get_opts_route(Opts), Party = get_opts_party(Opts), + PartyID = get_opts_party_id(Opts), ShopID = get_invoice_shop_id(Invoice), - Shop = hg_party:get_shop(ShopID, Party, Revision), - VS = collect_validation_varset(Party, Shop, Payment, Body), + ShopObj = {_, Shop} = hg_party:get_shop(ShopID, Party, Revision), + VS = collect_validation_varset(PartyID, ShopObj, Payment, Body), ServiceTerms = get_merchant_chargeback_terms(Party, Shop, VS, Revision, CreatedAt), PaymentsTerms = hg_routing:get_payment_terms(Route, VS, Revision), ProviderTerms = get_provider_chargeback_terms(PaymentsTerms, Payment), @@ -430,8 +437,8 @@ build_chargeback_final_cash_flow(State, Opts) -> Provider = get_route_provider(Route, Revision), CollectAccountContext = #{ payment => Payment, - party => Party, - shop => Shop, + party_id => PartyID, + shop => ShopObj, route => Route, payment_institution => PaymentInst, provider => Provider, @@ -512,11 +519,9 @@ construct_chargeback_plan_id(State, Opts) -> genlib:to_binary(Stage) ]). -collect_validation_varset(Party, Shop, Payment, Body) -> +collect_validation_varset(PartyID, {ShopID, Shop}, Payment, Body) -> #domain_InvoicePayment{cost = #domain_Cash{currency = Currency}} = Payment, - #domain_PartyConfig{id = PartyID} = Party, #domain_ShopConfig{ - id = ShopID, category = Category } = Shop, #{ @@ -716,6 +721,9 @@ get_route_provider(#domain_PaymentRoute{provider = ProviderRef}, Revision) -> get_opts_party(#{party := Party}) -> Party. +get_opts_party_id(#{party_id := PartyID}) -> + PartyID. + get_opts_invoice(#{invoice := Invoice}) -> Invoice. diff --git a/apps/hellgate/src/hg_invoice_payment_refund.erl b/apps/hellgate/src/hg_invoice_payment_refund.erl index c1b15a33..4aa42256 100644 --- a/apps/hellgate/src/hg_invoice_payment_refund.erl +++ b/apps/hellgate/src/hg_invoice_payment_refund.erl @@ -78,9 +78,11 @@ %% Internal types -type party() :: dmsl_domain_thrift:'PartyConfig'(). +-type party_id() :: dmsl_domain_thrift:'PartyID'(). -type invoice() :: dmsl_domain_thrift:'Invoice'(). -type payment() :: dmsl_domain_thrift:'InvoicePayment'(). -type shop() :: dmsl_domain_thrift:'ShopConfig'(). +-type shop_id() :: dmsl_domain_thrift:'ShopConfigID'(). -type invoice_id() :: dmsl_domain_thrift:'InvoiceID'(). -type payment_id() :: dmsl_domain_thrift:'InvoicePaymentID'(). -type domain_refund() :: dmsl_domain_thrift:'InvoicePaymentRefund'(). @@ -114,9 +116,11 @@ -type injected_context() :: #{ party := party(), + party_id := party_id(), invoice := invoice(), payment := payment(), shop := shop(), + shop_id := shop_id(), invoice_id := invoice_id(), payment_id := payment_id(), repair_scenario => repair_scenario(), @@ -125,6 +129,7 @@ -type options() :: #{ party => party(), + party_id => party_id(), invoice => invoice(), timestamp => hg_datetime:timestamp(), @@ -270,12 +275,14 @@ do_process(finished, _Refund) -> process_refund_cashflow(Refund) -> Action = hg_machine_action:set_timeout(0, hg_machine_action:new()), - Party = get_injected_party(Refund), + PartyID = get_injected_party_id(Refund), + ShopID = get_injected_shop_id(Refund), Shop = get_injected_shop(Refund), - #domain_InvoicePayment{cost = #domain_Cash{currency = Currency}} = get_injected_payment(Refund), hold_refund_limits(Refund), - #{{merchant, settlement} := SettlementID} = hg_accounting:collect_merchant_account_map(Currency, Party, Shop, #{}), + #{{merchant, settlement} := SettlementID} = hg_accounting:collect_merchant_account_map( + PartyID, {ShopID, Shop}, #{} + ), _ = prepare_refund_cashflow(Refund), % NOTE we assume that posting involving merchant settlement account MUST be present in the cashflow #{min_available_amount := AvailableAmount} = hg_accounting:get_balance(SettlementID), @@ -371,9 +378,9 @@ get_limits(Refund) -> get_provider_terms(Revision, Payment, Invoice, Party, Refund) -> Route = route(Refund), #domain_Invoice{shop_id = ShopID} = Invoice, - Shop = hg_party:get_shop(ShopID, Party, Revision), + ShopObj = hg_party:get_shop(ShopID, Party, Revision), VS0 = construct_payment_flow(Payment), - VS1 = collect_validation_varset(Party, Shop, Payment, VS0), + VS1 = collect_validation_varset(get_injected_party_id(Refund), ShopObj, Payment, VS0), hg_routing:get_payment_terms(Route, VS1, Revision). construct_payment_flow(Payment) -> @@ -389,10 +396,8 @@ reconstruct_payment_flow(?invoice_payment_flow_hold(_OnHoldExpiration, HeldUntil Seconds = hg_datetime:parse_ts(HeldUntil) - hg_datetime:parse_ts(CreatedAt), #{flow => {hold, ?hold_lifetime(Seconds)}}. -collect_validation_varset(Party, Shop, Payment, VS) -> - #domain_PartyConfig{id = PartyID} = Party, +collect_validation_varset(PartyID, {ShopID, Shop}, Payment, VS) -> #domain_ShopConfig{ - id = ShopID, category = Category } = Shop, #domain_InvoicePayment{ @@ -491,12 +496,15 @@ inject_context(Options, Refund) -> #domain_Invoice{id = InvoiceID, shop_id = ShopID} = Invoice, #domain_InvoicePayment{id = PaymentID, domain_revision = Revision} = Payment, Party = maps:get(party, Options), - Shop = hg_party:get_shop(ShopID, Party, Revision), + PartyID = maps:get(party_id, Options), + {ShopID, Shop} = hg_party:get_shop(ShopID, Party, Revision), Context = genlib_map:compact(#{ party => Party, + party_id => PartyID, invoice => Invoice, payment => Payment, shop => Shop, + shop_id => ShopID, invoice_id => InvoiceID, payment_id => PaymentID, repair_scenario => maps:get(repair_scenario, Options, undefined), @@ -505,9 +513,11 @@ inject_context(Options, Refund) -> Refund#{injected_context => Context}. get_injected_party(#{injected_context := #{party := V}}) -> V. +get_injected_party_id(#{injected_context := #{party_id := V}}) -> V. get_injected_invoice(#{injected_context := #{invoice := V}}) -> V. get_injected_payment(#{injected_context := #{payment := V}}) -> V. get_injected_shop(#{injected_context := #{shop := V}}) -> V. +get_injected_shop_id(#{injected_context := #{shop_id := V}}) -> V. get_injected_invoice_id(#{injected_context := #{invoice_id := V}}) -> V. get_injected_payment_id(#{injected_context := #{payment_id := V}}) -> V. get_injected_repair_scenario(#{injected_context := Context}) -> maps:get(repair_scenario, Context, undefined). diff --git a/apps/hellgate/src/hg_invoice_registered_payment.erl b/apps/hellgate/src/hg_invoice_registered_payment.erl index cb38abf4..98f42377 100644 --- a/apps/hellgate/src/hg_invoice_registered_payment.erl +++ b/apps/hellgate/src/hg_invoice_registered_payment.erl @@ -45,14 +45,14 @@ init_(PaymentID, Params, Opts = #{timestamp := CreatedAt0}) -> } = Params, CreatedAt1 = genlib:define(OccurredAt, CreatedAt0), Revision = hg_domain:head(), - Party = get_party(Opts), - Shop = get_shop(Opts, Revision), + PartyID = get_party_id(Opts), + ShopObj = {ShopID, Shop} = get_shop(Opts, Revision), Invoice = get_invoice(Opts), %% NOTE even if payment cost < invoice cost, invoice will gain status 'paid' Cost1 = genlib:define(Cost0, get_invoice_cost(Invoice)), - {ok, Payer, _} = hg_invoice_payment:construct_payer(PayerParams, Shop), + {ok, Payer, _} = hg_invoice_payment:construct_payer(PayerParams), PaymentTool = get_payer_payment_tool(Payer), - VS = collect_validation_varset(Party, Shop, Cost1, PaymentTool, RiskScore), + VS = collect_validation_varset(PartyID, ShopObj, Cost1, PaymentTool, RiskScore), PaymentInstitutionRef = get_payment_institution_ref(Opts, Revision), PaymentInstitution = hg_payment_institution:compute_payment_institution(PaymentInstitutionRef, VS, Revision), @@ -61,8 +61,8 @@ init_(PaymentID, Params, Opts = #{timestamp := CreatedAt0}) -> CreatedAt1, Cost1, Payer, - Party, - Shop, + PartyID, + ShopID, PayerSessionInfo, Context, ExternalID, @@ -195,8 +195,8 @@ get_turnover_limits(Payment, Route, St) -> Route = hg_invoice_payment:get_route(St), Opts = hg_invoice_payment:get_opts(St), Revision = hg_invoice_payment:get_payment_revision(St), - Party = get_party(Opts), - Shop = get_shop(Opts, Revision), + PartyID = get_party_id(Opts), + ShopObj = get_shop(Opts, Revision), #domain_InvoicePayment{ cost = Cost, payer = Payer, @@ -204,7 +204,7 @@ get_turnover_limits(Payment, Route, St) -> } = Payment = hg_invoice_payment:get_payment(St), PaymentTool = get_payer_payment_tool(Payer), RiskScore = hg_invoice_payment:get_risk_score(St), - VS = collect_validation_varset(Party, Shop, Cost, PaymentTool, RiskScore), + VS = collect_validation_varset(PartyID, ShopObj, Cost, PaymentTool, RiskScore), ProviderTerms = hg_routing:get_payment_terms(Route, VS, Revision), TurnoverLimitSelector = ProviderTerms#domain_PaymentsProvisionTerms.turnover_limits, hg_limiter:get_turnover_limits(TurnoverLimitSelector). @@ -214,8 +214,8 @@ construct_payment( CreatedAt, Cost, Payer, - Party, - Shop, + PartyID, + ShopID, PayerSessionInfo, Context, ExternalID, @@ -224,8 +224,8 @@ construct_payment( #domain_InvoicePayment{ id = PaymentID, created_at = CreatedAt, - owner_id = Party#domain_PartyConfig.id, - shop_id = Shop#domain_ShopConfig.id, + owner_id = PartyID, + shop_id = ShopID, domain_revision = Revision, status = ?pending(), cost = Cost, @@ -238,10 +238,8 @@ construct_payment( registration_origin = ?invoice_payment_provider_reg_origin() }. -collect_validation_varset(Party, Shop, #domain_Cash{currency = Currency} = Cost, PaymentTool, RiskScore) -> - #domain_PartyConfig{id = PartyID} = Party, +collect_validation_varset(PartyID, {ShopID, Shop}, #domain_Cash{currency = Currency} = Cost, PaymentTool, RiskScore) -> #domain_ShopConfig{ - id = ShopID, category = Category } = Shop, #{ @@ -257,13 +255,13 @@ collect_validation_varset(Party, Shop, #domain_Cash{currency = Currency} = Cost, %% -get_party(#{party := Party}) -> - Party. +get_party_id(#{party_id := PartyID}) -> + PartyID. get_shop(#{party := Party, invoice := Invoice}, Revision) -> hg_party:get_shop(get_invoice_shop_id(Invoice), Party, Revision). get_payment_institution_ref(Opts, Revision) -> - Shop = get_shop(Opts, Revision), + {_, Shop} = get_shop(Opts, Revision), Shop#domain_ShopConfig.payment_institution. get_invoice(#{invoice := Invoice}) -> diff --git a/apps/hellgate/src/hg_invoice_template.erl b/apps/hellgate/src/hg_invoice_template.erl index c0ba0cc4..ed02e06e 100644 --- a/apps/hellgate/src/hg_invoice_template.erl +++ b/apps/hellgate/src/hg_invoice_template.erl @@ -92,13 +92,13 @@ handle_function_('ComputeTerms', {TplID}, _Opts) -> undefined end, Revision = hg_party:get_party_revision(), - Party = hg_party:checkout(Tpl#domain_InvoiceTemplate.owner_id, Revision), - Shop = hg_party:get_shop(Tpl#domain_InvoiceTemplate.shop_id, Party, Revision), + {PartyID, Party} = hg_party:checkout(Tpl#domain_InvoiceTemplate.owner_id, Revision), + {ShopID, Shop} = hg_party:get_shop(Tpl#domain_InvoiceTemplate.shop_id, Party, Revision), _ = assert_party_shop_operable(Shop, Party), VS = #{ cost => Cost, - shop_id => Shop#domain_ShopConfig.id, - party_id => Party#domain_PartyConfig.id, + shop_id => ShopID, + party_id => PartyID, category => Shop#domain_ShopConfig.category, currency => hg_invoice_utils:get_shop_currency(Shop) }, @@ -114,12 +114,14 @@ assert_party_shop_operable(Shop, Party) -> ok. get_party(PartyID) -> - Party = hg_party:get_party(PartyID), + {PartyID, Party} = hg_party:get_party(PartyID), _ = hg_invoice_utils:assert_party_operable(Party), Party. get_shop(ShopID, Party) -> - Shop = hg_invoice_utils:assert_shop_exists(hg_party:get_shop(ShopID, Party, hg_party:get_party_revision())), + {ShopID, Shop} = hg_invoice_utils:assert_shop_exists( + hg_party:get_shop(ShopID, Party, hg_party:get_party_revision()) + ), _ = hg_invoice_utils:assert_shop_operable(Shop), Shop. diff --git a/apps/hellgate/src/hg_invoice_utils.erl b/apps/hellgate/src/hg_invoice_utils.erl index 496a481b..9a2d8b28 100644 --- a/apps/hellgate/src/hg_invoice_utils.erl +++ b/apps/hellgate/src/hg_invoice_utils.erl @@ -30,6 +30,7 @@ -type cash_range() :: dmsl_domain_thrift:'CashRange'(). -type party() :: dmsl_domain_thrift:'PartyConfig'(). -type shop() :: dmsl_domain_thrift:'ShopConfig'(). +-type shop_id() :: dmsl_domain_thrift:'ShopConfigID'(). -type term_set() :: dmsl_domain_thrift:'TermSet'(). -type payment_service_terms() :: dmsl_domain_thrift:'PaymentsServiceTerms'(). -type varset() :: dmsl_payproc_thrift:'Varset'(). @@ -82,8 +83,8 @@ assert_shop_operable(V) -> _ = assert_shop_active(V), V. --spec assert_shop_exists(shop() | undefined) -> shop(). -assert_shop_exists(#domain_ShopConfig{} = V) -> +-spec assert_shop_exists({shop_id(), shop()} | undefined) -> {shop_id(), shop()}. +assert_shop_exists({_, #domain_ShopConfig{}} = V) -> V; assert_shop_exists(undefined) -> throw(#payproc_ShopNotFound{}). @@ -128,21 +129,17 @@ validate_currency_(_, _) -> throw(#base_InvalidRequest{errors = [<<"Invalid currency">>]}). -spec get_shop_currency(shop()) -> currency(). -get_shop_currency(#domain_ShopConfig{currency_configs = Configs}) when is_map(Configs) -> - %% TODO: fix it when add multi currency support - [Currency | _] = maps:keys(Configs), +get_shop_currency(#domain_ShopConfig{account = #domain_ShopAccount{currency = Currency}}) -> Currency. -spec get_shop_account(shop()) -> {account_id(), account_id()}. -get_shop_account(#domain_ShopConfig{currency_configs = Configs}) when is_map(Configs) -> - %% TODO: fix it when add multi currency support - [{_Currency, #domain_ShopCurrencyConfig{settlement = SettlementID, guarantee = GuaranteeID}} | _] = maps:to_list( - Configs - ), +get_shop_account(#domain_ShopConfig{ + account = #domain_ShopAccount{settlement = SettlementID, guarantee = GuaranteeID} +}) -> {SettlementID, GuaranteeID}. -spec assert_party_unblocked(party()) -> true | no_return(). -assert_party_unblocked(#domain_PartyConfig{blocking = V = {Status, _}}) -> +assert_party_unblocked(#domain_PartyConfig{block = V = {Status, _}}) -> Status == unblocked orelse throw(#payproc_InvalidPartyStatus{status = {blocking, V}}). -spec assert_party_active(party()) -> true | no_return(). @@ -150,7 +147,7 @@ assert_party_active(#domain_PartyConfig{suspension = V = {Status, _}}) -> Status == active orelse throw(#payproc_InvalidPartyStatus{status = {suspension, V}}). -spec assert_shop_unblocked(shop()) -> true | no_return(). -assert_shop_unblocked(#domain_ShopConfig{blocking = V = {Status, _}}) -> +assert_shop_unblocked(#domain_ShopConfig{block = V = {Status, _}}) -> Status == unblocked orelse throw(#payproc_InvalidShopStatus{status = {blocking, V}}). -spec assert_shop_active(shop()) -> true | no_return(). diff --git a/apps/hellgate/src/hg_limiter.erl b/apps/hellgate/src/hg_limiter.erl index 031c00eb..6859f53e 100644 --- a/apps/hellgate/src/hg_limiter.erl +++ b/apps/hellgate/src/hg_limiter.erl @@ -16,8 +16,8 @@ -type cash() :: dmsl_domain_thrift:'Cash'(). -type handling_flag() :: ignore_business_error | ignore_not_found. -type turnover_limit_value() :: dmsl_payproc_thrift:'TurnoverLimitValue'(). --type party() :: hg_party:party(). --type shop() :: dmsl_domain_thrift:'ShopConfig'(). +-type party_id() :: hg_party:party_id(). +-type shop_id() :: dmsl_domain_thrift:'ShopConfigID'(). -type change_queue() :: [hg_limiter_client:limit_change()]. @@ -42,14 +42,6 @@ terminal = TerminalRef }). --define(party(PartyID), #domain_PartyConfig{ - id = PartyID -}). - --define(shop(ShopID), #domain_ShopConfig{ - id = ShopID -}). - -spec get_turnover_limits(turnover_selector() | undefined) -> [turnover_limit()]. get_turnover_limits(undefined) -> []; @@ -116,12 +108,12 @@ check_limits(TurnoverLimits, Invoice, Payment, Route, Iter) -> {error, {limit_overflow, IDs, Limits}} end. --spec check_shop_limits([turnover_limit()], party(), shop(), invoice(), payment()) -> +-spec check_shop_limits([turnover_limit()], party_id(), shop_id(), invoice(), payment()) -> ok | {error, {limit_overflow, [binary()]}}. -check_shop_limits(TurnoverLimits, Party, Shop, Invoice, Payment) -> +check_shop_limits(TurnoverLimits, PartyID, ShopID, Invoice, Payment) -> Context = gen_limit_shop_context(Invoice, Payment), - Limits = get_limit_values(Context, TurnoverLimits, make_shop_operation_segments(Party, Shop, Invoice, Payment)), + Limits = get_limit_values(Context, TurnoverLimits, make_shop_operation_segments(PartyID, ShopID, Invoice, Payment)), try check_limits_(Limits, Context) catch @@ -130,7 +122,7 @@ check_shop_limits(TurnoverLimits, Party, Shop, Invoice, Payment) -> {error, {limit_overflow, IDs}} end. -make_shop_operation_segments(?party(PartyID), ?shop(ShopID), Invoice, Payment) -> +make_shop_operation_segments(PartyID, ShopID, Invoice, Payment) -> [ PartyID, ShopID, @@ -179,15 +171,17 @@ batch_hold_limits(Context, TurnoverLimits, OperationIdSegments) -> _ = hg_limiter_client:hold_batch(LimitRequest, Context), ok. --spec hold_shop_limits([turnover_limit()], party(), shop(), invoice(), payment()) -> ok. -hold_shop_limits(TurnoverLimits, Party, Shop, Invoice, Payment) -> +-spec hold_shop_limits([turnover_limit()], party_id(), shop_id(), invoice(), payment()) -> ok. +hold_shop_limits(TurnoverLimits, PartyID, ShopID, Invoice, Payment) -> Context = gen_limit_shop_context(Invoice, Payment), {LegacyTurnoverLimits, BatchTurnoverLimits} = split_turnover_limits_by_available_limiter_api(TurnoverLimits), - ok = legacy_hold_shop_limits(Context, LegacyTurnoverLimits, Party, Shop, Invoice, Payment), - ok = batch_hold_limits(Context, BatchTurnoverLimits, make_shop_operation_segments(Party, Shop, Invoice, Payment)). + ok = legacy_hold_shop_limits(Context, LegacyTurnoverLimits, PartyID, ShopID, Invoice, Payment), + ok = batch_hold_limits( + Context, BatchTurnoverLimits, make_shop_operation_segments(PartyID, ShopID, Invoice, Payment) + ). -legacy_hold_shop_limits(Context, TurnoverLimits, Party, Shop, Invoice, Payment) -> - ChangeIDs = [construct_shop_change_id(Party, Shop, Invoice, Payment)], +legacy_hold_shop_limits(Context, TurnoverLimits, PartyID, ShopID, Invoice, Payment) -> + ChangeIDs = [construct_shop_change_id(PartyID, ShopID, Invoice, Payment)], LimitChanges = gen_limit_changes(TurnoverLimits, ChangeIDs), hold(LimitChanges, get_latest_clock(), Context). @@ -234,18 +228,18 @@ legacy_commit_payment_limits(Clock, Context, TurnoverLimits, Invoice, Payment, R LimitChanges = gen_limit_changes(TurnoverLimits, ChangeIDs), commit(LimitChanges, Clock, Context). --spec commit_shop_limits([turnover_limit()], party(), shop(), invoice(), payment()) -> ok. -commit_shop_limits(TurnoverLimits, Party, Shop, Invoice, Payment) -> +-spec commit_shop_limits([turnover_limit()], party_id(), shop_id(), invoice(), payment()) -> ok. +commit_shop_limits(TurnoverLimits, PartyID, ShopID, Invoice, Payment) -> Context = gen_limit_shop_context(Invoice, Payment), {LegacyTurnoverLimits, BatchTurnoverLimits} = split_turnover_limits_by_available_limiter_api(TurnoverLimits), Clock = get_latest_clock(), - ok = legacy_commit_shop_limits(Clock, Context, LegacyTurnoverLimits, Party, Shop, Invoice, Payment), - OperationIdSegments = make_shop_operation_segments(Party, Shop, Invoice, Payment), + ok = legacy_commit_shop_limits(Clock, Context, LegacyTurnoverLimits, PartyID, ShopID, Invoice, Payment), + OperationIdSegments = make_shop_operation_segments(PartyID, ShopID, Invoice, Payment), ok = batch_commit_limits(Context, BatchTurnoverLimits, OperationIdSegments), ok = log_limit_changes(TurnoverLimits, Clock, Context). -legacy_commit_shop_limits(Clock, Context, TurnoverLimits, Party, Shop, Invoice, Payment) -> - ChangeIDs = [construct_shop_change_id(Party, Shop, Invoice, Payment)], +legacy_commit_shop_limits(Clock, Context, TurnoverLimits, PartyID, ShopID, Invoice, Payment) -> + ChangeIDs = [construct_shop_change_id(PartyID, ShopID, Invoice, Payment)], LimitChanges = gen_limit_changes(TurnoverLimits, ChangeIDs), ok = commit(LimitChanges, Clock, Context). @@ -295,17 +289,17 @@ legacy_rollback_payment_limits(Context, TurnoverLimits, Invoice, Payment, Route, LimitChanges = gen_limit_changes(TurnoverLimits, ChangeIDs), rollback(LimitChanges, get_latest_clock(), Context, Flags). --spec rollback_shop_limits([turnover_limit()], party(), shop(), invoice(), payment(), [handling_flag()]) -> +-spec rollback_shop_limits([turnover_limit()], party_id(), shop_id(), invoice(), payment(), [handling_flag()]) -> ok. -rollback_shop_limits(TurnoverLimits, Party, Shop, Invoice, Payment, Flags) -> +rollback_shop_limits(TurnoverLimits, PartyID, ShopID, Invoice, Payment, Flags) -> Context = gen_limit_shop_context(Invoice, Payment), {LegacyTurnoverLimits, BatchTurnoverLimits} = split_turnover_limits_by_available_limiter_api(TurnoverLimits), - ok = legacy_rollback_shop_limits(Context, LegacyTurnoverLimits, Party, Shop, Invoice, Payment, Flags), - OperationIdSegments = make_shop_operation_segments(Party, Shop, Invoice, Payment), + ok = legacy_rollback_shop_limits(Context, LegacyTurnoverLimits, PartyID, ShopID, Invoice, Payment, Flags), + OperationIdSegments = make_shop_operation_segments(PartyID, ShopID, Invoice, Payment), ok = batch_rollback_limits(Context, BatchTurnoverLimits, OperationIdSegments). -legacy_rollback_shop_limits(Context, TurnoverLimits, Party, Shop, Invoice, Payment, Flags) -> - ChangeIDs = [construct_shop_change_id(Party, Shop, Invoice, Payment)], +legacy_rollback_shop_limits(Context, TurnoverLimits, PartyID, ShopID, Invoice, Payment, Flags) -> + ChangeIDs = [construct_shop_change_id(PartyID, ShopID, Invoice, Payment)], LimitChanges = gen_limit_changes(TurnoverLimits, ChangeIDs), rollback(LimitChanges, get_latest_clock(), Context, Flags). @@ -458,7 +452,7 @@ construct_payment_change_id(?route(ProviderRef, TerminalRef), Iter, Invoice, Pay integer_to_binary(Iter) ]). -construct_shop_change_id(?party(PartyID), ?shop(ShopID), Invoice, Payment) -> +construct_shop_change_id(PartyID, ShopID, Invoice, Payment) -> hg_utils:construct_complex_id([ PartyID, ShopID, diff --git a/apps/hellgate/src/hg_party.erl b/apps/hellgate/src/hg_party.erl index 0ce0619a..1dcd003c 100644 --- a/apps/hellgate/src/hg_party.erl +++ b/apps/hellgate/src/hg_party.erl @@ -11,19 +11,18 @@ -export([get_shop/3]). -export_type([party/0]). --export_type([party_status/0]). +-export_type([party_id/0]). %% -type party() :: dmsl_domain_thrift:'PartyConfig'(). -type party_id() :: dmsl_domain_thrift:'PartyID'(). --type party_status() :: dmsl_domain_thrift:'PartyStatus'(). -type shop() :: dmsl_domain_thrift:'ShopConfig'(). -type shop_id() :: dmsl_domain_thrift:'ShopID'(). %% Interface --spec get_party(party_id()) -> party() | hg_domain:get_error(). +-spec get_party(party_id()) -> {party_id(), party()} | hg_domain:get_error(). get_party(PartyID) -> checkout(PartyID, get_party_revision()). @@ -31,25 +30,31 @@ get_party(PartyID) -> get_party_revision() -> hg_domain:head(). --spec checkout(party_id(), hg_domain:revision()) -> party() | hg_domain:get_error(). +-spec checkout(party_id(), hg_domain:revision()) -> {party_id(), party()} | hg_domain:get_error(). checkout(PartyID, Revision) -> - case hg_domain:get(Revision, {party_config, #domain_PartyConfigRef{id = PartyID}}) of - {object_not_found, _Ref} = Error -> + Ref = {party_config, #domain_PartyConfigRef{id = PartyID}}, + case hg_domain:get(Revision, Ref) of + {object_not_found, _} = Error -> Error; - Party -> - Party + PartyConfig -> + {PartyID, PartyConfig} end. --spec get_shop(shop_id(), party()) -> shop() | undefined. +-spec get_shop(shop_id(), party()) -> {shop_id(), shop()} | undefined. get_shop(ID, Party) -> get_shop(ID, Party, get_party_revision()). --spec get_shop(shop_id(), party(), hg_domain:revision()) -> shop() | undefined. +-spec get_shop(shop_id(), party(), hg_domain:revision()) -> {shop_id(), shop()} | undefined. get_shop(ID, #domain_PartyConfig{shops = Shops}, Revision) -> Ref = #domain_ShopConfigRef{id = ID}, case lists:member(Ref, Shops) of true -> - hg_domain:get(Revision, {shop_config, Ref}); + case hg_domain:get(Revision, {shop_config, Ref}) of + {object_not_found, _} = Error -> + Error; + ShopConfig -> + {ID, ShopConfig} + end; false -> undefined end. diff --git a/apps/hellgate/src/hg_proxy_provider.erl b/apps/hellgate/src/hg_proxy_provider.erl index ea437916..ff266f8b 100644 --- a/apps/hellgate/src/hg_proxy_provider.erl +++ b/apps/hellgate/src/hg_proxy_provider.erl @@ -25,8 +25,7 @@ -type change() :: dmsl_payproc_thrift:'SessionChangePayload'(). -type proxy_state() :: dmsl_base_thrift:'Opaque'(). -type proxy_intent() :: - dmsl_proxy_provider_thrift:'Intent'() - | dmsl_proxy_provider_thrift:'RecurrentTokenIntent'(). + dmsl_proxy_provider_thrift:'Intent'(). %% diff --git a/apps/hellgate/src/hg_varset.erl b/apps/hellgate/src/hg_varset.erl index beede202..da688a29 100644 --- a/apps/hellgate/src/hg_varset.erl +++ b/apps/hellgate/src/hg_varset.erl @@ -15,8 +15,7 @@ shop_id => dmsl_domain_thrift:'ShopID'(), risk_score => hg_inspector:risk_score(), flow => instant | {hold, dmsl_domain_thrift:'HoldLifetime'()}, - wallet_id => dmsl_domain_thrift:'WalletID'(), - identification_level => dmsl_domain_thrift:'ContractorIdentificationLevel'() + wallet_id => dmsl_domain_thrift:'WalletID'() }. -spec prepare_varset(varset()) -> dmsl_payproc_thrift:'Varset'(). @@ -27,7 +26,6 @@ prepare_varset(Varset) -> amount = genlib_map:get(cost, Varset), wallet_id = genlib_map:get(wallet_id, Varset), payment_tool = genlib_map:get(payment_tool, Varset), - identification_level = genlib_map:get(identification_level, Varset), party_id = genlib_map:get(party_id, Varset), shop_id = genlib_map:get(shop_id, Varset) }. diff --git a/apps/hellgate/test/hg_ct_domain.hrl b/apps/hellgate/test/hg_ct_domain.hrl index e9800c1a..aab43154 100644 --- a/apps/hellgate/test/hg_ct_domain.hrl +++ b/apps/hellgate/test/hg_ct_domain.hrl @@ -16,13 +16,11 @@ -define(pmt(C, T), #domain_PaymentMethodRef{id = {C, T}}). -define(pmt_sys(ID), #domain_PaymentSystemRef{id = ID}). -define(pmt_srv(ID), #domain_PaymentServiceRef{id = ID}). --define(pomt(M), #domain_PayoutMethodRef{id = M}). -define(cat(ID), #domain_CategoryRef{id = ID}). -define(prx(ID), #domain_ProxyRef{id = ID}). -define(prv(ID), #domain_ProviderRef{id = ID}). -define(prvtrm(ID), #domain_ProviderTerminalRef{id = ID}). -define(trm(ID), #domain_TerminalRef{id = ID}). --define(tmpl(ID), #domain_ContractTemplateRef{id = ID}). -define(trms(ID), #domain_TermSetHierarchyRef{id = ID}). -define(sas(ID), #domain_SystemAccountSetRef{id = ID}). -define(eas(ID), #domain_ExternalAccountSetRef{id = ID}). diff --git a/apps/hellgate/test/hg_ct_fixture.erl b/apps/hellgate/test/hg_ct_fixture.erl index 1c515b4d..16321519 100644 --- a/apps/hellgate/test/hg_ct_fixture.erl +++ b/apps/hellgate/test/hg_ct_fixture.erl @@ -9,14 +9,11 @@ -export([construct_category/2]). -export([construct_category/3]). -export([construct_payment_method/1]). --export([construct_payout_method/1]). -export([construct_proxy/2]). -export([construct_proxy/3]). -export([construct_inspector/3]). -export([construct_inspector/4]). -export([construct_inspector/5]). --export([construct_contract_template/2]). --export([construct_contract_template/4]). -export([construct_provider_account_set/1]). -export([construct_system_account_set/1]). -export([construct_system_account_set/3]). @@ -42,9 +39,6 @@ -type proxy() :: dmsl_domain_thrift:'ProxyRef'(). -type inspector() :: dmsl_domain_thrift:'InspectorRef'(). -type risk_score() :: hg_inspector:risk_score(). --type template() :: dmsl_domain_thrift:'ContractTemplateRef'(). --type terms() :: dmsl_domain_thrift:'TermSetHierarchyRef'(). --type lifetime() :: dmsl_domain_thrift:'Lifetime'() | undefined. -type payment_routing_ruleset() :: dmsl_domain_thrift:'RoutingRulesetRef'(). -type payment_system() :: dmsl_domain_thrift:'PaymentSystemRef'(). -type mobile_operator() :: dmsl_domain_thrift:'MobileOperatorRef'(). @@ -122,18 +116,6 @@ construct_payment_method(Name, Ref) when is_binary(Name) -> } }}. --spec construct_payout_method(dmsl_domain_thrift:'PayoutMethodRef'()) -> - {payout_method, dmsl_domain_thrift:'PayoutMethodObject'()}. -construct_payout_method(?pomt(M) = Ref) -> - Def = erlang:atom_to_binary(M, unicode), - {payout_method, #domain_PayoutMethodObject{ - ref = Ref, - data = #domain_PayoutMethodDefinition{ - name = Def, - description = Def - } - }}. - -spec construct_proxy(proxy(), name()) -> {proxy, dmsl_domain_thrift:'ProxyObject'()}. construct_proxy(Ref, Name) -> construct_proxy(Ref, Name, #{}). @@ -175,23 +157,6 @@ construct_inspector(Ref, Name, ProxyRef, Additional, FallBackScore) -> } }}. --spec construct_contract_template(template(), terms()) -> - {contract_template, dmsl_domain_thrift:'ContractTemplateObject'()}. -construct_contract_template(Ref, TermsRef) -> - construct_contract_template(Ref, TermsRef, undefined, undefined). - --spec construct_contract_template(template(), terms(), ValidSince :: lifetime(), ValidUntil :: lifetime()) -> - {contract_template, dmsl_domain_thrift:'ContractTemplateObject'()}. -construct_contract_template(Ref, TermsRef, ValidSince, ValidUntil) -> - {contract_template, #domain_ContractTemplateObject{ - ref = Ref, - data = #domain_ContractTemplate{ - valid_since = ValidSince, - valid_until = ValidUntil, - terms = TermsRef - } - }}. - -spec construct_provider_account_set([currency()]) -> dmsl_domain_thrift:'ProviderAccountSet'(). construct_provider_account_set(Currencies) -> ok = hg_context:save(hg_context:create()), diff --git a/apps/hellgate/test/hg_ct_helper.erl b/apps/hellgate/test/hg_ct_helper.erl index b9f065bf..70b7fab8 100644 --- a/apps/hellgate/test/hg_ct_helper.erl +++ b/apps/hellgate/test/hg_ct_helper.erl @@ -23,7 +23,6 @@ -export([block_shop/1]). -export([unblock_shop/1]). -export([create_battle_ready_shop/6]). --export([adjust_contract/4]). -export([make_invoice_params/4]). -export([make_invoice_params/5]). @@ -55,9 +54,6 @@ -export([make_disposable_payment_resource/1]). --export([make_meta_ns/0]). --export([make_meta_data/0]). --export([make_meta_data/1]). -export([get_hellgate_url/0]). -export([make_trace_id/1]). @@ -152,7 +148,7 @@ start_app(hg_proto = AppName) -> } }, party_config => #{ - url => <<"http://party-management:8022/v1/processing/partycfg">>, + url => <<"http://party-management:8022/v1/processing/partymgmt">>, transport_opts => #{ pool => party_config, max_connections => 300 @@ -443,8 +439,6 @@ create_client_w_context(RootUrl, WoodyCtx) -> -type invoice_template_id() :: dmsl_domain_thrift:'InvoiceTemplateID'(). -type party_id() :: dmsl_domain_thrift:'PartyID'(). -type party() :: dmsl_domain_thrift:'PartyConfig'(). --type contract_id() :: dmsl_domain_thrift:'ContractID'(). --type contract_tpl() :: dmsl_domain_thrift:'ContractTemplateRef'(). -type termset_ref() :: dmsl_domain_thrift:'TermSetHierarchyRef'(). -type turnover_limit() :: dmsl_domain_thrift:'TurnoverLimit'(). -type turnover_limits() :: ordsets:ordset(turnover_limit()). @@ -472,12 +466,11 @@ create_client_w_context(RootUrl, WoodyCtx) -> create_party(PartyID, _Client) -> % Создаем Party как объект конфигурации PartyConfig = #domain_PartyConfig{ - id = PartyID, contact_info = #domain_PartyContactInfo{ registration_email = <<"test@test.ru">> }, - created_at = hg_datetime:format_now(), - blocking = + name = <<"Test Party">>, + block = {unblocked, #domain_Unblocked{ reason = <<"">>, since = hg_datetime:format_now() @@ -526,7 +519,7 @@ activate_party(PartyID) -> block_party(PartyID) -> change_party(PartyID, fun(PartyConfig) -> PartyConfig#domain_PartyConfig{ - blocking = + block = {blocked, #domain_Blocked{ reason = <<"test">>, since = hg_datetime:format_now() @@ -538,7 +531,7 @@ block_party(PartyID) -> unblock_party(PartyID) -> change_party(PartyID, fun(PartyConfig) -> PartyConfig#domain_PartyConfig{ - blocking = + block = {unblocked, #domain_Unblocked{ reason = <<"test">>, since = hg_datetime:format_now() @@ -575,9 +568,7 @@ create_shop(PartyID, Category, Currency, TermsRef, PaymentInstRef, TurnoverLimit % Создаем Shop как объект конфигурации ShopConfig = #domain_ShopConfig{ - id = ShopID, - created_at = hg_datetime:format_now(), - blocking = + block = {unblocked, #domain_Unblocked{ reason = <<"">>, since = hg_datetime:format_now() @@ -586,18 +577,14 @@ create_shop(PartyID, Category, Currency, TermsRef, PaymentInstRef, TurnoverLimit {active, #domain_Active{ since = hg_datetime:format_now() }}, - details = #domain_Details{ - name = <<"Test Shop">>, - description = <<"Test description">> - }, + name = <<"Test Shop">>, + description = <<"Test description">>, location = {url, <<"www.url.ru">>}, category = Category, - currency_configs = #{ - #domain_CurrencyRef{symbolic_code = Currency} => #domain_ShopCurrencyConfig{ - currency = #domain_CurrencyRef{symbolic_code = Currency}, - settlement = SettlementID, - guarantee = GuaranteeID - } + account = #domain_ShopAccount{ + currency = #domain_CurrencyRef{symbolic_code = Currency}, + settlement = SettlementID, + guarantee = GuaranteeID }, payment_institution = PaymentInstRef, terms = TermsRef, @@ -655,7 +642,7 @@ activate_shop(ShopID) -> block_shop(ShopID) -> change_shop(ShopID, fun(ShopConfig) -> ShopConfig#domain_ShopConfig{ - blocking = + block = {blocked, #domain_Blocked{ reason = <<"test">>, since = hg_datetime:format_now() @@ -667,7 +654,7 @@ block_shop(ShopID) -> unblock_shop(ShopID) -> change_shop(ShopID, fun(ShopConfig) -> ShopConfig#domain_ShopConfig{ - blocking = + block = {unblocked, #domain_Unblocked{ reason = <<"test">>, since = hg_datetime:format_now() @@ -699,12 +686,11 @@ create_party_and_shop(PartyID, Category, Currency, TermsRef, PaymentInstRef, _Cl % Создаем Party как объект конфигурации PartyConfig = #domain_PartyConfig{ - id = PartyID, contact_info = #domain_PartyContactInfo{ registration_email = <<"test@test.ru">> }, - created_at = hg_datetime:format_now(), - blocking = + name = <<"Test Party">>, + block = {unblocked, #domain_Unblocked{ reason = <<"">>, since = hg_datetime:format_now() @@ -731,9 +717,7 @@ create_party_and_shop(PartyID, Category, Currency, TermsRef, PaymentInstRef, _Cl % Создаем Shop как объект конфигурации ShopConfig = #domain_ShopConfig{ - id = ShopID, - created_at = hg_datetime:format_now(), - blocking = + block = {unblocked, #domain_Unblocked{ reason = <<"">>, since = hg_datetime:format_now() @@ -742,18 +726,14 @@ create_party_and_shop(PartyID, Category, Currency, TermsRef, PaymentInstRef, _Cl {active, #domain_Active{ since = hg_datetime:format_now() }}, - details = #domain_Details{ - name = <<"Test Shop">>, - description = <<"Test description">> - }, + name = <<"Test Shop">>, + description = <<"Test description">>, location = {url, <<"www.url.ru">>}, category = Category, - currency_configs = #{ - #domain_CurrencyRef{symbolic_code = Currency} => #domain_ShopCurrencyConfig{ - currency = #domain_CurrencyRef{symbolic_code = Currency}, - settlement = SettlementID, - guarantee = GuaranteeID - } + account = #domain_ShopAccount{ + currency = #domain_CurrencyRef{symbolic_code = Currency}, + settlement = SettlementID, + guarantee = GuaranteeID }, terms = TermsRef, payment_institution = PaymentInstRef, @@ -805,9 +785,7 @@ create_battle_ready_shop(PartyID, Category, Currency, TermsRef, PaymentInstRef, % Создаем Shop как объект конфигурации с дополнительными настройками для боевой среды ShopConfig = #domain_ShopConfig{ - id = ShopID, - created_at = hg_datetime:format_now(), - blocking = + block = {unblocked, #domain_Unblocked{ reason = <<"">>, since = hg_datetime:format_now() @@ -816,18 +794,14 @@ create_battle_ready_shop(PartyID, Category, Currency, TermsRef, PaymentInstRef, {active, #domain_Active{ since = hg_datetime:format_now() }}, - details = #domain_Details{ - name = <<"Battle Ready Shop">>, - description = <<"Battle Ready Description">> - }, + name = <<"Battle Ready Shop">>, + description = <<"Battle Ready Descriptio">>, location = {url, <<"www.battle-ready.ru">>}, category = Category, - currency_configs = #{ - #domain_CurrencyRef{symbolic_code = Currency} => #domain_ShopCurrencyConfig{ - currency = #domain_CurrencyRef{symbolic_code = Currency}, - settlement = SettlementID, - guarantee = GuaranteeID - } + account = #domain_ShopAccount{ + currency = #domain_CurrencyRef{symbolic_code = Currency}, + settlement = SettlementID, + guarantee = GuaranteeID }, payment_institution = PaymentInstRef, terms = TermsRef, @@ -850,33 +824,6 @@ create_battle_ready_shop(PartyID, Category, Currency, TermsRef, PaymentInstRef, ShopID. --spec adjust_contract(party_id(), contract_id(), contract_tpl(), party_client()) -> ok. -adjust_contract(PartyID, ContractID, TemplateRef, Client) -> - Changeset = [ - {contract_modification, #payproc_ContractModificationUnit{ - id = ContractID, - modification = - {adjustment_modification, #payproc_ContractAdjustmentModificationUnit{ - adjustment_id = hg_utils:unique_id(), - modification = - {creation, #payproc_ContractAdjustmentParams{ - template = TemplateRef - }} - }} - }} - ], - create_claim(PartyID, Changeset, Client). - --spec create_claim(party_id(), list(), party_client()) -> ok. -create_claim(PartyID, Changeset, {Client, Context}) -> - {ok, Claim} = party_client_thrift:create_claim(PartyID, Changeset, Client, Context), - case Claim of - #payproc_Claim{status = {accepted, _}} -> - ok; - #payproc_Claim{id = ID, revision = Rev} -> - party_client_thrift:accept_claim(PartyID, ID, Rev, Client, Context) - end. - -spec make_invoice_params(party_id(), shop_id(), binary(), cash()) -> invoice_params(). make_invoice_params(PartyID, ShopID, Product, Cost) -> make_invoice_params(PartyID, ShopID, Product, make_due_date(), Cost). @@ -1075,22 +1022,6 @@ make_disposable_payment_resource({PaymentTool, SessionID}) -> client_info = #domain_ClientInfo{} }. --spec make_meta_ns() -> dmsl_domain_thrift:'PartyMetaNamespace'(). -make_meta_ns() -> - list_to_binary(lists:concat(["NS-", erlang:system_time()])). - --spec make_meta_data() -> dmsl_domain_thrift:'PartyMetaData'(). -make_meta_data() -> - make_meta_data(<<"NS-0">>). - --spec make_meta_data(dmsl_domain_thrift:'PartyMetaNamespace'()) -> dmsl_domain_thrift:'PartyMetaData'(). -make_meta_data(NS) -> - {obj, #{ - {str, <<"NS">>} => {str, NS}, - {i, 42} => {str, <<"42">>}, - {str, <<"STRING!">>} => {arr, []} - }}. - -spec get_hellgate_url() -> string(). get_hellgate_url() -> "http://" ++ ?HELLGATE_HOST ++ ":" ++ integer_to_list(?HELLGATE_PORT). diff --git a/apps/hellgate/test/hg_direct_recurrent_tests_SUITE.erl b/apps/hellgate/test/hg_direct_recurrent_tests_SUITE.erl index 7fe02da7..cbbb25bf 100644 --- a/apps/hellgate/test/hg_direct_recurrent_tests_SUITE.erl +++ b/apps/hellgate/test/hg_direct_recurrent_tests_SUITE.erl @@ -529,8 +529,6 @@ construct_domain_fixture(TermSet) -> hg_ct_fixture:construct_inspector(?insp(1), <<"Rejector">>, ?prx(2), #{<<"risk_score">> => <<"low">>}), - hg_ct_fixture:construct_contract_template(?tmpl(1), ?trms(1)), - hg_ct_fixture:construct_system_account_set(?sas(1)), hg_ct_fixture:construct_external_account_set(?eas(1)), @@ -539,7 +537,6 @@ construct_domain_fixture(TermSet) -> data = #domain_PaymentInstitution{ name = <<"Test Inc.">>, system_account_set = {value, ?sas(1)}, - default_contract_template = {value, ?tmpl(1)}, payment_routing_rules = #domain_RoutingRules{ policies = ?ruleset(2), prohibitions = ?ruleset(1) @@ -583,12 +580,7 @@ construct_domain_fixture(TermSet) -> ref = ?trms(1), data = #domain_TermSetHierarchy{ parent_terms = undefined, - term_sets = [ - #domain_TimedTermSet{ - action_time = #base_TimestampInterval{}, - terms = TermSet - } - ] + term_set = TermSet } }}, {provider, #domain_ProviderObject{ diff --git a/apps/hellgate/test/hg_dummy_provider.erl b/apps/hellgate/test/hg_dummy_provider.erl index 35e611d2..bac03cb7 100644 --- a/apps/hellgate/test/hg_dummy_provider.erl +++ b/apps/hellgate/test/hg_dummy_provider.erl @@ -82,18 +82,6 @@ {success, #proxy_provider_Success{token = Token, changed_cost = ChangedCash}} ). --define(recurrent_token_finish(Token), - {finish, #proxy_provider_RecurrentTokenFinishIntent{ - status = {success, #proxy_provider_RecurrentTokenSuccess{token = Token}} - }} -). - --define(recurrent_token_finish_w_failure(Failure), - {finish, #proxy_provider_RecurrentTokenFinishIntent{ - status = {failure, Failure} - }} -). - -define(DEFAULT_SESSION(PaymentTool), {PaymentTool, <<"">>}). -define(SESSION42(PaymentTool), {PaymentTool, <<"SESSION42">>}). @@ -132,26 +120,6 @@ construct_silent_callback(Form) -> -include_lib("hellgate/include/payment_events.hrl"). -spec handle_function(woody:func(), woody:args(), hg_woody_service_wrapper:handler_opts()) -> term() | no_return(). -handle_function( - 'GenerateToken', - {#proxy_provider_RecurrentTokenContext{ - session = #proxy_provider_RecurrentTokenSession{state = State}, - token_info = TokenInfo, - options = _ - }}, - Opts -) -> - generate_token(State, TokenInfo, Opts); -handle_function( - 'HandleRecurrentTokenCallback', - {Payload, #proxy_provider_RecurrentTokenContext{ - session = #proxy_provider_RecurrentTokenSession{state = State}, - token_info = TokenInfo, - options = _ - }}, - Opts -) -> - handle_token_callback(Payload, State, TokenInfo, Opts); handle_function( 'ProcessPayment', {#proxy_provider_PaymentContext{ @@ -193,75 +161,6 @@ handle_function( ) -> handle_payment_callback(Payload, Target, State, PaymentInfo, Opts). -% -% Recurrent tokens -% - -generate_token(undefined, #proxy_provider_RecurrentTokenInfo{payment_tool = RecurrentPaytool}, _Opts) -> - case get_recurrent_paytool_scenario(RecurrentPaytool) of - forbidden -> - #proxy_provider_RecurrentTokenProxyResult{ - intent = ?recurrent_token_finish_w_failure(#domain_Failure{code = <<"forbidden">>}) - }; - unexpected_failure -> - error(unexpected_failure); - _ -> - token_result(?sleep(0), <<"sleeping">>) - end; -generate_token(<<"sleeping">>, #proxy_provider_RecurrentTokenInfo{payment_tool = RecurrentPaytool}, _Opts) -> - case get_recurrent_paytool_scenario(RecurrentPaytool) of - {preauth_3ds, Timeout} -> - Tag = generate_tag(<<"recurrent">>), - Uri = get_callback_url(), - UserInteraction = ?redirect(Uri, #{<<"tag">> => Tag}), - token_result(?suspend(Tag, Timeout, UserInteraction), <<"suspended">>); - {preauth_3ds_sleep, Timeout} -> - Tag = generate_tag(<<"recurrent-sleep">>), - Uri = get_callback_url(), - UserInteraction = ?redirect(Uri, #{<<"tag">> => Tag}), - token_result(?suspend(Tag, Timeout, UserInteraction), <<"suspended">>); - no_preauth_timeout -> - Tag = generate_tag(<<"recurrent-suspend-timeout">>), - Callback = {callback, Tag}, - token_result(?suspend(Tag, 1, undefined, Callback), <<"suspended">>); - no_preauth_timeout_failure -> - Tag = generate_tag(<<"recurrent-suspend-timeout-failure">>), - Failure = {operation_failure, failure(preauthorization_failed)}, - token_result(?suspend(Tag, 1, undefined, Failure), <<"suspended">>); - no_preauth_suspend_default -> - Tag = generate_tag(<<"recurrent-suspend-timeout-default">>), - token_result(?suspend(Tag, 1), <<"suspended">>); - no_preauth -> - token_result(?sleep(0), <<"finishing">>) - end; -generate_token(<<"finishing">>, TokenInfo, _Opts) -> - Token = ?REC_TOKEN, - token_finish(TokenInfo, Token). - -handle_token_callback(<<"recurrent-sleep-", _/binary>>, <<"suspended">>, TokenInfo, _Opts) -> - token_respond(<<"sure">>, token_finish(TokenInfo, ?REC_TOKEN)); -handle_token_callback(_Tag, <<"suspended">>, _TokenInfo, _Opts) -> - Intent = ?sleep(0, undefined, ?completed), - token_respond(<<"sure">>, token_result(Intent, <<"finishing">>)). - -token_finish(#proxy_provider_RecurrentTokenInfo{payment_tool = PaymentTool}, Token) -> - #proxy_provider_RecurrentTokenProxyResult{ - intent = ?recurrent_token_finish(Token), - trx = #domain_TransactionInfo{id = PaymentTool#proxy_provider_RecurrentPaymentTool.id, extra = #{}} - }. - -token_result(Intent, State) -> - #proxy_provider_RecurrentTokenProxyResult{ - intent = Intent, - next_state = State - }. - -token_respond(Response, CallbackResult) -> - #proxy_provider_RecurrentTokenCallbackResult{ - response = Response, - result = CallbackResult - }. - % % Payments % @@ -654,10 +553,6 @@ get_payment_resource_scenario({disposable_payment_resource, PaymentResource}) -> get_payment_resource_scenario({recurrent_payment_resource, _}) -> recurrent. -get_recurrent_paytool_scenario(#proxy_provider_RecurrentPaymentTool{payment_resource = PaymentResource}) -> - PaymentTool = get_payment_tool(PaymentResource), - get_payment_tool_scenario(PaymentTool). - get_payment_tool_scenario({'bank_card', #domain_BankCard{token = <<"change_cash_increase">>}}) -> change_cash_increase; get_payment_tool_scenario({'bank_card', #domain_BankCard{token = <<"change_cash_decrease">>}}) -> @@ -919,9 +814,6 @@ callback_to_hell(Tag, Payload) -> case Tag of <<"payment-", _Rest/binary>> -> 'ProcessPaymentCallback'; - <<"recurrent-", _Rest/binary>> -> - 'ProcessRecurrentTokenCallback'; - % FIXME adhoc for old tests, probably can be safely removed _ -> 'ProcessPaymentCallback' end, diff --git a/apps/hellgate/test/hg_invoice_lite_tests_SUITE.erl b/apps/hellgate/test/hg_invoice_lite_tests_SUITE.erl index 2046c365..34f26eac 100644 --- a/apps/hellgate/test/hg_invoice_lite_tests_SUITE.erl +++ b/apps/hellgate/test/hg_invoice_lite_tests_SUITE.erl @@ -724,8 +724,6 @@ construct_domain_fixture() -> hg_ct_fixture:construct_inspector(?insp(1), <<"Rejector">>, ?prx(2), #{<<"risk_score">> => <<"trusted">>}), - hg_ct_fixture:construct_contract_template(?tmpl(1), ?trms(1)), - hg_ct_fixture:construct_system_account_set(?sas(1)), hg_ct_fixture:construct_external_account_set(?eas(1)), @@ -748,12 +746,6 @@ construct_domain_fixture() -> data = #domain_PaymentInstitution{ name = <<"Test Inc.">>, system_account_set = {value, ?sas(1)}, - default_contract_template = {value, ?tmpl(1)}, - providers = - {value, - ?ordset([ - ?prv(1) - ])}, payment_routing_rules = #domain_RoutingRules{ policies = ?ruleset(1), prohibitions = ?ruleset(3) @@ -791,12 +783,7 @@ construct_domain_fixture() -> {term_set_hierarchy, #domain_TermSetHierarchyObject{ ref = ?trms(1), data = #domain_TermSetHierarchy{ - term_sets = [ - #domain_TimedTermSet{ - action_time = #base_TimestampInterval{}, - terms = TestTermSet - } - ] + term_set = TestTermSet } }}, diff --git a/apps/hellgate/test/hg_invoice_template_tests_SUITE.erl b/apps/hellgate/test/hg_invoice_template_tests_SUITE.erl index 0c4c52b8..425dfddb 100644 --- a/apps/hellgate/test/hg_invoice_template_tests_SUITE.erl +++ b/apps/hellgate/test/hg_invoice_template_tests_SUITE.erl @@ -584,7 +584,6 @@ construct_domain_fixture() -> hg_ct_fixture:construct_category(?cat(1), <<"Test category">>), hg_ct_fixture:construct_proxy(?prx(1), <<"Dummy proxy">>), hg_ct_fixture:construct_inspector(?insp(1), <<"Dummy Inspector">>, ?prx(1)), - hg_ct_fixture:construct_contract_template(?tmpl(1), ?trms(1)), hg_ct_fixture:construct_system_account_set(?sas(1)), hg_ct_fixture:construct_external_account_set(?eas(1)), @@ -598,8 +597,6 @@ construct_domain_fixture() -> data = #domain_PaymentInstitution{ name = <<"Test Inc.">>, system_account_set = {value, ?sas(1)}, - default_contract_template = {value, ?tmpl(1)}, - providers = {value, ?ordset([])}, inspector = {value, ?insp(1)}, residences = [], realm = test @@ -617,17 +614,12 @@ construct_domain_fixture() -> ref = ?trms(1), data = #domain_TermSetHierarchy{ parent_terms = undefined, - term_sets = [ - #domain_TimedTermSet{ - action_time = #base_TimestampInterval{}, - terms = #domain_TermSet{ - payments = #domain_PaymentsServiceTerms{ - currencies = {value, ordsets:from_list([?cur(<<"RUB">>)])}, - categories = {value, ordsets:from_list([?cat(1)])} - } - } + term_set = #domain_TermSet{ + payments = #domain_PaymentsServiceTerms{ + currencies = {value, ordsets:from_list([?cur(<<"RUB">>)])}, + categories = {value, ordsets:from_list([?cat(1)])} } - ] + } } }} ]. @@ -666,11 +658,6 @@ construct_term_set_for_cost(LowerBound, UpperBound) -> ref = ?trms(1), data = #domain_TermSetHierarchy{ parent_terms = undefined, - term_sets = [ - #domain_TimedTermSet{ - action_time = #base_TimestampInterval{}, - terms = TermSet - } - ] + term_set = TermSet } }}. diff --git a/apps/hellgate/test/hg_invoice_tests_SUITE.erl b/apps/hellgate/test/hg_invoice_tests_SUITE.erl index 2a02baf4..87e54ff3 100644 --- a/apps/hellgate/test/hg_invoice_tests_SUITE.erl +++ b/apps/hellgate/test/hg_invoice_tests_SUITE.erl @@ -1640,20 +1640,16 @@ mk_provider_w_term(TerminalRef, TerminalName, ProviderRef, ProviderName, Provide ]. new_merchant_terms_attempt_limit(TermSetHierarchyRef, TargetTermSetHierarchyRef, Attempts, Revision) -> - #domain_TermSetHierarchy{term_sets = [BaseTermSet0]} = + #domain_TermSetHierarchy{term_set = TermsSet} = hg_domain:get(Revision, {term_set_hierarchy, TermSetHierarchyRef}), - #domain_TimedTermSet{terms = TermsSet} = BaseTermSet0, #domain_TermSet{payments = PaymentsTerms0} = TermsSet, PaymentsTerms1 = PaymentsTerms0#domain_PaymentsServiceTerms{ attempt_limit = {value, #domain_AttemptLimit{attempts = Attempts}} }, - BaseTermSet1 = BaseTermSet0#domain_TimedTermSet{ - terms = TermsSet#domain_TermSet{payments = PaymentsTerms1} - }, [ {term_set_hierarchy, #domain_TermSetHierarchyObject{ ref = TargetTermSetHierarchyRef, - data = #domain_TermSetHierarchy{term_sets = [BaseTermSet1]} + data = #domain_TermSetHierarchy{term_set = TermsSet#domain_TermSet{payments = PaymentsTerms1}} }} ]. @@ -1860,8 +1856,8 @@ payment_error_in_cancel_session_does_not_cause_payment_failure(C) -> PartyID = cfg(party_id, C), PartyPair = cfg(party_client, C), ShopID = hg_ct_helper:create_battle_ready_shop(PartyID, ?cat(2), <<"RUB">>, ?trms(2), ?pinst(2), PartyPair), - Party = hg_party:get_party(PartyID), - Shop = hg_party:get_shop(ShopID, Party), + {PartyID, Party} = hg_party:get_party(PartyID), + {ShopID, Shop} = hg_party:get_shop(ShopID, Party), {SettlementID, _GuaranteeID} = hg_invoice_utils:get_shop_account(Shop), InvoiceID = start_invoice(ShopID, <<"rubberduck">>, make_due_date(1000), 42000, C), PaymentParams = make_scenario_payment_params([good, fail, good], {hold, capture}, ?pmt_sys(<<"visa-ref">>)), @@ -1887,8 +1883,8 @@ payment_error_in_capture_session_does_not_cause_payment_failure(C) -> ShopID = hg_ct_helper:create_battle_ready_shop(PartyID, ?cat(2), <<"RUB">>, ?trms(2), ?pinst(2), PartyPair), Amount = 42000, Cost = ?cash(Amount, <<"RUB">>), - Party = hg_party:get_party(PartyID), - Shop = hg_party:get_shop(ShopID, Party), + {PartyID, Party} = hg_party:get_party(PartyID), + {ShopID, Shop} = hg_party:get_shop(ShopID, Party), {SettlementID, _GuaranteeID} = hg_invoice_utils:get_shop_account(Shop), InvoiceID = start_invoice(ShopID, <<"rubberduck">>, make_due_date(1000), Amount, C), PaymentParams = make_scenario_payment_params([good, fail, good], {hold, cancel}, ?pmt_sys(<<"visa-ref">>)), @@ -2687,8 +2683,7 @@ payment_adjustment_chargeback_success(C) -> PartyPair = cfg(party_client, C), % % Контракт на основе шаблона ?trms(1) ShopID = hg_ct_helper:create_shop(PartyID, ?cat(1), <<"RUB">>, ?trms(3), ?pinst(1), PartyPair), - % Shop = hg_party:get_shop(PartyID, ShopID, PartyClient, , hg_party:get_party_revision()), - % ok = hg_ct_helper:adjust_contract(PartyID, Shop#domain_ShopConfig.contract_id, ?tmpl(3), PartyPair), + % {ShopID, Shop} = hg_party:get_shop(PartyID, ShopID, PartyClient, , hg_party:get_party_revision()), InvoiceID = start_invoice(ShopID, <<"rubberduck">>, make_due_date(10), 10000, C), PaymentID = execute_payment(InvoiceID, make_payment_params(?pmt_sys(<<"visa-ref">>)), Client), CashFlow = get_payment_cashflow_mapped(InvoiceID, PaymentID, Client), @@ -2912,12 +2907,10 @@ payment_adjustment_change_amount_and_captured(C) -> Client = cfg(client, C), % PartyID = cfg(party_id, C), % {PartyClient, PartyCtx} = PartyPair = cfg(party_client, C), - % Shop = hg_party:get_shop(PartyID, cfg(shop_id, C), hg_party:get_party_revision()), + % {ShopID, Shop} = hg_party:get_shop(PartyID, cfg(shop_id, C), hg_party:get_party_revision()), % reinit terminal cashflow ok = update_payment_terms_cashflow(?prv(100), get_payment_adjustment_provider_cashflow(initial)), - % reinit merchant fees - % ok = hg_ct_helper:adjust_contract(PartyID, Shop#domain_ShopConfig.contract_id, ?trms(1), PartyPair), OriginalAmount = 100000, NewAmount = 200000, @@ -3060,10 +3053,8 @@ payment_adjustment_change_amount_and_refund_all(C) -> % PartyID = cfg(party_id, C), ShopID = cfg(shop_id, C), % {PartyClient, PartyCtx} = PartyPair = cfg(party_client, C), - % Shop = hg_party:get_shop(PartyID, ShopID, hg_party:get_party_revision()), + % {ShopID, Shop} = hg_party:get_shop(PartyID, ShopID, hg_party:get_party_revision()), ok = update_payment_terms_cashflow(?prv(100), get_payment_adjustment_provider_cashflow(initial)), - % reinit merchant fees - % ok = hg_ct_helper:adjust_contract(PartyID, Shop#domain_ShopConfig.contract_id, ?trms(1), PartyPair), OriginalAmount = 100000, NewAmount = 200000, @@ -4458,8 +4449,8 @@ start_chargeback(C, Cost, CBParams, PaymentParams) -> PartyID = cfg(party_id, C), PartyPair = cfg(party_client, C), ShopID = hg_ct_helper:create_battle_ready_shop(PartyID, ?cat(2), <<"RUB">>, ?trms(2), ?pinst(2), PartyPair), - Party = hg_party:get_party(PartyID), - Shop = hg_party:get_shop(ShopID, Party), + {PartyID, Party} = hg_party:get_party(PartyID), + {ShopID, Shop} = hg_party:get_shop(ShopID, Party), {SettlementID, _} = hg_invoice_utils:get_shop_account(Shop), Settlement0 = hg_accounting:get_balance(SettlementID), % 0.045 @@ -4478,8 +4469,8 @@ start_chargeback_partial_capture(C, Cost, Partial, CBParams, PmtSys) -> Cash = ?cash(Partial, <<"RUB">>), PartyPair = cfg(party_client, C), ShopID = hg_ct_helper:create_battle_ready_shop(PartyID, ?cat(2), <<"RUB">>, ?trms(2), ?pinst(2), PartyPair), - Party = hg_party:get_party(PartyID), - Shop = hg_party:get_shop(ShopID, Party), + {PartyID, Party} = hg_party:get_party(PartyID), + {ShopID, Shop} = hg_party:get_shop(ShopID, Party), {SettlementID, _} = hg_invoice_utils:get_shop_account(Shop), Settlement0 = hg_accounting:get_balance(SettlementID), % Fee = 450, % 0.045 @@ -5899,11 +5890,11 @@ consistent_account_balances(C) -> end end, - Party = hg_party:get_party(cfg(party_id, C)), + {_PartyID, Party} = hg_party:get_party(cfg(party_id, C)), #domain_PartyConfig{shops = Shops} = Party, _ = lists:foreach( fun(#domain_ShopConfigRef{id = ShopID}) -> - Shop = hg_party:get_shop(ShopID, Party), + {ShopID, Shop} = hg_party:get_shop(ShopID, Party), {ID1, ID2} = hg_invoice_utils:get_shop_account(Shop), ok = Fun(ID1, Shop), ok = Fun(ID2, Shop) @@ -6381,10 +6372,6 @@ payment_cascade_success_w_refund(C) -> payment_big_cascade_success_fixture_pre(Revision, _C) -> lists:flatten([ - hg_ct_fixture:construct_contract_template( - ?tmpl(?CASCADE_ID_RANGE(?PAYMENT_BIG_CASCADE_SUCCESS_ID)), - ?trms(?CASCADE_ID_RANGE(?PAYMENT_BIG_CASCADE_SUCCESS_ID)) - ), new_merchant_terms_attempt_limit( ?trms(1), ?trms(?CASCADE_ID_RANGE(?PAYMENT_BIG_CASCADE_SUCCESS_ID)), @@ -6519,10 +6506,6 @@ payment_big_cascade_success_fixture(Revision, _C) -> payment_cascade_limit_overflow_fixture_pre(Revision, _C) -> lists:flatten([ - hg_ct_fixture:construct_contract_template( - ?tmpl(?CASCADE_ID_RANGE(?PAYMENT_CASCADE_LIMIT_OVERFLOW_ID)), - ?trms(?CASCADE_ID_RANGE(?PAYMENT_CASCADE_LIMIT_OVERFLOW_ID)) - ), new_merchant_terms_attempt_limit( ?trms(1), ?trms(?CASCADE_ID_RANGE(?PAYMENT_CASCADE_LIMIT_OVERFLOW_ID)), @@ -6751,10 +6734,6 @@ payment_big_cascade_success(C) -> payment_cascade_fail_provider_error_fixture_pre(Revision, _C) -> lists:flatten([ - hg_ct_fixture:construct_contract_template( - ?tmpl(?CASCADE_ID_RANGE(?PAYMENT_CASCADE_FAIL_PROVIDER_ERROR_ID)), - ?trms(?CASCADE_ID_RANGE(?PAYMENT_CASCADE_FAIL_PROVIDER_ERROR_ID)) - ), new_merchant_terms_attempt_limit( ?trms(1), ?trms(?CASCADE_ID_RANGE(?PAYMENT_CASCADE_FAIL_PROVIDER_ERROR_ID)), @@ -6871,10 +6850,6 @@ payment_cascade_fail_provider_error(C) -> payment_cascade_fail_ui_fixture_pre(Revision, _C) -> lists:flatten([ - hg_ct_fixture:construct_contract_template( - ?tmpl(?CASCADE_ID_RANGE(?PAYMENT_CASCADE_FAIL_UI_ID)), - ?trms(?CASCADE_ID_RANGE(?PAYMENT_CASCADE_FAIL_UI_ID)) - ), new_merchant_terms_attempt_limit( ?trms(1), ?trms(?CASCADE_ID_RANGE(?PAYMENT_CASCADE_FAIL_UI_ID)), @@ -6994,10 +6969,6 @@ payment_cascade_fail_ui(C) -> payment_cascade_fail_wo_route_candidates_fixture_pre(Revision, _C) -> lists:flatten([ - hg_ct_fixture:construct_contract_template( - ?tmpl(?CASCADE_ID_RANGE(?PAYMENT_CASCADE_FAIL_WO_ROUTE_CANDIDATES_ID)), - ?trms(?CASCADE_ID_RANGE(?PAYMENT_CASCADE_FAIL_WO_ROUTE_CANDIDATES_ID)) - ), new_merchant_terms_attempt_limit( ?trms(1), ?trms(?CASCADE_ID_RANGE(?PAYMENT_CASCADE_FAIL_WO_ROUTE_CANDIDATES_ID)), @@ -7078,10 +7049,6 @@ payment_cascade_fail_wo_route_candidates(C) -> payment_cascade_fail_wo_available_attempt_limit_fixture_pre(Revision, _C) -> lists:flatten([ - hg_ct_fixture:construct_contract_template( - ?tmpl(?CASCADE_ID_RANGE(?PAYMENT_CASCADE_FAIL_WO_AVAILABLE_ATTEMPT_LIMIT_ID)), - ?trms(?CASCADE_ID_RANGE(?PAYMENT_CASCADE_FAIL_WO_AVAILABLE_ATTEMPT_LIMIT_ID)) - ), new_merchant_terms_attempt_limit( ?trms(1), ?trms(?CASCADE_ID_RANGE(?PAYMENT_CASCADE_FAIL_WO_AVAILABLE_ATTEMPT_LIMIT_ID)), @@ -8420,10 +8387,6 @@ construct_domain_fixture() -> #{<<"link_state">> => <<"temporary_failure">>} ), - hg_ct_fixture:construct_contract_template(?tmpl(1), ?trms(1)), - hg_ct_fixture:construct_contract_template(?tmpl(2), ?trms(2)), - hg_ct_fixture:construct_contract_template(?tmpl(3), ?trms(3)), - hg_ct_fixture:construct_system_account_set(?sas(1)), hg_ct_fixture:construct_system_account_set(?sas(2)), hg_ct_fixture:construct_external_account_set(?eas(1)), @@ -8491,16 +8454,6 @@ construct_domain_fixture() -> data = #domain_PaymentInstitution{ name = <<"Test Inc.">>, system_account_set = {value, ?sas(1)}, - default_contract_template = {value, ?tmpl(1)}, - providers = - {value, - ?ordset([ - ?prv(1), - ?prv(2), - ?prv(3), - ?prv(4), - ?prv(5) - ])}, payment_routing_rules = #domain_RoutingRules{ policies = ?ruleset(2), prohibitions = ?ruleset(3) @@ -8563,18 +8516,10 @@ construct_domain_fixture() -> data = #domain_PaymentInstitution{ name = <<"Chetky Payments Inc.">>, system_account_set = {value, ?sas(2)}, - default_contract_template = {value, ?tmpl(2)}, payment_routing_rules = #domain_RoutingRules{ policies = ?ruleset(5), prohibitions = ?ruleset(3) }, - providers = - {value, - ?ordset([ - ?prv(1), - ?prv(2), - ?prv(3) - ])}, inspector = {decisions, [ #domain_InspectorDecision{ @@ -8664,30 +8609,20 @@ construct_domain_fixture() -> {term_set_hierarchy, #domain_TermSetHierarchyObject{ ref = ?trms(1), data = #domain_TermSetHierarchy{ - term_sets = [ - #domain_TimedTermSet{ - action_time = #base_TimestampInterval{}, - terms = TestTermSet - } - ] + term_set = TestTermSet } }}, {term_set_hierarchy, #domain_TermSetHierarchyObject{ ref = ?trms(2), data = #domain_TermSetHierarchy{ - term_sets = [ - #domain_TimedTermSet{ - action_time = #base_TimestampInterval{}, - terms = DefaultTermSet - } - ] + term_set = DefaultTermSet } }}, {term_set_hierarchy, #domain_TermSetHierarchyObject{ ref = ?trms(3), data = #domain_TermSetHierarchy{ parent_terms = ?trms(1), - term_sets = [] + term_set = DefaultTermSet } }}, @@ -9496,17 +9431,11 @@ construct_term_set_for_refund_eligibility_time(Seconds) -> } }, [ - hg_ct_fixture:construct_contract_template(?tmpl(100), ?trms(100)), {term_set_hierarchy, #domain_TermSetHierarchyObject{ ref = ?trms(100), data = #domain_TermSetHierarchy{ parent_terms = ?trms(2), - term_sets = [ - #domain_TimedTermSet{ - action_time = #base_TimestampInterval{}, - terms = TermSet - } - ] + term_set = TermSet } }} ]. @@ -9517,34 +9446,29 @@ get_payment_adjustment_fixture(Revision) -> {term_set_hierarchy, #domain_TermSetHierarchyObject{ ref = ?trms(3), data = #domain_TermSetHierarchy{ - term_sets = [ - #domain_TimedTermSet{ - action_time = #base_TimestampInterval{}, - terms = #domain_TermSet{ - payments = #domain_PaymentsServiceTerms{ - fees = - {value, [ - ?cfpost( - {merchant, settlement}, - {system, settlement}, - ?merchant_to_system_share_3 - ) - ]}, - chargebacks = #domain_PaymentChargebackServiceTerms{ - allow = {constant, true}, - fees = - {value, [ - ?cfpost( - {merchant, settlement}, - {system, settlement}, - ?share(1, 1, surplus) - ) - ]} - } - } + term_set = #domain_TermSet{ + payments = #domain_PaymentsServiceTerms{ + fees = + {value, [ + ?cfpost( + {merchant, settlement}, + {system, settlement}, + ?merchant_to_system_share_3 + ) + ]}, + chargebacks = #domain_PaymentChargebackServiceTerms{ + allow = {constant, true}, + fees = + {value, [ + ?cfpost( + {merchant, settlement}, + {system, settlement}, + ?share(1, 1, surplus) + ) + ]} } } - ], + }, parent_terms = ?trms(1) } }}, @@ -9817,13 +9741,7 @@ payments_w_bank_card_issuer_conditions_fixture(Revision, _C) -> [ {payment_institution, #domain_PaymentInstitutionObject{ ref = ?pinst(1), - data = PaymentInstitution#domain_PaymentInstitution{ - providers = - {value, - ?ordset([ - ?prv(100) - ])} - } + data = PaymentInstitution#domain_PaymentInstitution{} }}, {provider, #domain_ProviderObject{ ref = ?prv(100), @@ -9929,44 +9847,38 @@ payments_w_bank_card_issuer_conditions_fixture(Revision, _C) -> ref = ?trms(4), data = #domain_TermSetHierarchy{ parent_terms = ?trms(1), - term_sets = [ - #domain_TimedTermSet{ - action_time = #base_TimestampInterval{}, - terms = #domain_TermSet{ - payments = #domain_PaymentsServiceTerms{ - cash_limit = - {decisions, [ - #domain_CashLimitDecision{ - if_ = - {condition, - {payment_tool, - {bank_card, #domain_BankCardCondition{ - definition = {issuer_country_is, kaz} - }}}}, - then_ = - {value, - ?cashrng( - {inclusive, ?cash(1000, <<"RUB">>)}, - {inclusive, ?cash(1000, <<"RUB">>)} - )} - }, - #domain_CashLimitDecision{ - if_ = {constant, true}, - then_ = - {value, - ?cashrng( - {inclusive, ?cash(1000, <<"RUB">>)}, - {exclusive, ?cash(1000000000, <<"RUB">>)} - )} - } - ]} - } - } + term_set = #domain_TermSet{ + payments = #domain_PaymentsServiceTerms{ + cash_limit = + {decisions, [ + #domain_CashLimitDecision{ + if_ = + {condition, + {payment_tool, + {bank_card, #domain_BankCardCondition{ + definition = {issuer_country_is, kaz} + }}}}, + then_ = + {value, + ?cashrng( + {inclusive, ?cash(1000, <<"RUB">>)}, + {inclusive, ?cash(1000, <<"RUB">>)} + )} + }, + #domain_CashLimitDecision{ + if_ = {constant, true}, + then_ = + {value, + ?cashrng( + {inclusive, ?cash(1000, <<"RUB">>)}, + {exclusive, ?cash(1000000000, <<"RUB">>)} + )} + } + ]} } - ] + } } - }}, - hg_ct_fixture:construct_contract_template(?tmpl(4), ?trms(4)) + }} ]. payments_w_bank_conditions_fixture(_Revision, _C) -> @@ -9975,41 +9887,36 @@ payments_w_bank_conditions_fixture(_Revision, _C) -> ref = ?trms(4), data = #domain_TermSetHierarchy{ parent_terms = ?trms(1), - term_sets = [ - #domain_TimedTermSet{ - action_time = #base_TimestampInterval{}, - terms = #domain_TermSet{ - payments = #domain_PaymentsServiceTerms{ - cash_limit = - {decisions, [ - #domain_CashLimitDecision{ - if_ = - {condition, - {payment_tool, - {bank_card, #domain_BankCardCondition{ - definition = {issuer_bank_is, ?bank(1)} - }}}}, - then_ = - {value, - ?cashrng( - {inclusive, ?cash(1000, <<"RUB">>)}, - {inclusive, ?cash(1000, <<"RUB">>)} - )} - }, - #domain_CashLimitDecision{ - if_ = {constant, true}, - then_ = - {value, - ?cashrng( - {inclusive, ?cash(1000, <<"RUB">>)}, - {exclusive, ?cash(1000000000, <<"RUB">>)} - )} - } - ]} - } - } + term_set = #domain_TermSet{ + payments = #domain_PaymentsServiceTerms{ + cash_limit = + {decisions, [ + #domain_CashLimitDecision{ + if_ = + {condition, + {payment_tool, + {bank_card, #domain_BankCardCondition{ + definition = {issuer_bank_is, ?bank(1)} + }}}}, + then_ = + {value, + ?cashrng( + {inclusive, ?cash(1000, <<"RUB">>)}, + {inclusive, ?cash(1000, <<"RUB">>)} + )} + }, + #domain_CashLimitDecision{ + if_ = {constant, true}, + then_ = + {value, + ?cashrng( + {inclusive, ?cash(1000, <<"RUB">>)}, + {exclusive, ?cash(1000000000, <<"RUB">>)} + )} + } + ]} } - ] + } } }}, {bank, #domain_BankObject{ @@ -10020,8 +9927,7 @@ payments_w_bank_conditions_fixture(_Revision, _C) -> bins = ordsets:from_list([<<"42424242">>]), binbase_id_patterns = ordsets:from_list([<<"TEST*BANK">>]) } - }}, - hg_ct_fixture:construct_contract_template(?tmpl(4), ?trms(4)) + }} ]. payment_manual_refund_fixture(_Revision) -> @@ -10063,15 +9969,9 @@ construct_term_set_for_partial_capture_service_permit(_Revision, _C) -> ref = ?trms(5), data = #domain_TermSetHierarchy{ parent_terms = ?trms(1), - term_sets = [ - #domain_TimedTermSet{ - action_time = #base_TimestampInterval{}, - terms = TermSet - } - ] + term_set = TermSet } - }}, - hg_ct_fixture:construct_contract_template(?tmpl(6), ?trms(5)) + }} ]. construct_term_set_for_partial_capture_provider_permit(Revision, _C) -> diff --git a/apps/hellgate/test/hg_route_rules_tests_SUITE.erl b/apps/hellgate/test/hg_route_rules_tests_SUITE.erl index 2f81c9c4..5524a7e1 100644 --- a/apps/hellgate/test/hg_route_rules_tests_SUITE.erl +++ b/apps/hellgate/test/hg_route_rules_tests_SUITE.erl @@ -884,7 +884,6 @@ construct_domain_fixture() -> data = #domain_PaymentInstitution{ name = <<"Test Inc.">>, system_account_set = {decisions, []}, - default_contract_template = {decisions, []}, inspector = {decisions, []}, residences = [], realm = test, @@ -900,7 +899,6 @@ construct_domain_fixture() -> data = #domain_PaymentInstitution{ name = <<"Chetky Payments Inc.">>, system_account_set = {decisions, []}, - default_contract_template = {decisions, []}, inspector = {decisions, []}, residences = [], realm = live diff --git a/apps/hg_proto/src/hg_proto.erl b/apps/hg_proto/src/hg_proto.erl index 9d36cad2..358a5ec1 100644 --- a/apps/hg_proto/src/hg_proto.erl +++ b/apps/hg_proto/src/hg_proto.erl @@ -41,7 +41,7 @@ get_service(fault_detector) -> get_service(limiter) -> {limproto_limiter_thrift, 'Limiter'}; get_service(party_config) -> - {dmsl_payproc_thrift, 'PartyConfigManagement'}. + {dmsl_payproc_thrift, 'PartyManagement'}. -spec get_service_spec(Name :: atom()) -> service_spec(). get_service_spec(Name) -> diff --git a/apps/routing/src/hg_routing_explanation.erl b/apps/routing/src/hg_routing_explanation.erl index 835145d3..8f6ff7c2 100644 --- a/apps/routing/src/hg_routing_explanation.erl +++ b/apps/routing/src/hg_routing_explanation.erl @@ -278,13 +278,10 @@ gather_varset(Payment, Opts) -> payer = Payer, domain_revision = Revision } = Payment, - #domain_PartyConfig{ - id = PartyID - } = get_party(Opts), - #domain_ShopConfig{ - id = ShopID, + PartyID = get_party_id(Opts), + {ShopID, #domain_ShopConfig{ category = Category - } = get_shop(Opts, Revision), + }} = get_shop(Opts, Revision), #payproc_Varset{ category = Category, currency = Cost#domain_Cash.currency, @@ -294,8 +291,8 @@ gather_varset(Payment, Opts) -> party_id = PartyID }. -get_party(#{party := Party}) -> - Party. +get_party_id(#{party_id := PartyID}) -> + PartyID. get_shop(#{party := Party, invoice := Invoice}, Revision) -> #domain_Invoice{shop_id = ShopID} = Invoice, diff --git a/compose.yaml b/compose.yaml index 8b2af8d9..f1eac2c6 100644 --- a/compose.yaml +++ b/compose.yaml @@ -27,7 +27,7 @@ services: command: /sbin/init dmt: - image: ghcr.io/valitydev/dominant-v2:sha-109d2ea + image: ghcr.io/valitydev/dominant-v2:sha-f55c065 command: /opt/dmt/bin/dmt foreground healthcheck: test: "/opt/dmt/bin/dmt ping" @@ -65,7 +65,7 @@ services: retries: 10 limiter: - image: ghcr.io/valitydev/limiter:sha-8fd529e + image: ghcr.io/valitydev/limiter:sha-9eb96a7 command: /opt/limiter/bin/limiter foreground depends_on: machinegun: @@ -100,7 +100,7 @@ services: disable: true liminator: - image: ghcr.io/valitydev/liminator:sha-63b164d + image: ghcr.io/valitydev/liminator:sha-672e804 restart: unless-stopped entrypoint: - java @@ -121,7 +121,7 @@ services: retries: 20 party-management: - image: ghcr.io/valitydev/party-management:sha-6b6d4a5 + image: ghcr.io/valitydev/party-management:sha-7649525 command: /opt/party-management/bin/party-management foreground depends_on: db: diff --git a/rebar.config b/rebar.config index adae26cc..b43d7ab4 100644 --- a/rebar.config +++ b/rebar.config @@ -31,12 +31,12 @@ {gproc, "0.9.0"}, {genlib, {git, "https://github.com/valitydev/genlib.git", {tag, "v1.1.0"}}}, {woody, {git, "https://github.com/valitydev/woody_erlang.git", {tag, "v1.1.0"}}}, - {damsel, {git, "https://github.com/valitydev/damsel.git", {tag, "v2.2.0"}}}, + {damsel, {git, "https://github.com/valitydev/damsel.git", {tag, "v2.2.11"}}}, {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", {tag, "v2.0.0"}}}, + {dmt_client, {git, "https://github.com/valitydev/dmt-client.git", {tag, "v2.0.2"}}}, {scoper, {git, "https://github.com/valitydev/scoper.git", {tag, "v1.1.0"}}}, - {party_client, {git, "https://github.com/valitydev/party-client-erlang.git", {tag, "v2.0.0"}}}, + {party_client, {git, "https://github.com/valitydev/party-client-erlang.git", {tag, "v2.0.1"}}}, {bender_client, {git, "https://github.com/valitydev/bender-client-erlang.git", {tag, "v1.1.0"}}}, {erl_health, {git, "https://github.com/valitydev/erlang-health.git", {branch, "master"}}}, {fault_detector_proto, {git, "https://github.com/valitydev/fault-detector-proto.git", {branch, "master"}}}, diff --git a/rebar.lock b/rebar.lock index fdbeb28e..d180dd9e 100644 --- a/rebar.lock +++ b/rebar.lock @@ -27,16 +27,12 @@ {<<"ctx">>,{pkg,<<"ctx">>,<<"0.6.0">>},2}, {<<"damsel">>, {git,"https://github.com/valitydev/damsel.git", - {ref,"ba7414811590859d058817b8f22d2e9c22f627f8"}}, + {ref,"ff9b01f552f922ce4a16710827aa872325dbe5a9"}}, 0}, {<<"dmt_client">>, {git,"https://github.com/valitydev/dmt-client.git", - {ref,"fcfb028a041149caeebec8d9cef469c8cdbbc63e"}}, + {ref,"fff521d3d50b48e3c6b628fe4796b3628aedc6b7"}}, 0}, - {<<"dmt_core">>, - {git,"https://github.com/valitydev/dmt-core.git", - {ref,"19d8f57198f2cbe5b64aa4a923ba32774e505503"}}, - 1}, {<<"epg_connector">>, {git,"https://github.com/valitydev/epg_connector.git", {ref,"dd93e27c00d492169e8a7bfc38976b911c6e7d05"}}, @@ -91,7 +87,7 @@ {<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.1">>},2}, {<<"party_client">>, {git,"https://github.com/valitydev/party-client-erlang.git", - {ref,"b10b102673d899f6661e0c1a9e70f04ebddc9263"}}, + {ref,"88cb5a9b5abd9bb437222de168bba096edd10882"}}, 0}, {<<"payproc_errors">>, {git,"https://github.com/valitydev/payproc-errors-erlang.git",