Update a payment method

The isDefault and label fields of a payment method can be updated.
In order to do that, call the updatePaymentMethod function, providing the updated PaymentMethod.

Update a payment method

ParameterDescription
paymentMethodA valid payment method from the users wallet.
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
var paymentMethodToUpdate = paymentMethod
paymentMethodToUpdate.label = "New label"
paymentMethodToUpdate.isDefault = true

SveaAppWallet.shared.update(paymentMethod: paymentMethod) {
    switch $0 {
    case .success(let updatedMethod):
        print("Payment method successfully updated!")
    case .failure(let error):
        print("Could not update payment method, got error: \(error)")
    }
}
Copy
Copied
var paymentMethodToUpdate = paymentMethod
paymentMethodToUpdate.label = "New label"
paymentMethodToUpdate.isDefault = true

SveaWalletClient.shared.update(paymentMethod: paymentMethod) {
    switch $0 {
    case .onSuccess(let updatedMethod):
        print("Payment method successfully updated!")
    case .onFailure(let error):
        print("Could not update payment method, got error: \(error)")
    }
}

onSuccess

Returned when the payment method is successfully updated.

onFailure

Returned when an error occurs. If this happens, the payment method has not been updated.

Possible errors

Copy
Copied
case noUserTokenProvided             // A user token has not been provided.
case failedToUpdatePaymentMethod     // Payment method could not be updated.