캔 결제 화면 문자열 리소스화
This commit is contained in:
@@ -78,7 +78,7 @@ class CanPaymentActivity : BaseActivity<ActivityCanPaymentBinding>(
|
||||
if (canResponse == null) {
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
"다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다.",
|
||||
getString(R.string.msg_can_payment_missing_data),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
|
||||
@@ -90,7 +90,7 @@ class CanPaymentActivity : BaseActivity<ActivityCanPaymentBinding>(
|
||||
false
|
||||
)
|
||||
|
||||
binding.toolbar.tvBack.text = "결제하기"
|
||||
binding.toolbar.tvBack.text = getString(R.string.screen_can_payment_title)
|
||||
binding.toolbar.tvBack.setOnClickListener { finish() }
|
||||
|
||||
binding.tvChargeCanTitle.text = canResponse!!.title
|
||||
@@ -109,7 +109,7 @@ class CanPaymentActivity : BaseActivity<ActivityCanPaymentBinding>(
|
||||
if (viewModel.paymentMethodLiveData.value == null) {
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
"결제수단을 선택해 주세요.",
|
||||
getString(R.string.msg_can_payment_method_required),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
return@setOnClickListener
|
||||
@@ -118,7 +118,7 @@ class CanPaymentActivity : BaseActivity<ActivityCanPaymentBinding>(
|
||||
if (!binding.tvAgree.isSelected) {
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
"결제 진행에 동의하셔야 결제가 가능합니다.",
|
||||
getString(R.string.msg_can_payment_agree_required),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
return@setOnClickListener
|
||||
@@ -188,7 +188,8 @@ class CanPaymentActivity : BaseActivity<ActivityCanPaymentBinding>(
|
||||
startPayverse(response.payloadJson)
|
||||
},
|
||||
onFailure = {
|
||||
Toast.makeText(applicationContext, it, Toast.LENGTH_LONG).show()
|
||||
val message = it ?: getString(R.string.common_error_unknown)
|
||||
Toast.makeText(applicationContext, message, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -201,13 +202,18 @@ class CanPaymentActivity : BaseActivity<ActivityCanPaymentBinding>(
|
||||
requestPayment(chargeId = it)
|
||||
},
|
||||
onFailure = {
|
||||
Toast.makeText(applicationContext, it, Toast.LENGTH_LONG).show()
|
||||
val message = it ?: getString(R.string.common_error_unknown)
|
||||
Toast.makeText(applicationContext, message, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
else -> {
|
||||
Toast.makeText(applicationContext, "결제수단을 다시 선택해 주세요.", Toast.LENGTH_LONG).show()
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
getString(R.string.msg_can_payment_method_required),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -283,7 +289,11 @@ class CanPaymentActivity : BaseActivity<ActivityCanPaymentBinding>(
|
||||
viewModel.verifyHecto(
|
||||
request,
|
||||
onSuccess = {
|
||||
Toast.makeText(applicationContext, "캔이 충전되었습니다", Toast.LENGTH_LONG).show()
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
getString(R.string.msg_can_charge_success),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
SharedPreferenceManager.can += (canResponse!!.rewardCan + canResponse!!.can)
|
||||
if (gotoPrevPage) {
|
||||
setResult(RESULT_OK)
|
||||
@@ -294,7 +304,8 @@ class CanPaymentActivity : BaseActivity<ActivityCanPaymentBinding>(
|
||||
finish()
|
||||
},
|
||||
onFailure = {
|
||||
Toast.makeText(applicationContext, it, Toast.LENGTH_LONG).show()
|
||||
val message = it ?: getString(R.string.common_error_unknown)
|
||||
Toast.makeText(applicationContext, message, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -395,7 +406,7 @@ class CanPaymentActivity : BaseActivity<ActivityCanPaymentBinding>(
|
||||
Logger.e(e.message ?: "payverse start error")
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
"결제 초기화에 실패했습니다.",
|
||||
getString(R.string.msg_can_payment_init_failed),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
binding.webviewPayverse.visibility = View.GONE
|
||||
@@ -436,7 +447,7 @@ class CanPaymentActivity : BaseActivity<ActivityCanPaymentBinding>(
|
||||
) {
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
"결제를 하지 못했습니다.\n다시 시도해 주세요",
|
||||
getString(R.string.msg_can_payment_retry),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
|
||||
@@ -452,14 +463,19 @@ class CanPaymentActivity : BaseActivity<ActivityCanPaymentBinding>(
|
||||
completePaymentSuccess()
|
||||
},
|
||||
onFailure = {
|
||||
Toast.makeText(applicationContext, it, Toast.LENGTH_LONG).show()
|
||||
val message = it ?: getString(R.string.common_error_unknown)
|
||||
Toast.makeText(applicationContext, message, Toast.LENGTH_LONG).show()
|
||||
binding.webviewPayverse.visibility = View.GONE
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private fun completePaymentSuccess() {
|
||||
Toast.makeText(applicationContext, "캔이 충전되었습니다", Toast.LENGTH_LONG).show()
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
getString(R.string.msg_can_charge_success),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
SharedPreferenceManager.can += (canResponse!!.rewardCan + canResponse!!.can)
|
||||
if (gotoPrevPage) {
|
||||
setResult(RESULT_OK)
|
||||
|
||||
@@ -56,23 +56,24 @@ class CanPaymentTempActivity : BaseActivity<ActivityCanPaymentBinding>(
|
||||
if (title.isBlank() || can <= 0) {
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
"다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다.",
|
||||
getString(R.string.msg_can_payment_missing_data),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
|
||||
finish()
|
||||
}
|
||||
|
||||
binding.toolbar.tvBack.text = "결제하기"
|
||||
binding.toolbar.tvBack.text = getString(R.string.screen_can_payment_title)
|
||||
binding.toolbar.tvBack.setOnClickListener { finish() }
|
||||
|
||||
binding.ivCan.visibility = View.GONE
|
||||
binding.tvAlert.visibility = View.GONE
|
||||
binding.tvChargeCanTitle.text = title
|
||||
binding.tvPrice.text = (can * 110).moneyFormat()
|
||||
binding.tvPaymentPrice.text = "${(can * 110).moneyFormat()}원".fontSpan(
|
||||
val currencyUnit = getString(R.string.screen_can_payment_currency_unit)
|
||||
binding.tvPaymentPrice.text = "${(can * 110).moneyFormat()}$currencyUnit".fontSpan(
|
||||
ResourcesCompat.getFont(applicationContext, R.font.gmarket_sans_light),
|
||||
"원"
|
||||
currencyUnit
|
||||
)
|
||||
|
||||
binding.tvAgree.setOnClickListener {
|
||||
@@ -83,7 +84,7 @@ class CanPaymentTempActivity : BaseActivity<ActivityCanPaymentBinding>(
|
||||
if (viewModel.paymentMethodLiveData.value == null) {
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
"결제수단을 선택해 주세요.",
|
||||
getString(R.string.msg_can_payment_method_required),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
return@setOnClickListener
|
||||
@@ -92,7 +93,7 @@ class CanPaymentTempActivity : BaseActivity<ActivityCanPaymentBinding>(
|
||||
if (!binding.tvAgree.isSelected) {
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
"결제 진행에 동의하셔야 결제가 가능합니다.",
|
||||
getString(R.string.msg_can_payment_agree_required),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
return@setOnClickListener
|
||||
@@ -138,7 +139,8 @@ class CanPaymentTempActivity : BaseActivity<ActivityCanPaymentBinding>(
|
||||
requestPayment(chargeId = it)
|
||||
},
|
||||
onFailure = {
|
||||
Toast.makeText(applicationContext, it, Toast.LENGTH_LONG).show()
|
||||
val message = it ?: getString(R.string.common_error_unknown)
|
||||
Toast.makeText(applicationContext, message, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -206,7 +208,8 @@ class CanPaymentTempActivity : BaseActivity<ActivityCanPaymentBinding>(
|
||||
finish()
|
||||
},
|
||||
onFailure = {
|
||||
Toast.makeText(applicationContext, it, Toast.LENGTH_LONG).show()
|
||||
val message = it ?: getString(R.string.common_error_unknown)
|
||||
Toast.makeText(applicationContext, message, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class CanPaymentTempViewModel(private val repository: CanPaymentTempRepository)
|
||||
can: Int,
|
||||
paymentGateway: PaymentGateway,
|
||||
onSuccess: (Long) -> Unit,
|
||||
onFailure: (String) -> Unit
|
||||
onFailure: (String?) -> Unit
|
||||
) {
|
||||
_isLoading.value = true
|
||||
val request = ChargeTempRequest(can, can * 110, paymentGateway)
|
||||
@@ -36,23 +36,19 @@ class CanPaymentTempViewModel(private val repository: CanPaymentTempRepository)
|
||||
if (it.success && it.data != null) {
|
||||
onSuccess(it.data.chargeId)
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
onFailure(it.message)
|
||||
} else {
|
||||
onFailure("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
}
|
||||
onFailure(it.message)
|
||||
}
|
||||
},
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
onFailure("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
onFailure(it.message)
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun verify(request: VerifyRequest, onSuccess: () -> Unit, onFailure: (String) -> Unit) {
|
||||
fun verify(request: VerifyRequest, onSuccess: () -> Unit, onFailure: (String?) -> Unit) {
|
||||
_isLoading.value = true
|
||||
compositeDisposable.add(
|
||||
repository.verify(
|
||||
@@ -66,17 +62,13 @@ class CanPaymentTempViewModel(private val repository: CanPaymentTempRepository)
|
||||
if (it.success) {
|
||||
onSuccess()
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
onFailure(it.message)
|
||||
} else {
|
||||
onFailure("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
}
|
||||
onFailure(it.message)
|
||||
}
|
||||
},
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
onFailure("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
onFailure(it.message)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanPaymentViewModel(private val repository: CanRepository) : BaseViewModel
|
||||
canId: Long,
|
||||
paymentGateway: PaymentGateway,
|
||||
onSuccess: (Long) -> Unit,
|
||||
onFailure: (String) -> Unit
|
||||
onFailure: (String?) -> Unit
|
||||
) {
|
||||
_isLoading.value = true
|
||||
val request = ChargeRequest(canId = canId, paymentGateway = paymentGateway)
|
||||
@@ -42,23 +42,19 @@ class CanPaymentViewModel(private val repository: CanRepository) : BaseViewModel
|
||||
if (it.success && it.data != null) {
|
||||
onSuccess(it.data.chargeId)
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
onFailure(it.message)
|
||||
} else {
|
||||
onFailure("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
}
|
||||
onFailure(it.message)
|
||||
}
|
||||
},
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
onFailure("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
onFailure(it.message)
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun verify(request: VerifyRequest, onSuccess: () -> Unit, onFailure: (String) -> Unit) {
|
||||
fun verify(request: VerifyRequest, onSuccess: () -> Unit, onFailure: (String?) -> Unit) {
|
||||
_isLoading.value = true
|
||||
compositeDisposable.add(
|
||||
repository.verify(
|
||||
@@ -72,23 +68,19 @@ class CanPaymentViewModel(private val repository: CanRepository) : BaseViewModel
|
||||
if (it.success) {
|
||||
onSuccess()
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
onFailure(it.message)
|
||||
} else {
|
||||
onFailure("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
}
|
||||
onFailure(it.message)
|
||||
}
|
||||
},
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
onFailure("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
onFailure(it.message)
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun verifyHecto(request: VerifyRequest, onSuccess: () -> Unit, onFailure: (String) -> Unit) {
|
||||
fun verifyHecto(request: VerifyRequest, onSuccess: () -> Unit, onFailure: (String?) -> Unit) {
|
||||
_isLoading.value = true
|
||||
compositeDisposable.add(
|
||||
repository.verifyHecto(
|
||||
@@ -102,17 +94,13 @@ class CanPaymentViewModel(private val repository: CanRepository) : BaseViewModel
|
||||
if (it.success) {
|
||||
onSuccess()
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
onFailure(it.message)
|
||||
} else {
|
||||
onFailure("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
}
|
||||
onFailure(it.message)
|
||||
}
|
||||
},
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { message -> Logger.e(message) }
|
||||
onFailure("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
onFailure(it.message)
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -125,7 +113,7 @@ class CanPaymentViewModel(private val repository: CanRepository) : BaseViewModel
|
||||
fun payverseChargeCan(
|
||||
canId: Long,
|
||||
onSuccess: (PayverseChargeResponse) -> Unit,
|
||||
onFailure: (String) -> Unit
|
||||
onFailure: (String?) -> Unit
|
||||
) {
|
||||
_isLoading.value = true
|
||||
compositeDisposable.add(
|
||||
@@ -140,13 +128,13 @@ class CanPaymentViewModel(private val repository: CanRepository) : BaseViewModel
|
||||
if (it.success && it.data != null) {
|
||||
onSuccess(it.data)
|
||||
} else {
|
||||
onFailure(it.message ?: "알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
onFailure(it.message)
|
||||
}
|
||||
},
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { m -> Logger.e(m) }
|
||||
onFailure("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
onFailure(it.message)
|
||||
}
|
||||
)
|
||||
)
|
||||
@@ -156,7 +144,7 @@ class CanPaymentViewModel(private val repository: CanRepository) : BaseViewModel
|
||||
transactionId: String,
|
||||
orderId: String,
|
||||
onSuccess: () -> Unit,
|
||||
onFailure: (String) -> Unit
|
||||
onFailure: (String?) -> Unit
|
||||
) {
|
||||
_isLoading.value = true
|
||||
compositeDisposable.add(
|
||||
@@ -172,13 +160,13 @@ class CanPaymentViewModel(private val repository: CanRepository) : BaseViewModel
|
||||
if (it.success) {
|
||||
onSuccess()
|
||||
} else {
|
||||
onFailure(it.message ?: "알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
onFailure(it.message)
|
||||
}
|
||||
},
|
||||
{
|
||||
_isLoading.value = false
|
||||
it.message?.let { m -> Logger.e(m) }
|
||||
onFailure("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||
onFailure(it.message)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user