Beispiel #1
0
        /// <summary>
        /// Handles the tokenize postback.
        /// </summary>
        private void HandleTokenizePostback()
        {
            Rock.Financial.HostedGatewayPaymentControlTokenEventArgs hostedGatewayPaymentControlTokenEventArgs = new Financial.HostedGatewayPaymentControlTokenEventArgs();

            var tokenResponse = PaymentInfoTokenRaw.FromJsonOrNull <TokenizerResponse>();

            if (tokenResponse?.IsSuccessStatus() != true)
            {
                hostedGatewayPaymentControlTokenEventArgs.IsValid = false;

                if (tokenResponse.HasValidationError())
                {
                    hostedGatewayPaymentControlTokenEventArgs.ErrorMessage = tokenResponse.ValidationMessage;
                }
                else
                {
                    hostedGatewayPaymentControlTokenEventArgs.ErrorMessage = tokenResponse?.Message ?? "null response from GetHostedPaymentInfoToken";
                }
            }
            else
            {
                hostedGatewayPaymentControlTokenEventArgs.IsValid      = true;
                hostedGatewayPaymentControlTokenEventArgs.ErrorMessage = null;
            }

            hostedGatewayPaymentControlTokenEventArgs.Token = _hfPaymentInfoToken.Value;

            TokenReceived?.Invoke(this, hostedGatewayPaymentControlTokenEventArgs);
        }
Beispiel #2
0
        /// <summary>
        /// Lbs the submit click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void _lbSubmit_Click(object sender, EventArgs e)
        {
            PaymentInfoToken = "token_" + Guid.NewGuid().ToString("N");
            Rock.Financial.HostedGatewayPaymentControlTokenEventArgs hostedGatewayPaymentControlTokenEventArgs = new Financial.HostedGatewayPaymentControlTokenEventArgs
            {
                Token   = this.PaymentInfoToken,
                IsValid = true
            };

            TokenReceived?.Invoke(this, hostedGatewayPaymentControlTokenEventArgs);
        }
Beispiel #3
0
        public void ReceiveToken(Uri uri)
        {
            if (string.IsNullOrEmpty(uri.Fragment))
            {
                throw new Exception($"Received weird URI: {uri}");
            }
            var arguments = uri.Fragment.Substring(1).Split("&")
                            .Select(param => param.Split("="))
                            .ToDictionary(param => param[0], param => param[1]);

            if (arguments["access_token"] == null)
            {
                throw new Exception($"No access token found in URI: {uri}");
            }

            TokenReceived?.Invoke(this, arguments["access_token"]);
        }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (this.Page.IsPostBack)
            {
                string[] eventArgs = (this.Page.Request.Form["__EVENTARGUMENT"] ?? string.Empty).Split(new[] { "=" }, StringSplitOptions.RemoveEmptyEntries);

                if (eventArgs.Length >= 1)
                {
                    if (eventArgs[0] == this.ID)
                    {
                        TokenReceived?.Invoke(this, new EventArgs());
                    }
                }
            }
        }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (this.Page.IsPostBack)
            {
                string[] eventArgs = (this.Page.Request.Form["__EVENTARGUMENT"] ?? string.Empty).Split(new[] { "=" }, StringSplitOptions.RemoveEmptyEntries);

                if (eventArgs.Length >= 2)
                {
                    // gatewayTokenizer will pass back '{this.ID}=TokenizerPostback' in a postback. If so, we know this is a postback from that
                    if (eventArgs[0] == this.ID && eventArgs[1] == "TokenizerPostback")
                    {
                        Rock.Financial.HostedGatewayPaymentControlTokenEventArgs hostedGatewayPaymentControlTokenEventArgs = new Financial.HostedGatewayPaymentControlTokenEventArgs();

                        var tokenResponse = PaymentInfoTokenRaw.FromJsonOrNull <TokenizerResponse>();

                        if (tokenResponse?.IsSuccessStatus() != true)
                        {
                            hostedGatewayPaymentControlTokenEventArgs.IsValid = false;

                            if (tokenResponse.HasValidationError())
                            {
                                hostedGatewayPaymentControlTokenEventArgs.ErrorMessage = tokenResponse.ValidationMessage;
                            }
                            else
                            {
                                hostedGatewayPaymentControlTokenEventArgs.ErrorMessage = tokenResponse?.Message ?? "null response from GetHostedPaymentInfoToken";
                            }
                        }
                        else
                        {
                            hostedGatewayPaymentControlTokenEventArgs.IsValid      = true;
                            hostedGatewayPaymentControlTokenEventArgs.ErrorMessage = null;
                        }

                        hostedGatewayPaymentControlTokenEventArgs.Token = _hfPaymentInfoToken.Value;

                        TokenReceived?.Invoke(this, hostedGatewayPaymentControlTokenEventArgs);
                    }
                }
            }
        }