initialize static method

void initialize({
  1. required String clientId,
  2. required String referrer,
  3. required int merchantId,
  4. required String appId,
  5. required Environment environment,
  6. String? baseUrlOverride,
  7. String? clientSecret,
  8. String? secretHashKey,
})

Call once, as early as possible (e.g. in main()), before any other SwichPay method.

No merchant-backend proxy to wire up - given clientSecret, the SDK exchanges it for an OAuth2 bearer token itself (and refreshes it automatically); pass it whenever you have it, which is required for the payment sheet / session-based checkout to work reliably. Without one, the SDK falls back to sending clientId as a plain x-public-key header, which only a subset of endpoints accept.

secretHashKey is a different secret, only needed for SwichPay.presentCardCheckout - don't pass the same value for both, the server rejects the token exchange if you do.

Implementation

static void initialize({
  required String clientId,
  required String referrer,
  required int merchantId,
  required String appId,
  required Environment environment,
  String? baseUrlOverride,
  String? clientSecret,
  String? secretHashKey,
}) {
  _client = SwichPayClient(
    SwichPayConfig(
      clientId: clientId,
      referrer: referrer,
      merchantId: merchantId,
      appId: appId,
      environment: environment,
      baseUrlOverride: baseUrlOverride,
      clientSecret: clientSecret,
      secretHashKey: secretHashKey,
    ),
  );
}