Skip to content

Commit

Permalink
Merge pull request #70 from iamport/feat/custom-user-agent
Browse files Browse the repository at this point in the history
feat: 임의의 user agent를 받을 수 있는 파라미터 추가
  • Loading branch information
anymate98 authored Jul 10, 2023
2 parents c77ff6c + 171850b commit 91f14eb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import java.util.*

class PaymentFragment: Fragment() {
class PaymentFragment : Fragment() {

private lateinit var binding: PaymentFragmentBinding

Expand Down
9 changes: 7 additions & 2 deletions sdk/src/main/java/com/iamport/sdk/domain/core/Iamport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ object Iamport {
// default WebSettings.LOAD_NO_CACHE 이나, 세틀뱅크 뒤로가기시 오동작하여(캐시가 필요) 가맹점에서 선택할 수 있게 수정
var webViewCacheMode: Int = WebSettings.LOAD_NO_CACHE

var customUserAgent: String? = null // 웹뷰 user agent 조작

var response: IamPortResponse? = null // 내부의 imp_uid로 종료 콜백 중복호출 방지

// ===========================================
Expand Down Expand Up @@ -297,7 +299,8 @@ object Iamport {
tierCode: String? = null,
webviewMode: WebView? = null,
iamPortCertification: IamPortCertification,
resultCallback: (IamPortResponse?) -> Unit
customUserAgent: String? = null,
resultCallback: (IamPortResponse?) -> Unit,
) {
val payment = Payment(userCode, tierCode = tierCode, iamPortCertification = iamPortCertification)
if (!isSDKInit(payment)) {
Expand All @@ -310,14 +313,16 @@ object Iamport {
}

preventOverlapRun.launch {
coreCertification(payment, resultCallback)
coreCertification(payment, customUserAgent, resultCallback)
}
}

internal fun coreCertification(
payment: Payment,
customUserAgent: String? = null,
paymentResultCallback: ((IamPortResponse?) -> Unit)?
) {
if (customUserAgent != null) this.customUserAgent = customUserAgent
impCallbackFunction = paymentResultCallback
iamportSdk?.initStart(payment, paymentResultCallback)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface BaseMain {
}

cacheMode = Iamport.webViewCacheMode // default WebSettings.LOAD_NO_CACHE
if (Iamport.customUserAgent != null) userAgentString = Iamport.customUserAgent

blockNetworkImage = false
loadsImagesAutomatically = true
Expand Down

0 comments on commit 91f14eb

Please sign in to comment.