diff --git a/android/src/main/java/com/komoju/android/sdk/ui/screens/payment/KomojuPaymentScreenModel.kt b/android/src/main/java/com/komoju/android/sdk/ui/screens/payment/KomojuPaymentScreenModel.kt index c4fcd58..a1e3ae0 100644 --- a/android/src/main/java/com/komoju/android/sdk/ui/screens/payment/KomojuPaymentScreenModel.kt +++ b/android/src/main/java/com/komoju/android/sdk/ui/screens/payment/KomojuPaymentScreenModel.kt @@ -134,6 +134,7 @@ internal class KomojuPaymentScreenModel(private val config: KomojuSDK.Configurat when (this) { is Payment.Konbini -> mutableRouter.value = Router.Replace(KomojuPaymentRoute.KonbiniAwaitingPayment(config, payment = this)) is Payment.PayPay -> _offSitePaymentURL.value = redirectURL + is Payment.RakutenPay -> _offSitePaymentURL.value = redirectURL else -> Unit } } @@ -142,6 +143,7 @@ internal class KomojuPaymentScreenModel(private val config: KomojuSDK.Configurat is PaymentMethod.CreditCard -> state.value.creditCardDisplayData.validate() is PaymentMethod.Konbini -> state.value.konbiniDisplayData.validate(state.value.commonDisplayData) is PaymentMethod.PayPay -> true // No input required + is PaymentMethod.RakutenPay -> true // No input required else -> false } @@ -215,7 +217,7 @@ internal class KomojuPaymentScreenModel(private val config: KomojuSDK.Configurat is PaymentMethod.Paidy -> TODO() is PaymentMethod.PayEasy -> TODO() is PaymentMethod.PayPay -> PaymentRequest.PayPay(paymentMethod = this) - is PaymentMethod.RakutenPay -> TODO() + is PaymentMethod.RakutenPay -> PaymentRequest.RakutenPay(paymentMethod = this) is PaymentMethod.WebMoney -> TODO() } diff --git a/shared/src/commonMain/kotlin/com/komoju/mobile/sdk/entities/Payment.kt b/shared/src/commonMain/kotlin/com/komoju/mobile/sdk/entities/Payment.kt index 10abbe0..cb63a61 100644 --- a/shared/src/commonMain/kotlin/com/komoju/mobile/sdk/entities/Payment.kt +++ b/shared/src/commonMain/kotlin/com/komoju/mobile/sdk/entities/Payment.kt @@ -21,6 +21,8 @@ sealed interface Payment { data class CreditCard(override val status: PaymentStatus, override val amount: String, override val currency: String) : Payment + data class RakutenPay(override val status: PaymentStatus, override val amount: String, override val currency: String, val redirectURL: String) : Payment + data class Error(val code: String, val message: String, override val amount: String, override val currency: String) : Payment { override val status: PaymentStatus = PaymentStatus.EXPIRED } diff --git a/shared/src/commonMain/kotlin/com/komoju/mobile/sdk/entities/PaymentRequest.kt b/shared/src/commonMain/kotlin/com/komoju/mobile/sdk/entities/PaymentRequest.kt index 9db8146..f44f60b 100644 --- a/shared/src/commonMain/kotlin/com/komoju/mobile/sdk/entities/PaymentRequest.kt +++ b/shared/src/commonMain/kotlin/com/komoju/mobile/sdk/entities/PaymentRequest.kt @@ -8,4 +8,5 @@ sealed interface PaymentRequest { data class Konbini(override val paymentMethod: PaymentMethod.Konbini, val konbiniBrand: KonbiniBrand, val email: String) : PaymentRequest data class PayPay(override val paymentMethod: PaymentMethod.PayPay) : PaymentRequest + data class RakutenPay(override val paymentMethod: PaymentMethod.RakutenPay) : PaymentRequest } diff --git a/shared/src/commonMain/kotlin/com/komoju/mobile/sdk/remote/dtos/PaymentRequestDto.kt b/shared/src/commonMain/kotlin/com/komoju/mobile/sdk/remote/dtos/PaymentRequestDto.kt index 93f68ea..0b9d9f1 100644 --- a/shared/src/commonMain/kotlin/com/komoju/mobile/sdk/remote/dtos/PaymentRequestDto.kt +++ b/shared/src/commonMain/kotlin/com/komoju/mobile/sdk/remote/dtos/PaymentRequestDto.kt @@ -20,6 +20,12 @@ internal data class PaymentRequestDto(@SerialName("payment_details") val payment type = "paypay", ), ) + + is PaymentRequest.RakutenPay -> PaymentRequestDto( + paymentDetails = PaymentDetails( + type = "rakutenpay", + ), + ) } } diff --git a/shared/src/commonMain/kotlin/com/komoju/mobile/sdk/remote/mappers/PaymentMapper.kt b/shared/src/commonMain/kotlin/com/komoju/mobile/sdk/remote/mappers/PaymentMapper.kt index a7d203a..b282bb5 100644 --- a/shared/src/commonMain/kotlin/com/komoju/mobile/sdk/remote/mappers/PaymentMapper.kt +++ b/shared/src/commonMain/kotlin/com/komoju/mobile/sdk/remote/mappers/PaymentMapper.kt @@ -36,6 +36,13 @@ internal object PaymentMapper { status = PaymentStatus.fromString(payment.status.orEmpty()), ) + "rakutenpay" -> Payment.RakutenPay( + amount = payment.amount.orEmpty(), + currency = payment.currency.orEmpty(), + redirectURL = payment.paymentDetails.redirectUrl.orEmpty(), + status = PaymentStatus.fromString(payment.status.orEmpty()), + ) + else -> error("Invalid payment type") } }