Phone Number Validation - javascript

I want to validate a phone number entered by user according to his/her country which I know.
I am using PHP/Javascript/MYSQL in my site.
OR
have anybody list of mobile number format for all countries i.e. area code,country code, minimum and maximum length??

I've been using a free API called numverify.com - you can request any national or international phone number, and the API will return a simple JSON result containing validation results, country, location, line type infos, and more.

I know about a paid service from data8
I am sure there are others out there do a Google for "mobile phone validation api"

Related

Zip code validation to match City and State

Hi I have a registration form, and on the address details we require the user to input it's State, City and Zipcode.
My problem is I need to verify the Zipcode if it is the correct Zipcode on the Users State and City.
Example.
If user put's Minnesota (State), Bloomington (City) so if user puts 55437 it should be a valid zipcode. But the tricky part is that some City have multiple Zipcodes so I need to have a data for all of the Zipcode available on that City.
I tried google api geocoding but the return from the API is not consistent. Can anyone suggest on what API or package that is best for this? or Some data where I can store on my DB so that I'll have reference for all the City and Zipcodes.
You can use this data or maybe search for another free zipcode resource. Hope this helps.
https://github.com/midwire/free_zipcode_data
You could use https://www.zipcodeapi.com/. This call https://www.zipcodeapi.com/API#locToZips gives you possible zip codes for a city. There is a free version and a low cost version.

Run code once for new visitors with laravel

I am using laravel 8 and I am creating a world wide webshop.
There are 2 currencies available: usd & euro.
But how can i run code only once when a new visitor comes to my website?
What i want to do is check if someone lives in europe and set the currency to euro, otherwise set it to usd.
But this code should only run once per visitor because they can change the currency and it should not automatically transfer back to the original currency.
I'd get their IP address from the Request object, either by DI-ing in the controller method, or the helper, request()->ip(). Run the IP through a geolocation API, and log it in your database.
Might want to trigger this off creating an account though, or else have some garbage collection of older records, or else that visitor_location log could get a little cumbersome.

Accept Credit Card Payments via JavaScript

I have a Square Account. I also have a web page. On this web page, I'm collecting credit card details (name, number, expiration date, cvv). I want to charge the user an amount against the credit card details they've provided. I thought that Square had an API that allowed this. However, I don't see it. It looks like everything has to be done on the server.
Isn't there a way to securely do this from JavaScript purely on the client-side? It seems riskier to send details over the internet to a server, just to pass that information onto Square.
At this time, I have the following:
var creditCardNumber = '....';
var credidCardHolderName = 'Joe Smith';
var creditCardExpiration = '10/2020';
var creditCardCvv = '...';
var purchaseAmount = 50.50;
Is there a way to charge the purchaseAmount against the user's credit card using JavaScript on the client-side via Square? If so, how?
Thank you
You can't cut your own server out of the equation entirely. That would mean you would never get to know about the order. Money would just appear in your account.
You shouldn't be collecting credit card information though. Look at the Square Documentation for online transactions.
As part of the process, the user is redirected to Square's website where the credit card information is collected. You never need to send the credit card details to your server.
Merchant - Create a POST request: . Package the order information as a JSON message. NOTE: Currently, Square Checkout cannot calculate
shipping costs or taxes dynamically, those totals must be provided in
the POST request as line items in the order.
Add an authorization token to the header.
Merchant - Send the generated POST request to Square Checkout and process the response:
Save the returned checkout ID.
Automatically redirect the customer to the returned Checkout page URL.
Customer - Provide payment details using the Square Checkout UI.
Square Checkout - Process the transaction and sends email confirmation to merchant and customer.
Merchant - Verify the transaction results.
To process the payment you probably need to send some API credentials which wouldn't be safe to show on your frontend. That's why you may need some backend for that.
And of course you would allow customer to change the payment amount, which usually isn't OK.
Square documentation has got few nice diagrams and images showing how their API works and how to understand integrating it, e.g.
Take a look at "Get started" guide on their website, especially how it works.
Unfortunately, I am unable to find the specific documentation you would need to do this. It appears you need to log into the developer portal using your account credentials. If you are unable to find the documentation you need then you should reach out to Square support. That being said, I can give you some basic guidance.
DO NOT store any credit card information in your website. Do not store in javascript variables, send to your sever, or store them in any database. There is specific code Square will have you use that keeps that data secure and ensures it only ever is shared with Square.
Try digging around in the documentation of the product you're trying to use. What you are trying to accomplish should be found in some kind of "Setup" or "Get Started" type documentation that will be prominently displayed.

Is there any way to find phone number from string?

I am stack to finding a filter or any way to find a phone number from string. Actually I get a response in string and there is a phone number too and client want to make link because of smart-phone when user tab on it. it's goes to call directory.
here is client request to do with response.
"Low priority but could we make it so that the phone number is a hyper link so the user can press and it goes to make call.
I.e.
0035312998080
Or
+35312998080"
here is a test response.
Unable to process this booking online it is too close to the party date. To book please phone Fun Fitness - Play Centre on 353 - 1 - 2998080
Why do you need to find it? It's right there...
To make it callable:
555-555-1212
Stolen from How to create hyperlink to call phone number on mobile devices?

what would i need in order to build a price look up service or a price comparison service?

What id need it to do is login in to another websites account and look up prices for items as it applies to that user. this is because the users may have specific contract deals that gives them cheaper prices. id then need to show all of the results side by side and maybe link to the company offereing the price but it wouldn't have to do anymore than that (like buying etc). I am familiar with HTML, CSS and PHP, but please tell me if i need to learn another language, frameworks i can start with etc. thanks.
You will have to check with "another website" about availability of API for finding the information you need.
Generally, if API is available - you will be able to get the profile or account info, to find out a group of the user (if the discounts are provided to the groups, like "beginner" get 5%, "advanced" get 10% rates), or activity (make 500 posts on the forum - get 10%, buy 10000$ worth of products within a year - get 15% discount) and etc. After that you might get another API function to use which will give you the product info and price actual for the user.
If API is not available, you will need to find out what is available.
Worst way in terms of work required for programming and etc - you have to use pure PHP or perhaps some browser imitating library to manually authorize with your users's login and password, store session and browse the "another website". But a question here - will your users provide you with their login and password for "another website"??
At this point it isn't a PHP, Javascript or anything else question. It is a question of how you can get your data.

Categories