9090% % API
9191
9292-spec get (hg_machine :id ()) -> {ok , st ()} | {error , notfound }.
93- get (Id ) ->
94- case hg_machine :get_history (? NS , Id ) of
93+ get (ID ) ->
94+ case hg_machine :get_history (? NS , ID ) of
9595 {ok , History } ->
9696 {ok , collapse_history (unmarshal_history (History ))};
9797 Error ->
@@ -108,7 +108,7 @@ get_payment(PaymentID, St) ->
108108 end .
109109
110110-spec get_payment_opts (st ()) -> hg_invoice_payment :opts ().
111- get_payment_opts (St = # st {invoice = Invoice , party = undefined }) ->
111+ get_payment_opts (# st {invoice = Invoice , party = undefined } = St ) ->
112112 {PartyConfigRef , Party } = hg_party :get_party (get_party_config_ref (St )),
113113 #{
114114 party => Party ,
@@ -126,7 +126,7 @@ get_payment_opts(#st{invoice = Invoice, party = Party, party_config_ref = PartyC
126126
127127-spec get_payment_opts (hg_domain :revision (), st ()) ->
128128 hg_invoice_payment :opts ().
129- get_payment_opts (Revision , St = # st {invoice = Invoice }) ->
129+ get_payment_opts (Revision , # st {invoice = Invoice } = St ) ->
130130 {PartyConfigRef , Party } = hg_party :checkout (get_party_config_ref (St ), Revision ),
131131 #{
132132 party => Party ,
@@ -144,7 +144,7 @@ get_payment_opts(Revision, St = #st{invoice = Invoice}) ->
144144 revision ()
145145) ->
146146 invoice ().
147- create (ID , InvoiceTplID , V = # payproc_InvoiceParams {}, _Allocation , Mutations , DomainRevision ) ->
147+ create (ID , InvoiceTplID , # payproc_InvoiceParams {} = V , _Allocation , Mutations , DomainRevision ) ->
148148 PartyConfigRef = V # payproc_InvoiceParams .party_id ,
149149 ShopConfigRef = V # payproc_InvoiceParams .shop_id ,
150150 Cost = V # payproc_InvoiceParams .cost ,
@@ -262,8 +262,8 @@ process_with_tag(Tag, F) ->
262262% %
263263
264264-spec fail (hg_machine :id ()) -> ok .
265- fail (Id ) ->
266- try hg_machine :call (? NS , Id , fail ) of
265+ fail (ID ) ->
266+ try hg_machine :call (? NS , ID , fail ) of
267267 {error , failed } ->
268268 ok ;
269269 {error , Error } ->
@@ -315,7 +315,7 @@ handle_repair({changes, Changes, RepairAction, Params}, St) ->
315315 };
316316handle_repair ({scenario , _ }, # st {activity = Activity }) when Activity =:= invoice orelse Activity =:= undefined ->
317317 throw ({exception , invoice_has_no_active_payment });
318- handle_repair ({scenario , Scenario }, St = # st {activity = {payment , PaymentID }}) ->
318+ handle_repair ({scenario , Scenario }, # st {activity = {payment , PaymentID }} = St ) ->
319319 PaymentSession = get_payment_session (PaymentID , St ),
320320 Activity = hg_invoice_payment :get_activity (PaymentSession ),
321321 case {Scenario , Activity } of
@@ -329,11 +329,11 @@ handle_repair({scenario, Scenario}, St = #st{activity = {payment, PaymentID}}) -
329329process_signal (Signal , #{history := History }) ->
330330 handle_result (handle_signal (Signal , collapse_history (unmarshal_history (History )))).
331331
332- handle_signal (timeout , St = # st {activity = {payment , PaymentID }}) ->
332+ handle_signal (timeout , # st {activity = {payment , PaymentID }} = St ) ->
333333 % there's a payment pending
334334 PaymentSession = get_payment_session (PaymentID , St ),
335335 process_payment_signal (timeout , PaymentID , PaymentSession , St );
336- handle_signal (timeout , St = # st {activity = invoice }) ->
336+ handle_signal (timeout , # st {activity = invoice } = St ) ->
337337 % invoice is expired
338338 handle_expiration (St ).
339339
@@ -493,10 +493,10 @@ handle_call({session_change, _Tag, _SessionChange} = Call, St) ->
493493
494494-spec dispatch_to_session ({callback , tag (), callback ()} | {session_change , tag (), session_change ()}, st ()) ->
495495 call_result ().
496- dispatch_to_session ({callback , Tag , {provider , Payload }}, St = # st {activity = {payment , PaymentID }}) ->
496+ dispatch_to_session ({callback , Tag , {provider , Payload }}, # st {activity = {payment , PaymentID }} = St ) ->
497497 PaymentSession = get_payment_session (PaymentID , St ),
498498 process_payment_call ({callback , Tag , Payload }, PaymentID , PaymentSession , St );
499- dispatch_to_session ({session_change , _Tag , _SessionChange } = Call , St = # st {activity = {payment , PaymentID }}) ->
499+ dispatch_to_session ({session_change , _Tag , _SessionChange } = Call , # st {activity = {payment , PaymentID }} = St ) ->
500500 PaymentSession = get_payment_session (PaymentID , St ),
501501 process_payment_call (Call , PaymentID , PaymentSession , St );
502502dispatch_to_session (_Call , _St ) ->
@@ -733,7 +733,7 @@ define_refund_id(#payproc_InvoicePaymentRefundParams{id = ID}, _PaymentSession)
733733-define (MANUAL_REFUND_ID_PREFIX , " m" ).
734734
735735% % If something breaks - this is why
736- force_refund_id_format (manual_refund , Correct = <<? MANUAL_REFUND_ID_PREFIX , _Rest /binary >>) ->
736+ force_refund_id_format (manual_refund , <<? MANUAL_REFUND_ID_PREFIX , _Rest /binary >> = Correct ) ->
737737 Correct ;
738738force_refund_id_format (manual_refund , Incorrect ) ->
739739 <<? MANUAL_REFUND_ID_PREFIX , Incorrect /binary >>;
@@ -816,7 +816,7 @@ try_to_get_repair_state({complex, #payproc_InvoiceRepairComplex{scenarios = Scen
816816try_to_get_repair_state (Scenario , St ) ->
817817 repair_scenario (Scenario , St ).
818818
819- repair_complex ([], St = # st {activity = {payment , PaymentID }}) ->
819+ repair_complex ([], # st {activity = {payment , PaymentID }} = St ) ->
820820 PaymentSession = get_payment_session (PaymentID , St ),
821821 Activity = hg_invoice_payment :get_activity (PaymentSession ),
822822 throw ({exception , {activity_not_compatible_with_complex_scenario , Activity }});
@@ -828,7 +828,7 @@ repair_complex([Scenario | Rest], St) ->
828828 repair_complex (Rest , St )
829829 end .
830830
831- repair_scenario (Scenario , St = # st {activity = {payment , PaymentID }}) ->
831+ repair_scenario (Scenario , # st {activity = {payment , PaymentID }} = St ) ->
832832 PaymentSession = get_payment_session (PaymentID , St ),
833833 Activity = hg_invoice_payment :get_activity (PaymentSession ),
834834 NewActivity =
@@ -923,7 +923,7 @@ try_get_payment_session(PaymentID, #st{payments = Payments}) ->
923923 undefined
924924 end .
925925
926- set_payment_session (PaymentID , PaymentSession , St = # st {payments = Payments }) ->
926+ set_payment_session (PaymentID , PaymentSession , # st {payments = Payments } = St ) ->
927927 St # st {payments = lists :keystore (PaymentID , 1 , Payments , {PaymentID , PaymentSession })}.
928928
929929% %
0 commit comments