@startuml
autonumber
title __Management Payment__
box "T-Mobile" #FFFFFF
    participant ClientApps
    participant Apigee
    participant ManagePayment
    participant StoredPaymentInstrument
    database StoredPaymentInstrumentsRepositoryV4

end box


ClientApps -> Apigee :/managePayment
Apigee -> ManagePayment :/payments/v4/mpi

alt Wallet Terms Accpted
    alt MSISDN is passed
        ManagePayment -> UserInfoAPI :/userInfo(MSISDN)
        UserInfoAPI --> ManagePayment : UserInfo Response
    end
    alt If New Wallet is created for customer
        alt MSISDN is not linked to existing TMOID & Wallet Creation flow
            ManagePayment -> CreateIAMProfile :/createIAMProfile(MSISDN)
            CreateIAMProfile --> ManagePayment : CreatePrfofile Response
        end
        ManagePayment -> StoredPaymentInstrument : /storedPayments POST
        StoredPaymentInstrument -> StoredPaymentInstrumentsRepository :/updateWallet(TMOID)

    else Updating Payment method in exsting Wallet
        ManagePayment -> StoredPaymentInstrument : /storedPayments PUT
        StoredPaymentInstrument -> StoredPaymentInstrumentsRepository :/updateWallet(TMOID)

    else Deleting Payment method from existing Wallet
        ManagePayment -> StoredPaymentInstrument : /storedPayments DELETE
        StoredPaymentInstrument -> StoredPaymentInstrumentsRepository :/updateWallet(TMOID)

    end
    StoredPaymentInstrument --> ManagePayment : StorePaymentInstrument Response
end
ManagePayment --> Apigee : ManagePayment Response
Apigee --> ClientApps : ManagePayment Response

@enduml