private void closeWaiting() { if (waitingCon == null) { return; } Application.Current.Dispatcher.Invoke(() => { waitingCon.CloseDialog(); waitingCon = null; }); }
void IAPExternalCall(string msg) { Debug.Log("IAPExternalCall(" + msg + ")"); Dictionary <string, string> dic = AnySDKUtil.stringToDictionary(msg); int code = Convert.ToInt32(dic["code"]); string result = dic["msg"]; switch (code) { case (int)PayResultCode.kPaySuccess: //支付成功回调 LoadingDialog.CloseDialog(); break; case (int)PayResultCode.kPayFail: //支付失败回调 LoadingDialog.CloseDialog(); break; case (int)PayResultCode.kPayCancel: //支付取消回调 LoadingDialog.CloseDialog(); break; case (int)PayResultCode.kPayNetworkError: //支付超时回调 LoadingDialog.CloseDialog(); break; case (int)PayResultCode.kPayProductionInforIncomplete: //支付信息不完整 LoadingDialog.CloseDialog(); break; /** * 新增加:正在进行中回调 * 支付过程中若SDK没有回调结果,就认为支付正在进行中 * 游戏开发商可让玩家去判断是否需要等待,若不等待则进行下一次的支付 */ case (int)PayResultCode.kPayNowPaying: break; default: break; } }
private static void OnTransactionComplete(IOSStoreKitResponse response) { Debug.Log("OnTransactionComplete: " + response.productIdentifier); Debug.Log("OnTransactionComplete: state: " + response.state); LoadingDialog.CloseDialog(); switch (response.state) { case InAppPurchaseState.Purchased: case InAppPurchaseState.Restored: //Our product been succsesly purchased or restored //So we need to provide content to our user depends on productIdentifier UnlockProducts(response.productIdentifier); break; case InAppPurchaseState.Deferred: //iOS 8 introduces Ask to Buy, which lets parents approve any purchases initiated by children //You should update your UI to reflect this deferred state, and expect another Transaction Complete to be called again with a new transaction state //reflecting the parent’s decision or after the transaction times out. Avoid blocking your UI or gameplay while waiting for the transaction to be updated. break; case InAppPurchaseState.Failed: //Our purchase flow is failed. //We can unlock intrefase and repor user that the purchase is failed. Debug.Log("Transaction failed with error, code: " + response.error.code); Debug.Log("Transaction failed with error, description: " + response.error.description); break; } if (response.state == InAppPurchaseState.Failed) { IOSNativePopUpManager.showMessage("Transaction Failed", "Error code: " + response.error.code + "\n" + "Error description:" + response.error.description); } else { // IOSNativePopUpManager.showMessage("Store Kit Response", "product " + response.productIdentifier + " state: " + response.state.ToString()); } }