public function test_api_credentials($credentials, $environment = 'sandbox')
 {
     $this->set_credential($credentials);
     $this->set_environment($environment);
     $result = $this->get_pal_details();
     if ('Success' != $result['ACK'] && 'SuccessWithWarning' != $result['ACK']) {
         // Look at the result a little more closely to make sure it's a credentialing issue.
         $found_10002 = false;
         foreach ($result as $index => $value) {
             if (preg_match('/^L_ERRORCODE\\d+$/', $index)) {
                 if ('10002' == $value) {
                     $found_10002 = true;
                 }
             }
         }
         if ($found_10002) {
             return false;
         } else {
             // Call failed for some other reason.
             throw new PayPal_API_Exception($result);
         }
     }
     update_option('woocommerce_ppec_payer_id_' . $this->_environment . '_' . md5($this->_credential->get_username() . ':' . $this->_credential->get_password()), wc_clean($result['PAL']));
     return $result['PAL'];
 }
 /**
  * Allow certificate-based credential to configure cURL, especially
  * to set CURLOPT_SSLCERT and CURLOPT_SSLCERTPASSWD.
  *
  * @throws Exception
  *
  * @param resource &$handle The cURL handle returned by curl_init().
  * @param array    $r       The HTTP request arguments.
  * @param string   $url     The request URL.
  *
  * @return void
  */
 public function configure_curl($handle, $r, $url)
 {
     parent::configure_curl($handle, $r, $url);
     $password = uniqid();
     $certificate_file = $this->_maybe_create_certificate_file($password);
     if (false === curl_setopt($handle, CURLOPT_SSLCERT, $certificate_file)) {
         throw new Exception(__('Unable to accept certificate during cURL configuration', 'woocommerce-gateway-paypal-express-checkout'), WC_Gateway_PPEC_Client::INVALID_ENVIRONMENT_ERROR);
     }
     if ($this->_use_secure_transport() && false === curl_setopt($handle, CURLOPT_SSLCERTPASSWD, $password)) {
         throw new Exception(__('Unable to accept certificate password during cURL configuration', 'woocommerce-gateway-paypal-express-checkout'), WC_Gateway_PPEC_Client::INVALID_ENVIRONMENT_ERROR);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function get_request_params()
 {
     $params = parent::get_request_params();
     $params['SIGNATURE'] = $this->_signature;
     return $params;
 }