예제 #1
0
파일: Transfer.php 프로젝트: neevan1e/Done
 public function transactions($params = null)
 {
     $requestor = new Stripe_ApiRequestor($this->_apiKey);
     $url = $this->instanceUrl() . '/transactions';
     list($response, $apiKey) = $requestor->request('get', $url, $params);
     return Stripe_Util::convertToStripeObject($response, $apiKey);
 }
예제 #2
0
 public static function upcoming($params = null, $apiKey = null)
 {
     $requestor = new Stripe_ApiRequestor($apiKey);
     $url = self::classUrl(get_class()) . '/upcoming';
     list($response, $apiKey) = $requestor->request('get', $url, $params);
     return Stripe_Util::convertToStripeObject($response, $apiKey);
 }
예제 #3
0
 /**
  * @return Stripe_Subscription The updated subscription.
  */
 public function deleteDiscount()
 {
     $requestor = new Stripe_ApiRequestor($this->_apiKey);
     $url = $this->instanceUrl() . '/discount';
     list($response, $apiKey) = $requestor->request('delete', $url);
     $this->refreshFrom(array('discount' => null), $apiKey, true);
 }
예제 #4
0
 public function cancelSubscription($params = null)
 {
     $requestor = new Stripe_ApiRequestor($this->_apiKey);
     $url = $this->instanceUrl() . '/subscription';
     list($response, $apiKey) = $requestor->request('delete', $url, $params);
     $this->refreshFrom(array('subscription' => $response), $apiKey, true);
     return $this->subscription;
 }
 public function closeDispute()
 {
     $requestor = new Stripe_ApiRequestor($this->_apiKey);
     $url = $this->instanceUrl() . '/dispute/close';
     list($response, $apiKey) = $requestor->request('post', $url);
     $this->refreshFrom($response, $apiKey);
     return $this;
 }
예제 #6
0
 public function updateDispute($params = null)
 {
     $requestor = new Stripe_ApiRequestor($this->_apiKey);
     $url = $this->instanceUrl() . '/dispute';
     list($response, $apiKey) = $requestor->request('post', $url, $params);
     $this->refreshFrom(array('dispute' => $response), $apiKey, true);
     return $this->dispute;
 }
예제 #7
0
 public function capture($params = null)
 {
     $requestor = new Stripe_ApiRequestor($this->_apiKey);
     $url = $this->instanceUrl() . '/capture';
     list($response, $apiKey) = $requestor->request('post', $url, $params);
     $this->refreshFrom($response, $apiKey);
     return $this;
 }
예제 #8
0
 public function retrieve($id, $params = null)
 {
     list($url, $params) = $this->extractPathAndUpdateParams($params);
     $requestor = new Stripe_ApiRequestor($this->_apiKey);
     $id = Stripe_ApiRequestor::utf8($id);
     $extn = urlencode($id);
     list($response, $apiKey) = $requestor->request('get', "{$url}/{$extn}", $params);
     return Stripe_Util::convertToStripeObject($response, $apiKey);
 }
예제 #9
0
 public function retrieve($id, $params = null)
 {
     $requestor = new Stripe_ApiRequestor($this->_apiKey);
     $base = $this['url'];
     $id = Stripe_ApiRequestor::utf8($id);
     $extn = urlencode($id);
     list($response, $apiKey) = $requestor->request('get', "{$base}/{$extn}", $params);
     return Stripe_Util::convertToStripeObject($response, $apiKey);
 }
예제 #10
0
파일: Charge.php 프로젝트: rodhoff/MNW
 public function markAsSafe()
 {
     $params = array('fraud_details' => array('user_report' => 'safe'));
     $requestor = new Stripe_ApiRequestor($this->_apiKey);
     $url = $this->instanceUrl();
     list($response, $apiKey) = $requestor->request('post', $url, $params);
     $this->refreshFrom($response, $apiKey);
     return $this;
 }
예제 #11
0
 /**
  * @return string The instance URL for this resource. It needs to be special
  *    cased because it doesn't fit into the standard resource pattern.
  */
 public function instanceUrl()
 {
     $id = $this['id'];
     if (!$id) {
         $class = get_class($this);
         $msg = "Could not determine which URL to request: {$class} instance " . "has invalid ID: {$id}";
         throw new Stripe_InvalidRequestError($msg, null);
     }
     if (isset($this['customer'])) {
         $parent = $this['customer'];
         $base = self::classUrl('Stripe_Customer');
     } else {
         if (isset($this['recipient'])) {
             $parent = $this['recipient'];
             $base = self::classUrl('Stripe_Recipient');
         } else {
             return null;
         }
     }
     $parent = Stripe_ApiRequestor::utf8($parent);
     $id = Stripe_ApiRequestor::utf8($id);
     $parentExtn = urlencode($parent);
     $extn = urlencode($id);
     return "{$base}/{$parentExtn}/cards/{$extn}";
 }
 public function testEncode()
 {
     $a = array('my' => 'value', 'that' => array('your' => 'example'), 'bar' => 1, 'baz' => null);
     $enc = Stripe_ApiRequestor::encode($a);
     $this->assertEqual($enc, 'my=value&that%5Byour%5D=example&bar=1');
     $a = array('that' => array('your' => 'example', 'foo' => null));
     $enc = Stripe_ApiRequestor::encode($a);
     $this->assertEqual($enc, 'that%5Byour%5D=example');
 }
예제 #13
0
 public function testUtf8()
 {
     // UTF-8 string
     $x = "é";
     $this->assertEqual(Stripe_ApiRequestor::utf8($x), $x);
     // Latin-1 string
     $x = "é";
     $this->assertEqual(Stripe_ApiRequestor::utf8($x), "é");
     // Not a string
     $x = TRUE;
     $this->assertEqual(Stripe_ApiRequestor::utf8($x), $x);
 }
예제 #14
0
 public function instanceUrl()
 {
     $id = $this['id'];
     $fee = $this['fee'];
     if (!$id) {
         throw new Stripe_InvalidRequestError("Could not determine which URL to request: " . "class instance has invalid ID: {$id}", null);
     }
     $id = Stripe_ApiRequestor::utf8($id);
     $fee = Stripe_ApiRequestor::utf8($fee);
     $base = self::classUrl('Stripe_ApplicationFee');
     $feeExtn = urlencode($fee);
     $extn = urlencode($id);
     return "{$base}/{$feeExtn}/refunds/{$extn}";
 }
예제 #15
0
파일: Card.php 프로젝트: sgh1986915/php-crm
 public function instanceUrl()
 {
     $id = $this['id'];
     $customer = $this['customer'];
     $class = get_class($this);
     if (!$id) {
         throw new Stripe_InvalidRequestError("Could not determine which URL to request: {$class} instance has invalid ID: {$id}", null);
     }
     $id = Stripe_ApiRequestor::utf8($id);
     $customer = Stripe_ApiRequestor::utf8($customer);
     $base = self::classUrl('Stripe_Customer');
     $customerExtn = urlencode($customer);
     $extn = urlencode($id);
     return "{$base}/{$customerExtn}/cards/{$extn}";
 }
예제 #16
0
 protected function _scopedDelete($class, $params = null, $options = null)
 {
     self::_validateCall('delete', $params, $options);
     $opts = Stripe_RequestOptions::parse($options);
     $key = $opts->apiKey ? $opts->apiKey : $this->_apiKey;
     $requestor = new Stripe_ApiRequestor($key, self::baseUrl());
     $url = $this->instanceUrl();
     list($response, $apiKey) = $requestor->request('delete', $url, $params);
     $this->refreshFrom($response, $apiKey);
     return $this;
 }
예제 #17
0
 protected function _scopedDelete($class, $params = null)
 {
     self::_validateCall('delete');
     $requestor = new Stripe_ApiRequestor($this->_apiKey);
     $url = $this->instanceUrl();
     list($response, $apiKey) = $requestor->request('delete', $url, $params);
     $this->refreshFrom($response, $apiKey);
     return $this;
 }
예제 #18
0
 private function _curlRequest($method, $absUrl, $headers, $params)
 {
     if (!self::$_preFlight) {
         self::$_preFlight = $this->checkSslCert($this->apiUrl());
     }
     $curl = curl_init();
     $method = strtolower($method);
     $opts = array();
     if ($method == 'get') {
         $opts[CURLOPT_HTTPGET] = 1;
         if (count($params) > 0) {
             $encoded = self::encode($params);
             $absUrl = "{$absUrl}?{$encoded}";
         }
     } else {
         if ($method == 'post') {
             $opts[CURLOPT_POST] = 1;
             $opts[CURLOPT_POSTFIELDS] = self::encode($params);
         } else {
             if ($method == 'delete') {
                 $opts[CURLOPT_CUSTOMREQUEST] = 'DELETE';
                 if (count($params) > 0) {
                     $encoded = self::encode($params);
                     $absUrl = "{$absUrl}?{$encoded}";
                 }
             } else {
                 throw new Stripe_ApiError("Unrecognized method {$method}");
             }
         }
     }
     $absUrl = self::utf8($absUrl);
     $opts[CURLOPT_URL] = $absUrl;
     $opts[CURLOPT_RETURNTRANSFER] = true;
     $opts[CURLOPT_CONNECTTIMEOUT] = 30;
     $opts[CURLOPT_TIMEOUT] = 80;
     $opts[CURLOPT_RETURNTRANSFER] = true;
     $opts[CURLOPT_HTTPHEADER] = $headers;
     if (!Stripe::$verifySslCerts) {
         $opts[CURLOPT_SSL_VERIFYPEER] = false;
     }
     curl_setopt_array($curl, $opts);
     $rbody = curl_exec($curl);
     if (!defined('CURLE_SSL_CACERT_BADFILE')) {
         define('CURLE_SSL_CACERT_BADFILE', 77);
         // constant not defined in PHP
     }
     $errno = curl_errno($curl);
     if ($errno == CURLE_SSL_CACERT || $errno == CURLE_SSL_PEER_CERTIFICATE || $errno == CURLE_SSL_CACERT_BADFILE) {
         array_push($headers, 'X-Stripe-Client-Info: {"ca":"using Stripe-supplied CA bundle"}');
         $cert = $this->caBundle();
         curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
         curl_setopt($curl, CURLOPT_CAINFO, $cert);
         $rbody = curl_exec($curl);
     }
     if ($rbody === false) {
         $errno = curl_errno($curl);
         $message = curl_error($curl);
         curl_close($curl);
         $this->handleCurlError($errno, $message);
     }
     $rcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
     curl_close($curl);
     return array($rbody, $rcode);
 }
예제 #19
0
파일: List.php 프로젝트: sgh1986915/php-crm
 public function all($params = null)
 {
     $requestor = new Stripe_ApiRequestor($this->_apiKey);
     list($response, $apiKey) = $requestor->request('get', $this['url'], $params);
     return Stripe_Util::convertToStripeObject($response, $apiKey);
 }