Pay with Invoice

Important

Introduced in Android version 2.6.0 and iOS version 3.4.0

To pay with an invoice the app must require a BankId token using the getBankIdUrlForPayment method, providing a payment token.

After obtaining this URL, the app should use it to create an intent and launch the BankId App.
The staging environment can be configured to return URLs launching either bankID-sandbox or a web interface mocking the bankId responses.
The URLs are constructed in a way so that you should not need to process it before launching an app request on your platform.

Once the BankId intent is handled, the app should call getPaymentResponse in order to obtain the payment status. Invoice Flow

Get BankId Url

Provides a valid BankId token for this payment.

ParameterDescription
paymentTokenA payment token provider by the partner's backend
redirectUrlA valid URL for returning to the application.
receiveOnThe dispatch queue used when invoking the result callback handler. Defaults to main.
onResultResult callback handler.
Copy
Copied
SveaAppWallet.shared.getBankIdUrlForPayment(paymentToken: paymentToken, redirectUrl: URL) { [weak self] result in
    switch result {
    case .success(let bankIdUrl):
        // Using this bankId URL open BankId if installed.
        UIApplication.shared.open(bankIdUrl. options: [:], completionHandler: nil])
    case .failure(let error):
        print("Could not get bankId url, got error \(error)")
    }
}

onSuccess

Returned when a BankId token is successfully generated.

onFailure

Returned when an error occurs.

Possible errors

Copy
Copied
case noPaymentTokenProvided       // No payment token was found
case failedToGetBankIdUrl         //The bankId url could not be fetched

Get payment response

Returns the status of an invoice payment.

ParameterDescription
onResultResult callback handler.

onSuccess

Returned when a BankId payment is successfully completed.

onFailure

Returned when an error occurs.

Possible errors

Copy
Copied
case failedToPay                     // Failed to pay using invoice.
case failedToConfirmPayment          // Failed to get payment status