Skip to content

Commit 9821a2d

Browse files
authored
feature/cp-376 : 로깅 시점 변경 및 샘플 앱 redirectUrl 이슈 수정 (#19)
* 샘플 앱 redirectUrl 반영 안 되는 문제 수정 * selectedPaymentMethod 로깅 시점 변경
1 parent 590782b commit 9821a2d

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

app/src/main/java/com/tosspayments/paymentsdk/sample/activity/PaymentWidgetActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ class PaymentWidgetActivity : AppCompatActivity() {
216216
}
217217
}
218218
)
219+
Log.d("selectedPaymentMethod", paymentWidget.getSelectedPaymentMethod().toString())
219220
}
220221

221222
binding.changeAmountCta.setOnClickListener {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.tosspayments.paymentsdk.sample.extension
2+
3+
import kotlinx.coroutines.flow.Flow
4+
5+
fun <T1, T2, T3, T4, T5, T6, R> combine(
6+
flow: Flow<T1>,
7+
flow2: Flow<T2>,
8+
flow3: Flow<T3>,
9+
flow4: Flow<T4>,
10+
flow5: Flow<T5>,
11+
flow6: Flow<T6>,
12+
transform6: suspend (T1, T2, T3, T4, T5, T6) -> R,
13+
): Flow<R> =
14+
kotlinx.coroutines.flow.combine(flow, flow2, flow3, flow4, flow5, flow6) { args: Array<*> ->
15+
@Suppress("UNCHECKED_CAST")
16+
transform6(
17+
args[0] as T1,
18+
args[1] as T2,
19+
args[2] as T3,
20+
args[3] as T4,
21+
args[4] as T5,
22+
args[5] as T6,
23+
)
24+
25+
}

app/src/main/java/com/tosspayments/paymentsdk/sample/viewmodel/PaymentWidgetInfoViewModel.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ import androidx.lifecycle.AndroidViewModel
66
import androidx.lifecycle.LiveData
77
import androidx.lifecycle.MutableLiveData
88
import androidx.lifecycle.viewModelScope
9+
import com.tosspayments.paymentsdk.sample.extension.combine
910
import com.tosspayments.paymentsdk.view.PaymentMethod
10-
import kotlinx.coroutines.flow.*
11+
import kotlinx.coroutines.flow.MutableStateFlow
12+
import kotlinx.coroutines.flow.SharingStarted
13+
import kotlinx.coroutines.flow.StateFlow
14+
import kotlinx.coroutines.flow.stateIn
1115

1216
@SuppressLint("ApplySharedPref")
1317
class PaymentWidgetInfoViewModel(application: Application) : AndroidViewModel(application) {
@@ -30,8 +34,9 @@ class PaymentWidgetInfoViewModel(application: Application) : AndroidViewModel(ap
3034
_clientKey,
3135
_customerKey,
3236
_orderId,
33-
_orderName
34-
) { amount, clientKey, customerKey, orderId, orderName ->
37+
_orderName,
38+
_redirectUrl,
39+
) { amount, clientKey, customerKey, orderId, orderName, redirectUrl ->
3540
val isValid = amount.toDouble() > 0 && arrayOf(
3641
clientKey,
3742
customerKey,
@@ -48,7 +53,7 @@ class PaymentWidgetInfoViewModel(application: Application) : AndroidViewModel(ap
4853
customerKey = customerKey,
4954
orderId = orderId,
5055
orderName = orderName,
51-
redirectUrl = _redirectUrl.value
56+
redirectUrl = redirectUrl,
5257
)
5358
}
5459
}.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), UiState.Invalid)

paymentsdk/src/main/java/com/tosspayments/paymentsdk/PaymentWidget.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import android.app.Activity
44
import android.content.Context
55
import android.content.Intent
66
import android.net.Uri
7-
import android.util.Log
87
import android.webkit.JavascriptInterface
98
import androidx.activity.result.ActivityResultLauncher
109
import androidx.activity.result.contract.ActivityResultContracts
@@ -78,7 +77,6 @@ class PaymentWidget(
7877
PaymentMethod.EVENT_NAME_CHANGE_PAYMENT_METHOD -> {
7978
kotlin.runCatching { SelectedPaymentMethod.fromJson(params) }.getOrNull()?.let {
8079
selectedPaymentMethod = it
81-
Log.d("selectedPaymentMethod", it.toString())
8280
}
8381
}
8482
Agreement.EVENT_NAME_UPDATE_AGREEMENT_STATUS -> {

0 commit comments

Comments
 (0)