mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-18 06:14:21 +01:00
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:
@@ -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.
|
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">
|
<custom-tabs category="lang">
|
||||||
|
|
||||||
<div slot="title">Rust</div>
|
<div slot="title">Rust</div>
|
||||||
@@ -32,8 +36,17 @@ do {
|
|||||||
<div slot="title">Android</div>
|
<div slot="title">Android</div>
|
||||||
<section>
|
<section>
|
||||||
|
|
||||||
```kotlin,ignore
|
```kotlin
|
||||||
// TODO add docs
|
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>
|
</section>
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
## React Native
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,10 @@ do {
|
|||||||
|
|
||||||
```kotlin,ignore
|
```kotlin,ignore
|
||||||
try {
|
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) {
|
} catch (e: Exception) {
|
||||||
// handle error
|
// handle error
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ do {
|
|||||||
|
|
||||||
```kotlin,ignore
|
```kotlin,ignore
|
||||||
try {
|
try {
|
||||||
val swapInfo = sdk.receiveOnchain()
|
val swapInfo = sdk.receiveOnchain(ReceiveOnchainRequest())
|
||||||
// Send your funds to the bellow bitcoin address
|
// Send your funds to the bellow bitcoin address
|
||||||
val address = swapInfo.bitcoinAddress
|
val address = swapInfo.bitcoinAddress
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|||||||
Reference in New Issue
Block a user