Billing with Stripe i have a form and i submit information and place the order following error has occured....
Unexpected error communicating with Stripe. If this problem persists, let us know at support#stripe.com. (Network error [errno 77]: error setting certificate verify locations: CAfile: C:\xampp\htdocs\PhpProject2\app\Lib\Stripe/../data/ca-certificates.crt CApath: none )
my controller action code
if(!empty($this->request->data)){
$email = $this->request->data['email'];
$credit_card = $this->request->data['card_number'];
$expire_month = $this->request->data['expiration_month'];
$expire_year = $this->request->data['expiration_year'];
$cvc = $this->request->data['cvc'];
//require_once('./lib/Stripe.php');
require_once "./../lib/Stripe.php";
Stripe::setApiKey("sk_test_KEY");
$token = Stripe_Token::create(array(
"card" => array(
"number" => $credit_card,
"exp_month" => $expire_month,
"exp_year" => $expire_year,
"cvc" => $cvc)));
and my view
<?php
echo $this->Form->create(false, array('action' => 'index'));
echo $this->Form->input('email', array('id' => 'email'));
echo $this->Form->input('card_number');
$options = array('1' => 'January', '2' => 'February', '3' => 'March', '4' => 'April',
'5' =>'May', '6' => 'June', '7' => 'July', '8' => 'August', '9' => 'September',
'10' => 'October',
'11' => 'November', '12' => 'December');
$start_year =array('1'=>2013,'2'=>2014,'3'=>2015,'4'=>2016,
'5'=>2017,'6'=>2018,'7'=>2019,'8'=>2020,'9'=>2021);
echo $this->Form->input('expiration_month', array('type' => 'select', 'options' => $options));
echo $this->Form->input('cvc');
echo $this->Form->end('place order', array('controller' => 'stripes', 'action' => 'index'));
?>
any help will appreciated
You will get this error if you do not have your CA bundle configured correctly.
You can use the following before making your charge calls to get around this.
\Stripe\Stripe::setVerifySslCerts(false);
This will leave your traffic, including client PII, vulnerable to interception and/or tampering.
Disabling SSL Certificates verification (\Stripe\Stripe::setVerifySslCerts(false); suggested by ykay) was useful to me in a test/local environment, but in production this verification still needs to happen.
So I contacted Stripe support and they suggested me a few steps (explained below) that finally led me to the real problem, my file structure:
data/ca-certificates.crt is referenced by Stripe.php's getDefaultCABundlePath(). If this file is not found, you might get an ApiConnection error with empty properties as output, like the one posted in this other question.
So the solution was either simply to place this file exactly on that path, or to move it to a different directory and update its location using Stripe::setCABundlePath().
If all Stripe files are properly referenced: steps for verifying TLSv1.2 support
Testing TLS in the server: after ensuring TLSv1.2 was operational in the server through this script that Stripe support recommended, producing the following output:
TLS test (default): TLS 1.2
TLS test (TLS_v1): TLS 1.2
TLS test (TLS_v1_2): TLS 1.2
They then suggested me to check for compatibility issues:
https://github.com/stripe/stripe-php#ssl--tls-compatibility-issues
This lead me to run the script in upgrade cURL and OpenSSL packages which tests and uses the Stripe's PHP integration (requires Stripe's init.php code):
https://support.stripe.com/questions/how-do-i-upgrade-my-stripe-integration-from-tls-1-0-to-tls-1-2#php
The following was produced:
TLS 1.2 is not supported. You will need to upgrade your integration.
Since the server is running Ubuntu (cat /etc/*-release) I then upgraded the OpenSSL version:
https://support.stripe.com/questions/how-do-i-upgrade-my-openssl-to-support-tls-1-2
With the following commands:
sudo apt-get update && sudo apt-get install --only-upgrade openssl
sudo apt-get update && sudo apt-get install --only-upgrade libssl-dev
Since these packages were in their latest version in the server, I decided to have another look into the Stripe's zip file structure and found out that when I unzipped the files, the path to ca-certificates.crt was not the same as the one in Stripe.php (which was causing the issue).
Not sure, but your code might be working. The issue is they require encrypted communication accomplished by certificate files which you either haven't set (in the library itself, SDKs often work like this) when using the library or the path is unparseable (mixed forward / and back \ slashes).
Related
From #DamienMcKenna in Slack
Having problems creating a Solr instance with a D7 site. I copied the conf files to ~/.ddev/solr/conf but when Solr starts there is no default instance created. I ran ddev stop --remove-data --omit-snapshot and recreated the instance, but the instance still doesn't exist. When I go to the Solr UI to check the system it shows "no cores available", when I try to create one named "dev" it says:
Error CREATEing SolrCore 'dev': Unable to create core [dev] Caused by: Can't find resource 'solrconfig.xml' in classpath or '/opt/solr/server/solr/dev'
I had success on a Drupal 7 project using the example docker-compose-solr.yaml file from version 1.11.0 of DDEV.
Copy https://github.com/drud/ddev/blob/v1.11.0/pkg/servicetest/testdata/services/docker-compose.solr.yaml into your .ddev folder and ensure line 34 matches the solr version you're going to copy from step 2 below, eg solr: 6.6
Copy the files from sites/all/modules/contrib/search_api_solr/solr-conf/6.x/*.* into the .ddev/solr/conf folder.
Download and enable search_api_override module.
Add the following in settings.local.php:
// For ddev only.
$conf['search_api_override_mode'] = 'load';
$conf['search_api_override_servers']['content'] = array(
'name' => 'DDEV: Solr Server',
'options' => array(
'host' => 'solr',
'port' => '8983',
'path' => '/solr/dev',
'http_user' => '',
'http_pass' => '',
'excerpt' => 0,
'retrieve_data' => 1,
'highlight_data' => 0,
'http_method' => 'AUTO',
),
);
Also, ymmv. It may be better to only override the values you need individually… a la:
$conf['search_api_override_servers']['content']['options']['host'] = 'solr';
$conf['search_api_override_servers']['content']['options']['port'] = '8983';
$conf['search_api_override_servers']['content']['options']['host'] = '/solr/dev';
You may need to modify 'content' array index to match whatever you configured in Drupal 7 to be your Solr index's machine name.
Start ddev with ddev start.
NOTE, I place the Search API override values in sites/default/settings.local.php instead of what one would think to be the logical place (sites/default/settings.ddev.php) so as not to interfere with DDEV's own auto-generation of the latter file.
It would be cool if DDEV did this automatically in settings.ddev.php similar to how the DB service settings work, but AFAICT this level of integration is not there and likely never will be for Drupal 7. Firstly, because you need an additional module (search_api_override) that may or may not be present, and secondly because users have the ability to name their Solr server whatever they want, so it would be hard to automate that. E.g. $conf['search_api_override_servers']['content'] could be anything like: $conf['search_api_override_servers']['foo'].
I am trying to use Memcache on NGINX for CakePHP (2.4.7) but when I update the core.php & bootstrap.php to do this I am then thrown the following exception:
Fatal error: Uncaught exception 'CacheException' with message 'Cache engine _cake_core_ is not properly configured
I have tried to search if any other configuration is required but can't see anything. Any help would be appreciated
Thanks,
First of all you need be sure that your Memcached configured and working properly.
Check memcached port (11211 if default settings) / process etc... for example memcached -u www-data -vv.
Then if you using memcached default configurations you should change core.php configurations like following:
Uncomment section about memcached. After it it's should looks like this:
Cache::config('default', array(
'engine' => 'Memcache', //[required]
'duration' => 1800, //[optional]
'probability' => 100, //[optional]
'prefix' => Inflector::slug(APP_DIR) . '_',
'servers' => array(
'127.0.0.1:11211'),
'persistent' => true,
'compress' => false));
Now change $engine = 'File'; to $engine = 'Memcache';
Use caching for example in controller you need write data with key => value, then access that data with key. Example:
Cache::write($key, $value);
Cache::read($key);
That's all.
Hope it's help you.
so my idea was to install tomcat7 using puppet, and then deploy the war file of Solr as a web app. Here is what i found.
There are many tomcat7 modules on puppet forge but none of them work out of box, and i am not sure if any of them actually work and a lot of them pertains to have code as documentation.
Take puppet module install fhuertas-tomcat7 as first example:
installs fhuertas-tomcat7 (v0.0.1)
i get an error, when i run:
sudo puppet apply --modulepath=/home/qa/puppet_qa/modules/ -e "include tomcat7" --debug
Error: Could not find data item service_path in any Hiera data file and no default supplied
and similar scenario follows for :
puppet module install llehmijo-tomcat7_rhel ( no longer maintained )
https://github.com/Spredzy/puppet-tomcat7 ( claims to be for CentOs ) but has an Apt (apt for centos ??) pre-requisite, plus it did not install either.
All i want to do is to install tomcat7 via puppet, and then install Solr. seems to be a simple request. Meanwhile i am working on my own to resolve the exact issue, and was able to install and run tomcat7, but not sure how i can install tomcat-users.xml
here is a portion of my init.pp
exec {'start service':
command => 'sh "startup.sh"',
cwd => "/usr/share/apache-tomcat-7.0.42/bin",
path => '/usr/share/apache-tomcat-7.0.42/bin/:/usr/bin:/bin',
#require => File['/usr/share/apache-tomcat-7.0.42/conf/tomcat-users.xml']
}
so if i un-comment the require => File[]
Error: Could not find dependency File[/usr/share/apache-tomcat-7.0.42/conf/tomcat-users.xml] for Exec[start service]
file { "/etc/tomcat7/tomcat-users.xml":
owner => 'root',
require => Package['tomcat'],
notify => Service['tomcat'],
content => template('tomcat/tomcat-users.xml.erb')
}
This works, as for the modules not working on puppet forge , and github, i think there is no resolution as if not working then these modules can be taken as guidelines, or hints.
I used the supported one https://forge.puppetlabs.com/puppetlabs/tomcat and following the examples everything was properly installed using packages (at least on Ubuntu). It is also possible to install it from source.
https://github.com/puppetlabs/puppetlabs-tomcat/tree/master/examples. See the example below:
class { 'java': }
class { 'tomcat':
install_from_source => false,
user => 'tomcat7',
require => Class['java']
}
tomcat::instance { 'tomcat7':
package_name => 'tomcat7',
require => Class['tomcat']
}->
tomcat::instance { 'tomcat7-admin':
package_name => 'tomcat7-admin',
}->
tomcat::config::server::tomcat_users {
'tomcat-admin':
catalina_base => '/var/lib/tomcat7',
element => 'user',
password => 'test',
roles => ['manager-gui','admin'];
'deployer':
catalina_base => '/var/lib/tomcat7',
element => 'user',
password => 'deployer',
roles => ['manager-script'];
}->
tomcat::service { 'tomcat7':
service_ensure => running,
catalina_base => '/var/lib/tomcat7',
require => Tomcat::Instance['tomcat7']
}
I have created my database, and used cake bake my_project to create my project, and now when I try cake bake all form within my project directory, I get an error relating to Mysql. When I view my project from the browser, it all lights up green, including connecting to the database.
Warning Error: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in [/Users/billy/Documents/projects/cakephp/lib/Cake/Model/Datasource/Database/Mysql.php, line 160]
Any ideas as to what this error is about?
EDIT: Added relevant configuration details (php --info |grep mysql)
I don't really know what to look for in here, but maybe someone does...
$ php --info |grep mysql
Configure Command => '/var/tmp/apache_mod_php/apache_mod_php-53.3.1~2/php/configure' '--prefix=/usr' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--disable-dependency-tracking' '--sysconfdir=/private/etc' '--with-apxs2=/usr/sbin/apxs' '--enable-cli' '--with-config-file-path=/etc' '--with-libxml-dir=/usr' '--with-openssl=/usr' '--with-kerberos=/usr' '--with-zlib=/usr' '--enable-bcmath' '--with-bz2=/usr' '--enable-calendar' '--with-curl=/usr' '--enable-exif' '--enable-ftp' '--with-gd' '--with-jpeg-dir=/BinaryCache/apache_mod_php/apache_mod_php-53.3.1~2/Root/usr/local' '--with-png-dir=/BinaryCache/apache_mod_php/apache_mod_php-53.3.1~2/Root/usr/local' '--enable-gd-native-ttf' '--with-ldap=/usr' '--with-ldap-sasl=/usr' '--enable-mbstring' '--enable-mbregex' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-mysql-sock=/var/mysql/mysql.sock' '--with-iodbc=/usr' '--enable-shmop' '--with-snmp=/usr' '--enable-soap' '--enable-sockets' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--with-xmlrpc' '--with-iconv-dir=/usr' '--with-xsl=/usr' '--enable-zend-multibyte' '--enable-zip' '--with-pcre-regex=/usr'
mysql
Client API version => mysqlnd 5.0.7-dev - 091210 - $Revision: 300533 $
mysql.allow_local_infile => On => On
mysql.allow_persistent => On => On
mysql.connect_timeout => 60 => 60
mysql.default_host => no value => no value
mysql.default_password => no value => no value
mysql.default_port => no value => no value
mysql.default_socket => /var/mysql/mysql.sock => /var/mysql/mysql.sock
mysql.default_user => no value => no value
mysql.max_links => Unlimited => Unlimited
mysql.max_persistent => Unlimited => Unlimited
mysql.trace_mode => Off => Off
mysqli
Client API library version => mysqlnd 5.0.7-dev - 091210 - $Revision: 300533 $
mysqli.allow_local_infile => On => On
mysqli.allow_persistent => On => On
mysqli.default_host => no value => no value
mysqli.default_port => 3306 => 3306
mysqli.default_pw => no value => no value
mysqli.default_socket => /var/mysql/mysql.sock => /var/mysql/mysql.sock
mysqli.default_user => no value => no value
mysqli.max_links => Unlimited => Unlimited
mysqli.max_persistent => Unlimited => Unlimited
mysqli.reconnect => Off => Off
mysqlnd
mysqlnd => enabled
Version => mysqlnd 5.0.7-dev - 091210 - $Revision: 300533 $
PDO drivers => mysql, sqlite, sqlite2
pdo_mysql
Client API version => mysqlnd 5.0.7-dev - 091210 - $Revision: 300533 $
pdo_mysql.default_socket => /var/mysql/mysql.sock => /var/mysql/mysql.sock
Edit: More info
I tried the suggestion from #0k32, but unfortunately it did not work for me. I soft linked php from my XAMPP folder to /usr/bin/php, and checked it was the right one with which php. I then did a php --info | grep sock and got:
MYSQL_SOCKET => /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
mysql.default_socket => /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock => /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
MYSQLI_SOCKET => /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
mysqli.default_socket => /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock => /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
Which seems to suggest that the correct version of MySQL is being activated. Still I am getting exactly the same error.
I think this issue could appear because of different configuration files (php.ini) used by apache's php module and command line php. Default settings for mysql connections may differ in those configs.
Compare phpinfo() output from apache and php --info from command line.
Update:
In your case it seems you are on MacOS and are using MAMP/MAMP PRO. So am I. And I had the same problem.
My solution was very simple. I replaced default php cli binary with a symlink to MAMP's php binary:
$ sudo mv /usr/bin/php /usr/bin/php_default
$ sudo ln -s /Applications/MAMP/bin/php/php5.3.6/bin/php /usr/bin/php
MAMP's php is connecting to MySQL via /Applications/MAMP/tmp/mysql/mysql.sock by default and MacOS's default command line php is trying to use /var/mysql/mysql.sock.
Anyway I think it's a good practice to use the same php with the same config for both web and cli.
update:
A smarter solution would be not to replace default php but just add path to MAMP's php binaries to the PATH. So in your ~/.bash_profile:
export PATH=/Applications/MAMP/bin/php/php5.3.6/bin:$PATH
Correct it if needed.
Then reopen terminal or execute this: source ~/.bash_profile. Then you can check which php you are using by executing which php. It should point to MAMP's php.
I'm using cakephp 2.0 and Wamp and it's all good. However, production server is unix Ubuntu. Both computers access the same mysql data.
I have these relations:
Model setup.php
var $belongsTo = array('Client', 'User');
Model client.php
var $hasMany = array('Setup');
Model user.php
var $hasMany = array('Setup');
Everything works great in localhost WAMP, but the production server is unix ubunto, to which I copy the whole directory. After chmod 777 everything, the app works fine except these errors:
Notice (8): Undefined index: Client [APP/View/Setups/index.ctp, line 38]
index.php line 38
<td><?php echo $this->Html->link($setup['Client']['name'], array('controller' =>
'clients', 'action' => 'view', $setup['Setup']['client_id'])); ?> </td>
Notice (8): Undefined index: User [APP/View/Setups/view.ctp, line 66]
view.php line 66
<?php echo $this->Html->link($setup['User']['name'], array('controller' => 'users',
'action' => 'view', $setup['User']['id'])); ?>`
Also, upon http://mailsender.asc/setups/add
Fatal error: Call to a member function find() on a non-object in
/disk/www/mailsender/app/Controller/SetupsController.php on line 69
SetupsController.php (line 69 is the "find" on add function)
public function add() {
// The relations belongs, has many etc.
$users = $this->Setup->User->find('list');
(IT suggested /cake upgrade all for fix, and it seemed to fix the above but broke other things, such as logout and login).
Can Anyone help?
I was wondering also if are there any steps I should take upon moving my whole app from windows local machine to unix ubuntu.
Thank you in advance !
Best regrds.
Carlos
from Tijuana, México.
unix version:
Linux genesi 3.0.0-12-generic-pae #20-Ubuntu SMP Fri Oct 7 16:37:17 UTC 2011 i686 i686 i386 GNU/Linux
php version:
Localhost: Version 5.3.0
genesi (production server) : Version 5.3.6-13ubuntu3.6
users.php should be user.php (singular)