0
votes

I am using XAMPP latest version for mac and I am trying from this site https://www.appcoda.com/braintree-ios-integration/

PHP code is

<?php
require 'vendor/autoload.php';

Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('**********');
Braintree_Configuration::publicKey('**********');
Braintree_Configuration::privateKey('************');

// Get the credit card details submitted by the form
$paymentMethodNonce =  $_POST['payment_method_nonce'];
echo $paymentMethodNonce;

$amount = $_POST['amount'];
echo $amount;

$result = Braintree_Transaction::sale([
  'amount' => $amount,
  'paymentMethodNonce' => $paymentMethodNonce,
  'options' => [
    'submitForSettlement' => True
  ]
]);

echo json_encode($result);
?> 

Why am I getting this error? I didn't understand from this site braintreegateway Uncaught exception

Fatal error: Uncaught Braintree\Exception\SSLCertificate: Couldn't resolve host 'api.sandbox.braintreegateway.com' in /opt/lampp/htdocs/donate/vendor/braintree/braintree_php/lib/Braintree/Http.php:168 Stack trace: #0 /opt/lampp/htdocs/donate/vendor/braintree/braintree_php/lib/Braintree/Http.php(99): Braintree\Http->_doUrlRequest('POST', 'https://api.san...', '_doRequest('POST', '/merchants/fxd6...', 'post('/merchants/fxd6...', Array) #3 /opt/lampp/htdocs/donate/vendor/braintree/braintree_php/lib/Braintree/TransactionGateway.php(48): Braintree\TransactionGateway->_doCreate('/transactions', Array) #4 /opt/lampp/htdocs/donate/vendor/braintree/braintree_php/lib/Braintree/TransactionGateway.php(290): Braintree\TransactionGateway->create(Array) #5 /opt/lampp/htdocs/dona in /opt/lampp/htdocs/donate/vendor/braintree/braintree_php/lib/Braintree/Http.php on line 168

1
i hope you replaced those public and private keys with random values - Scriptable
Your code can't connect to the url "api.sandbox.braintreegateway.com". If I try to ping that URL, it does work. Also, please tell me those keys you posted aren't the actual keys of your project. If yes, change them right now. - Loek
@Loek I changed them anyway - Scriptable
@Scriptable Still, some bot may have scraped them already. Seen it happen so many times that I would still recommend OP to change his keys. - Loek
What will I do now? - KhanShaheb

1 Answers

1
votes

Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.

The error you are seeing is due to the fact that your server is not using TLSv1.2. As of December 13, 2016, we are no longer accepting connections using SSL (any version), TLSv1.0, or TLSv1.2 for the Sandbox environment. You can find more information about this change in our blog post. These changes will affect our Production environment soon as well.

To find the OpenSSL information for cURL, run:

php -r 'echo json_encode(curl_version(), JSON_PRETTY_PRINT);'

You can take a look at the PayPal Guideline for updating your SSL/TSL libraries and information for updating the OpenSSL version on your machine as well.