/
home
/
desid573
/
public_html
/
angel
/
stripe
/
lib
/
/home/desid573/public_html/angel/stripe/lib
mkdir
upload
Name
Size
Mode
Actions
ApiOperations/
-
0755
rm
Checkout/
-
0755
rm
Error/
-
0755
rm
HttpClient/
-
0755
rm
Issuing/
-
0755
rm
Radar/
-
0755
rm
Reporting/
-
0755
rm
Sigma/
-
0755
rm
Terminal/
-
0755
rm
Util/
-
0755
rm
Account.php
13293
0644
edit
dl
rm
AccountLink.php
301
0644
edit
dl
rm
AlipayAccount.php
2274
0644
edit
dl
rm
ApiRequestor.php
16250
0644
edit
dl
rm
ApiResource.php
3294
0644
edit
dl
rm
ApiResponse.php
609
0644
edit
dl
rm
ApplePayDomain.php
549
0644
edit
dl
rm
ApplicationFee.php
2833
0644
edit
dl
rm
ApplicationFeeRefund.php
1325
0644
edit
dl
rm
Balance.php
504
0644
edit
dl
rm
BalanceTransaction.php
2712
0644
edit
dl
rm
BankAccount.php
3572
0644
edit
dl
rm
BitcoinReceiver.php
1341
0644
edit
dl
rm
BitcoinTransaction.php
180
0644
edit
dl
rm
Capability.php
2314
0644
edit
dl
rm
Card.php
4338
0644
edit
dl
rm
Charge.php
8058
0644
edit
dl
rm
Collection.php
2958
0644
edit
dl
rm
CountrySpec.php
559
0644
edit
dl
rm
Coupon.php
742
0644
edit
dl
rm
CreditNote.php
2097
0644
edit
dl
rm
Customer.php
10145
0644
edit
dl
rm
CustomerBalanceTransaction.php
2898
0644
edit
dl
rm
Discount.php
319
0644
edit
dl
rm
Dispute.php
2697
0644
edit
dl
rm
EphemeralKey.php
893
0644
edit
dl
rm
Event.php
11263
0644
edit
dl
rm
ExchangeRate.php
222
0644
edit
dl
rm
File.php
1705
0644
edit
dl
rm
FileLink.php
522
0644
edit
dl
rm
FileUpload.php
154
0644
edit
dl
rm
Invoice.php
6569
0644
edit
dl
rm
InvoiceItem.php
869
0644
edit
dl
rm
InvoiceLineItem.php
705
0644
edit
dl
rm
IssuerFraudRecord.php
435
0644
edit
dl
rm
LoginLink.php
235
0644
edit
dl
rm
OAuth.php
3200
0644
edit
dl
rm
Order.php
1646
0644
edit
dl
rm
OrderItem.php
354
0644
edit
dl
rm
OrderReturn.php
470
0644
edit
dl
rm
PaymentIntent.php
3263
0644
edit
dl
rm
PaymentMethod.php
1475
0644
edit
dl
rm
Payout.php
3072
0644
edit
dl
rm
Person.php
3128
0644
edit
dl
rm
Plan.php
870
0644
edit
dl
rm
Product.php
1117
0644
edit
dl
rm
Recipient.php
1061
0644
edit
dl
rm
RecipientTransfer.php
918
0644
edit
dl
rm
Refund.php
1813
0644
edit
dl
rm
RequestTelemetry.php
559
0644
edit
dl
rm
Review.php
1644
0644
edit
dl
rm
SetupIntent.php
2171
0644
edit
dl
rm
SingletonApiResource.php
937
0644
edit
dl
rm
SKU.php
691
0644
edit
dl
rm
Source.php
4486
0644
edit
dl
rm
SourceTransaction.php
414
0644
edit
dl
rm
Stripe.php
6751
0644
edit
dl
rm
StripeObject.php
17756
0644
edit
dl
rm
Subscription.php
2802
0644
edit
dl
rm
SubscriptionItem.php
1612
0644
edit
dl
rm
SubscriptionSchedule.php
1857
0644
edit
dl
rm
TaxId.php
2255
0644
edit
dl
rm
TaxRate.php
599
0644
edit
dl
rm
ThreeDSecure.php
333
0644
edit
dl
rm
Token.php
766
0644
edit
dl
rm
Topup.php
1557
0644
edit
dl
rm
Transfer.php
3704
0644
edit
dl
rm
TransferReversal.php
1452
0644
edit
dl
rm
UsageRecord.php
1243
0644
edit
dl
rm
UsageRecordSummary.php
382
0644
edit
dl
rm
Webhook.php
1494
0644
edit
dl
rm
WebhookEndpoint.php
549
0644
edit
dl
rm
WebhookSignature.php
4239
0644
edit
dl
rm
Edit:
/home/desid573/public_html/angel/stripe/lib/ApiRequestor.php
(16250B)
<?php namespace Stripe; /** * Class ApiRequestor * * @package Stripe */ class ApiRequestor { /** * @var string|null */ private $_apiKey; /** * @var string */ private $_apiBase; /** * @var HttpClient\ClientInterface */ private static $_httpClient; /** * @var RequestTelemetry */ private static $requestTelemetry; /** * ApiRequestor constructor. * * @param string|null $apiKey * @param string|null $apiBase */ public function __construct($apiKey = null, $apiBase = null) { $this->_apiKey = $apiKey; if (!$apiBase) { $apiBase = Stripe::$apiBase; } $this->_apiBase = $apiBase; } /** * Creates a telemetry json blob for use in 'X-Stripe-Client-Telemetry' headers * @static * * @param RequestTelemetry $requestTelemetry * @return string */ private static function _telemetryJson($requestTelemetry) { $payload = array( 'last_request_metrics' => array( 'request_id' => $requestTelemetry->requestId, 'request_duration_ms' => $requestTelemetry->requestDuration, )); $result = json_encode($payload); if ($result != false) { return $result; } else { Stripe::getLogger()->error("Serializing telemetry payload failed!"); return "{}"; } } /** * @static * * @param ApiResource|bool|array|mixed $d * * @return ApiResource|array|string|mixed */ private static function _encodeObjects($d) { if ($d instanceof ApiResource) { return Util\Util::utf8($d->id); } elseif ($d === true) { return 'true'; } elseif ($d === false) { return 'false'; } elseif (is_array($d)) { $res = []; foreach ($d as $k => $v) { $res[$k] = self::_encodeObjects($v); } return $res; } else { return Util\Util::utf8($d); } } /** * @param string $method * @param string $url * @param array|null $params * @param array|null $headers * * @return array An array whose first element is an API response and second * element is the API key used to make the request. * @throws Error\Api * @throws Error\Authentication * @throws Error\Card * @throws Error\InvalidRequest * @throws Error\OAuth\InvalidClient * @throws Error\OAuth\InvalidGrant * @throws Error\OAuth\InvalidRequest * @throws Error\OAuth\InvalidScope * @throws Error\OAuth\UnsupportedGrantType * @throws Error\OAuth\UnsupportedResponseType * @throws Error\Permission * @throws Error\RateLimit * @throws Error\Idempotency * @throws Error\ApiConnection */ public function request($method, $url, $params = null, $headers = null) { $params = $params ?: []; $headers = $headers ?: []; list($rbody, $rcode, $rheaders, $myApiKey) = $this->_requestRaw($method, $url, $params, $headers); $json = $this->_interpretResponse($rbody, $rcode, $rheaders); $resp = new ApiResponse($rbody, $rcode, $rheaders, $json); return [$resp, $myApiKey]; } /** * @param string $rbody A JSON string. * @param int $rcode * @param array $rheaders * @param array $resp * * @throws Error\InvalidRequest if the error is caused by the user. * @throws Error\Authentication if the error is caused by a lack of * permissions. * @throws Error\Permission if the error is caused by insufficient * permissions. * @throws Error\Card if the error is the error code is 402 (payment * required) * @throws Error\InvalidRequest if the error is caused by the user. * @throws Error\Idempotency if the error is caused by an idempotency key. * @throws Error\OAuth\InvalidClient * @throws Error\OAuth\InvalidGrant * @throws Error\OAuth\InvalidRequest * @throws Error\OAuth\InvalidScope * @throws Error\OAuth\UnsupportedGrantType * @throws Error\OAuth\UnsupportedResponseType * @throws Error\Permission if the error is caused by insufficient * permissions. * @throws Error\RateLimit if the error is caused by too many requests * hitting the API. * @throws Error\Api otherwise. */ public function handleErrorResponse($rbody, $rcode, $rheaders, $resp) { if (!is_array($resp) || !isset($resp['error'])) { $msg = "Invalid response object from API: $rbody " . "(HTTP response code was $rcode)"; throw new Error\Api($msg, $rcode, $rbody, $resp, $rheaders); } $errorData = $resp['error']; $error = null; if (is_string($errorData)) { $error = self::_specificOAuthError($rbody, $rcode, $rheaders, $resp, $errorData); } if (!$error) { $error = self::_specificAPIError($rbody, $rcode, $rheaders, $resp, $errorData); } throw $error; } /** * @static * * @param string $rbody * @param int $rcode * @param array $rheaders * @param array $resp * @param array $errorData * * @return Error\RateLimit|Error\Idempotency|Error\InvalidRequest|Error\Authentication|Error\Card|Error\Permission|Error\Api */ private static function _specificAPIError($rbody, $rcode, $rheaders, $resp, $errorData) { $msg = isset($errorData['message']) ? $errorData['message'] : null; $param = isset($errorData['param']) ? $errorData['param'] : null; $code = isset($errorData['code']) ? $errorData['code'] : null; $type = isset($errorData['type']) ? $errorData['type'] : null; switch ($rcode) { case 400: // 'rate_limit' code is deprecated, but left here for backwards compatibility // for API versions earlier than 2015-09-08 if ($code == 'rate_limit') { return new Error\RateLimit($msg, $param, $rcode, $rbody, $resp, $rheaders); } if ($type == 'idempotency_error') { return new Error\Idempotency($msg, $rcode, $rbody, $resp, $rheaders); } // no break case 404: return new Error\InvalidRequest($msg, $param, $rcode, $rbody, $resp, $rheaders); case 401: return new Error\Authentication($msg, $rcode, $rbody, $resp, $rheaders); case 402: return new Error\Card($msg, $param, $code, $rcode, $rbody, $resp, $rheaders); case 403: return new Error\Permission($msg, $rcode, $rbody, $resp, $rheaders); case 429: return new Error\RateLimit($msg, $param, $rcode, $rbody, $resp, $rheaders); default: return new Error\Api($msg, $rcode, $rbody, $resp, $rheaders); } } /** * @static * * @param string|bool $rbody * @param int $rcode * @param array $rheaders * @param array $resp * @param string $errorCode * * @return null|Error\OAuth\InvalidClient|Error\OAuth\InvalidGrant|Error\OAuth\InvalidRequest|Error\OAuth\InvalidScope|Error\OAuth\UnsupportedGrantType|Error\OAuth\UnsupportedResponseType */ private static function _specificOAuthError($rbody, $rcode, $rheaders, $resp, $errorCode) { $description = isset($resp['error_description']) ? $resp['error_description'] : $errorCode; switch ($errorCode) { case 'invalid_client': return new Error\OAuth\InvalidClient($errorCode, $description, $rcode, $rbody, $resp, $rheaders); case 'invalid_grant': return new Error\OAuth\InvalidGrant($errorCode, $description, $rcode, $rbody, $resp, $rheaders); case 'invalid_request': return new Error\OAuth\InvalidRequest($errorCode, $description, $rcode, $rbody, $resp, $rheaders); case 'invalid_scope': return new Error\OAuth\InvalidScope($errorCode, $description, $rcode, $rbody, $resp, $rheaders); case 'unsupported_grant_type': return new Error\OAuth\UnsupportedGrantType($errorCode, $description, $rcode, $rbody, $resp, $rheaders); case 'unsupported_response_type': return new Error\OAuth\UnsupportedResponseType($errorCode, $description, $rcode, $rbody, $resp, $rheaders); } return null; } /** * @static * * @param null|array $appInfo * * @return null|string */ private static function _formatAppInfo($appInfo) { if ($appInfo !== null) { $string = $appInfo['name']; if ($appInfo['version'] !== null) { $string .= '/' . $appInfo['version']; } if ($appInfo['url'] !== null) { $string .= ' (' . $appInfo['url'] . ')'; } return $string; } else { return null; } } /** * @static * * @param string $apiKey * @param null $clientInfo * * @return array */ private static function _defaultHeaders($apiKey, $clientInfo = null) { $uaString = 'Stripe/v1 PhpBindings/' . Stripe::VERSION; $langVersion = phpversion(); $uname = php_uname(); $appInfo = Stripe::getAppInfo(); $ua = [ 'bindings_version' => Stripe::VERSION, 'lang' => 'php', 'lang_version' => $langVersion, 'publisher' => 'stripe', 'uname' => $uname, ]; if ($clientInfo) { $ua = array_merge($clientInfo, $ua); } if ($appInfo !== null) { $uaString .= ' ' . self::_formatAppInfo($appInfo); $ua['application'] = $appInfo; } $defaultHeaders = [ 'X-Stripe-Client-User-Agent' => json_encode($ua), 'User-Agent' => $uaString, 'Authorization' => 'Bearer ' . $apiKey, ]; return $defaultHeaders; } /** * @param string $method * @param string $url * @param array $params * @param array $headers * * @return array * @throws Error\Api * @throws Error\ApiConnection * @throws Error\Authentication */ private function _requestRaw($method, $url, $params, $headers) { $myApiKey = $this->_apiKey; if (!$myApiKey) { $myApiKey = Stripe::$apiKey; } if (!$myApiKey) { $msg = 'No API key provided. (HINT: set your API key using ' . '"Stripe::setApiKey(<API-KEY>)". You can generate API keys from ' . 'the Stripe web interface. See https://stripe.com/api for ' . 'details, or email support@stripe.com if you have any questions.'; throw new Error\Authentication($msg); } // Clients can supply arbitrary additional keys to be included in the // X-Stripe-Client-User-Agent header via the optional getUserAgentInfo() // method $clientUAInfo = null; if (method_exists($this->httpClient(), 'getUserAgentInfo')) { $clientUAInfo = $this->httpClient()->getUserAgentInfo(); } $absUrl = $this->_apiBase.$url; $params = self::_encodeObjects($params); $defaultHeaders = $this->_defaultHeaders($myApiKey, $clientUAInfo); if (Stripe::$apiVersion) { $defaultHeaders['Stripe-Version'] = Stripe::$apiVersion; } if (Stripe::$accountId) { $defaultHeaders['Stripe-Account'] = Stripe::$accountId; } if (Stripe::$enableTelemetry && self::$requestTelemetry != null) { $defaultHeaders["X-Stripe-Client-Telemetry"] = self::_telemetryJson(self::$requestTelemetry); } $hasFile = false; $hasCurlFile = class_exists('\CURLFile', false); foreach ($params as $k => $v) { if (is_resource($v)) { $hasFile = true; $params[$k] = self::_processResourceParam($v, $hasCurlFile); } elseif ($hasCurlFile && $v instanceof \CURLFile) { $hasFile = true; } } if ($hasFile) { $defaultHeaders['Content-Type'] = 'multipart/form-data'; } else { $defaultHeaders['Content-Type'] = 'application/x-www-form-urlencoded'; } $combinedHeaders = array_merge($defaultHeaders, $headers); $rawHeaders = []; foreach ($combinedHeaders as $header => $value) { $rawHeaders[] = $header . ': ' . $value; } $requestStartMs = Util\Util::currentTimeMillis(); list($rbody, $rcode, $rheaders) = $this->httpClient()->request( $method, $absUrl, $rawHeaders, $params, $hasFile ); if (array_key_exists('request-id', $rheaders)) { self::$requestTelemetry = new RequestTelemetry( $rheaders['request-id'], Util\Util::currentTimeMillis() - $requestStartMs ); } return [$rbody, $rcode, $rheaders, $myApiKey]; } /** * @param resource $resource * @param bool $hasCurlFile * * @return \CURLFile|string * @throws Error\Api */ private function _processResourceParam($resource, $hasCurlFile) { if (get_resource_type($resource) !== 'stream') { throw new Error\Api( 'Attempted to upload a resource that is not a stream' ); } $metaData = stream_get_meta_data($resource); if ($metaData['wrapper_type'] !== 'plainfile') { throw new Error\Api( 'Only plainfile resource streams are supported' ); } if ($hasCurlFile) { // We don't have the filename or mimetype, but the API doesn't care return new \CURLFile($metaData['uri']); } else { return '@'.$metaData['uri']; } } /** * @param string $rbody * @param int $rcode * @param array $rheaders * * @return mixed * @throws Error\Api * @throws Error\Authentication * @throws Error\Card * @throws Error\InvalidRequest * @throws Error\OAuth\InvalidClient * @throws Error\OAuth\InvalidGrant * @throws Error\OAuth\InvalidRequest * @throws Error\OAuth\InvalidScope * @throws Error\OAuth\UnsupportedGrantType * @throws Error\OAuth\UnsupportedResponseType * @throws Error\Permission * @throws Error\RateLimit * @throws Error\Idempotency */ private function _interpretResponse($rbody, $rcode, $rheaders) { $resp = json_decode($rbody, true); $jsonError = json_last_error(); if ($resp === null && $jsonError !== JSON_ERROR_NONE) { $msg = "Invalid response body from API: $rbody " . "(HTTP response code was $rcode, json_last_error() was $jsonError)"; throw new Error\Api($msg, $rcode, $rbody); } if ($rcode < 200 || $rcode >= 300) { $this->handleErrorResponse($rbody, $rcode, $rheaders, $resp); } return $resp; } /** * @static * * @param HttpClient\ClientInterface $client */ public static function setHttpClient($client) { self::$_httpClient = $client; } /** * @static * * Resets any stateful telemetry data */ public static function resetTelemetry() { self::$requestTelemetry = null; } /** * @return HttpClient\ClientInterface */ private function httpClient() { if (!self::$_httpClient) { self::$_httpClient = HttpClient\CurlClient::instance(); } return self::$_httpClient; } }
Save
cmd:
run