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);
        }
        /// <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);
                    }
                }
            }
        }