context commerce.payment {
  exports opaque { AuthId }

  type AuthId = opaque String
  type PaymentError = | Declined

  capability Logger {
    fn log(msg: String) -> Effect[()]
  }

  provides Logger = NoOpLogger {
    fn log(msg: String) -> Effect[()] {
      ()
    }
  }

  service authorise {
    on call(amount: Int) -> Effect[Result[AuthId, PaymentError]] given Logger {
      let _ <- Logger.log("authorise")
      if amount > 0 {
        Ok(AuthId.unsafe("AUTH-OK"))
      } else {
        Err(Declined)
      }
    }
  }
}
