Braintree - Form validation before opening the lightbox - braintree

This is the first time I am implementing Braintree.js, I am using "Add PayPal button" approach to display the PayPal button on the page. Once the PayPal button is generated (by passing braintree token) I need to invoke some Ajax function to validate the form fields and once these are validated then only want to open the PayPal lightbox and get the nonce value after the final submit on the lightbox. How do I implement the ajax call using the braintree generated "PayPal" button BEFORE opening the lightbox. Any help would be greatly appreciated. Thanks in anticipation.

Currently there is not a callback that fires before the PayPal lightbox or popup opens.
Correct me if I'm wrong, but it sounds like you want to use the PayPal button as your form's submit button, which is not that button's intended function. Using Braintree's PayPal integration returns a nonce which you can then submit along with rest of your form as a separate action. When a user submits the form, you can validate that your form fields are valid, and that a nonce has been successfully generated before submitting it.
For a more in-depth description of integrating with PayPal visit Braintree's PayPal Guide.
Let me know if you have any other questions.

Related

How to handle Stripe payment failure via AJAX, with standard page load for success? (using Laravel backend)

I've got a long and fairly complex form for a booking system that a user fills in, then pays using Stripe Checkout. I'm trying to figure out the best solution to both handle payment failure easily (so submitting form over AJAX so I don't have to try and regenerate the whole booking form with all the data the user's entered), whilst also handling payment success gracefully (so with a new page showing a booking summary and a different URL so if user clicks reload button in their browser it doesn't just take them back to the search results and booking form again)
I'm using a mixture of Laravel 5.4 and JS/JQuery to generate the booking form on the front end, and after Stripe Checkout (I'm using their standard simple integration pop up) it submits all the form + Stripe token etc back to a POST route in my Laravel backend. In my controller, I then try and charge the credit card using standard Stripe API and process the booking details into my database, and then return a Laravel view from a Blade template thus giving the user a different page and URL. As mentioned I want to switch the form submission to AJAX so payment failure can be handled easily (i.e. their big filled in form doesn't disappear, and just an alert pops up to user so they can try and enter a new card into the Stripe Checkout). That bit's fine, I'll just use this: https://stackoverflow.com/a/34099169/4059141 but then in payment succeeds I basically want the same behaviour as if I'd done a regular form POST, so the new page being displayed with a new URL.
I can generate and pass back the rendered HTML from the blade template over AJAX no problem, but that leaves the original URL in the browser's address bar, so if they hit reload on the booking summary they'll just see the search results page and blank booking form again - not what I want.
Any thoughts on a solution are welcome! Thanks

Subscribe to newsletter, mailchimp

Is it possible to have single button on website that leads user to MailChimp subscribe form that is not physically on that website? Like for example MailChimp "Thank you" page.
Go to MailChimp Dashboard.
Select the list that you want to setup the subscriber form.
Go to 'Signup forms'
Select 'General forms'
Build the form and copy 'Signup form URL'
Use the URL in your website, which leads anyone to the subscription form of your MailChimp list.

WooCommerce Paypal Form Won't Submit

Hey I customized my woocommerce checkout form to post some hidden input values to paypal instead of doing an ajax post but somehow the ajax post is overriding the normal post and sending its own value to paypal. Can someone help me with this issue please. The form is at...
http://www.dreamhomevacationrentals.com/hotels/spanish-modern-retreat/
Click "Availability" on the left and then click "Book Now" and fill in some dummy data to get to the cart page and then click "proceed to checkout" to see the paypal form.
~Alex

MVC4 Remote Validation clashes with submit button

I have a remote validator setup on my text box which primarily checks if the data that the user enters is unique. I do understand this works on mouse out of the original control and does an AJAX call for the same.
My problem is that while this works fine while am tabbing between controls on my form containing like 6 other controls, if I am directly clicking on the submit button on my form, the request does not go across since the AJAX call for the remote validation is in progress, and the user would in this scenario have to click on the submit button twice to actually save the form.
Anyone come across this scenario?
I would suggest, leave your button disabled; and only enable if all of your validations have been passed. This way, your button will only be enabled once you have got the response back from the remote validation.

What is an accepted way to submit form data to sites like paypal?

I'm setting up a website that uses paypal to process payments.
The easiest way to implement the checkout form would be to create an HTML form that submits directly to paypal, sending the order details and redirecting the user to paypal in order to finalize the transaction.
However, there is a security vulnerability with this process. The client could edit the information submitted to paypal, such as changing the price of the checkout to $0.00.
What is an accepted way to handle this type of situation? Is it to submit the form back to my server, then do some processing in PHP, then submit verified data to paypal and redirect the user to paypal? Is this possible?
Thanks!
There are two main ways to handle this issue.
The first is somewhat like what you outline: You send the filled in form to PayPal, and provide a callback-url. When PayPal has processed the payment, they will call your provided url, and you can check whether or not the information given in that call is the same as what you provided. For this to work, you need to store the information in the meantime, like in a database. You will then only give access to the product after the validation has happened.
You can also encrypt the information you send to PayPal, making it practically impossible to alter information in your form.
See https://www.x.com/developers/paypal for details.

Resources