private void TurnBackToTrophy()
    {
        ViewsEvents viewEvents = new ViewsEvents();

        viewEvents.WinMoneyClick();
        SceneManager.UnloadScene("BankingInformation");
        eventsController.ShowPopupError("popupOups");
        //Debug.Log("turn back to trophy with Ouups popup");
    }
예제 #2
0
    void selectWinMoney()
    {
        ViewsEvents viewEvents = new ViewsEvents();

        viewEvents.WinMoneyClick();
        BottomMenuController bottomMenu = BottomMenuController.getInstance();

        bottomMenu.selectWinMoney();
        bottomMenu.unselectSettings();
        bottomMenu.unselectHome();
        bottomMenu.unselectHaveFun();
    }
 void OnApplicationPause(bool pauseStatus)
 {
     if (pauseStatus)
     {
         //android onPause()
     }
     else
     {
         //android onResume()
         //Debug.Log("OnResume");
         // is Back after payement ?
         UnityThreading.ActionThread myThread;
         string token = um.getCurrentSessionToken();
         myThread = UnityThreadHelper.CreateThread(() => {
             //Debug.Log("check status");
             string trasactionState = checkStatus(orderId, token);
             //
             //				UnityThreadHelper.Dispatcher.Dispatch (() => {
             //					try {
             //						SceneManager.UnloadScene ("Loader");
             //					} catch (Exception ex) {
             //					}
             //				});
             if (isBackAfterPayment == true)
             {
                 //Debug.Log("orderId " + orderId);
                 //Debug.Log("trasactionState " + trasactionState);
                 if (!string.IsNullOrEmpty(orderId))
                 {
                     //Debug.Log("Line:1184 ");
                     if (!string.IsNullOrEmpty(trasactionState))
                     {
                         //Debug.Log("Line:1189 ");
                         if (trasactionState == "completed")
                         {
                             //Debug.Log("Line:1196");
                             //Debug.Log("Line:1197");
                             Thread.Sleep(6000);
                             var notification = getNotificationfromServer(N["details"]["order"]["id"]);
                             //Debug.Log("Line:1202: " + notification);
                             if (notification["data"]["state"].Value == "completed")
                             {
                                 //Debug.Log("Line:1205:");
                                 UnityThreadHelper.Dispatcher.Dispatch(() => {
                                     // Payment Completed
                                     orderId            = null;
                                     isBackAfterPayment = false;
                                     //	SceneManager.UnloadScene ("Loader");
                                     UserManager.CurrentMoney = (usr.money_credit + WalletScript.LastCredit).ToString("N2").Replace(",", ".");
                                     ViewsEvents viewEvents   = new ViewsEvents();
                                     viewEvents.WinMoneyClick();
                                     EventsController nbs = new EventsController();
                                     nbs.ShowPopup("popupCongrat");
                                     //GameObject.Find ("popupCongrat").transform.localScale = Vector3.one;
                                     Text TextMain = GameObject.Find("TextMain").GetComponent <Text> ();
                                     TextMain.text = WalletScript.LastCredit.ToString("N2").Replace(",", ".") + CurrencyManager.CURRENT_CURRENCY;
                                     try {
                                         SceneManager.UnloadScene("Loader");
                                     } catch (Exception ex) {}
                                     SceneManager.UnloadScene("BankingInformation");
                                 });
                             }
                         }
                         else if (trasactionState == "forwarding")
                         {
                             //Debug.Log("Line:1252:");
                             UnityThreadHelper.Dispatcher.Dispatch(() => {
                                 try {
                                     SceneManager.UnloadScene("Loader");
                                 } catch (Exception ex) {}
                                 //Debug.Log("please confirm your payment");
                                 GameObject.Find("popupPaymentWaitingForApproval").transform.localScale = Vector3.zero;
                                 GameObject.Find("popupPaymentNotConfirmed").transform.localScale       = Vector3.one;
                             });
                         }
                         else if (trasactionState == "declined")
                         {
                             //Debug.Log("Line:1265:");
                             UnityThreadHelper.Dispatcher.Dispatch(() => {
                                 //SceneManager.UnloadScene ("Loader");
                                 try {
                                     SceneManager.UnloadScene("Loader");
                                 } catch (Exception ex) {}
                                 GameObject.Find("popup_payment").transform.localScale = Vector3.zero;
                                 ViewsEvents viewEvents = new ViewsEvents();
                                 viewEvents.WinMoneyClick();
                                 SceneManager.UnloadScene("BankingInformation");
                                 eventsController.ShowPopupError("popupOups");
                                 //Debug.Log("turn back to trophy with Ouups popup");
                             });
                         }
                         else
                         {
                         }
                     }
                     else
                     {
                         //Debug.Log("Line:1286:");
                         UnityThreadHelper.Dispatcher.Dispatch(() => {
                             ViewsEvents viewEvents = new ViewsEvents();
                             viewEvents.WinMoneyClick();
                             try {
                                 SceneManager.UnloadScene("Loader");
                             } catch (Exception ex) {}
                             SceneManager.UnloadScene("BankingInformation");
                             eventsController.ShowPopupError("popupOups");
                         });
                     }
                 }
             }
         });
     }
 }
    void HipayConfig(string card_number, string cvc, string card_expiry_month, string card_expiry_year, string card_holder, string amount, string token, string userId)
    {
        UserManager um  = new UserManager();
        string      url = Endpoint.classesURL + "/payments/charge/" + userId;

        ServicePointManager.ServerCertificateValidationCallback = MyRemoteCertificateValidationCallback;
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

        request.Method = "POST";
        request.Headers["x-access-token"] = token;
        request.Headers["Access-Control-Request-Headers"] = "Content-Type";
        request.Headers["Access-Control-Request-Headers"] = "Authorization";
        request.ContentType = @"application/json";
        using (var stream = request.GetRequestStream()) {
            byte[] jsonAsBytes = Encoding.UTF8.GetBytes("{\"card_number\":\"" + card_number + "\",\"cvc\":\"" + cvc + "\",\"card_expiry_month\":\"" + card_expiry_month + "\",\"card_expiry_year\":\"" + card_expiry_year + "\",\"card_holder\":\"" + card_holder.ToUpper() + "\",\"amount\":\"" + amount + "\",\"user_id\":\"" + userId + "\"}");
            stream.Write(jsonAsBytes, 0, jsonAsBytes.Length);
        }
        try {
            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {
                ////Debug.Log ("Line: 822");
                System.IO.Stream s = response.GetResponseStream();
                using (System.IO.StreamReader sr = new System.IO.StreamReader(s)) {
                    //	//Debug.Log ("Line: 824");
                    var jsonResponse = sr.ReadToEnd();
                    //Debug.Log(jsonResponse);
                    N = JSON.Parse(jsonResponse);
                    try {
                        //Get the order id to check payment confirmation
                        orderId = N["details"]["order"]["id"].Value;
                        //TODO TO Verify
                        if (UserManager.CurrentHipayOrderId != null && UserManager.CurrentHipayOrderId != orderId)
                        {
                            UserManager.CurrentHipayOrderId = orderId;
                        }
                        //Debug.Log("forwardUrl: " + N["forwardUrl"].Value);
                        forwardUrl = N["details"]["forwardUrl"].Value;
                        if (!string.IsNullOrEmpty(N["details"]["forwardUrl"].Value))
                        {
                            //Open Browser to verify URL
                            UnityThreadHelper.Dispatcher.Dispatch(() => {
                                isBackAfterPayment = true;
                                Application.OpenURL(N["details"]["forwardUrl"].Value);
                            });
                            /*-----------------------------------------------------------------*/
                            //checkStatus(orderId);
                            /*-----------------------------------------------------------------*/
                        }
                        else
                        {
                            //Debug.Log("state: " + N["details"]["state"].Value);
                            if (N["details"]["state"].Value != "declined")
                            {
                                //Debug.Log("before notification ......");
                                /*-----------------------------------------------------------------*/
                                //Get Server-to-server Notification from hipay to confirm transaction
                                /*-----------------------------------------------------------------*/
                                Thread.Sleep(2000);
                                //Debug.Log("after thread sleeping ......");
                                var notification = getNotificationfromServer(N["details"]["order"]["id"].Value);
                                //Debug.Log("notification state: " + notification["data"]["state"].Value);
                                if (notification["data"]["state"].Value == "completed")
                                {
                                    UnityThreadHelper.Dispatcher.Dispatch(() => {
                                        //Debug.Log("user argent after float parse " + usr.money_credit);
                                        //Debug.Log("WalletScript.LastCredit " + WalletScript.LastCredit);
                                        //Debug.Log("CurrentMoney " + (usr.money_credit + WalletScript.LastCredit).ToString("N2").Replace(",", "."));
                                        // Payment Completed
                                        orderId                  = null;
                                        isBackAfterPayment       = false;
                                        UserManager.CurrentMoney = (usr.money_credit + WalletScript.LastCredit).ToString("N2").Replace(",", ".");
                                        //TODO
                                        ViewsEvents viewEvents = new ViewsEvents();
                                        viewEvents.WinMoneyClick();
                                        eventsController.ShowPopup("popupCongrat");
                                        Text TextMain = GameObject.Find("TextMain").GetComponent <Text> ();
                                        TextMain.text = WalletScript.LastCredit.ToString("N2").Replace(",", ".") + CurrencyManager.CURRENT_CURRENCY;
                                        SceneManager.UnloadScene("BankingInformation");
                                    });
                                }
                                else if (notification["data"]["state"].Value == "declined")
                                {
                                    UnityThreadHelper.Dispatcher.Dispatch(() => {
                                        //turn back to trophy with Ouups popup
                                        TurnBackToTrophy();
                                    });
                                }
                                else
                                {
                                    if (notification["data"]["state"].Value == "pending")
                                    {
                                        if (notification["data"]["message"].Value == "Risk Challenged")
                                        {
                                            UnityThreadHelper.Dispatcher.Dispatch(() => {
                                                GameObject.Find("popupPaymentWaitingForApproval").transform.localScale = Vector3.zero;
                                                //turn back to trophy with Ouups popup
                                                TurnBackToTrophy();
                                            });
                                        }
                                    }
                                }
                            }
                            else if (N["details"]["state"].Value == "declined")
                            {
                                UnityThreadHelper.Dispatcher.Dispatch(() => {
                                    //turn back to trophy with Ouups popup
                                    TurnBackToTrophy();
                                });
                            }
                        }
                    } catch (Exception e) {
                        UnityThreadHelper.Dispatcher.Dispatch(() => {
                            //turn back to trophy with Ouups popup
                            //Debug.Log(e);
                            TurnBackToTrophy();
                        });
                    }
                }
            }
        } catch (WebException ex) {
            //Debug.Log(ex);
            UnityThreadHelper.Dispatcher.Dispatch(() => {
                //turn back to trophy with Ouups popup
                TurnBackToTrophy();
            });
        }
    }