Ejemplo n.º 1
0
    private void AuthCallback(ILoginResult result)
    {
        if (FB.IsLoggedIn)
        {
            // AccessToken class will have session details
            var aToken = AccessToken.CurrentAccessToken;

            FBAccessToken fbAccessToken = new FBAccessToken();
            fbAccessToken.TokenString = aToken.TokenString;
            fbAccessToken.UserType    = "Instructor";

            StartCoroutine(
                HTTPClient.Post("/updateUser", JsonUtility.ToJson(fbAccessToken), statusCode => {
                if (statusCode == "200")
                {
                    SceneManager.LoadScene("SetupMeditationRoom");
                }
                else
                {
                    HFTDialog.MessageBox("Authentication error", "Facebook authentication failed.", () => {
                        Debug.Log("statusCode");
                        Debug.Log(statusCode);
                    });
                }
            })
                );
        }
        else
        {
            Debug.Log("Error");
            Debug.Log(result);
            Debug.Log(result.Error);
            Debug.Log("User cancelled login");
        }
    }
Ejemplo n.º 2
0
        private async Task <PaymentResult> Validate3D(VerifyPaymentModel paymentModel, IFormCollection collection)
        {
            var config = (YKBConfiguration)ProviderConfiguration;

            string encKey = config.HashKey;

            if (paymentModel.Order.CurrencyCode.IsEmpty())
            {
                paymentModel.Order.CurrencyCode = "TL";
            }

            Log.Information($"YKBProvider:ENC:{encKey}");

            string xid            = collection["Xid"];
            var    amount         = (decimal.Parse(collection["Amount"], new CultureInfo("tr-TR"))).ToString("0", new CultureInfo("en-US"));
            string firstShaString = encKey + ';' + config.TerminalId;
            string firstHash      = HashHelper.GetSHA256(firstShaString);
            string macShaString   = xid + ';' + amount + ';' + paymentModel.Order.CurrencyCode + ';' + config.MerchantId + ';' + firstHash;
            string mac            = HashHelper.GetSHA256(macShaString);

            Log.Information($"YKBProvider:firstShaString:{firstShaString}");
            Log.Information($"YKBProvider:firstHash:{firstHash}");
            Log.Information($"YKBProvider:sha256String:{macShaString}");
            Log.Information($"YKBProvider:mac:{mac}");



            paymentModel.Attributes.Add(new SanalPosTRAttribute {
                Key = "mac", Value = mac
            });

            string template = TemplateHelper.ReadEmbedResource($"{EmbededDirectory}.3D_Resolve.xml");
            string postData = TemplateHelper.PrepaireXML(new ViewModel
            {
                Use3DSecure   = true,
                Configuration = ProviderConfiguration,
                Attributes    = paymentModel.Attributes
            }, template);

            var post = GetPostForm();

            post.Content = System.Net.WebUtility.UrlEncode(postData);

            HTTPClient client = new HTTPClient(EndPointConfiguration.BaseUrl);
            var        result = await client.Post(EndPointConfiguration.ApiEndPoint, post, Handler);

            if (TemplateHelper.GetInlineContent(result.ServerResponseRaw, "mdStatus") != "1")
            {
                result.Status    = false;
                result.ErrorCode = TemplateHelper.GetInlineContent("mdErrorMessage", result.ServerResponseRaw);
            }

            return(result);
        }
Ejemplo n.º 3
0
        public async virtual Task <PaymentResult> ProcessPayment(PaymentModel paymentModel)
        {
            Log.Information($"ProcessPayment-Start");

            //after may be fluent validation here
            string resource = string.Empty;

            if (paymentModel.Use3DSecure)
            {
                resource = $"{EmbededDirectory}.3D.xml";
            }
            else
            {
                resource = $"{EmbededDirectory}.Pay.xml";
            }

            string embededResource = TemplateHelper.ReadEmbedResource(resource);

            Log.Information($"ProcessPayment-ReadEmbedResource");

            string viewModel = OnCompilingTemplate(paymentModel, embededResource);

            Log.Information($"ProcessPayment-CompiledTemplate");

            if (viewModel.IsEmpty() == false)
            {
                var form = GetPostForm();
                form.Content = viewModel;

                if (paymentModel.Use3DSecure == false)
                {
                    Log.Information($"ProcessPayment-HttpPost - NonUse3DSecure");

                    HTTPClient httpClient = new HTTPClient(EndPointConfiguration.BaseUrl);
                    return(await httpClient.Post(EndPointConfiguration.ApiEndPoint, form, Handler));
                }
                else
                {
                    Log.Information($"ProcessPayment-HttpPost - Use3DSecure");

                    PaymentResult paymentResult = new PaymentResult();
                    paymentResult.IsRedirectContent = true;
                    paymentResult.ServerResponseRaw = viewModel;
                    paymentResult.Status            = true;

                    return(paymentResult);
                }
            }
            else
            {
                throw new ApplicationException($"{this.GetType().Name} template is empty");
            }
        }
Ejemplo n.º 4
0
        public virtual async Task <PaymentResult> ProcessRefound(Refund refund)
        {
            var resource = $"{EmbededDirectory}.Refund.xml";

            string embededResource = TemplateHelper.ReadEmbedResource(resource);
            string viewModel       = OnCompilingTemplate(refund, embededResource);

            var form = GetPostForm();

            form.Content = viewModel;

            HTTPClient httpClient = new HTTPClient(EndPointConfiguration.BaseUrl);

            return(await httpClient.Post(EndPointConfiguration.RefundEndPoint, form, Handler));
        }
Ejemplo n.º 5
0
        public async virtual Task <PaymentResult> VerifyPayment(VerifyPaymentModel paymentModel, IFormCollection collection)
        {
            Log.Information($"{paymentModel.Order.OrderId} - VerifyPayment Process");

            var    postForm        = GetPostForm();
            var    resource        = $"{EmbededDirectory}.3DEnd.xml";
            string embededResource = TemplateHelper.ReadEmbedResource(resource);
            string viewModel       = OnCompilingTemplate(paymentModel, embededResource);

            postForm.Content = viewModel;

            Log.Information($"{paymentModel.Order.OrderId} - VerifyPayment Http Post");


            HTTPClient httpClient = new HTTPClient(EndPointConfiguration.BaseUrl);

            return(await httpClient.Post(EndPointConfiguration.SecureReturnEndPoint, postForm, Handler));
        }
Ejemplo n.º 6
0
        public async override Task <PaymentResult> ProcessPayment(PaymentModel paymentModel)
        {
            var cloneObj = paymentModel.Clone();

            string orderId = cloneObj.Order.OrderId.PadLeft(cloneObj.Use3DSecure ? 20 : 24, '0');

            if (cloneObj.Order.Installment.HasValue && (cloneObj.Order.Installment == 1 || cloneObj.Order.Installment == 0))
            {
                cloneObj.Order.Installment = null;
            }

            cloneObj.Order.Total  *= 100;
            cloneObj.Order.OrderId = orderId;

            if (cloneObj.Order.CurrencyCode.IsEmpty())
            {
                cloneObj.Order.CurrencyCode = "TL";
            }

            if (cloneObj.Use3DSecure)
            {
                string template = TemplateHelper.ReadEmbedResource($"{EmbededDirectory}.3D_before.xml");
                string postData = TemplateHelper.PrepaireXML(new ViewModel
                {
                    CreditCard    = cloneObj.CreditCard,
                    Order         = cloneObj.Order,
                    Use3DSecure   = true,
                    Configuration = ProviderConfiguration,
                    SessionId     = cloneObj.SessionId
                }, template);

                var post = GetPostForm();
                post.Content = postData;

                Log.Information("ProcessPayment - YKB Use3DSecure - POST");

                HTTPClient client = new HTTPClient(EndPointConfiguration.BaseUrl);
                var        result = await client.Post(EndPointConfiguration.ApiEndPoint, post, Handler3D);

                if (result.Status)
                {
                    cloneObj.Attributes.Add(new SanalPosTRAttribute {
                        Key = "Data1", Value = result.Data1
                    });
                    cloneObj.Attributes.Add(new SanalPosTRAttribute {
                        Key = "Data2", Value = result.Data2
                    });
                    cloneObj.Attributes.Add(new SanalPosTRAttribute {
                        Key = "Sign", Value = result.Sign
                    });
                }
                else
                {
                    return(new PaymentResult
                    {
                        Status = result.Status,
                        Error = result.Error,
                        ErrorCode = result.ErrorCode
                    });
                }
            }

            return(await base.ProcessPayment(cloneObj));
        }