Example #1
0
 /**
  * Get API URL for this Stripe transfer reversal.
  *
  * @throws \Arcanedev\Stripe\Exceptions\InvalidRequestException
  *
  * @return string
  */
 public function instanceUrl()
 {
     if (is_null($id = $this['id'])) {
         throw new InvalidRequestException('Could not determine which URL to request: class instance has invalid ID [null]', null);
     }
     return implode('/', [Transfer::classUrl(), urlencode(str_utf8($this['transfer'])), 'reversals', urlencode(str_utf8($id))]);
 }
Example #2
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()
 {
     if (!is_null($result = parent::instanceUrl())) {
         return $result;
     }
     return self::classUrl() . '/' . urlencode(str_utf8($this['id']));
 }
Example #3
0
 /**
  * Make Curl Options.
  *
  * @param  string  $method
  * @param  string  $url
  * @param  string  $params
  * @param  array   $headers
  * @param  bool    $hasFile
  *
  * @return self
  */
 public function make($method, $url, $params, $headers, $hasFile = false)
 {
     $this->checkMethod($method);
     $this->options = [];
     $this->prepareMethodOptions($method, $params, $hasFile);
     $this->setOptions([CURLOPT_URL => str_utf8($url), CURLOPT_RETURNTRANSFER => true, CURLOPT_CONNECTTIMEOUT => 30, CURLOPT_TIMEOUT => 80, CURLOPT_HTTPHEADER => $headers]);
     if (!Stripe::$verifySslCerts) {
         $this->setOption(CURLOPT_SSL_VERIFYPEER, false);
     }
     return $this;
 }
Example #4
0
 /**
  * Get The instance URL for this resource.
  * It needs to be special cased because it doesn't fit into the standard resource pattern.
  *
  * @throws InvalidRequestException
  *
  * @return string
  */
 public function instanceUrl()
 {
     $id = $this['id'];
     if (!$id) {
         $class = get_class($this);
         throw new InvalidRequestException("Could not determine which URL to request: {$class} instance has invalid ID: {$id}", null);
     }
     if ($this['account']) {
         $parent = $this['account'];
         $class = Resources\Account::class;
         $path = 'external_accounts';
     } elseif ($this['customer']) {
         $parent = $this['customer'];
         $class = Resources\Customer::class;
         $path = 'sources';
     } elseif ($this['recipient']) {
         $parent = $this['recipient'];
         $class = 'Arcanedev\\Stripe\\Resources\\Recipient';
         $path = 'cards';
     } else {
         return null;
     }
     return implode('/', [self::classUrl($class), urlencode(str_utf8($parent)), $path, str_utf8($id)]);
 }
 /**
  * Get instance URL - The API URL for this Stripe refund.
  *
  * @return string
  */
 public function instanceUrl()
 {
     $this->checkId($this['id']);
     return implode('/', [self::classUrl(ApplicationFee::class), urlencode(str_utf8($this['fee'])), 'refunds', urlencode(str_utf8($this['id']))]);
 }
Example #6
0
 /**
  * Retrieve Function.
  *
  * @param  string             $id
  * @param  array              $params
  * @param  array|string|null  $options
  *
  * @throws \Arcanedev\Stripe\Exceptions\ApiException
  *
  * @return \Arcanedev\Stripe\StripeObject|\Arcanedev\Stripe\StripeResource|array
  */
 public function retrieve($id, $params = [], $options = null)
 {
     list($url, $params) = $this->extractPathAndUpdateParams($params);
     list($response, $opts) = $this->request('get', $url . '/' . urlencode(str_utf8($id)), $params);
     $this->setRequestParams($params);
     return Util::convertToStripeObject($response, $opts);
 }
Example #7
0
/**
 * [strNormalize description]
 *
 * @param [type] $str [description]
 *
 * @return [type]      [description]
 */
function str_normalize($str)
{
    $str = str_utf8($str);
    $chars = array('Š' => 'S', 'š' => 's', 'Đ' => 'Dj', 'đ' => 'dj', 'Ž' => 'Z', 'ž' => 'z', 'Č' => 'C', 'č' => 'c', 'Ć' => 'C', 'ć' => 'c', 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', 'Æ' => 'A', 'Ç' => 'C', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'O', 'Ø' => 'O', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'U', 'Ý' => 'Y', 'Þ' => 'B', 'ß' => 'Ss', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'å' => 'a', 'æ' => 'a', 'ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ð' => 'o', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ø' => 'o', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ý' => 'y', 'ý' => 'y', 'þ' => 'b', 'ÿ' => 'y', 'Ŕ' => 'R', 'ŕ' => 'r');
    $str = strtr($str, $chars);
    return $str;
}
Example #8
0
 /**
  * Encode Objects.
  *
  * @param  \Arcanedev\Stripe\StripeResource|bool|array|string  $obj
  *
  * @throws \Arcanedev\Stripe\Exceptions\ApiException
  *
  * @return array|string
  */
 private static function encodeObjects($obj)
 {
     if ($obj instanceof StripeResource) {
         return str_utf8($obj->id);
     }
     if (is_bool($obj)) {
         return $obj ? 'true' : 'false';
     }
     if (is_array($obj)) {
         return array_map(function ($v) {
             return self::encodeObjects($v);
         }, $obj);
     }
     return str_utf8($obj);
 }
Example #9
0
 /**
  * Get the instance endpoint URL for the given class.
  *
  * @param  string  $id
  *
  * @return string
  *
  * @throws Exceptions\InvalidRequestException
  */
 public static function resourceUrl($id)
 {
     if ($id === null) {
         $class = get_called_class();
         throw new Exceptions\InvalidRequestException("Could not determine which URL to request: {$class} instance has invalid ID: {$id}", null);
     }
     return static::classUrl() . '/' . urlencode(str_utf8($id));
 }