Pay with Swish
Important
Introduced in Android version 2.5.0 and iOS version 3.3.0.
getSwishUrl
function using a payment token provided by your server.After obtaining this URL, the app should use it to create an intent and launch the Swish App. The staging environment can be configured to return URLs launching either swish-sandbox or a web interface mocking the swish responses. The URLs are consutructed in a way so that you should not need to process it before launching an app request on your platform.Once the Swish intent is handled, the app should call
getPaymentResponse
in order to obtain the payment status.

Get Swish URL
Provides a valid Swish URL for this payment.
Parameter | Description |
---|---|
paymentToken | A valid payment token from your backend. |
callbackUrl | 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.getSwishUrl(paymentToken: paymentToken, callbackUrl: URL) { [weak self] result in
switch result {
case .success(let swishUrl):
// Using swish url open Swish if installed.
UIApplication.shared.open(swishUrl. options: [:], completionHandler: nil])
case .failure(let error):
print("Could not get swish url, got error: \(error)")
}
}
onSuccess
Returned when a URL to used to launch swish is successfully generated
onFailure
Returned when an error occurs.
Possible errors
case noPaymentTokenProvided // No payment token was found
case failedToGetSwishUrl // The request could not be completed.
Get payment response
Returns the status of a Swish payment
Parameter | Description |
---|---|
receiveOn | The dispatch queue used when invoking the result callback handler. Defaults to main. |
onResult | Result callback handler. |
Please note
SveaWalletClient
is deprecated in version 3.1.0. Use new class SveaAppWallet
instead.
SveaAppWalletSveaWalletClient
SveaAppWallet.shared.getSwishPaymentResponse { [weak self] result in
switch result {
case .success:
print("Swish payment completed!")
case .failure(let error):
print("Swish payment could not be completed, got error \(error)")
}
}
SveaWalletClient.shared.getSwishPaymentResponse { [weak self] result in
switch result {
case .onSuccess:
print("Swish payment completed!")
case .onFailure(let error):
print("Swish payment could not be completed, got error \(error)")
}
}
onSuccess
Returned when a Swish payment is successfully completed.
onFailure
Returned when an error occurs.
Possible errors
case noPaymentTokenProvided // No payment token was found
case failedToConfirmPaymentStatus // Payment failed