SwishAgent class

Swish Agent

Handles Public key infrastructure (PKI). Must be initialized with the organization’s Swish certificate, key, and certificate authority.

It is important that it is ensured that everything has been loaded before calling SwishAgent.initializeAgent. This is preferably done using:

WidgetsFlutterBinding.ensureInitialized();

This sample demonstrates how to initialize a SwishAgent using test PKI files.

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');

  String credential = "swish";

  SwishAgent swishAgent = SwishAgent.initializeAgent(
    cert: cert,
    key: key,
    credential: credential,
  );

  SwishClient swishClient = SwishClient(
    swishAgent: swishAgent,
  );
  runApp(
    FlutterSwishPaymentDemo(
      swishClient: swishClient,
    ),
  );
}

For more info about PKI:

Constructors

SwishAgent.initializeAgent({required ByteData key, required ByteData cert, required String credential})
Create an instance of SwishAgent, all parameters mustn’t be null.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
instructionUUID String
Get a random 32 hexadecimal UUID (Universally unique identifier). While it is random, a collision is extremely unlikely. The number of random UUIDs which need to be generated in order to have a 50% probability of at least one collision is 2.71 quintillion…
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
securityContext SecurityContext
Get the security context based on the provided certificates.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited