# Accept payments

import { Aside, Steps, Tabs, TabItem } from '@astrojs/starlight/components';

This guide shows the core card-reader payment flow for both mobile SDKs.

For platform-specific setup details, permissions, and advanced options, use the full documentation:

- [iOS Terminal SDK](/terminal-payments/sdks/ios-sdk)
- [Android Reader SDK](/terminal-payments/sdks/android-sdk)
- [Android Tap-to-Pay SDK](/terminal-payments/sdks/android-ttp) (phone-based contactless payments without a separate reader)

## Prerequisites

- A SumUp merchant account (or [sandbox merchant account](/terminal-payments/#getting-a-sandbox-merchant-account)).
- An [Affiliate Key](/tools/authorization/affiliate-keys/) linked to your app.
- A compatible card reader paired with the merchant account.

## Basic Payment Flow

<Steps>

1. Initialize the SDK with your Affiliate Key.
2. Log the merchant in.
3. Optionally prepare the reader connection before checkout.
4. Create a checkout request and start payment.
5. Handle the result in your app.

</Steps>

### 1. Initialize the SDK

<Tabs syncKey="mobile_platform">
  <TabItem label="iOS">

```swift
import SumUpSDK

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
    ) -> Bool {
        SumUpSDK.setup(withAPIKey: "sup_afk_abcqwerty")
        return true
    }
}
```

  </TabItem>
  <TabItem label="Android">

```java
public class SampleApplication extends Application {
  @Override
  public void onCreate() {
    super.onCreate();
    SumUpState.init(this);
  }
}
```

  </TabItem>
</Tabs>

### 2. Authenticate

<Tabs syncKey="mobile_platform">
  <TabItem label="iOS">

```swift
SumUpSDK.presentLogin(from: self, animated: true) { success, error in
    if let error {
        print("Login error: \(error)")
        return
    }

    if success {
        print("Merchant logged in")
    }
}
```

  </TabItem>
  <TabItem label="Android">

```java
SumUpLogin login = SumUpLogin.builder("sup_afk_abcqwerty").build();
SumUpAPI.openLoginActivity(this, login, 1);
```

  </TabItem>
</Tabs>

### 3. Prepare for Checkout (Optional)

Use this when the merchant is about to charge, so the SDK can wake/reconnect the reader early.

<Tabs syncKey="mobile_platform">
  <TabItem label="iOS">

```swift
SumUpSDK.prepareForCheckout()
```

  </TabItem>
  <TabItem label="Android">

```java
SumUpAPI.prepareForCheckout();
```

  </TabItem>
</Tabs>

### 4. Start a Payment

<Tabs syncKey="mobile_platform">
  <TabItem label="iOS">

```swift
guard let merchantCurrencyCode = SumUpSDK.currentMerchant?.currencyCode else {
    return
}

let request = CheckoutRequest(
    total: NSDecimalNumber(string: "12.34"),
    title: "Coffee",
    currencyCode: merchantCurrencyCode
)
request.foreignTransactionID = UUID().uuidString

SumUpSDK.checkout(with: request, from: self) { result, error in
    if let error {
        print("Checkout error: \(error)")
        return
    }

    if let result {
        print("Result: \(result.success), transactionCode: \(result.transactionCode ?? "-")")
    }
}
```

  </TabItem>
  <TabItem label="Android">

```java
SumUpPayment payment = SumUpPayment.builder()
    .total(new BigDecimal("12.34"))
    .currency(SumUpPayment.Currency.EUR)
    .title("Coffee")
    .foreignTransactionId(UUID.randomUUID().toString())
    .build();

SumUpAPI.checkout(this, payment, 2);
```

  </TabItem>
</Tabs>

### 5. Handle the Checkout Result

<Tabs syncKey="mobile_platform">
  <TabItem label="iOS">

```swift
// Handled in the completion block of SumUpSDK.checkout(...)
// Use result.success, result.transactionCode, and error for your UI/state updates.
```

  </TabItem>
  <TabItem label="Android">

```java
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  if (requestCode == 2 && data != null) {
    int code = data.getExtras().getInt(SumUpAPI.Response.RESULT_CODE);
    String message = data.getExtras().getString(SumUpAPI.Response.MESSAGE);
    String txCode = data.getExtras().getString(SumUpAPI.Response.TX_CODE);
    // Update your UI/state here.
  }
}
```

  </TabItem>
</Tabs>

<Aside type="note">
Use a unique `foreignTransactionId` per payment to avoid duplicate transaction conflicts and to simplify reconciliation.
</Aside>

## Continue with Full SDK Guides

- [iOS Terminal SDK full guide](/terminal-payments/sdks/ios-sdk)
- [Android Reader SDK full guide](/terminal-payments/sdks/android-sdk)