class AppContext : Application() {
override fun onCreate() {
super.onCreate()
//cash-button
CashButtonSDK(
application = this,
skProductType = SKProductType.OK_CASH_BAG, // or SKProductType.SYRUP
appId = "AppId",
appSecret = "AppSecret"
).apply {
// debug-mode
setUseDebug(use = true)
// market
setMarketType(marketType = MarketType.GooglePlayStore)
// 포인트명 변경(OKCashBag("콕"))
setPointName(pointName = "콕")
// 포인트 전환 안내 문구 등록
setPointExchangeMessage(message = "<font color=\"#ff0000\">※포인트 전환 후 취소 및 환불이 불가능합니다.</font>")
// 포인트 전환 이벤트 리스너 등록(전환 사용시 필수)
setCashExchangeListener(listener = object : ICashExchangeListener {
override fun onRequestExchange(transactionID: String, exchangeItemID: String) {
/**
* transactionID 포인트 전환 TransactionID
* exchangeItemID 포인트 전환 아이템 코드
*/
}
})
// 탈퇴 이벤트 리스너 등록
setWithdrawListener(listener = object : IWithdrawListener {
override fun onCompleted(resultCode: Int) {
/**
* 성공 -> resultCode == 1
* 실패 -> resultCode =- -999(일반적인 오류)
*/
}
})
}.build(listener = object : CashButtonSDK.IResultListener {
override fun onCompleted(resultCode: Int) {
/**
* 1: success
* -500 : AppId or AppSecret is null or empty
* -501 : Wrong Product Type
*/
Toast.makeText(
this@AppContext,
"CashButtonSDK.Init::onCompleted { resultCode: $resultCode }",
Toast.LENGTH_SHORT
).show()
}
})
}
}