33use actix:: prelude:: * ;
44use bigdecimal:: BigDecimal ;
55use chrono:: { DateTime , Utc } ;
6- use futures:: TryFutureExt ;
76use std:: collections:: HashSet ;
87use std:: time:: Duration ;
9- use ya_client:: { model, payment:: requestor :: PaymentRequestorApi } ;
8+ use ya_client:: { model, payment:: PaymentApi } ;
109
1110pub struct PaymentManager {
12- payment_api : PaymentRequestorApi ,
11+ payment_api : PaymentApi ,
1312 allocation_id : String ,
1413 total_amount : BigDecimal ,
1514 amount_paid : BigDecimal ,
@@ -28,7 +27,7 @@ impl Actor for PaymentManager {
2827}
2928
3029impl PaymentManager {
31- pub fn new ( payment_api : PaymentRequestorApi , allocation : model:: payment:: Allocation ) -> Self {
30+ pub fn new ( payment_api : PaymentApi , allocation : model:: payment:: Allocation ) -> Self {
3231 let now = Utc :: now ( ) ;
3332 PaymentManager {
3433 payment_api,
@@ -47,11 +46,11 @@ impl PaymentManager {
4746
4847 let f = async move {
4948 let events = api
50- . get_debit_note_events ( Some ( & ts) , Some ( Duration :: from_secs ( 60 ) ) )
49+ . get_debit_note_events ( Some ( & ts) , Some ( Duration :: from_secs ( 60 ) ) , None , None )
5150 . await ?;
5251 for event in events {
5352 log:: debug!( "got debit note: {:?}" , event) ;
54- ts = event. timestamp ;
53+ ts = event. event_date ;
5554 }
5655 Ok :: < _ , anyhow:: Error > ( ts)
5756 }
@@ -78,16 +77,16 @@ impl PaymentManager {
7877
7978 let f = async move {
8079 let events = api
81- . get_invoice_events ( Some ( & ts) , Some ( Duration :: from_secs ( 60 ) ) )
80+ . get_invoice_events ( Some ( & ts) , Some ( Duration :: from_secs ( 60 ) ) , None , None )
8281 . await ?;
8382 let mut new_invoices = Vec :: new ( ) ;
8483 for event in events {
8584 log:: debug!( "Got invoice: {:?}" , event) ;
86- if event. event_type == model:: payment:: EventType :: Received {
85+ if event. event_type == model:: payment:: InvoiceEventType :: InvoiceReceivedEvent {
8786 let invoice = api. get_invoice ( & event. invoice_id ) . await ?;
8887 new_invoices. push ( invoice) ;
8988 }
90- ts = event. timestamp ;
89+ ts = event. event_date ;
9190 }
9291 Ok :: < _ , anyhow:: Error > ( ( ts, new_invoices) )
9392 }
@@ -200,8 +199,8 @@ impl Handler<ReleaseAllocation> for PaymentManager {
200199 async move {
201200 payment_api
202201 . release_allocation ( & allocation_id)
203- . map_err ( anyhow:: Error :: from)
204202 . await
203+ . map_err ( anyhow:: Error :: from)
205204 }
206205 . into_actor ( self ) ,
207206 )
0 commit comments