cego/seamless-wallet-client

此包已被弃用,不再维护。未建议替代包。

用于与无缝钱包服务交互的包


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")