Skip to content

Commit

Permalink
Added RakutenPay Support
Browse files Browse the repository at this point in the history
  • Loading branch information
AmniX committed Oct 9, 2024
1 parent 30cb5ec commit ee66ba3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -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
}

Expand Down Expand Up @@ -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()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ internal data class PaymentRequestDto(@SerialName("payment_details") val payment
type = "paypay",
),
)

is PaymentRequest.RakutenPay -> PaymentRequestDto(
paymentDetails = PaymentDetails(
type = "rakutenpay",
),
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

0 comments on commit ee66ba3

Please sign in to comment.