Pay with Invoice

Deprecated
Deprecated in version 2.6.0 for Android SDK and version 3.4.0 for iOS SDK.
Use getBankIdUrl instead.
To pay with an invoice the app must require a BankId token using the getBankIdTokenForPayment method, providing a payment token.
After obtaining this token, the app should use it to start the BankId app. Once the BankId intent is handled, the app should call getPaymentResponse in order to obtain the payment status.

Get BankId Token

Provides a valid BankId token for this payment.

ParameterDescription
receiveOnThe dispatch queue used when invoking the result callback handler. Defaults to main.
paymentTokenA payment token provider by the partner's backend
onResultResult callback handler.
Please note
SveaWalletClient is deprecated in version 3.1.0. Use new class SveaAppWallet instead.
SveaAppWalletSveaWalletClient (deprecated)
Copy
Copied
SveaAppWallet.shared.getBankIdTokenForPayment(paymentToken: paymentToken) { [weak self] result in
    switch result {
    case .success(let bankIdToken):
        // Build bankId URL with token and open BankId if installed.
        guard let bankUrl = URL(string: "bankid:///?autostarttoken=\(bankIdToken)&redirect=yourapp://example")
        else { return } // Handle error creating url
        UIApplication.shared.open(bankUrl. options: [:], completionHandler: nil])
    case .failure(let error):
        print("Could not get bankId token, got error \(error)")
    }
}
Copy
Copied
SveaWalletClient.shared.getBankIdTokenForPayment(paymentToken: paymentToken) { [weak self] result in
    switch result {
    case .onSuccess(let bankIdToken):
        // Build bankId URL with token and open BankId if installed.
        guard let bankUrl = URL(string: "bankid:///?autostarttoken=\(bankIdToken)&redirect=yourapp://example")
        else { return } // Handle error creating url
        UIApplication.shared.open(bankUrl. options: [:], completionHandler: nil])
    case .onFailure(let error):
        print("Could not get bankId token, got error \(error)")
    }
}

onSuccess

Returned when a BankId token is successfully generated.

onFailure

Returned when an error occurs.

Possible errors

Copy
Copied
case unknownError                 // An unknown error occurred.
case failedToRetrieveBankIdToken  //The bankId token could not be fetched

Get payment response

Returns the status of an invoice payment.

ParameterDescription
onResultResult callback handler.
Copy
Copied
SveaWalletClient.shared.getPaymentResponse() { [weak self] result in
    switch result {
    case .onSuccess():
        print("Invoice payment completed!")
    case .onFailure(let error):
        print("Invoice payment could not be completed, got error \(error)")
    }
}

onSuccess

Returned when a BankId payment is successfully completed.

onFailure

Returned when an error occurs.

Possible errors

Copy
Copied
case unknownError           // An unknown error occurred.
case failedToPay            // Failed to pay using invoice.