# Checkout (iOS SDK) The checkout flow wraps the complete payment experience, allowing users to select a payment method, then creates and pays the invoice. ![Tilia Hosted Checkout](/assets/ios-checkout-final.98af8bf6729684924566682b61937005c34dec479de4a5f1c693aae0552178dc.9c1bb791.png) ### Prerequisites - Authorized User Password Token (A User Password Token is a string that enables Tilia Wallet to verify that a request belongs to an authorized session) - Authorized Invoice ID (The ID for the Authorized invoice you created - see more info below) All methods and flows in the Tilia SDK require you to have a server setup that communicates with Tilia’s APIs (your server will have a private api key which needs to remain secure and should never be exposed to client-side applications). Your client application should communicate with your own api (ensuring user authentication) to retrieve data required by the Tilia SDK. #### Server-Side Code Example to create an Authorized Invoice and retrieve required information for the SDK - Requires your server to retrieve a client credentials access token. See more [here](/authentication). - Requires an account id for a user that has been registered with Tilia. See more [here](/guides/register-user). - Requires a payload outlining the details of your Authorized Invoice. See more . ```json curl --location --request POST 'https://invoicing.staging.tilia-inc.com/v2/authorize/invoice' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer CLIENT_CREDENTIALS_ACCESS_TOKEN' \ --data-raw '{ "account_id": "USER_ACCOUNT_ID", "is_escrow": false, "invoice_mechanism": "api", "reference_type": "My test order", "reference_id": "123456789", "line_items": [ { "description": "Line item 1", "product_sku": "ABC123", "transaction_type": "user_to_integrator", "currency": "USD", "amount": 1, "recipients": [] }, { "description": "Line item 2", "product_sku": "DEF456", "transaction_type": "user_to_integrator", "currency": "USD", "amount": 2, "recipients": [] }, { "description": "Line item 3", "product_sku": "GHI789", "transaction_type": "user_to_integrator", "currency": "USD", "amount": 3, "recipients": [] } ] }' ``` #### Example Response Payload ```json { "status": "Success", "message": [], "codes": [], "payload": { "authorized_invoice_id": "AUTHORIZED_INVOICE_ID", "password_token": "AUTHORIZED_USER_PASSWORD_TOKEN" } } ``` Your api should return the `authorized_invoice_id` and `password_token` to your client application to use in the Tilia SDK. ### Swift Code Example ```swift let yourViewControllerForPresenting = UIViewController() TLManager.shared.setToken("AUTHORIZED_USER_PASSWORD_TOKEN") TLManager.shared.presentCheckoutViewController(on: yourViewControllerForPresenting, withInvoiceId: "AUTHORIZED_INVOICE_ID", animated: true, onUpdate: { onUpdate in print(onUpdate.description) }, onComplete: { onComplete in print(onComplete.description) }, onError: { onError in print(onError.description) }) ``` ### Demo App Example You can see an example of the Checkout flow in our demo application. See more [here](/sdks/ios-demo-app)