mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-17 13:54:20 +01:00
Consolidate "receive payment" snippets, expose invoice
This commit is contained in:
@@ -7,8 +7,10 @@ public class ReceivePaymentSnippets
|
|||||||
// ANCHOR: receive-payment
|
// ANCHOR: receive-payment
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var invoice = sdk.ReceivePayment(
|
var receivePaymentResponse = sdk.ReceivePayment(
|
||||||
new ReceivePaymentRequest(3_000_000, "Invoice for 3000 sats"));
|
new ReceivePaymentRequest(3_000_000, "Invoice for 3000 sats"));
|
||||||
|
|
||||||
|
var invoice = receivePaymentResponse.lnInvoice;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ Future<ReceivePaymentResponse> receivePayment() async {
|
|||||||
amountMsat: 3000000,
|
amountMsat: 3000000,
|
||||||
description: "Invoice for 3000 sats",
|
description: "Invoice for 3000 sats",
|
||||||
);
|
);
|
||||||
ReceivePaymentResponse resp = await BreezSDK().receivePayment(req: req);
|
ReceivePaymentResponse receivePaymentResponse = await BreezSDK().receivePayment(req: req);
|
||||||
print(resp.lnInvoice);
|
|
||||||
|
print(receivePaymentResponse.lnInvoice);
|
||||||
// ANCHOR_END: receive-payment
|
// ANCHOR_END: receive-payment
|
||||||
return resp;
|
return receivePaymentResponse;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ func ReceivePayment() {
|
|||||||
Description: "Invoice for 3000 sats",
|
Description: "Invoice for 3000 sats",
|
||||||
}
|
}
|
||||||
if receivePaymentResponse, err := sdk.ReceivePayment(receivePaymentRequest); err == nil {
|
if receivePaymentResponse, err := sdk.ReceivePayment(receivePaymentRequest); err == nil {
|
||||||
log.Printf("%#v", receivePaymentResponse)
|
log.Printf("Invoice: %#v", receivePaymentResponse.LnInvoice)
|
||||||
}
|
}
|
||||||
// ANCHOR_END: receive-payment
|
// ANCHOR_END: receive-payment
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ class ReceivePayment {
|
|||||||
fun receive_payment(sdk: BlockingBreezServices) {
|
fun receive_payment(sdk: BlockingBreezServices) {
|
||||||
// ANCHOR: receive-payment
|
// ANCHOR: receive-payment
|
||||||
try {
|
try {
|
||||||
val invoice = sdk.receivePayment(ReceivePaymentRequest(
|
val receivePaymentResponse = sdk.receivePayment(ReceivePaymentRequest(
|
||||||
3_000_000.toULong(),
|
3_000_000.toULong(),
|
||||||
"Invoice for 3000 sats",
|
"Invoice for 3000 sats",
|
||||||
))
|
))
|
||||||
|
|
||||||
|
val invoice = receivePaymentResponse.lnInvoice;
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
// handle error
|
// handle error
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,12 @@ def receive_payment(sdk_services):
|
|||||||
# ANCHOR: receive-payment
|
# ANCHOR: receive-payment
|
||||||
req = breez_sdk.ReceivePaymentRequest(
|
req = breez_sdk.ReceivePaymentRequest(
|
||||||
amount_msat=3000000,
|
amount_msat=3000000,
|
||||||
description="Invoice for 3 000 000 sats")
|
description="Invoice for 3 000 sats")
|
||||||
result = sdk_services.receive_payment(req)
|
receive_payment_response = sdk_services.receive_payment(req)
|
||||||
|
|
||||||
|
invoice = receive_payment_response.ln_invoice
|
||||||
# ANCHOR_END: receive-payment
|
# ANCHOR_END: receive-payment
|
||||||
return result
|
return receive_payment_response
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
print(error)
|
print(error)
|
||||||
raise
|
raise
|
||||||
@@ -2,9 +2,11 @@ import { receivePayment } from '@breeztech/react-native-breez-sdk'
|
|||||||
|
|
||||||
const exampleReceiveLightningPayment = async () => {
|
const exampleReceiveLightningPayment = async () => {
|
||||||
// ANCHOR: receive-payment
|
// ANCHOR: receive-payment
|
||||||
const invoice = await receivePayment({
|
const receivePaymentResponse = await receivePayment({
|
||||||
amountMsat: 3000000,
|
amountMsat: 3_000_000,
|
||||||
description: 'Invoice for 3000 sats'
|
description: 'Invoice for 3000 sats'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const invoice = receivePaymentResponse.lnInvoice
|
||||||
// ANCHOR_END: receive-payment
|
// ANCHOR_END: receive-payment
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,15 @@ use breez_sdk_core::*;
|
|||||||
|
|
||||||
async fn receive_payment(sdk: Arc<BreezServices>) -> Result<()> {
|
async fn receive_payment(sdk: Arc<BreezServices>) -> Result<()> {
|
||||||
// ANCHOR: receive-payment
|
// ANCHOR: receive-payment
|
||||||
let res = sdk
|
let receive_payment_response = sdk
|
||||||
.receive_payment(ReceivePaymentRequest {
|
.receive_payment(ReceivePaymentRequest {
|
||||||
amount_msat: 3_000_000,
|
amount_msat: 3_000_000,
|
||||||
description: "Invoice for 3000 sats".into(),
|
description: "Invoice for 3000 sats".into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
let invoice = receive_payment_response.ln_invoice;
|
||||||
// ANCHOR_END: receive-payment
|
// ANCHOR_END: receive-payment
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -9,10 +9,12 @@ import BreezSDK
|
|||||||
|
|
||||||
func receivePayment(sdk: BlockingBreezServices) -> ReceivePaymentResponse? {
|
func receivePayment(sdk: BlockingBreezServices) -> ReceivePaymentResponse? {
|
||||||
// ANCHOR: receive-payment
|
// ANCHOR: receive-payment
|
||||||
let repsonse = try? sdk.receivePayment(
|
let receivePaymentResponse = try? sdk.receivePayment(
|
||||||
req: ReceivePaymentRequest(
|
req: ReceivePaymentRequest(
|
||||||
amountMsat: 3_000_000,
|
amountMsat: 3_000_000,
|
||||||
description: "Invoice for 3 000 000 sats"))
|
description: "Invoice for 3 000 sats"))
|
||||||
|
|
||||||
|
let invoice = receivePaymentResponse?.lnInvoice;
|
||||||
// ANCHOR_END: receive-payment
|
// ANCHOR_END: receive-payment
|
||||||
return repsonse
|
return receivePaymentResponse
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user