Stripe checkout embedded form response - httpresponse

I am use stripe embedded form for checkout
<script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="{!! env('STRIPE_PK') !!}"
data-amount="{{$total*100}}"
data-name="LaravelShop.IO"
data-description="Products"
data-image="/128x128.png"
data-locale="auto">
</script>
My question is how I can display error returned from https://api.stripe.com/v1/tokens after clicking Blue Payment Button.
Any link or code snippet.
Thanks

You can't. If the token creation fails, the Checkout form itself will handle the error and the form will not be submitted.
Depending on the reason for the failure, a message will be displayed and certain fields will be highlighted in red.

Related

validation does not work in popup form values in magento

I am using Ajax for sending data on controller. Here I use TinyMCE editer in my popup form and I need to validate it. But here validation does not work properly in Magento.
Yes you should clarify more on this.
By the way wherever you have put your form in popup give it an ID like and in your form if you have text boxes then put class 'required-entry' in all required textboxes and you should have one submit button.
Then finally put this script after form :
<script type="text/javascript">
//<![CDATA[
var popupForm = new VarienForm('popupform', true);
//]]>
</script>
See how it goes.

codeignighter redirect issues to refresh

I have a registration page.after completing the registration the user will redirect to a new page. In new page when I click the back button I redirect to last page with last data filled up.how to refresh the page to delete form data. The framework is codeignighter.
To refresh or redirect page in codeigniter there is function redirect(YOUR_URL).
Have a Look in Helper class for more details
If you are referring to browser back button keep autocomplete off for the form fields in your first form
You can use autocomplete for the complete form
<form action="/action_page.php" autocomplete="off">
Or specifically to each control as
<input type="email" name="email" autocomplete="off">
You can also make it on for specific controls/entire form if you need it
if your problem still persists you could use
<body onload="document.refresh();">
This shall refresh the page on loading for the first time
include this in your page if required to force reset the form on load if you need you can bind this with a javascript onload function
<script type="text/javascript">
document.getElementById("myForm").reset();
</script>
in case of application back button {if used with href or redirect()}
Shall keep form clean even if autocomplete is not set unless the user takes from browser autofill or you fill them with code

Radbutton Onclick mozilla bug

When i click a radbutton then postback changing page url as /blabla.aspx?btnMsg_ClientState=&btnCarDetails=Sorgula&btnCarDetails_ClientState=&btnPrice_ClientState=&btnReject_ClientState=# ..
First pop-up work but then break.
There are 5 extra buttons and seems all in page url. Where is coming these query strings ?
Ie Developer tools says:
ScriptResource.axd...
I cant find solution, please help.
It appears that the form on your page is configured to use a GET request when submitted.
<form id="form1" runat="server" method="get">
In this case all parameters on the page are specified as part of the URL, which includes the input elements that are used for rendering the button, as well as the other input elements on your page.
You can change this behavior by setting the method attribute of the form to post, so that a POST request is utilized for submitting the form.
<form id="form1" runat="server" method="post">
In this case the parameters will be passed in the message body of the HTTP request.

Refresh Captcha Image on JQUERY Dialog

I've a jquery model dialg box below. When user clicks on one of the link on page, the dialog box appears with Captcha. When user enters the invalid captch the captch image should be refreshed and should show new text. But this is not happening. Below is the code snippet:
<div id="model">
<img id="captchaImage" src="#Url.Content("~/CaptchaImage.ashx?text=" + ViewBag.EncryptedCaptcha)" />
<input id="captchText" type="text" value="" />
Validate
</div>
When user clicks on Validate, the text is sent to MVC controller via $.getJSON. The controller returns back isCpatchValid and encryptedText wrapped in JSON object Captcha. I've a done below if
the captcha text is not valid:
$("#captchaImage").attr("src", "~/CaptchaImage.ashx?text=" +
Captcha.encryptedText);
On Chrome debugger I can see the controller is returning a correct encrypted text. But this line above doesn't deem to fresh the captch image. I suspect this is due to async call.
COuld someone please help me with how to refresh the captcha image on Jauery Dialog box.
You can't use the "~" feature in javascript. That's a .NET thing. You'll need to wrap it around a .NET call, like:
attr("src", "#Url.Content("~/CaptchaImage.ashx")?text=" + Captcha.encryptedText)
Or if this JS is in a separate file, you can define a variable back on the view, then use it in the JS file, like:
** in the view **
var CAPTCHA_IMAGE_URL = "#Url.Content("~/CaptchaImage.ashx")";
** in the JS file **
attr("src", CAPTCHA_IMAGE_URL + "?text=" + Captcha.encryptedText)

Executing Javascript functions from an AJAX - HTML response

I have a web page that displays comments, and users can click a 'Flag' link to report an inappropriate comment.
When they click the Flag link, I use AJAX and innerHTML to display a dropdown box underneath the comment with a reason code, e.g. Spam, Offensive, Unrelated to topic, etc., as well as a Cancel button.
If the user clicks Submit, I want to use another AJAX request to send their response to a PHP file, where the database is updated, and they receive a "Thank you" on their end (without reloading the page). I essentially want the DIV that displays the dropdown box to be replaced with "Thank you" using another AJAX request.
That's where the problem is. It seems that I cannot execute an AJAX request from within the HTML response from the first AJAX request. The JavaScript functions fail -- even a simple Alert('hello world') doesn't work. I tried placing the JavaScript functions in the main page that calls the first AJAX request, as well placing it in the PHP file that displays as the HTML response from the first AJAX request, but I did not have any luck -- the functions just do not run when they are called.
Everything works fine if I load the PHP file externally, so I know the JavaScript is correct. It just doesn't work when I load the PHP file into the HTML response DIV and then call the JavaScript from there.
So to sum everything up, how do you execute JavaScript functions from the HTML response of an AJAX request?
EDIT: here is a sample of what I want to do:
This is the AJAX part that populates the DIV when the person clicks the Flag link:
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4)
{
document.getElementById(whichdiv).innerHTML=xmlhttp.responseText;
}
};
The value of xmlhttp.responseText comes from this external file:
<input type="hidden"/>
<script type="text/javascript" language="javascript">
function displayalert()
{
alert ('Hello World!');
}
</script>
<form name="myform" id="myform">
<input type="text" name="myfield" value="teststring"/><br/>
<input type="button" name="button" value="Submit"
onclick="displayalert();"/>
</form>
Note: the <input type="hidden"/> above comes from a suggestion I found off of http://msdn.microsoft.com/en-us/library/ms533897%28VS.85%29.aspx.
When the user clicks the button, the javascript displayalert() function doesn't run. The alert box never pops up. If I load the file externally instead of calling it with innerHTML, the script works fine.
Can the xmlhttp.responseText contain JavaScript code?
depends on the browser:
IE doesnt support scriptEval on html that is loaded with ajax, which means that if you have script blocks in your html, they wont be called.
Firefox supports script eval.
What i usually do is shove some json into an input, then check if the browser supports scriptEval, if it doesnt, pull the json, eval it, and call some method passing json.
if the browser supports scriptEval, i also include a script block that contains a call to the same method with the json.
you may also want to read this:
http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html

Resources