@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update WePay API to HEAD

Summary: This is mostly to pick up the LICENSE file for packaging purposes,
but also fixes a bug I reported.

Auditors: btrahan

+49 -18
+21
externals/wepay/LICENSE
··· 1 + MIT License 2 + 3 + Copyright (C) 2013, WePay, Inc. <api at wepay dot com> 4 + 5 + Permission is hereby granted, free of charge, to any person obtaining a copy of 6 + this software and associated documentation files (the "Software"), to deal in 7 + the Software without restriction, including without limitation the rights to 8 + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 + of the Software, and to permit persons to whom the Software is furnished to do 10 + so, subject to the following conditions: 11 + 12 + The above copyright notice and this permission notice shall be included in all 13 + copies or substantial portions of the Software. 14 + 15 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 + SOFTWARE.
+13
externals/wepay/composer.json
··· 1 + { 2 + "name": "wepay/php-sdk", 3 + "description": "WePay APIv2 SDK for PHP", 4 + "authors": [ 5 + { 6 + "name": "WePay", 7 + "email": "api@wepay.com" 8 + } 9 + ], 10 + "autoload": { 11 + "files": ["wepay.php"] 12 + } 13 + }
externals/wepay/iframe_demoapp/checkout.php
externals/wepay/iframe_demoapp/list_accounts.php
+15 -18
externals/wepay/wepay.php
··· 5 5 /** 6 6 * Version number - sent in user agent string 7 7 */ 8 - const VERSION = '0.1.3'; 8 + const VERSION = '0.1.4'; 9 9 10 10 /** 11 11 * Scope fields ··· 183 183 self::$ch = NULL; 184 184 } 185 185 } 186 - 186 + 187 187 /** 188 188 * create the cURL request and execute it 189 189 */ ··· 196 196 curl_setopt(self::$ch, CURLOPT_HTTPHEADER, $headers); 197 197 curl_setopt(self::$ch, CURLOPT_TIMEOUT, 30); // 30-second timeout, adjust to taste 198 198 curl_setopt(self::$ch, CURLOPT_POST, !empty($values)); // WePay's API is not strictly RESTful, so all requests are sent as POST unless there are no request values 199 - 199 + 200 200 $uri = self::getDomain() . $endpoint; 201 201 curl_setopt(self::$ch, CURLOPT_URL, $uri); 202 - 202 + 203 203 if (!empty($values)) { 204 204 curl_setopt(self::$ch, CURLOPT_POSTFIELDS, json_encode($values)); 205 205 } 206 - 206 + 207 207 $raw = curl_exec(self::$ch); 208 208 if ($errno = curl_errno(self::$ch)) { 209 209 // Set up special handling for request timeouts ··· 213 213 throw new Exception('cURL error while making API call to WePay: ' . curl_error(self::$ch), $errno); 214 214 } 215 215 $result = json_decode($raw); 216 - 217 - $error_code = null; 218 - if (isset($result->error_code)) { 219 - $error_code = $result->error_code; 220 - } 221 - 222 216 $httpCode = curl_getinfo(self::$ch, CURLINFO_HTTP_CODE); 223 217 if ($httpCode >= 400) { 218 + if (!isset($result->error_code)) { 219 + throw new WePayServerException("WePay returned an error response with no error_code, please alert api@wepay.com. Original message: $result->error_description", $httpCode, $result, 0); 220 + } 224 221 if ($httpCode >= 500) { 225 - throw new WePayServerException($result->error_description, $httpCode, $result, $error_code); 222 + throw new WePayServerException($result->error_description, $httpCode, $result, $result->error_code); 226 223 } 227 224 switch ($result->error) { 228 225 case 'invalid_request': 229 - throw new WePayRequestException($result->error_description, $httpCode, $result, $error_code); 226 + throw new WePayRequestException($result->error_description, $httpCode, $result, $result->error_code); 230 227 case 'access_denied': 231 228 default: 232 - throw new WePayPermissionException($result->error_description, $httpCode, $result, $error_code); 229 + throw new WePayPermissionException($result->error_description, $httpCode, $result, $result->error_code); 233 230 } 234 231 } 235 - 232 + 236 233 return $result; 237 234 } 238 235 ··· 246 243 */ 247 244 public function request($endpoint, array $values = array()) { 248 245 $headers = array(); 249 - 246 + 250 247 if ($this->token) { // if we have an access_token, add it to the Authorization header 251 248 $headers[] = "Authorization: Bearer $this->token"; 252 249 } 253 - 250 + 254 251 $result = self::make_request($endpoint, $values, $headers); 255 - 252 + 256 253 return $result; 257 254 } 258 255 }