Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Support for BitCash, NetCash and Paidy #52

Merged
merged 4 commits into from
Oct 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added Support for webMoney
AmniX committed Oct 17, 2024
commit 338a3688b8cd47073747b48caefc5f7c5ff82f1d
Original file line number Diff line number Diff line change
@@ -216,10 +216,27 @@ internal class KomojuPaymentScreenModel(private val config: KomojuSDK.Configurat
is PaymentMethod.Paidy -> state.value.paidyDisplayData.validate()
is PaymentMethod.NetCash -> state.value.netCashDisplayData.validate()
is PaymentMethod.BitCash -> state.value.bitCashDisplayData.validate()
is PaymentMethod.WebMoney -> state.value.webMoneyDisplayData.validate()
is PaymentMethod.OffSitePayment -> true // No input required for Offsite payment
else -> false
}

private fun WebMoneyDisplayData.validate(): Boolean{
val prepaidNumberError = when {
prepaidNumber.isBlank() -> "The entered prepaid number cannot be empty"
prepaidNumber.length != 16 -> "The entered prepaid number is not valid"
else -> null
}
mutableState.update {
it.copy(
webMoneyDisplayData = it.webMoneyDisplayData.copy(
prepaidNumberError = prepaidNumberError,
),
)
}
return prepaidNumberError == null
}

private fun BitCashDisplayData.validate(): Boolean {
val idError = when {
bitCashId.isBlank() -> "The entered net cash id cannot be empty"
@@ -349,7 +366,10 @@ internal class KomojuPaymentScreenModel(private val config: KomojuSDK.Configurat
phoneNumber = state.value.paidyDisplayData.phoneNumber,
)
is PaymentMethod.PayEasy -> TODO()
is PaymentMethod.WebMoney -> TODO()
is PaymentMethod.WebMoney -> PaymentRequest.WebMoney(
paymentMethod = this,
prepaidNumber = state.value.webMoneyDisplayData.prepaidNumber,
)
is PaymentMethod.OffSitePayment -> PaymentRequest.OffSitePaymentRequest(this)
}

Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ internal data class BitCashDisplayData(val bitCashId: String = String.empty, val

internal data class NetCashDisplayData(val netCashId: String = String.empty, val netCashError: String? = null)

internal data class WebMoneyDisplayData(val prepaidNumber: String = String.empty)
internal data class WebMoneyDisplayData(val prepaidNumber: String = String.empty, val prepaidNumberError: String? = null)

internal data class PaidyDisplayData(
val fullName: String = String.empty,
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@ internal fun WebMoneyForm(
onValueChange = {
onWebMoneyDisplayDataChange(webMoneyDisplayData.copy(prepaidNumber = it))
},
error = webMoneyDisplayData.prepaidNumberError,
)
Spacer(modifier = Modifier.height(16.dp))
PrimaryButton(
Original file line number Diff line number Diff line change
@@ -10,4 +10,5 @@ sealed interface PaymentRequest {
data class OffSitePaymentRequest(override val paymentMethod: PaymentMethod.OffSitePayment) : PaymentRequest
data class NetCash(override val paymentMethod: PaymentMethod.NetCash, val netCashId: String) : PaymentRequest
data class BitCash(override val paymentMethod: PaymentMethod.BitCash, val bitCashId: String) : PaymentRequest
data class WebMoney(override val paymentMethod: PaymentMethod.WebMoney, val prepaidNumber: String) : PaymentRequest
}
Original file line number Diff line number Diff line change
@@ -42,6 +42,13 @@ internal data class PaymentRequestDto(@SerialName("payment_details") val payment
prepaidNumber = paymentRequest.bitCashId,
),
)

is PaymentRequest.WebMoney -> PaymentRequestDto(
paymentDetails = PaymentDetails(
type = "bit_cash",
prepaidNumber = paymentRequest.prepaidNumber,
),
)
}
}

Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ internal object PaymentMapper {
type = type.orEmpty(),
)

"net_cash", "bit_cash" -> Payment.Completed(
"net_cash", "bit_cash", "web_money" -> Payment.Completed(
amount = payment.amount.orEmpty(),
currency = payment.currency.orEmpty(),
status = PaymentStatus.fromString(payment.status.orEmpty()),