From e091b02a3722db2c4b544ef17a3c80dbd0d54f8c Mon Sep 17 00:00:00 2001 From: lpcdma Date: Wed, 7 Jan 2015 21:46:03 +0800 Subject: [PATCH] IAP plugin lua logic error --- protocols/platform/android/ProtocolIAP.cpp | 13 +++++++++---- protocols/platform/ios/IAPWrapper.mm | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/protocols/platform/android/ProtocolIAP.cpp b/protocols/platform/android/ProtocolIAP.cpp index 0c6ef76e..c4861c34 100644 --- a/protocols/platform/android/ProtocolIAP.cpp +++ b/protocols/platform/android/ProtocolIAP.cpp @@ -42,13 +42,18 @@ extern "C" { ProtocolIAP* pIAP = dynamic_cast(pPlugin); if (pIAP != NULL) { - pIAP->onPayResult((PayResultCode) ret, strMsg.c_str()); + ProtocolIAP::ProtocolIAPCallback callback = pIAP->getCallback(); + if (callback) { + PluginUtils::outputLog("ProtocolIAP", "IAP plugin callback function"); + callback(ret, strMsg); + }else{ + PluginUtils::outputLog("ProtocolIAP", "IAP plugin running onPayResult"); + pIAP->onPayResult((PayResultCode) ret, strMsg.c_str()); + } } else { - ProtocolIAP::ProtocolIAPCallback callback = pIAP->getCallback(); - if(callback) - callback(ret, strMsg); + PluginUtils::outputLog("ProtocolIAP", "Can't find the C++ object of the IAP plugin"); } } } diff --git a/protocols/platform/ios/IAPWrapper.mm b/protocols/platform/ios/IAPWrapper.mm index 745cf1de..ad9da759 100644 --- a/protocols/platform/ios/IAPWrapper.mm +++ b/protocols/platform/ios/IAPWrapper.mm @@ -36,14 +36,19 @@ + (void) onPayResult:(id) obj withRet:(IAPResult) ret withMsg:(NSString*) msg { PluginProtocol* plugin = PluginUtilsIOS::getPluginPtr(obj); ProtocolIAP* iapPlugin = dynamic_cast(plugin); + PayResultListener *listener = iapPlugin->getResultListener(); ProtocolIAP::ProtocolIAPCallback callback = iapPlugin->getCallback(); const char* chMsg = [msg UTF8String]; PayResultCode cRet = (PayResultCode) ret; if (iapPlugin) { - iapPlugin->onPayResult(cRet, chMsg); - }else if(callback){ - std::string stdmsg(chMsg); - callback(cRet,stdmsg); + if (callback) { + PluginUtilsIOS::outputLog("IAP plugin callback function"); + std::string stdmsg(chMsg); + callback(cRet,stdmsg); + }else{ + PluginUtilsIOS::outputLog("IAP plugin running onPayResult"); + iapPlugin->onPayResult(cRet, chMsg); + } } else { PluginUtilsIOS::outputLog("Can't find the C++ object of the IAP plugin"); }