mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
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
This commit is contained in:
parent
4f0f95f7b5
commit
09be177376
5 changed files with 49 additions and 18 deletions
21
externals/wepay/LICENSE
vendored
Normal file
21
externals/wepay/LICENSE
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (C) 2013, WePay, Inc. <api at wepay dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
13
externals/wepay/composer.json
vendored
Normal file
13
externals/wepay/composer.json
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"name": "wepay/php-sdk",
|
||||
"description": "WePay APIv2 SDK for PHP",
|
||||
"authors": [
|
||||
{
|
||||
"name": "WePay",
|
||||
"email": "api@wepay.com"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"files": ["wepay.php"]
|
||||
}
|
||||
}
|
0
externals/wepay/iframe_demoapp/checkout.php
vendored
Normal file → Executable file
0
externals/wepay/iframe_demoapp/checkout.php
vendored
Normal file → Executable file
0
externals/wepay/iframe_demoapp/list_accounts.php
vendored
Normal file → Executable file
0
externals/wepay/iframe_demoapp/list_accounts.php
vendored
Normal file → Executable file
17
externals/wepay/wepay.php
vendored
Normal file → Executable file
17
externals/wepay/wepay.php
vendored
Normal file → Executable file
|
@ -5,7 +5,7 @@ class WePay {
|
|||
/**
|
||||
* Version number - sent in user agent string
|
||||
*/
|
||||
const VERSION = '0.1.3';
|
||||
const VERSION = '0.1.4';
|
||||
|
||||
/**
|
||||
* Scope fields
|
||||
|
@ -213,23 +213,20 @@ class WePay {
|
|||
throw new Exception('cURL error while making API call to WePay: ' . curl_error(self::$ch), $errno);
|
||||
}
|
||||
$result = json_decode($raw);
|
||||
|
||||
$error_code = null;
|
||||
if (isset($result->error_code)) {
|
||||
$error_code = $result->error_code;
|
||||
}
|
||||
|
||||
$httpCode = curl_getinfo(self::$ch, CURLINFO_HTTP_CODE);
|
||||
if ($httpCode >= 400) {
|
||||
if (!isset($result->error_code)) {
|
||||
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);
|
||||
}
|
||||
if ($httpCode >= 500) {
|
||||
throw new WePayServerException($result->error_description, $httpCode, $result, $error_code);
|
||||
throw new WePayServerException($result->error_description, $httpCode, $result, $result->error_code);
|
||||
}
|
||||
switch ($result->error) {
|
||||
case 'invalid_request':
|
||||
throw new WePayRequestException($result->error_description, $httpCode, $result, $error_code);
|
||||
throw new WePayRequestException($result->error_description, $httpCode, $result, $result->error_code);
|
||||
case 'access_denied':
|
||||
default:
|
||||
throw new WePayPermissionException($result->error_description, $httpCode, $result, $error_code);
|
||||
throw new WePayPermissionException($result->error_description, $httpCode, $result, $result->error_code);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue