Ejemplo n.º 1
0
 private static function _doRequest($httpVerb, $path, $requestBody = null)
 {
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_TIMEOUT, 60);
     curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $httpVerb);
     curl_setopt($curl, CURLOPT_URL, Braintree_Configuration::merchantUrl() . $path);
     curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/xml', 'Content-Type: application/xml', 'User-Agent: Braintree PHP Library ' . Braintree_Version::get(), 'X-ApiVersion: ' . Braintree_Configuration::API_VERSION));
     curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
     curl_setopt($curl, CURLOPT_USERPWD, Braintree_Configuration::publicKey() . ':' . Braintree_Configuration::privateKey());
     // curl_setopt($curl, CURLOPT_VERBOSE, true);
     if (Braintree_Configuration::sslOn()) {
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
         curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
         curl_setopt($curl, CURLOPT_CAINFO, Braintree_Configuration::caFile());
     }
     if (!empty($requestBody)) {
         curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);
     }
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     $response = curl_exec($curl);
     $httpStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);
     curl_close($curl);
     if (Braintree_Configuration::sslOn()) {
         if ($httpStatus == 0) {
             throw new Braintree_Exception_SSLCertificate();
         }
     }
     return array('status' => $httpStatus, 'body' => $response);
 }
 function testParseAndValidateQueryString_throwsDownForMaintenanceErrorIfDownForMaintenance()
 {
     Braintree_TestHelper::suppressDeprecationWarnings();
     $trData = Braintree_TransparentRedirect::createCustomerData(array("redirectUrl" => "http://www.example.com"));
     $queryString = Braintree_TestHelper::submitTrRequest(Braintree_Configuration::merchantUrl() . '/test/maintenance', array(), $trData);
     $this->setExpectedException('Braintree_Exception_DownForMaintenance');
     Braintree_Customer::createFromTransparentRedirect($queryString);
 }
Ejemplo n.º 3
0
 /**
  *
  * @access public
  * @param none
  * @return string
  */
 public static function createTransactionUrl()
 {
     trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::url", E_USER_NOTICE);
     return Braintree_Configuration::merchantUrl() . '/transactions/all/create_via_transparent_redirect_request';
 }
Ejemplo n.º 4
0
 private static function _doRequest($httpVerb, $path, $requestBody = null)
 {
     return self::_doUrlRequest($httpVerb, Braintree_Configuration::merchantUrl() . $path, $requestBody);
 }
Ejemplo n.º 5
0
 /**
  *
  * @access public
  * @param none
  * @return string
  */
 public static function updateCreditCardUrl()
 {
     trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::url", E_USER_NOTICE);
     return Braintree_Configuration::merchantUrl() . '/payment_methods/all/update_via_transparent_redirect_request';
 }
 function testmerchantUrl()
 {
     Braintree_Configuration::merchantId('abc123');
     Braintree_Configuration::environment('sandbox');
     $mu = Braintree_Configuration::merchantUrl();
     $this->assertEquals('https://sandbox.braintreegateway.com:443/merchants/abc123', $mu);
     Braintree_Configuration::reset();
 }
Ejemplo n.º 7
0
 public static function url()
 {
     return Braintree_Configuration::merchantUrl() . "/transparent_redirect_requests";
 }