cego / seamless-wallet-client
此包已被弃用,不再维护。未建议替代包。
用于与无缝钱包服务交互的包
0.6.2
2021-08-18 11:44 UTC
Requires
- php: ^7.4|^8.0
- ext-bcmath: *
- ext-json: *
- cego/service-client-base: ^0.1.9
- guzzlehttp/guzzle: ^6.5.5|^7.0.1
- illuminate/http: ^7.0|^8.0
- illuminate/support: ^7.0|^8.0
- nbj/property-container: ^1.4
- nesbot/carbon: ^2.42
- phpoption/phpoption: ^1.7
- vlucas/phpdotenv: ^5.2
Requires (Dev)
- cego/request-insurance: ^0.3.2
- friendsofphp/php-cs-fixer: ^2.16
- orchestra/testbench: ^6.13
- phpstan/phpstan: ^0.12
- phpunit/phpunit: ^9.0
- ramsey/uuid: ^4.1
Suggests
- cego/request-insurance: Allows for sending asynchronous requests
- dev-master
- 0.6.2
- 0.6.1
- 0.6.0
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.0
- 0.3.10
- 0.3.9
- 0.3.8
- 0.3.7
- 0.3.6
- 0.3.5
- 0.3.4
- 0.3.3
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.16
- 0.1.15
- 0.1.14
- 0.1.13
- 0.1.12
- 0.1.11
- 0.1.10
- 0.1.9
- 0.1.8
- 0.1.7
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- 0.0.14
- 0.0.13
- 0.0.12
- 0.0.11
- 0.0.10
- 0.0.9
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
- 0.0.1-rc2
- 0.0.1-rc1
- dev-thwo/bump-base-client
- dev-thwo/remove-composer-lock
- dev-niza/add-wallet-summary-endpoint
- dev-niza/add-description-to-transactions
- dev-niza/implement-service-client-base
- dev-niza/add-request-insurance-option
- dev-niza/add-transaction-endpoint
- dev-mjn/add-github-actions
- dev-niza/add-sum-of-wallet-balances-endpoint
This package is auto-updated.
Last update: 2022-01-18 12:44:18 UTC
README
项目最初由
- Niki Ewald Zakariassen (NIZA)
- Nikolaj Boel Jensen (NBJ)
用法
无缝钱包客户端实现了一个用于与无缝钱包服务交互的流畅界面。
接口
// Getting a client instance $seamlessWallet = SeamlessWallet::create('base_url') ->auth(/* < Credentials > */); // Setting the target player $seamlessWallet->forPlayer($playerId);
// Creating a user wallet SeamlessWallet::create(/* < Base Url > */) ->auth(/* < Credentials > */) ->forPlayer($playerId) ->createWallet();
// Deposits / withdraws / balance / rollback SeamlessWallet::create(/* < Base Url > */) ->auth(/* < Credentials > */) ->forPlayer($playerId) ->deposit(100, "UUID6" /*, $transaction_context, $external_id */); SeamlessWallet::create(/* < Base Url > */) ->auth(/* < Credentials > */) ->forPlayer($playerId) ->withdraw(20, "UUID6" /*, $transaction_context, $external_id */); SeamlessWallet::create(/* < Base Url > */) ->auth(/* < Credentials > */) ->forPlayer($playerId) ->getBalance(); SeamlessWallet::create(/* < Base Url > */) ->auth(/* < Credentials > */) ->rollbackTransaction("UUID6");
// Using request insurance SeamlessWallet::create(/* < Base Url > */) ->auth(/* < Credentials > */) ->useRequestInsurance() ->forPlayer($playerId) ->deposit(100, "UUID6" /*, $transaction_context, $external_id */);
注意:调用 ->forPlayer() 后,id 将被保存在内存中以备后用
注意:请求保险仅适用于 POST 请求,并且会记住后续请求。GET 请求将始终使用同步 HTTP 驱动程序
错误处理
客户端不使用错误返回值,这意味着如果请求失败,则将抛出异常:[SeamlessWalletRequestFailedException.php](https://github.com/cego/seamless-wallet-client/blob/HEAD/src/SeamlessWallet/Exceptions/SeamlessWalletRequestFailedException.php)。
客户端在抛出异常之前,会在服务器错误上尝试配置的重试次数。
- env("SEAMLESS_WALLET_CLIENT_MAXIMUM_NUMBER_OF_RETRIES")
- env("SEAMLESS_WALLET_CLIENT_TIMEOUT")