Stripe payment ssl protocol error WordPress - wordpress

We have used stripe payment using PHP. It works on the local machine but in live server, it's not worked as expected. We shared the code which we used and also attached the screenshot of the error. Not sure where we made the mistake, can you guide us?
Stripe Code :
require_once('Stripe.php');
Stripe::setApiKey('secret key');
echo '<form action="" method="post">
<script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="publish key"
data-description="Access for a year"
data-amount="5000"
data-locale="auto"></script>
</form>';
if($_POST) {
$token = $_POST['stripeToken'];
$customer = Stripe_Customer::create(array(
'email' => 'customer#example.com',
'source' => $token
));
$charge = Stripe_Charge::create(array(
'customer' => $customer->id,
'amount' => 5000,
'currency' => 'usd'
));
echo '<h1>Successfully charged $50.00!</h1>';
}
Local Machine
Live Server

1) It looks like potentially you haven't copied the data folder that comes with the stripe php bindings over to your server --- this contains the ca-certificates.crt file referenced in the failed loading cafile error. Make sure this folder is present on your server and see if that resolves the issue!
2) If you continue to have trouble the issue may involve an inability of your server to communicate over TLS 1.2 to Stripe. From your syntax it looks like you are using an older version of Stripe's PHP library so you'll want to use the second sample here to test that.
You can also run a test script like this to help determine your libcurl and openssl versions, if curl is able to make TLS 1.2 connections in the first place. If you need to upgrade curl and openssl some helpful advice is here. You can also chat with your sysadmin or web host on the matter.

Related

Unable to send mail (Wordpress and AWS)

Context:
I am using Amazon Web Services to build and run a Wordpress site.
Issue:
The problem I have is with sending e-mails from the site. I also installed the plugin "Post SMTP". The error message I am getting is "Email could not be resent. Error: Unable to send mail. ".
What I tried so far:
I reached out to AWS and they wrote me to use Amazon SES service. I have created and configured an identity on SES. The issue is still there.
I don't know where to look anymore. Can anyone help who faced same or similar issues?
Thanks!
Check if the phpmail function is working properly. You can use the following code to check it.
<?PHP
$sender = 'someone#somedomain.tld';
$recipient = 'you#yourdomain.tld';
$subject = "php mail test";
$message = "php test message";
$headers = 'From:' . $sender;
if (mail($recipient, $subject, $message, $headers))
{
echo "Message accepted";
}
else
{
echo "Error: Message not accepted";
}
?>
Create a php test file using a text editor and save it e.g. as test.php
Change the $sender and $recipient in the code.
Upload the php file to your webserver.
Open the uploaded php file in your browser to execute the php script.
The output show either "Message accepted" or "Error: Message not accepted".
If it's showing "Error: Message not accepted"Tell your provider that the standard php "mail()" function returns FALSE.
It's recommended to include the used php test script to show your provider, that the problem is not caused by the php script used.

Unable to rename directory using Google Cloud SDK getting 404: No such object:buket/olddirname

I am trying to rename a directory of google cloud using the SDK. I am getting error message of 404 No such object:buketname/previousDirName. Renaming a file works fine but only facing issue in renaming folder.
Here is the code i am using:
if(file_exists(dirname(__DIR__) .'/vendor/autoload.php')){
$selected_bucket = 'BucketName';
$key_file = dirname(__DIR__).'/authkey.json';
$client = new StorageClient([
'keyFilePath' => $key_file,
]);
$bucket = $client->bucket($selected_bucket);
$endpoint = 'https://storage.googleapis.com/'. $selected_bucket;
if(isset($subfolder)){
$adapter = new GoogleStorageAdapter($client, $bucket, $subfolder.'/'); // code to list specific subfolder of the bucket
} else {
$adapter = new GoogleStorageAdapter($client, $bucket);
}
$filesystem = new Filesystem($adapter, Array ( "url" => $endpoint ));
// rename a file
$filesystem->rename('filename.txt', 'newname.txt'); // works fine
// rename a directory
$response = $filesystem->rename('developer', 'developer123');
print_r($response);
die();
}
I tried to debug in the sdk but nothing found. I searched the issue if someone faced the same issue but didn't found any working solution. I found one but the solution was in gsutil.
Please please suggest me what I am missing in case of renaming directory.
Thanks
Google Cloud Storage does not not have the concept of "folder", there are only buckets that contain storage objects (flat namespace) and the meaning of "/" is really imposed by clients (and client libraries). As such, folders can't be renamed atomically and thus you would need to rename each of the contained files, by using the gsutil mv command as you have already figured out, like:
gsutil -d mv gs://my-bucket/folder1 gs://my-bucket/folder2
The -d option will cause it to output the sequence of requests gsutil generates to do the rename and additional debug info needed.
In addition, you could try using the -I option, which reads the file list from stdin and is supported with the mv command, as stated here.
Here you may find an example of code samples as well.

Lando has trouble accessing a URL from a non-Lando app on my system

My company has software that runs within Docker on my system, but is not using Lando. This software is serving some data via the URL:
http://local.relay.cool:8081/clicks-bff/api/ads/
I can hit this URL in an anonymous browser, cURL it from the terminal, and load it via Postman and it returns the expected data.
I'm running Lando with the Wordpress recipe and I'm developing a plugin. This plugin can hit external URLs and retrieve data, I've tried with several different ones just to confirm.
However when Lando attempts to hit the URL listed above I get a WP_Error:
object(WP_Error)#1269 (2) { ["errors"]=> array(1) { ["http_request_failed"]=> array(1) { [0]=> string(58) "cURL error 28: Resolving timed out after 5514 milliseconds" } } ["error_data"]=> array(0) { } }
Here's the .lando.yaml config block:
name: my app name
recipe: wordpress
config:
webroot: wordpress
Is there some configuration option that I'm missing to allow Lando access to another URL on my machine?
From your question, it sounds like the URL you're trying to access is running on a non-Lando docker container on your machine.
This means routing from your Lando instance to the service will be a bit different that usual. You should be able to accomplish this the same way you would access localhost endpoints. As explained in this Lando issue on GitHub, you must use the $LANDO_HOST_IP environment variable to route to local services.
Since your containers are all running inside of a light hyper-v instance you'll need to know the hostname or IP of the host machine. Generally we set $LANDO_HOST_IP to your computer . . .
So try something like this (assuming you're using PHP's curl):
curl_init('http://' . $_ENV["LANDO_HOST_IP"] . ':8081/clicks-bff/api/ads/');

Laravel 5.3 + Passport: always unauthenticated error

I'm always receiving "Unauthenticated error" when using Passport in my current project. That's what I did the lasts 3 days:
Install and configure Passport (as docs says)
Request a token (password grant token) with Postman
Request a protected route (auth:api middleware) with the token
Get
`{ "error": "Unauthenticated." }`
Search and search and research
Get
`{ "error": "Unauthenticated." }`
Then, I've installed a fresh L5.3 and a fresh DB and works fine. Even with my current DB!
I've tried all the solutions that I found without success ...
Can anyone help me? Any idea would be appreciated.
Thanks.
I had the same problem as you and looked everywhere to find a solution.
It appeared to be Apache's fault in my case. Apache was deleting the header "Authorization: Bearer TOKEN_HERE" so the auth:api wouldn't work as expected (getting 401 unauthorized).
We ended up trying adding to our .htaccess:
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
And it magically worked.
I really hope it helps, we spent a whole day trying many solutions, this is the one that worked for us.
Which grant_type have you used to generate this token?
Possible resolutions are as follows
1: If you are using client credentials to generate your access_token, you have to turn on client_credentials, middleware as follows.
1.1 Add to the routeMiddleware in \App\Http\Kernel.php
'client_credentials' => \Laravel\Passport\Http\Middleware\CheckClientCredentials::class,
1.2 Use 'client_credentials' middleware in your route too.
Route::group(['prefix' => 'v1','middleware' => 'client_credentials'], function () {
// Your routes here
});
2: For Grant Type Password
2.1 : Create a Password Grant Client
php artisan passport:client --password
2.2 : Request A token with following header fields
'grant_type' => 'password',
'client_id' => 'client-id',
'client_secret' => 'client-secret',
'username' => 'taylor#laravel.com',
'password' => 'my-password',
End point /oauth/token
The token you get now should give you access to your api.
My problem was an omision, I'm building a GraphQL api and in the middleware line at the configuration file "graphql.php" I put
'middleware' => ['auth'],
when the correct way is:
'middleware' => ['auth:api'],
check your user model has
use Laravel\Passport\HasApiTokens;
instead of
use Laravel\Sanctum\HasApiTokens;
and used HasApiTokens as a trait;

Metoer not running

I did the following:
meteor create simple-todos
cd simple-todos
meteor --port 3030
[[[[[ ~/simple-todos ]]]]]
=> Started proxy.
=> Started MongoDB.
=> Started your app.
=> App running at: http://localhost:3030/
But my browser at localhost:3030 doesn't show anything. Other than:
ERR_CONNECTION_TIMED_OUT
Any help would be super!
I'm on a Mac. Using meteor 1.3.2.4 (The current version)
I experience the same problem when running just the meteor command alone with no arguments.
I just noticed that my hostname is incorrect (name of a family member's ipad) I switched to a new hostname using the hostname command and set it to a new name (not my original) could this have something to do with issue?
It was a problem with my etc/hosts file (typo). If Vijay wants to post an answer I'll delete this and accept that.

Resources