Pay with Invoice
Important
Introduced in Android version 2.6.0 and iOS version 3.4.0
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 URLs are constructed in a way so that you should not need to process it before launching BankID from your app.
getPaymentResponse
in order to obtain the payment status.
Get BankId Url
Provides a valid BankId token for this payment.
Parameter | Description |
---|---|
paymentToken | A payment token provider by the partner's backend |
redirectUrl | A valid URL for returning to the application. |
receiveOn | The dispatch queue used when invoking the result callback handler. Defaults to main. |
onResult | Result callback handler. |
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
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.
Parameter | Description |
---|---|
onResult | Result callback handler. |
onSuccess
Returned when a BankId payment is successfully completed.
onFailure
Returned when an error occurs.
Possible errors
case failedToPay // Failed to pay using invoice.
case failedToConfirmPayment // Failed to get payment status
Test invoice payments with BankID
We provide two options for testing invoice payments with BankID in the stage environment. BankID mock will be used by default for new projects.
BankID mock
BankID mock is a web app that that simulates the BankID client. When configured for BankID mock, the example code above will open BankID mock in the default browser, and you will get options to test different scenarios.
Complete BankID session
Press one of the buttons to complete the BankID session and simulate a specific scenario:
- WebPay Approved will sign the BankID session with a test person that WebPay will approve credit for.
- When testing private invoice payment, this option will result in a successful payment.
- When testing company invoice payment, the payment will be approved or denied depending on the company org.no that was used when adding the company invoice.
- WebPay Denied (private invoice) will sign the BankID session with a test person that WebPay will deny credit for.
- Cancel will cancel the BankID session and no credit check will be made.
Note that the browser tab will stay open until you close it.
Test with redirectUrl
If you entered aredirectUrl
to your application you will get the option to use it when completing the BankID session.Note that some browsers will not work properly with this option
Test with delay
You can simulate either a delayed callback from the BankID server or a delayed redirect from the BankID client. This can be useful if you want to test your implementation for race conditions.
To use the client BankID redirect delay you must also provide theredirectUrl
. A server delay does not require the redirectUrl
, but you can use it for more precise timing.Get a BankID for test
The official BankID for test can be used for a more realistic test. Follow the link for instructions on how to set it up, then contact Svea to activate it.
If you are testing private invoice then you can use any of the personal numbers (person.no) bellow when setting up a BankID for test to get the desired result. They can also be used when testing company invoices, but they will not affect the result.
Result | Person.no | Name | Street | c/o | Zip code | City | Telephone |
---|---|---|---|---|---|---|---|
Approved | 4605092222 | Tess, T Persson | Testgatan 1 | c/o Eriksson, Erik | 99999 | Stan | 08 – 111 111 11 |
Denied | 4610081111 | Tess, T Persson | Testgatan 1 | c/o Eriksson, Erik | 99999 | Stan | 08 – 111 111 11 |
Abuse | 4606082222 | Tess, T Persson | Testgatan 1 | c/o Eriksson, Erik | 99999 | Stan | 08 – 111 111 11 |
Limit | 4611071111 | Tess, T Persson | Testgatan 1 | c/o Eriksson, Erik | 99999 | Stan | 08 – 111 111 11 |