2013-10-28 95 views

回答

3

是的,它的作用。當您使用store.init([storeName,] listener)啓動店裏指定的商店名稱和網上交易方式,即store.init("apple", transactionCallback)一個回調函數。在這個回調函數中,你可以檢查某些事務狀態。

local function transactionCallback(event) 
    local transaction = event.transaction 
    print("EVENT:PHASE = " .. transaction.state) 

    if transaction.state == "purchased" then 
     print("Transaction succuessful!") 
     print("productIdentifier", transaction.productIdentifier) 
     print("receipt", transaction.receipt) 
     print("signature", transaction.signature) 
     print("transactionIdentifier", transaction.identifier) 
     print("date", transaction.date) 
    elseif transaction.state == "restored" then 
     print("Transaction restored (from previous session)") 
     print("signature", transaction.signature)   
     print("productIdentifier", transaction.productIdentifier) 
     print("receipt", transaction.receipt) 
     print("transactionIdentifier", transaction.identifier) 
     print("date", transaction.date) 
     print("originalReceipt", transaction.originalReceipt) 
     print("originalTransactionIdentifier", transaction.originalIdentifier) 
     print("originalDate", transaction.originalDate) 
    elseif transaction.state == "cancelled" then 
     print("User cancelled transaction") 
    elseif transaction.state == "failed" then 
     print("Transaction failed, type:", transaction.errorType, transaction.errorString) 
    else 
     print("unknown event") 
    end 
end 
+0

其實我覺得我看到的時候它似乎鎖定了情景是一個凡購買過程中我的ADSL調制解調器連接到互聯網死去......任何意義......絕對卡住了,並沒有返回... – Greg

+0

@格雷格這是有道理的。但它應該超時。做到了? – Eyeball

+0

@Eyeball它被接管一分鐘,但我必須承認,我放棄了在此之後。一分鐘以上太長了。你有一個已部署的應用程序,它會假設它會返回?你有什麼問題嗎? – Greg

0

是的,但如果它感知某種互聯網連接的(哪怕是個壞),直到它接收響應,並考慮到玩家在玩移動互聯網上經常可以連接差會保持對話了。如果在合理的時間內沒有收到響應,您可能需要插入Corona計時器來取消進程並通過對話框通知用戶。

相關問題