예제 #1
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}";
 }
예제 #2
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);
 }
예제 #3
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);
 }
예제 #4
0
 public function instanceUrl()
 {
     $id = $this['id'];
     $class = get_class($this);
     if (!$id) {
         throw new Stripe_InvalidRequestError("Could not determine which URL to request: {$class} instance has invalid ID: {$id}");
     }
     $id = Stripe_ApiRequestor::utf8($id);
     $base = self::classUrl($class);
     $extn = urlencode($id);
     return "{$base}/{$extn}";
 }
예제 #5
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);
 }
예제 #6
0
 public function instanceUrl()
 {
     $id = $this['id'];
     $class = get_class($this);
     if ($id === null) {
         $message = "Could not determine which URL to request: " . "{$class} instance has invalid ID: {$id}";
         throw new Stripe_InvalidRequestError($message, null);
     }
     $id = Stripe_ApiRequestor::utf8($id);
     $base = $this->_lsb('classUrl', $class);
     $extn = urlencode($id);
     return "{$base}/{$extn}";
 }
예제 #7
0
 /**
  * @return string The API URL for this Stripe subscription.
  */
 public function instanceUrl()
 {
     $id = $this['id'];
     $customer = $this['customer'];
     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}/subscriptions/{$extn}";
 }
예제 #8
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}";
 }
예제 #9
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'];
     $customer = $this['customer'];
     $class = get_class($this);
     if (!$id) {
         $msg = "Could not determine which URL to request: {$class} instance " . "has invalid ID: {$id}";
         throw new Stripe_InvalidRequestError($msg, 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}";
 }
예제 #10
0
 public function instanceUrl()
 {
     $id = $this['id'];
     $class = get_class($this);
     if (!$id) {
         //throw new Stripe_InvalidRequestError("Could not determine which URL to request: $class instance has invalid ID: $id");
         try {
             throw new Stripe_InvalidRequestError(isset($error['message']) ? $error['message'] : null, $rcode, $rbody, $resp);
         } catch (Stripe_InvalidRequestError $e) {
             echo $e->getMessage();
         }
     }
     $id = Stripe_ApiRequestor::utf8($id);
     $base = self::classUrl($class);
     $extn = urlencode($id);
     return "{$base}/{$extn}";
 }