flutter_swish_payment 0.0.1-alpha flutter_swish_payment: ^0.0.1-alpha copied to clipboard
A Swish commerce widget library for Flutter.
flutter_swish_payment #
A Swish commerce widget library for Flutter.
What is Swish? #
Swish is a mobile payment system in Sweden. The service works through a smartphone application, through which the user's phone number is connected to their bank account, and which makes it possible to transfer money in real time. Learn more at Swish.
Usage #
After installing and importing flutter_swish_payment, follow these steps to start using it:
- Get the Swish certificates for your organization either from the Swish Company Portal or from your internal organization. If you are developing a private project and want to test around in the Swish environment, Swish provides downloadable test certificates on their environments page.
- Initialize a
SwishAgent
with the certificates. This could be done directly in the main function. (Be careful about how you store your certificates!)
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
ByteData cert = await rootBundle.load(
'assets/swish_merchant_test_certificate.pem',
);
ByteData key = await rootBundle.load(
'assets/swish_merchant_test_certificate.key',
);
ByteData ca = await rootBundle.load(
'assets/swish_TLS_root_CA.pem',
);
String credential = "passwordForCertificates";
SwishAgent swishAgent = SwishAgent.initializeAgent(
cert: cert,
key: key,
ca: ca,
credential: credential,
);
...
}
- Create a
SwishClient
and provide it theSwishAgent
.
SwishClient swishClient = SwishClient(
swishAgent: swishAgent,
);
- You are now all set to start sending payment requests. Check out the documentation for
SwishClient
for guidance.
Open Swish #
Redirecting the user to the Swish app upon a payment request differs from device to device. Currently the only supported device is Android.
Android 11 and later #
Declare intent to open Swish in AndroidManifest.xml
. Add the following in <queries> … </queries>
(if no queries section is present, create it inside of manifest
).
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="swish" />
</intent>
The end result should look something like this:
<manifest>
<application>
...
</application>
<queries>
<!-- Open swish -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="swish" />
</intent>
</queries>
</manifest>
Learn more at:
Contributing #
flutter_swish_payment is still in its early development. Help us out by reporting bugs, propose new features or even contribute with your own code on our Github. Together we can take this project to the next level and release a final version.