strike

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

strike

This package is a pure Dart SDK wrapper for the Strike APIs (offical docs).
Strike APIs enable you to accept payments securely and integrate your app with Strike.
Support #






❤️ Sponsor on GitHub
Roadmap #

✅ Find user profiles by handle
✅ Find user profiles by ID
✅ Issue basic invoice
✅ Issue invoice to specific receiver
✅ Find invoice by ID
✅ Issue quote for invoice
✅ Cancel unpaid invoice
✅ Get currency exchange rates
✅ Open Strike App from Invoice (mobile)
✅ Open Strike App from Quote (mobile)
❌ Open Strike App from Invoice (web)
❌ Open Strike App from Quote (web)
❌ Get webhook events
❌ Find webhook events by ID
❌ Get webhook subscriptions
❌ Create new webhook subscriptions
❌ Find webhook subscription by ID
❌ Update webhook subscription
❌ Delete webhook subscription

Getting started #
In order to use the Strike API, you will need to request an API key.
Secure your API Key #
You can use the flutter_dotenv package to keep your API key safely out of public repositories.

Add flutter_dotenv to your pubspec.yaml
Add *.env to your project's .gitignore file
Create a .env file in the root of your project and add the following contents

STRIKE_API_KEY=<YOUR_API_KEY>
copied to clipboard

Add the .env file to the assets section of your pubspec.yaml and run flutter pub get

assets:
- .env
copied to clipboard
Usage #
Create your Strike instance.
Without flutter_dotenv:
Strike _strike = Strike(apiKey: '<YOUR_API_KEY>');
copied to clipboard
With flutter_dotenv:
await dotenv.load(fileName: '.env');

Strike _strike = Strike(apiKey:dotenv.env['STRIKE_API_KEY']!);
copied to clipboard
Issue an Invoice #
The only thing required to issue an invoice is an InvoiceAmount (which includes the quantity and type of currency being requested). All other fields are optional.
Both of the following methods will return the generated Invoice.
Issue an Invoice for Yourself #
await strike.issueInvoice(
handle: null,
correlationId: null,
description: null,
invoiceAmount: InvoiceAmount(
amount: 10,
currency: CurrencyType.USD,
),
);
copied to clipboard
When you issue an invoice without specifying a receiver, the invoice is created with your own personal Strike ID as both the "Issuer" and the "Receiver". In other words, when this invoice is paid, you receive the funds.
Issue an Invoice for Someone Else #
await strike.issueInvoice(
handle: '<RECEIVER_HANDLE>',
correlationId: null,
description: "Nice work!",
invoiceAmount: InvoiceAmount(
amount: 1,
currency: CurrencyType.BTC,
),
);
copied to clipboard
Open an Invoice in Strike #
The Strike mobile app accepts deep links of the following format: https://strike.me/pay/<INVOICE_ID>
Below is the workflow for using the link:

User opens the link
User see's the invoice's description and amount
User presses "Pay"
The Strike app generates a QR code for the invoice

This package depends on url_launcher. Each Invoice has an openStrikeApp() method that will open the appropriate deep link.
OutlinedButton(
child: const Text('Open Strike App'),
onPressed: () {
invoice?.openStrikeApp(); // launchUrl(Uri.parse('https://strike.me/pay/$invoiceId'));
},
),
copied to clipboard
If you'd rather have the Strike app handle the QR code generation, you can ignore the "Issue a Quote" section below.
Cancel an Unpaid Invoice #
Invoice? cancelledInvoice = await strike.cancelUnpaidInvoice(invoiceId: invoice?.invoiceId);
copied to clipboard
This endpoint will respond with a 422 error code if the Invoice is already cancelled.
Issue a Quote #
Once you have an Invoice, you can generate a quote for it (source).

strike.issueQuoteForInvoice(invoiceId: invoice.invoiceId)
copied to clipboard
Open a Quote in Strike #
The URL scheme for lightning payments is "lightning:<LIGHTNING_INVOICE>"
All apps that can accept lightning payment requests can be opened with this URL scheme.
OutlinedButton(
child: const Text('Open Strike'),
onPressed: () {
quote.openStrikeApp(); // launchUrl(Uri.parse('lightning:$lnInvoice'));
},
),
copied to clipboard
At the moment, the Strike browser extension cannot be opened by using launchUrl(). Instead, you will need to use the Link widget from the url_launcher package.
Link(
target: LinkTarget.blank,
uri: Uri.parse('lightning:<LNINVOICE>'),
builder: (context, onTap) {
return ElevatedButton(
onPressed: onTap,
child: const Text('Send'),
);
},
);
copied to clipboard
Generate a QR Code for the Quote #
Each Quote contains an "lnInvoice" field which is the encoded lightning invoice. Using the qr_flutter package you can easily turn that field into a QR Code your users can scan.
if(quote.lnInvoice != null) {
return QrImage(
data: quote.lnInvoice!,
version: QrVersions.auto,
size: 200.0,
);
}
copied to clipboard
Note that the generated QR code must be scanned from inside the Strike app. If you scan it outside of the app, it simply opens your note app with the QR contents.
Relevant Issues #

https://github.com/flutter/flutter/issues/43809
https://github.com/flutter/flutter/issues/102608#issuecomment-1110832339

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.