withdraw method

  1. @override
Future<bool> withdraw(
  1. CreateWithdraw withdraw
)
override

Withdraw funds from merchant wallet to external wallet.

Throw UnauthorizedException when the secret key is invalid. Throw NotFoundException when the asset was not found. Throw InsufficienttFondsException when not have suficient founds. It throws exception TelePayException with any other error.

Implementation

@override
Future<bool> withdraw(CreateWithdraw withdraw) async {
  try {
    final response = await _dio.post<Map<String, dynamic>>(
      'withdraw',
      data: withdraw.toJson(),
      options: Options(headers: _headers),
    );
    if (response.statusCode == 200 && response.data != null) {
      return response.data!['success'] == true;
    }
  } on DioError catch (e) {
    _handlerError(e, 'withdraw');
  }
  throw const TelePayException('Failed to withdraw.');
}