in membership-attribute-service/app/services/zuora/payment/PaymentService.scala [68:85]
private def buildPaymentMethod(
defaultMandateIdIfApplicable: Option[String] = None,
soapPaymentMethod: Queries.PaymentMethod,
): Option[PaymentMethod] =
soapPaymentMethod.`type` match {
case `CreditCard` | `CreditCardReferenceTransaction` =>
val isReferenceTransaction = soapPaymentMethod.`type` == `CreditCardReferenceTransaction`
def asInt(num: String) = Try(num.toInt).toOption
val m = soapPaymentMethod
val details =
(m.creditCardNumber |@| m.creditCardExpirationMonth.flatMap(asInt) |@| m.creditCardExpirationYear.flatMap(asInt))(PaymentCardDetails)
Some(PaymentCard(isReferenceTransaction, m.creditCardType, details, m.numConsecutiveFailures, m.paymentMethodStatus))
case `BankTransfer` =>
buildBankTransferPaymentMethod(defaultMandateIdIfApplicable, soapPaymentMethod)
case `PayPal` =>
Some(PayPalMethod(soapPaymentMethod.payPalEmail.get, soapPaymentMethod.numConsecutiveFailures, soapPaymentMethod.paymentMethodStatus))
case _ => None
}