lai3221/laravel-wise
Composer 安装命令:
composer require lai3221/laravel-wise
包简介
A Laravel package for integrating with the Wise (formerly TransferWise) API
README 文档
README
A Laravel package for integrating with the Wise (formerly TransferWise) API.
Installation
You can install the package via composer:
composer require lai3221/laravel-wise
Configuration
Publish the configuration file:
php artisan vendor:publish --tag=wise-config
Add the following environment variables to your .env file:
WISE_ENVIRONMENT=sandbox # or production WISE_API_KEY=your_api_key_here
Usage
Basic Usage
use Lai3221\LaravelWise\Services\WiseService; use Lai3221\LaravelWise\Exceptions\WiseException; use Lai3221\LaravelWise\Exceptions\AuthenticationException; use Lai3221\LaravelWise\Exceptions\ValidationException; use Lai3221\LaravelWise\Exceptions\NotFoundException; use Lai3221\LaravelWise\Exceptions\ApiException; class WiseController extends Controller { protected $wiseService; public function __construct(WiseService $wiseService) { $this->wiseService = $wiseService; } public function getBalances($profileId) { try { $balances = $this->wiseService->getBalances($profileId); return response()->json($balances); } catch (AuthenticationException $e) { return response()->json([ 'error' => 'Authentication failed', 'message' => $e->getMessage(), 'details' => $e->getErrorResponse() ], 401); } catch (NotFoundException $e) { return response()->json([ 'error' => 'Resource not found', 'message' => $e->getMessage(), 'details' => $e->getErrorResponse() ], 404); } catch (ValidationException $e) { return response()->json([ 'error' => 'Validation failed', 'message' => $e->getMessage(), 'details' => $e->getErrorResponse() ], 422); } catch (ApiException $e) { return response()->json([ 'error' => 'API error', 'message' => $e->getMessage(), 'details' => $e->getErrorResponse() ], 500); } } public function getBalanceByCurrency($profileId, $currency) { try { $balance = $this->wiseService->getBalanceByCurrency($profileId, $currency); return response()->json($balance); } catch (WiseException $e) { return response()->json([ 'error' => 'Wise API error', 'message' => $e->getMessage(), 'details' => $e->getErrorResponse() ], $e->getCode()); } } public function createTransfer(Request $request) { $data = [ 'profile' => $request->profile_id, 'source_currency' => $request->source_currency, 'target_currency' => $request->target_currency, 'source_amount' => $request->amount, 'target_amount' => $request->target_amount, 'target_account' => $request->target_account, ]; return $this->wiseService->createTransfer($data); } }
Available Methods
Balance Operations
getBalances(int $profileId): arraygetBalanceByCurrency(int $profileId, string $currency): ?array
Transfer Operations
createTransfer(array $data): arraygetTransfer(int $transferId): arraycancelTransfer(int $transferId): array
Exception Handling
The package throws the following exceptions:
WiseException: Base exception class for all Wise-related errorsAuthenticationException: Thrown when API authentication fails (401)ValidationException: Thrown when request validation fails (422)NotFoundException: Thrown when a resource is not found (404)ApiException: Thrown for general API errors (500)
All exceptions contain:
- Message: A human-readable error message
- Code: The HTTP status code
- Error Response: The full error response from the API
Example of catching specific exceptions:
try { $balances = $wiseService->getBalances($profileId); } catch (AuthenticationException $e) { // Handle authentication error $errorDetails = $e->getErrorResponse(); } catch (ValidationException $e) { // Handle validation error $errorDetails = $e->getErrorResponse(); } catch (WiseException $e) { // Handle any other Wise-related error $errorDetails = $e->getErrorResponse(); }
Testing
composer test
Security
If you discover any security related issues, please email lai3221@example.com instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.
lai3221/laravel-wise 适用场景与选型建议
lai3221/laravel-wise 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 03 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 lai3221/laravel-wise 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lai3221/laravel-wise 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-03