Update a payment method
TheisDefault 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
| Parameter | Description |
|---|---|
| paymentMethod | A valid payment method from the users wallet. |
| 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)
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)")
}
}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
case noUserTokenProvided // A user token has not been provided.
case failedToUpdatePaymentMethod // Payment method could not be updated.