From c72ed71d4db09176501e833d987058bcfbdac423 Mon Sep 17 00:00:00 2001 From: Ademar Date: Thu, 21 Sep 2023 10:27:40 -0300 Subject: [PATCH] Add buy btc using Moonpay general instructions and an Android example (#51) * Update android examples * Add buy btc moonpay doc for android and more general instructions * Update src/guide/buy_btc.md Co-authored-by: Ruben <36157890+ubbabeck@users.noreply.github.com> * Update src/guide/buy_btc.md Co-authored-by: Ruben <36157890+ubbabeck@users.noreply.github.com> --------- Co-authored-by: Ruben <36157890+ubbabeck@users.noreply.github.com> --- src/guide/buy_btc.md | 17 +++++++++++++++-- src/guide/install.md | 2 +- src/guide/payments.md | 5 ++++- src/guide/receive_onchain.md | 2 +- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/guide/buy_btc.md b/src/guide/buy_btc.md index f55064e..56fb541 100644 --- a/src/guide/buy_btc.md +++ b/src/guide/buy_btc.md @@ -2,6 +2,10 @@ This section of the Breez SDK documentation provides an example on purchasing Bitcoin using Moonpay as the provider. The example code snippet demonstrates how to initiate a Bitcoin purchase transaction using the Breez SDK. +The SDK will generate a Bitcoin address and prepare a URL using the specified provider. The user needs to open the URL and proceed with the provider flow to buy the Bitcoin. + +Once the buy is completed, the provider will transfer the Bitcoin to the generated address and Breez SDK will add the received Bitcoin to the Lightning balance. +
Rust
@@ -32,8 +36,17 @@ do {
Android
-```kotlin,ignore -// TODO add docs +```kotlin +try { + // Choose your provider + val provider = BuyBitcoinProvider.MOONPAY + // request the url to proceed with the Bitcoin acquisition + val url = sdk.buyBitcoin(BuyBitcoinRequest(provider)).url + // Opens the url in the browser to buy on provider's site + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url))) +} catch (e: Exception) { + // Handle error +} ```
diff --git a/src/guide/install.md b/src/guide/install.md index c70b364..aa7f428 100644 --- a/src/guide/install.md +++ b/src/guide/install.md @@ -56,7 +56,7 @@ dependencies { } ``` -See [the example](https://github.com/breez/breez-sdk/tree/main/libs/sdk-bindings/bindings-android/example) for more details +See [the example](https://github.com/breez/breez-sdk-examples/tree/main/Android) for more details ## React Native diff --git a/src/guide/payments.md b/src/guide/payments.md index e599797..ade0347 100644 --- a/src/guide/payments.md +++ b/src/guide/payments.md @@ -44,7 +44,10 @@ do { ```kotlin,ignore try { - val invoice = sdk.receivePayment(3000L.toULong(), "Invoice for 3000 sats") + val invoice = sdk.receivePayment(ReceivePaymentRequest( + 3000L.toULong(), + "Invoice for 3000 sats", + )) } catch (e: Exception) { // handle error } diff --git a/src/guide/receive_onchain.md b/src/guide/receive_onchain.md index 52ea6a8..f562d8e 100644 --- a/src/guide/receive_onchain.md +++ b/src/guide/receive_onchain.md @@ -39,7 +39,7 @@ do { ```kotlin,ignore try { - val swapInfo = sdk.receiveOnchain() + val swapInfo = sdk.receiveOnchain(ReceiveOnchainRequest()) // Send your funds to the bellow bitcoin address val address = swapInfo.bitcoinAddress } catch (e: Exception) {