Пример #1
0
        public void IapPayResult(string content)
        {
            if (string.IsNullOrEmpty(content))
            {
                return;
            }

            MyLog.InfoWithFrame(name, string.Format("iappay result: {0}", content));
            IapPayResultTime = Time.time;
            IapPayResultData = JsonUtility.FromJson <IapResult>(content);
        }
Пример #2
0
        private void ProcessIapPayResult(IapResult res)
        {
            if (res == null)
            {
                EnableComponent(false, false, true);
                SetStateTxt(string.Format("<color=red>支付失败!</color>\n请联系下方客服QQ{0}",
                                          !string.IsNullOrEmpty(OutTradeNo) ? "\n订单号:" + OutTradeNo : ""));

                StopPay();
                AnalyticPayFail("iappay_res_parse_error");
                return;
            }

            if (res.Result == IapResult.IapSuccess)
            {
                _extra = "{\"receipt\":\"" + res.Receipt + "\"}";

                EnableComponent(false, true, true);
                SetStateTxt("恭喜您,充值成功^_^\n马上请求发货");

                AnalyticPayOk();
            }
            else
            {
                // 支付失败。

                if (res.Result == IapResult.IapFailProductInfo)
                {
                    EnableComponent(false, false, true);
                    SetStateTxt(string.Format("<color=red>向苹果请求订单失败!</color>\n请联系下方客服QQ{0}",
                                              !string.IsNullOrEmpty(OutTradeNo) ? "\n订单号:" + OutTradeNo : ""));

                    AnalyticPayFail("iap_product_fail");
                }
                else if (res.Result == IapResult.IapFailCannotPay)
                {
                    EnableComponent(false, false, true);
                    SetStateTxt(string.Format("<color=red>您的设备不支持支付功能!</color>\n请联系下方客服QQ{0}",
                                              !string.IsNullOrEmpty(OutTradeNo) ? "\n订单号:" + OutTradeNo : ""));

                    AnalyticPayFail("iap_cannot_pay");
                }
                else if (res.Result == IapResult.IapFailTradeInvalid)
                {
                    EnableComponent(false, false, true);
                    SetStateTxt(string.Format("<color=red>订单数据错误!</color>\n请联系下方客服QQ{0}",
                                              !string.IsNullOrEmpty(OutTradeNo) ? "\n订单号:" + OutTradeNo : ""));

                    AnalyticPayFail("iap_trade_invalid");
                }
                else if (res.Result == IapResult.IapFailPayment)
                {
                    EnableComponent(false, false, true);
                    SetStateTxt(string.Format("<color=red>支付失败!</color>\n请联系下方客服QQ{0}",
                                              !string.IsNullOrEmpty(OutTradeNo) ? "\n订单号:" + OutTradeNo : ""));

                    AnalyticPayFail("iap_fail_payment");
                }

                StopPay();
            }
        }