I have been trying to integrate stripe payment in laravel.
But when i try to create a customer in stripe,it won't created.
Here is my code,
try
{
$customer = \Stripe\Customer::create(array(
'email' => $this->user_email,
'card' => $this->stripe_token
));
echo "<pre>";
print_r($customer);exit;
$charge = \Stripe\Charge::create(array(
'customer' => $customer->id,
'amount' => $amountstripe,
'currency' => 'EUR'
));
}
I got an error message like,
Could not connect to Stripe (https://api.stripe.com/v1/customers). Please check your internet connection and try again. If this problem persists, you should check Stripe's service status at https://twitter.com/stripestatus, or let us know at support#stripe.com.
(Network error [errno 6]: Could not resolve host: api.stripe.com)
How can i resolve this problem?
This is not an error with Laravel or Stripe, but "simply" a network error. Your server cannot send requests to Stripe's API because it cannot resolve the hostname api.stripe.com to an IP address.
You'd need to get in touch with your network administrator or hosting provider and ask them to check the connectivity between your server and Stripe's. The following script may be helpful in diagnosing the issue: https://github.com/stripe/stripe-reachability#stripe-reachability
Related
Note this
It's a single ajax request.
As you can see, I wrote the duration in the result, it's the duration of all the queries executed in the api backend.
The Response length is 11 KByte, so it's not a response weight problem.
But as you can see the server is serving the page is 5 seconds.
I'm using nginx, and on this server (it's a single project dev VPS), there is NO trafic, no concurrency problems.
The backend is made in laravel 8 and it's doing only this:
$start = microtime(true);
$data = $this->articleRepository->getProducts($request->all());
$duration = microtime(true) - $start;
return response()->json([
'status' => 'success',
'data' => $data,
'debug' => [
'duration' => $duration
]
]);
I tried to replace laravel magics with
$json = json_encode([
'status' => 'success',
'data' => $data,
'debug' => [
'duration' => $duration
]
]);
return $json;
But it's taking same time. So I think that is a problem at server side.
By the way, please note that dev VPS is a debian 11 machine in my local network. We already verified that up/down band is well over 350Mbits/secs, symmetric, and stable.
I cannot diagnose it, I have root access to VPS, but I've no idea of what could causes so much slowness
Any idea?
In this very specific case, it was a question of DNS. "localhost" resolution are causing a series of problems and latencies. We moved all pointing from 'localhost' to 127.0.0.1 and ALL is resolved.
Note for future Googlers for Laragon and/or Xamp developers: we discovered accidentally that changing localhost to 127.0.0.1 when configuring redis in the laravel .env variabile fixes a huge amount on a windows machine when using both Laragon and Xamp
I am trying to connect my app to facebook login with Laravel and socialite package.But i don't know why facebook show me this error. I searched internet but i couldn't find anything .How can i fix this error ?
I thought that if i make my connection with https it will work but after making https again error appears.
My code in laravel:
web.php
Route::get('login/{provider}', 'SocialController#redirect');
Route::get('login/{provider}/callback','SocialController#Callback');
SocialController.php
public function redirect($provider)
{
return Socialite::driver($provider)->redirect();
}
public function Callback($provider){
$userSocial = Socialite::driver($provider)->stateless()->user();
$users = User::where(['email' => $userSocial->getEmail()])->first();
if($users){
Auth::login($users);
return redirect('/');
}else{$user = User::create([
'username' => $userSocial->getName(),
'email' => $userSocial->getEmail(),
'provider_id' => $userSocial->getId(),
'provider' => $provider,
]);
return redirect()->route('home');
}
}
You can do "Create Test App" and replace your App ID and Secret using the test app.
The simple answer is - Facebook will send sensitive data to provided redirect_uri, so it is ensuring this connection is private, by forcing you to use valid SSL.
As long as you do not setup a valid domain with proper certificate, Facebook won't let you use production API.
It looks like time expiration. I've just created another Facebook app and it works without that error.
You can use ngrok to make your localthost https.
download and run ngrok.exe.
Then run command ngrok.exe http {port}. In most cases, it will be 8000.
In case of angular : try to serve your app in secured socket layer true mode as Facebook is detecting insecure connection
Use the following command:
ng serve --ssl true
I've been following the Laravel Mail docs https://laravel.com/docs/5.4/mail to send email via a SparkPost account. When I try and send I'm getting
ClientException
Client error: `POST https://api.sparkpost.com/api/v1/transmissions` resulted in a `401 Unauthorized` response:
{"errors": [ {"message": "Unauthorized."} ]}
As per the docs I've got the sparkpost key in config/services.php and though the docs don't mention anything about it (why not!?) a bit of Googling convinced me to set the mail driver etc. in my .env file. I then have a web route to check the config being used,
Route::get('test', function()
{
dd(Config::get('mail'));
});
which gives
array:9 [▼
"driver" => "sparkpost"
"host" => "smtp.sparkpostmail.com"
"port" => "587"
"from" => array:2 [▶]
"encryption" => "tls"
"username" => "my-sparkpost-account-login-email-address"
"password" => "my-sparkpost-account-login-password"
"sendmail" => "/usr/sbin/sendmail -bs"
"markdown" => array:2 [▶]
]
I actually want to use a mailable and views which I've set up, but just to test the sending I bypassed these and set the following route to test:
Route::get('/sparkpost', function () {
Mail::send('emails.test', [], function ($message) {
$message
->from('marketing#my-sparkpost-sending-domain.com', 'Me')
->to('my-email-address', 'My-Name')
->subject('A Test Email');
});
});
which got the error at the top (testing with my mailables and views gave the exact same error which makes me think they are correctly set up - assuming the above test route is correct).
The on thing I'm wondering about is I'm testing on my local machine, so test URL is http://localhost/seg/public/sparkpost - I'm wondering if this is tripping SparkPost up (i.e. do I have to actually be sending from a server running at the same domain as the sending domain configured in sparkpost, or is it just the sending address in the email that has to match?)
Thanks for any suggestions!
if you use smtp driver,
You need go to Account > SMTP Relay to get credentials for SMTP,
it's not your sparkpost account credentials.
if you use sparkpost driver,
you need put api key of sparkpost into config/services.php, there is no need to input smtp username and password if you use sparkpost driver
i have some probleme using swiftmailer for setting my confirmation email, normaly everything is set well, but the mail is not sent, and i have my user in my database (but enable is set to 0 of course).
Since i don't have errors show by symfony i suppose it's my gmail account that blocked them, but i already set it to allow other application to use it as a "server", and i have a page that use swiftmailer to send normal mail, and it work fine.
i'm lost, thanks for your future help
My config.yml :
swiftmailer:
transport: %mailer_transport%
host: %mailer_host%
username: %mailer_user%
password: %mailer_password%
encryption: ssl
fos_user:
db_driver: orm
firewall_name: main
user_class: UserBundle\Entity\User
service:
mailer: fos_user.mailer.default
registration:
confirmation:
enabled: true
from_email:
address: maxime.duvey#gmail.com
sender_name: Registration mail
My config.yml :
mailer_transport: gmail
mailer_host: 127.0.0.1
mailer_user: maxime.duvey#gmail.com
mailer_password: XXXXXXXXXXX
i'm really lost, i don't understand why it don't work
It might be because you have to turn on "Less Secure Apps" as gmail allows doesn't allow you to access logins unless it is a secure app that they provide. This can be found in you google admin console.
See the link here for more info
I had the same problem when using PHPMailer.
However if you do decide to turn it on, it is not recommended.
They mention this in the link provided.
now that i think of it, it's maybe my manner to add a new user to my database :
my controler :
$userregister = new User();
$formregister = $this->get('form.factory')->createBuilder(FormType::class, $userregister);
$formregister
->add('firstname', TextType::class)
->add('lastname', TextType::class)
->add('email', EmailType::class)
->add('phonehome', NumberType::class)
->add('phoneportable', NumberType::class)
->add('username', TextType::class)
//->add('Password', PasswordType::class)
->add('plainPassword', RepeatedType::class, array(
'type' => PasswordType::class,
'first_options' => array('label' => 'Password'),
'second_options' => array('label' => 'Repeat Password'),
))
->add('submit', SubmitType::class);
$form = $formregister->getForm();
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid())
{
$em = $this->getDoctrine()->getManager();
$em->persist($userregister);
$em->flush();
$request->getSession()->getFlashBag()->add('notice', 'Annonce bien enregistrée.');
return $this->redirect($this->generateUrl('Contact_Action', array('id' => $userregister->getId())));
}
return $this->render('register.html.twig', array('form'=>$form->createView()));
and my twig :
{{ form(form) }}
i'm not sure, maybe
I am trying to create an email notification system with CI. The problem is the system on which I am working on has blocked gmail. So, i am unable to use the gmail SMTP. Now, I have to figure out a way to send emails with hotmail or any other SMTP services.
Here is my code which worked for gmail but now for hotmail
config/Email.php:
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.live.com',
'smtp_port' => 587,
'smtp_user' => 'muttalebr#hotmail.com',
'smtp_pass' => 'XXXXXX',
'charset' => 'utf-8',
'newline' => "\r\n",
'crlf' => "\r\n",
'mailtype' => "html",
);
the actual function that calls the email.php and send the email:
function sends($from,$to,$send,$user){
$link=base_url()."index.php/anonymouscoll/cmembersarea/".$user;
$emailmessage="Hello $to,<br />You have a new Gift from $from.<br />Click on the link:<a href=$link>$link</a> to check your gift.<br /><br /><br />Best Regards<br />Online Communication.";
$this->load->library('email');
$this->email->from('muttalebr#hotmail.com','Gift File');
$this->email->to($send);
$this->email->subject('You have a new Gift');
$this->email->message($emailmessage);
if($this->email->send()){
echo "Email sent";
}
else{
show_error($this->email->print_debugger());
}
Each time i call the ‘sends’ function i get the below error:
Severity: Warning
Message: fsockopen() [function.fsockopen]: SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
Filename: libraries/Email.php
Line Number: 1673
and
Severity: Warning
Message: fsockopen() [function.fsockopen]: Failed to enable crypto
Filename: libraries/Email.php
Line Number: 1673
I have also tried with
‘smtp_host’ => ‘sslv2://smtp.live.com’,
but it just wont work on my local machine.
I am using windows 7 on my local machine and windows Xp for the system I will use the application[the one which blocked gmail]. I tried with both XAMPP ver 1.8.1 and WAMPP ver 2.2
Looking forward for your responses
~muttalebm
The error because you didn't enable SSL in your php.info file. SO search how to enable to it . Otherwise you can look into my answer to the question in the below link which is same liek this. I faced this error when i am doing and i resolved it.
Reference Link
Which version of PHP are you using?
There is apparently a bug in fsockopen ssl in some versions:
https://bugs.php.net/bug.php?id=54511