Skip to content

Commit

Permalink
Added back LinePay, Because Why not :) (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
AmniX authored Oct 17, 2024
1 parent b55fec7 commit 7cc7084
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
Expand Down Expand Up @@ -69,6 +70,7 @@ internal data class KomojuPaymentScreen(private val sdkConfiguration: KomojuSDK.
selectedPaymentMethod = uiState.selectedPaymentMethod,
onSelected = screenViewModel::onNewPaymentMethodSelected,
)
Spacer(modifier = Modifier.height(8.dp))
uiState.selectedPaymentMethod?.let { paymentMethod ->
PaymentMethodForm(
paymentMethod = paymentMethod,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.onGloballyPositioned
Expand Down Expand Up @@ -58,7 +57,6 @@ import com.komoju.android.sdk.utils.CreditCardUtils.makeExpirationFilter
import com.komoju.android.sdk.utils.testID
import com.komoju.mobile.sdk.entities.PaymentMethod

@OptIn(ExperimentalComposeUiApi::class)
@Composable
internal fun CreditCardForm(
creditCard: PaymentMethod.CreditCard,
Expand All @@ -76,7 +74,6 @@ internal fun CreditCardForm(
}
val dividerColor = if (creditCardDisplayData.creditCardError == null) Gray200 else Red600
Column {
Spacer(modifier = Modifier.height(8.dp))
TextField(
creditCardDisplayData.fullNameOnCard,
titleKey = "CARD_HOLDER_NAME",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ internal fun OffSitePayForm(paymentMethod: PaymentMethod.OffSitePayment, onPayBu
OffSitePaymentType.MER_PAY -> "PAYMENT_VIA_MER_PAY"
OffSitePaymentType.PAY_PAY -> "PAYMENT_VIA_PAY_PAY"
OffSitePaymentType.RAKUTEN_PAY -> "PAYMENT_VIA_RAKUTEN"
OffSitePaymentType.LINE_PAY -> "PAYMENT_VIA_LINE_PAY"
else -> null
}
}
Expand All @@ -50,6 +51,7 @@ internal fun OffSitePayForm(paymentMethod: PaymentMethod.OffSitePayment, onPayBu
OffSitePaymentType.MER_PAY -> "MER_PAY_REDIRECT_MESSAGE"
OffSitePaymentType.PAY_PAY -> "PAY_PAY_REDIRECT_MESSAGE"
OffSitePaymentType.RAKUTEN_PAY -> "RAKUTEN_REDIRECT_MESSAGE"
OffSitePaymentType.LINE_PAY -> "LINE_PAY_REDIRECT_MESSAGE"
else -> null
}
}
Expand All @@ -61,6 +63,7 @@ internal fun OffSitePayForm(paymentMethod: PaymentMethod.OffSitePayment, onPayBu
OffSitePaymentType.MER_PAY -> "CONTINUE_TO_MER_PAY"
OffSitePaymentType.PAY_PAY -> "CONTINUE_TO_PAY_PAY"
OffSitePaymentType.RAKUTEN_PAY -> "CONTINUE_TO_RAKUTEN"
OffSitePaymentType.LINE_PAY -> "CONTINUE_TO_LINE_PAY"
else -> null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ private val PaymentMethod.displayIcon
OffSitePaymentType.MER_PAY -> R.drawable.komoju_ic_merpay
OffSitePaymentType.PAY_PAY -> R.drawable.komoju_ic_paypay
OffSitePaymentType.RAKUTEN_PAY -> R.drawable.komoju_ic_rakuten_pay
OffSitePaymentType.LINE_PAY -> R.drawable.komoju_ic_linepay
OffSitePaymentType.UNKNOWN -> R.drawable.komoju_ic_credit_card
}
is PaymentMethod.BankTransfer -> R.drawable.komoju_ic_bank_transfer
is PaymentMethod.BitCash -> R.drawable.komoju_ic_bitcash
Expand Down
15 changes: 15 additions & 0 deletions android/src/main/res/drawable/komoju_ic_linepay.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="44dp"
android:height="47dp"
android:viewportWidth="44"
android:viewportHeight="47">
<path
android:fillColor="#000"
android:pathData="M15.5 0h-2c-0.4 0-0.7 0.3-0.7 0.6v13.2c0 0.3 0.3 0.6 0.6 0.6h2.1c0.3 0 0.6-0.3 0.6-0.6V0.6c0-0.3-0.3-0.6-0.6-0.6zm-5.1 11H4.8V0.7c0-0.3-0.3-0.6-0.6-0.6H2c-0.3 0-0.6 0.3-0.6 0.6v13.2c0 0.3 0.3 0.5 0.6 0.5h8.3c0.4 0 0.6-0.2 0.6-0.5v-2.2c0-0.3-0.2-0.5-0.6-0.5zm31.3-7.7c0.3 0 0.6-0.3 0.6-0.6V0.6C42.3 0.3 42 0 41.7 0h-8.4c-0.3 0-0.5 0.3-0.5 0.6v13.2c0 0.3 0.2 0.5 0.5 0.5h8.4c0.3 0 0.6-0.2 0.6-0.5v-2.2c0-0.3-0.3-0.5-0.6-0.5H36V8.8h5.7c0.3 0 0.6-0.2 0.6-0.6v-2c0-0.4-0.3-0.7-0.6-0.7H36V3.3h5.7zM30 0h-2.2c-0.3 0-0.5 0.3-0.5 0.6v7.6l-5.5-8L21 0h-2.2c-0.3 0-0.6 0.3-0.6 0.6v13.2c0 0.3 0.3 0.5 0.6 0.5H21c0.3 0 0.6-0.2 0.6-0.5v-8l5.7 8.3h0.1c0.1 0.2 0.2 0.2 0.4 0.2H30c0.4 0 0.6-0.2 0.6-0.5V0.6C30.6 0.3 30.4 0 30 0z" />
<path
android:fillColor="#08BF5B"
android:pathData="M42.4 47H1.6C0.7 47 0 46.1 0 45.2V20.8c0-1 0.7-1.7 1.6-1.7h40.8c0.9 0 1.6 0.8 1.6 1.7v24.5c0 0.9-0.7 1.6-1.6 1.6z" />
<path
android:fillColor="#fff"
android:pathData="M15.9 30c0 2.4-2 4.4-4.5 4.4h-2V38c0 0.2-0.1 0.4-0.3 0.4H7A0.4 0.4 0 0 1 6.6 38V26c0-0.2 0.2-0.4 0.4-0.4h4.4c2.5 0 4.5 2 4.5 4.4zm-3 0c0-1-0.6-1.7-1.5-1.7h-2v3.3h2c0.9 0 1.5-0.7 1.5-1.6zm13.8-0.5v8.7l-0.2 0.2h-2.3a0.2 0.2 0 0 1-0.2-0.2v-0.6c-0.6 0.7-1.5 1-2.8 1-2.3 0-4.3-2-4.3-4.8 0-2.7 2-4.8 4.3-4.8 1.3 0 2.2 0.4 2.8 1.1v-0.6c0-0.1 0-0.2 0.2-0.2h2.3s0.2 0 0.2 0.2zM24 33.8c0-1.3-1-2.2-2.2-2.2-1.3 0-2.2 0.9-2.2 2.2 0 1.4 1 2.3 2.2 2.3 1.2 0 2.2-0.9 2.2-2.3zm11.8-4.3l-2.1 5.3-2.2-5.3c0-0.2-0.2-0.3-0.3-0.3h-2.4l-0.2 0.4 3.7 8.8-1.4 3.4c0 0.1 0 0.3 0.2 0.3h2.4l0.3-0.2 4.9-12.3c0-0.2 0-0.4-0.2-0.4H36c-0.1 0-0.3 0.1-0.3 0.3z" />
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,13 @@ internal object PaymentMapper {
currency = payment.currency.orEmpty(),
status = PaymentStatus.fromString(payment.status.orEmpty()),
)

OffSitePaymentType.RAKUTEN_PAY.id,
OffSitePaymentType.AU_PAY.id,
OffSitePaymentType.ALI_PAY.id,
OffSitePaymentType.MER_PAY.id,
OffSitePaymentType.PAY_PAY.id,
-> Payment.OffSitePayment(
amount = payment.amount.orEmpty(),
currency = payment.currency.orEmpty(),
redirectURL = payment.paymentDetails.redirectUrl.orEmpty(),
status = PaymentStatus.fromString(payment.status.orEmpty()),
type = type,
in OffSitePaymentType.supportedTypes -> Payment.OffSitePayment(
amount = payment?.amount.orEmpty(),
currency = payment?.currency.orEmpty(),
redirectURL = payment?.paymentDetails?.redirectUrl.orEmpty(),
status = PaymentStatus.fromString(payment?.status.orEmpty()),
type = type.orEmpty(),
)

else -> error("Invalid payment type")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,14 @@ internal object SessionMapper {
}.orEmpty(),
)

OffSitePaymentType.PAY_PAY.id,
OffSitePaymentType.MER_PAY.id,
OffSitePaymentType.ALI_PAY.id,
OffSitePaymentType.AU_PAY.id,
OffSitePaymentType.RAKUTEN_PAY.id,
-> PaymentMethod.OffSitePayment(
hashedGateway = paymentMethod.hashedGateway.orEmpty(),
exchangeRate = paymentMethod.exchangeRate ?: 1.0,
currency = paymentMethod.currency.orEmpty(),
in OffSitePaymentType.supportedTypes -> PaymentMethod.OffSitePayment(
hashedGateway = paymentMethod?.hashedGateway.orEmpty(),
exchangeRate = paymentMethod?.exchangeRate ?: 1.0,
currency = paymentMethod?.currency.orEmpty(),
amount = (response.amount ?: 0).toString(),
additionalFields = paymentMethod.additionalFields?.filterNotNull().orEmpty(),
displayName = i18nTexts[paymentMethodType],
type = OffSitePaymentType.entries.first { it.id == paymentMethodType },
additionalFields = paymentMethod?.additionalFields?.filterNotNull().orEmpty(),
displayName = i18nTexts[paymentMethodType.toString()],
type = OffSitePaymentType.fromId(paymentMethodType.orEmpty()),
)

"bank_transfer" -> PaymentMethod.BankTransfer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@ enum class OffSitePaymentType(val id: String) {
MER_PAY("merpay"),
PAY_PAY("paypay"),
RAKUTEN_PAY("rakutenpay"),
LINE_PAY("linepay"),
UNKNOWN(""),
;

companion object {
val supportedTypes = entries.map { it.id }
fun fromId(id: String): OffSitePaymentType = entries.find { it.id == id } ?: UNKNOWN
}
}

0 comments on commit 7cc7084

Please sign in to comment.