in membership-attribute-service/app/services/subscription/CancelSubscription.scala [17:36]
def cancel(
subscriptionNumber: SubscriptionNumber,
cancellationEffectiveDate: Option[LocalDate],
reason: Option[String],
accountId: memsub.Subscription.AccountId,
endOfTermDate: LocalDate,
)(implicit ec: ExecutionContext, logPrefix: LogPrefix): EitherT[ApiError, Future, Option[LocalDate]] =
(for {
_ <- disableAutoPayOnlyIfAccountHasOneSubscription(accountId).leftMap(message => s"Failed to disable AutoPay: $message")
_ <- reason match {
case Some(r) =>
EitherT(zuoraRestService.updateCancellationReason(subscriptionNumber, r)).leftMap(message =>
s"Failed to update cancellation reason: $message",
)
case None => EitherT.rightT[String, Future, Unit](Future.successful(()))
}
_ <- EitherT(zuoraRestService.cancelSubscription(subscriptionNumber, endOfTermDate, cancellationEffectiveDate)).leftMap(message =>
s"Failed to execute Zuora cancellation proper: $message",
)
} yield cancellationEffectiveDate).leftMap(ApiError(_, "", 500))