Created
January 11, 2024 15:25
-
-
Save SametSahin10/d04c08d87c56f396031c0ddb7b093cd7 to your computer and use it in GitHub Desktop.
The PaybisSDK class used to launch Paybis' UI in a Flutter app.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/services.dart'; | |
import 'package:volt/models/volt_api/create_paybis_request_model.dart'; | |
import 'package:volt/models/volt_api/crypto_wallet_address.dart'; | |
import 'package:volt/models/volt_api/get_paybis_quote_request_model.dart'; | |
import 'package:volt/services.dart'; | |
class PaybisSDK { | |
static const _paybisMethodChannel = MethodChannel( | |
"finance.voltage/paybis_method_channel", | |
); | |
Future<void> launchSdk({ | |
required String userID, | |
required String fiatCurrencyCode, | |
required String cryptoCurrencyCode, | |
required String walletAddress, | |
required String paymentMethod, | |
required String amount, | |
}) async { | |
final quoteID = | |
await _getQuote(fiatCurrencyCode, amount, cryptoCurrencyCode); | |
final cryptoWalletAddress = CryptoWalletAddress( | |
currencyCode: cryptoCurrencyCode, | |
address: walletAddress, | |
); | |
final paybisRequest = await voltAPI.createPaybisRequest( | |
CreatePaybisRequestModel( | |
cryptoWalletAddress: cryptoWalletAddress, | |
passwordless: false, | |
trustedKyc: false, | |
partnerUserId: userID, | |
quoteId: quoteID, | |
paymentMethod: paymentMethod, | |
), | |
); | |
final requestID = paybisRequest.requestId; | |
_paybisMethodChannel.invokeMethod('launchSdk', [requestID]); | |
} | |
Future<String> _getQuote( | |
String currencyCode, | |
String amount, | |
String currencyCodeTo, | |
) async { | |
final getPaybisQuoteRequestModel = GetPaybisQuoteRequestModel( | |
currencyCodeFrom: currencyCode, | |
amount: amount, | |
currencyCodeTo: currencyCodeTo, | |
); | |
return voltAPI.getPaybisQuote(getPaybisQuoteRequestModel); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment