11#![ no_std]
22
3- use soroban_sdk:: { contract, contractimpl, contracttype, Address , Env , String , Vec } ;
3+ use soroban_sdk:: { contract, contractimpl, contracttype, token , Address , Env , String , Vec } ;
44
55/// Billing interval in seconds
66#[ contracttype]
@@ -355,6 +355,13 @@ impl SubTrackrContract {
355355 . get ( & DataKey :: Plan ( sub. plan_id ) )
356356 . expect ( "Plan not found" ) ;
357357
358+ // Execute actual token transfer from subscriber to merchant
359+ token:: Client :: new ( & env, & plan. token ) . transfer (
360+ & sub. subscriber ,
361+ & plan. merchant ,
362+ & plan. price ,
363+ ) ;
364+
358365 sub. last_charged_at = now;
359366 sub. next_charge_at = now + plan. interval . seconds ( ) ;
360367 sub. total_paid += plan. price ;
@@ -528,6 +535,14 @@ mod test {
528535 use soroban_sdk:: testutils:: { Address as _, Ledger } ;
529536 use soroban_sdk:: Env ;
530537
538+ #[ contract]
539+ pub struct MockToken ;
540+
541+ #[ contractimpl]
542+ impl MockToken {
543+ pub fn transfer ( _env : Env , _from : Address , _to : Address , _amount : i128 ) { }
544+ }
545+
531546 fn setup (
532547 env : & Env ,
533548 ) -> (
@@ -543,7 +558,7 @@ mod test {
543558 let admin = Address :: generate ( env) ;
544559 let merchant = Address :: generate ( env) ;
545560 let subscriber = Address :: generate ( env) ;
546- let token = Address :: generate ( env) ;
561+ let token = env. register_contract ( None , MockToken ) ;
547562
548563 env. mock_all_auths ( ) ;
549564 client. initialize ( & admin) ;
0 commit comments