Get available payment methods
Important
This is only for card and invoice payments!
However, you don’t want your users to be able to add a card, a private invoice or a company invoice if you’re not offering these payment methods, right? Therefore, you must start with getting a list of available payment methods, and with that we mean that you need to check if Card- and Invoice payment is configured to your checkout.
In order to do that, call the
getAvailablePaymentMethods
function described below.info
You need to register a user token to get a successful response.
Getting available payment methods
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.getAvailablePaymentMethods() { [weak self] result in
switch result {
case .success(let availablePaymentMethods):
print("Got available payment methods: \(availablePaymentMethods)")
case .failure(let error):
print("Could not get available payment methods, got error: \(error)")
}
}
SveaWalletClient.shared.getAvailablePaymentMethods() { [weak self] result in
switch result {
case .onSuccess(let availablePaymentMethods):
print("Got available payment methods: \(availablePaymentMethods)")
case .onFailure(let error):
print("Could not get available payment methods, got error: \(error)")
}
}
onSuccess
Returned if successful, including a list of AvailablePaymentMethod
retrieved
from the Svea backend.
onFailure
Returned if the request to fetch available payment options failed.
Possible errors
case noUserTokenProvided // A user token has not been provided.
case failedToRetrieveAvailablePaymentMethods // The request could not be completed.
case unknownError // An unknown error occurred.