3131-export_type ([payment_id / 0 ]).
3232-export_type ([payment_st / 0 ]).
3333-export_type ([party / 0 ]).
34- -export_type ([party_id / 0 ]).
34+ -export_type ([party_config_ref / 0 ]).
3535
3636% % Public interface
3737
7777-type invoice () :: dmsl_domain_thrift :'Invoice' ().
7878-type allocation () :: dmsl_domain_thrift :'Allocation' ().
7979-type party () :: dmsl_domain_thrift :'PartyConfig' ().
80- -type party_id () :: dmsl_domain_thrift :'PartyID ' ().
80+ -type party_config_ref () :: dmsl_domain_thrift :'PartyConfigRef ' ().
8181-type revision () :: dmt_client :vsn ().
8282
8383-type payment_id () :: dmsl_domain_thrift :'InvoicePaymentID' ().
@@ -109,28 +109,28 @@ get_payment(PaymentID, St) ->
109109
110110-spec get_payment_opts (st ()) -> hg_invoice_payment :opts ().
111111get_payment_opts (St = # st {invoice = Invoice , party = undefined }) ->
112- {PartyID , Party } = hg_party :get_party (get_party_id (St )),
112+ {PartyConfigRef , Party } = hg_party :get_party (get_party_config_ref (St )),
113113 #{
114114 party => Party ,
115- party_id => PartyID ,
115+ party_config_ref => PartyConfigRef ,
116116 invoice => Invoice ,
117117 timestamp => hg_datetime :format_now ()
118118 };
119- get_payment_opts (# st {invoice = Invoice , party = Party , party_id = PartyID }) ->
119+ get_payment_opts (# st {invoice = Invoice , party = Party , party_config_ref = PartyConfigRef }) ->
120120 #{
121121 party => Party ,
122- party_id => PartyID ,
122+ party_config_ref => PartyConfigRef ,
123123 invoice => Invoice ,
124124 timestamp => hg_datetime :format_now ()
125125 }.
126126
127127-spec get_payment_opts (hg_domain :revision (), st ()) ->
128128 hg_invoice_payment :opts ().
129129get_payment_opts (Revision , St = # st {invoice = Invoice }) ->
130- {PartyID , Party } = hg_party :checkout (get_party_id (St ), Revision ),
130+ {PartyConfigRef , Party } = hg_party :checkout (get_party_config_ref (St ), Revision ),
131131 #{
132132 party => Party ,
133- party_id => PartyID ,
133+ party_config_ref => PartyConfigRef ,
134134 invoice => Invoice ,
135135 timestamp => hg_datetime :format_now ()
136136 }.
@@ -145,13 +145,13 @@ get_payment_opts(Revision, St = #st{invoice = Invoice}) ->
145145) ->
146146 invoice ().
147147create (ID , InvoiceTplID , V = # payproc_InvoiceParams {}, _Allocation , Mutations , DomainRevision ) ->
148- OwnerID = V # payproc_InvoiceParams .party_id ,
149- ShopID = V # payproc_InvoiceParams .shop_id ,
148+ PartyConfigRef = V # payproc_InvoiceParams .party_id ,
149+ ShopConfigRef = V # payproc_InvoiceParams .shop_id ,
150150 Cost = V # payproc_InvoiceParams .cost ,
151151 hg_invoice_mutation :apply_mutations (Mutations , # domain_Invoice {
152152 id = ID ,
153- shop_id = ShopID ,
154- owner_id = OwnerID ,
153+ party_ref = PartyConfigRef ,
154+ shop_ref = ShopConfigRef ,
155155 created_at = hg_datetime :format_now (),
156156 status = ? invoice_unpaid (),
157157 cost = Cost ,
@@ -169,13 +169,13 @@ assert_invoice(Checks, #st{} = St) when is_list(Checks) ->
169169 lists :foldl (fun assert_invoice /2 , St , Checks );
170170assert_invoice (operable , # st {party = Party } = St ) when Party =/= undefined ->
171171 assert_party_shop_operable (
172- hg_party :get_shop (get_shop_id (St ), Party , hg_party :get_party_revision ()),
172+ hg_party :get_shop (get_shop_config_ref (St ), get_party_config_ref ( St ) , hg_party :get_party_revision ()),
173173 Party
174174 ),
175175 St ;
176176assert_invoice (unblocked , # st {party = Party } = St ) when Party =/= undefined ->
177177 assert_party_shop_unblocked (
178- hg_party :get_shop (get_shop_id (St ), Party , hg_party :get_party_revision ()),
178+ hg_party :get_shop (get_shop_config_ref (St ), get_party_config_ref ( St ) , hg_party :get_party_revision ()),
179179 Party
180180 ),
181181 St ;
@@ -898,14 +898,14 @@ check_non_idle_payments_([{PaymentID, PaymentSession} | Rest], St) ->
898898 end .
899899
900900add_party_to_st (St ) ->
901- {PartyID , Party } = hg_party :get_party (get_party_id (St )),
902- St # st {party = Party , party_id = PartyID }.
901+ {PartyConfigRef , Party } = hg_party :get_party (get_party_config_ref (St )),
902+ St # st {party = Party , party_config_ref = PartyConfigRef }.
903903
904- get_party_id (# st {invoice = # domain_Invoice {owner_id = PartyID }}) ->
905- PartyID .
904+ get_party_config_ref (# st {invoice = # domain_Invoice {party_ref = PartyConfigRef }}) ->
905+ PartyConfigRef .
906906
907- get_shop_id (# st {invoice = # domain_Invoice {shop_id = ShopID }}) ->
908- ShopID .
907+ get_shop_config_ref (# st {invoice = # domain_Invoice {shop_ref = ShopConfigRef }}) ->
908+ ShopConfigRef .
909909
910910get_payment_session (PaymentID , St ) ->
911911 case try_get_payment_session (PaymentID , St ) of
@@ -970,11 +970,16 @@ get_invoice_event_log(EventType, StatusName, Invoice) ->
970970get_invoice_params (Invoice ) ->
971971 # domain_Invoice {
972972 id = ID ,
973- owner_id = PartyID ,
974973 cost = ? cash (Amount , Currency ),
975- shop_id = ShopID
974+ party_ref = PartyConfigRef ,
975+ shop_ref = ShopConfigRef
976976 } = Invoice ,
977- [{id , ID }, {owner_id , PartyID }, {cost , [{amount , Amount }, {currency , Currency }]}, {shop_id , ShopID }].
977+ [
978+ {id , ID },
979+ {party_ref , PartyConfigRef },
980+ {shop_ref , ShopConfigRef },
981+ {cost , [{amount , Amount }, {currency , Currency }]}
982+ ].
978983
979984get_message (invoice_created ) ->
980985 " Invoice is created" ;
0 commit comments