Pay with Swish
Deprecated
Deprecated in version 2.5.0 for Android SDK and version 3.3.0 for iOS SDK.
Use
Use
getSwishUrl instead.getSwishToken function using a payment token provided by your server.After obtaining this token, the app should use it to start the Swish app. Once the Swish intent is handled, the app should call
getPaymentResponse in order to obtain the payment status.
Get Swish Token
Provides a valid Swish token for this payment.
Note
Please read the official Swish documentation on how to launch the app with a token.
| 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 (deprecated)
SveaAppWallet.shared.getSwishToken(paymentToken: paymentToken) { [weak self] result in
switch result {
case .success(let swishToken):
// Build swish URL with token and open Swish if installed.
guard let swishUrl = URL(string: "swish://paymentrequest?token=\(token)&callbackurl=yourapp://example")
else { return } // Handle error creating url
UIApplication.shared.open(swishUrl. options: [:], completionHandler: nil])
case .failure(let error):
print("Could not get swish token, got error: \(error)")
}
}SveaWalletClient.shared.getSwishToken(paymentToken: paymentToken) { [weak self] result in
switch result {
case .onSuccess(let swishToken):
// Build swish URL with token and open Swish if installed.
guard let swishUrl = URL(string: "swish://paymentrequest?token=\(token)&callbackurl=yourapp://example")
else { return } // Handle error creating url
UIApplication.shared.open(swishUrl. options: [:], completionHandler: nil])
case .onFailure(let error):
print("Could not get swish token, got error: \(error)")
}
}onSuccess
Returned when a Swish token is successfully generated
onFailure
Returned when an error occurs.
Possible errors
case unknownError // An unknown error occurred.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 unknownError // An unknown error occurred.