Add a private invoice

Creating a private invoice

As the user enters their contact information, create a PrivateInvoiceInfo object.

Adding a private invoice

ParameterDescription
privateInvoiceInfoA PrivateInvoiceInfo object.
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
let myPrivateInvoiceInfo = PrivateInvoiceInfo(
    email: "user@email.com",
    isDefault: false
)

SveaAppWallet.shared.addPrivate(invoice: myPrivateInvoiceInfo) { [weak self] result in
    switch result {
    case .success(let paymentMethod):
        print("Invoice successfully added \(paymentMethod)")
    case .failure(let error):
        print("Invoice could not be added, got error \(error)")
    }
}
Copy
Copied
let myPrivateInvoiceInfo = PrivateInvoiceInfo(
    email: "user@email.com",
    isDefault: false
)

SveaWalletClient.shared.addPrivate(invoice: myPrivateInvoiceInfo) { [weak self] result in
    switch result {
    case .onSuccess(let paymentMethod):
        print("Invoice successfully added \(paymentMethod)")
    case .onFailure(let error):
        print("Invoice could not be added, got error \(error)")
    }
}

onSuccess

Returned if the invoice was successfully added, including the invoice information in a PaymentMethod.

onFailure

Returned if the private invoice cannot be added.

Possible errors

Copy
Copied
case unknownError           // An unknown error occurred.
case invalidEmailAddress    // The email is not valid.
case failedToAddInvoice     // Something went wrong while adding an invoice.