Get payment methods

To get a list of previously added payment methods that the user can create payments with (e.g. a specific card or Swish) call the getPaymentMethods function.
info

You need to register a user token to get a successful response.

Getting payment methods

ParameterDescription
receiveOnThe dispatch queue used when invoking the result callback handler. Defaults to main.
onResultResult callback handler.
Please note
SveaWalletClient is deprecated in version 3.1.0. Use new class SveaAppWallet instead.
SveaAppWalletSveaWalletClient (deprecated)
Copy
Copied
SveaAppWallet.shared.getPaymentMethods() { [weak self] result in
    switch result {
    case .success(let paymentMethods):
            print("Got payment methods: \(paymentMethods)")
    case .failure(let error):
            print("Could not get payment methods, got error: \(error)")
    }
}
Copy
Copied
SveaWalletClient.shared.getPaymentMethods() { [weak self] result in
    switch result {
    case .onSuccess(let paymentMethods):
            print("Got payment methods: \(paymentMethods)")
    case .onFailure(let error):
            print("Could not get payment methods, got error: \(error)")
    }
}

onSuccess

Returned if successful, including a list of PaymentMethod objects retrieved from the Svea backend.

onFailure

Returned if the request to fetch payment options failed.

Possible errors

Copy
Copied
case noUserTokenProvided                // A user token has not been provided.
case failedToRetrievePaymentMethods     // The request could not be completed.
case unknownError                       // An unknown error occurred.