Skip to main content

Sending Payments

Overview

The Strike API can be used to send payments over the Bitcoin Lightning Network from a Strike user’s cash balance. This walkthrough shows you how to integrate the Strike API into your payment process for sending payments.

How Sending a Payment Works​

Sending a payment via the Strike API begins with obtaining a Lightning invoice. A Lightning invoice is a unique alphanumeric code that acts as a request for payment, and includes an amount to be paid in bitcoin and the destination of the payment.

Once a Lightning invoice has been received, a quote must be generated. The quote specifies the dollar cost of paying the Lightning invoice’s bitcoin amount, and therefore offers a temporary conversion rate between dollars and bitcoin. Both the Lightning invoice and the quote have expiration times.

To send a payment, simply execute the quote. When the quote is executed, dollars are sent from the sender’s cash balance, converted into bitcoin, routed through the Lightning Network, and delivered to the recipient.

Sending flow

Integration Walkthrough

1. Create a payment quote​ for a Lightning invoice

The payment process begins by obtaining a Lightning invoice (lnInvoice), which contains within it an amount to be paid in bitcoin and the destination of the payment. Once the Lightning invoice has been received, use the create quote endpoint to generate a quote for paying the invoice. This endpoint requires that you specify the Lightning invoice you wish to pay, which must be in the standard BOLT11 encoded format.

Below is an example request to generate a quote:

Example request:
curl -X 'POST' \
'https://<ENVIRONMENT>/v1/payment-quotes/lightning' \
-H 'accept: application/json' \
-H 'Authorization: Bearer <API_KEY> \
-H 'Content-Type: application/json' \
-d '{
"lnInvoice": "<BOLT11_INVOICE>",
"sourceCurrency": "USD"
}'

To use this example yourself, simply replace the placeholder values with your own values. The <ENVIRONMENT> should be replaced with api.strike.me, the <BOLT11_INVOICE> should be replaced with the Lightning invoice you wish to pay, and the <API_KEY> should be replaced with your own API key bearer token.

When creating a quote, the sourceCurrency specifies which currency will be used to pay the Lightning invoice, and can be set to any of your account’s supported fiat currencies. Sending BTC is not currently supported. If no sourceCurrency is set, the quote will be generated with your account’s default currency. Use the fetch public account profile info by handle endpoint to find which currencies isAvailable for you to use to send payments.

Below is the response to the quote generation request:

Example response:
{
paymentQuoteId: "99bb499a-aa28-4bf6-b976-4b74b2bee31f",
description: "Invoice description",
validUntil: "2023-02-03T03:27:34+00:00",
"conversionRate": {
"amount": "0.00004120",
"sourceCurrency": "USD",
"targetCurrency": "BTC"
},
"amount": {
"currency": "USD",
"amount": "167.00"
},
"lighningNetworkFee": {
"currency": "USD",
"amount": "0.54"
},
"totalAmount": {
"currency": "USD",
"amount": "167.54"
}
}

The above response shows the generated quote, identifiable by its unique paymentQuoteId. The quote contains a conversion rate between the sourceCurrency and bitcoin (i.e. dollars per bitcoin), the amount needed to pay the Lightning invoice, a validUntil timestamp showing the expiration time, and the lightningNetworkFee. Lightning Network Fees are charged by participants in the Lightning Network for the service of routing payments to their intended destination.

The totalAmount combines both the invoiced amount and the Lightning Network fees, and therefore represents the actual amount that will be paid by executing the quote.

Please note that when sending a payment to a Strike user in the same currency, the conversionRate is not returned in the quote generation response.

Below is an example request to fetch public account profile info:

Example request:
curl -X 'GET' \
'https://<ENVIRONMENT>/v1/accounts/handle/<HANDLE>/profile' \
-H 'accept: application/json' \
-H 'Authorization: Bearer <API_KEY>'

Below is the response to the fetch public account profile info request:

Example response:
{
"handle": "astrid_waters64",
"canReceive": true,
"currencies": [
{
"currency": "BTC",
"isDefaultCurrency": false,
"isAvailable": true,
"isInvoiceable": false
},
{
"currency": "USD",
"isDefaultCurrency": true,
"isAvailable": true,
"isInvoiceable": true
}
]
}

2. Execute a payment quote

To pay the quote’s totalAmount, you must execute the quote. To execute the quote, use the payment quote execute endpoint and specify the paymentQuoteId that was returned in the quote generation response in step 1.

Below is an example request to execute a quote:

Example request:
curl -X 'PATCH' \
'https://<ENVIRONMENT>/v1/payment-quotes/<PAYMENT_QUOTE_ID>/execute' \
-H 'accept: application/json' \
-H 'Authorization: Bearer <API_KEY>' \
-H 'Content-Length: 0'

When a quote is executed, a response will be returned confirming the result of the quote execution, and the realized conversion rate and total amount paid.

Below is the response to the quote generation request:

Example response:
{
"result": "SUCCESS",
"delivered": "2023-02-03T03:28:34+00:00",
"conversionRate": {
"amount": "0.00004120",
"sourceCurrency": "USD",
"targetCurrency": "BTC"
},
"amount": {
"currency": "USD",
"amount": "0.50"
},
"lightningNetworkFee": {
"currency": "USD",
"amount": "0.01"
},
"totalAmount": {
"currency": "USD",
"amount": "0.51"
}
}

Please note that both the Lightning invoice you receive and the quote to pay that invoice have expiration times. If the Lightning invoice expires before being paid, then a new Lightning invoice must be obtained and a new quote must be generated to pay that new Lightning invoice. If only the quote expires before being executed, but the Lightning invoice remains unexpired, then you can simply generate a new quote to be executed.