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>
This commit is contained in:
Ademar
2023-09-21 10:27:40 -03:00
committed by GitHub
parent 5d220f67c5
commit c72ed71d4d
4 changed files with 21 additions and 5 deletions

View File

@@ -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.
<custom-tabs category="lang">
<div slot="title">Rust</div>
@@ -32,8 +36,17 @@ do {
<div slot="title">Android</div>
<section>
```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
}
```
</section>

View File

@@ -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

View File

@@ -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
}

View File

@@ -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) {