芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/bit-alphas-ltd.com/user/project/vendor/mollie/mollie-api-php/src/MollieApiClient.php
httpClient = $httpAdapterPicker->pickHttpAdapter($httpClient); $compatibilityChecker = new CompatibilityChecker; $compatibilityChecker->checkCompatibility(); $this->initializeEndpoints(); $this->addVersionString("Mollie/" . self::CLIENT_VERSION); $this->addVersionString("PHP/" . phpversion()); $httpClientVersionString = $this->httpClient->versionString(); if ($httpClientVersionString) { $this->addVersionString($httpClientVersionString); } } public function initializeEndpoints() { $this->payments = new PaymentEndpoint($this); $this->methods = new MethodEndpoint($this); $this->profileMethods = new ProfileMethodEndpoint($this); $this->customers = new CustomerEndpoint($this); $this->settlements = new SettlementsEndpoint($this); $this->settlementPayments = new SettlementPaymentEndpoint($this); $this->subscriptions = new SubscriptionEndpoint($this); $this->customerPayments = new CustomerPaymentsEndpoint($this); $this->mandates = new MandateEndpoint($this); $this->invoices = new InvoiceEndpoint($this); $this->permissions = new PermissionEndpoint($this); $this->profiles = new ProfileEndpoint($this); $this->onboarding = new OnboardingEndpoint($this); $this->organizations = new OrganizationEndpoint($this); $this->orders = new OrderEndpoint($this); $this->orderLines = new OrderLineEndpoint($this); $this->orderPayments = new OrderPaymentEndpoint($this); $this->orderRefunds = new OrderRefundEndpoint($this); $this->shipments = new ShipmentEndpoint($this); $this->refunds = new RefundEndpoint($this); $this->paymentRefunds = new PaymentRefundEndpoint($this); $this->paymentCaptures = new PaymentCaptureEndpoint($this); $this->paymentRoutes = new PaymentRouteEndpoint($this); $this->chargebacks = new ChargebackEndpoint($this); $this->paymentChargebacks = new PaymentChargebackEndpoint($this); $this->wallets = new WalletEndpoint($this); $this->paymentLinks = new PaymentLinkEndpoint($this); } /** * @param string $url * * @return MollieApiClient */ public function setApiEndpoint($url) { $this->apiEndpoint = rtrim(trim($url), '/'); return $this; } /** * @return string */ public function getApiEndpoint() { return $this->apiEndpoint; } /** * @return array */ public function getVersionStrings() { return $this->versionStrings; } /** * @param string $apiKey The Mollie API key, starting with 'test_' or 'live_' * * @return MollieApiClient * @throws ApiException */ public function setApiKey($apiKey) { $apiKey = trim($apiKey); if (! preg_match('/^(live|test)_\w{30,}$/', $apiKey)) { throw new ApiException("Invalid API key: '{$apiKey}'. An API key must start with 'test_' or 'live_' and must be at least 30 characters long."); } $this->apiKey = $apiKey; $this->oauthAccess = false; return $this; } /** * @param string $accessToken OAuth access token, starting with 'access_' * * @return MollieApiClient * @throws ApiException */ public function setAccessToken($accessToken) { $accessToken = trim($accessToken); if (! preg_match('/^access_\w+$/', $accessToken)) { throw new ApiException("Invalid OAuth access token: '{$accessToken}'. An access token must start with 'access_'."); } $this->apiKey = $accessToken; $this->oauthAccess = true; return $this; } /** * Returns null if no API key has been set yet. * * @return bool|null */ public function usesOAuth() { return $this->oauthAccess; } /** * @param string $versionString * * @return MollieApiClient */ public function addVersionString($versionString) { $this->versionStrings[] = str_replace([" ", "\t", "\n", "\r"], '-', $versionString); return $this; } /** * Perform an http call. This method is used by the resource specific classes. Please use the $payments property to * perform operations on payments. * * @param string $httpMethod * @param string $apiMethod * @param string|null $httpBody * * @return \stdClass * @throws ApiException * * @codeCoverageIgnore */ public function performHttpCall($httpMethod, $apiMethod, $httpBody = null) { $url = $this->apiEndpoint . "/" . self::API_VERSION . "/" . $apiMethod; return $this->performHttpCallToFullUrl($httpMethod, $url, $httpBody); } /** * Perform an http call to a full url. This method is used by the resource specific classes. * * @see $payments * @see $isuers * * @param string $httpMethod * @param string $url * @param string|null $httpBody * * @return \stdClass|null * @throws ApiException * * @codeCoverageIgnore */ public function performHttpCallToFullUrl($httpMethod, $url, $httpBody = null) { if (empty($this->apiKey)) { throw new ApiException("You have not set an API key or OAuth access token. Please use setApiKey() to set the API key."); } $userAgent = implode(' ', $this->versionStrings); if ($this->usesOAuth()) { $userAgent .= " OAuth/2.0"; } $headers = [ 'Accept' => "application/json", 'Authorization' => "Bearer {$this->apiKey}", 'User-Agent' => $userAgent, ]; if ($httpBody !== null) { $headers['Content-Type'] = "application/json"; } if (function_exists("php_uname")) { $headers['X-Mollie-Client-Info'] = php_uname(); } return $this->httpClient->send($httpMethod, $url, $headers, $httpBody); } /** * Serialization can be used for caching. Of course doing so can be dangerous but some like to live dangerously. * * \serialize() should be called on the collections or object you want to cache. * * We don't need any property that can be set by the constructor, only properties that are set by setters. * * Note that the API key is not serialized, so you need to set the key again after unserializing if you want to do * more API calls. * * @deprecated * @return string[] */ public function __sleep() { return ["apiEndpoint"]; } /** * When unserializing a collection or a resource, this class should restore itself. * * Note that if you have set an HttpAdapter, this adapter is lost on wakeup and reset to the default one. * * @throws IncompatiblePlatform If suddenly unserialized on an incompatible platform. */ public function __wakeup() { $this->__construct(); } }