샘플 파일은 Dungeons파일이 아니고 Bundell의 InAppPurchaseTwo로 작업했습니다.
코드가 절반 밖에 되지 않더군요.
http://blog.blundell-apps.com/simple-inapp-billing-payment/
콘솔에 개인 키 받은 APK파일을 올리고 테스트를 했습니다.
일단 처음 구매하기는 잘 작동합니다.
BillingHelper.java파일에서
protected static void verifyPurchase(String signedData, String signature) {
요 메소드에 결재 성공시 실행할 코드를 넣었습니다.
앱을 지우고 다시 깔아서 앱 결재를 시도했습니다.
구글 플레이에 접속해서 '이미 구입한 항목'이라는 메시지가 나옵니다.
여기서 질문입니다.
이미 구입한 항목으로 확인이 됬으면 뭘 실행을 시켜서 다음에는 이미 구입한 항목이라는 메시지가 안 나와야 할텐데
계속 이 창이 나오네요.
어디서 처리를 해 줘야 하나요?
프로덕트 타입은 비소멸성으로 지정을 해 놓은 상태입니다. 비소멸성 이어야 하구요. 제 질문의 핵심은 이미 구입한 항목인것은 맞지만 구입을 했으니 어떤 특정한 메소드를 실행을 시켜주고 싶은데 어디서 시켜야 하는지 모르겠다는거죠. 목적이 이미 구입했는지 안했는지 확인하는게 목적은 아니잖아요. 확인을 했으면 무언가를 실행시켜야 되는데, 어디서 실행을 하는건지...
이부분 아닐까요?
Now the BillingService won’t do anything on it’s own, so you need to load up the BillingHelper. The billing helper uses a handler to send callbacks on completed purchases:
1 | BillingHelper.setCompletedHandler(mTransactionHandler); |
This handler needs to be declared in your activity:
1 2 3 4 5 6 7 8 9 10 11 12 13 | public Handler mTransactionHandler = new Handler(){ public void handleMessage(android.os.Message msg) { Log.i(TAG, "Transaction complete" ); Log.i(TAG, "Transaction status: " +BillingHelper.latestPurchase.purchaseState); Log.i(TAG, "Item attempted purchase is: " +BillingHelper.latestPurchase.productId); if (BillingHelper.latestPurchase.isPurchased()){ showItem(); } else { // Failure } }; }; |
프로덕트 타입 설정을 하세요
http://blog.naver.com/lowmans/100167373677