# iOS: Swift: MobilePaymentsSDK: Payments screen would not get presented for card reader swipe

**URL:** <https://developer.squareup.com/forums/t/ios-swift-mobilepaymentssdk-payments-screen-would-not-get-presented-for-card-reader-swipe/22625>\
**Category:** Questions\
**Tags:** sdk, mobile-payments-sdk\
**Created:** [June 3, 2025, 5:38am UTC](https://developer.squareup.com/forums/t/ios-swift-mobilepaymentssdk-payments-screen-would-not-get-presented-for-card-reader-swipe/22625 "2025-06-03T05:38:26Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![iamchandra](https://avatars.discourse-cdn.com/v4/letter/i/46a35a/32.png) [@iamchandra](https://developer.squareup.com/forums/u/iamchandra)\
**Post date:** [June 3, 2025, 5:38am UTC](https://developer.squareup.com/forums/t/ios-swift-mobilepaymentssdk-payments-screen-would-not-get-presented-for-card-reader-swipe/22625/1 "2025-06-03T05:38:26Z")

</div>

I am expecting this below method would present attached screen on my app. But, it does not.

May I know the reasons in what instances this method `makeSquareTransaction()` would not present the payment screen? Or, how do I correct this method?

```auto
func makeSquareTransaction(
    centsAmount: Int,
    notes: String,
    from viewController: UIViewController) {
    guard let vc = viewController as? PaymentManagerDelegate else {
        print("PaymentManagerDelegate is required")
        return
    }
    let amountMoney = Money(amount: UInt(centsAmount), currency: .USD)
    let paymentParams = makePaymentParameters(amountMoney: amountMoney)
    let paymentPromptParameters = PromptParameters(
        mode: .default,
        additionalMethods: .all
    )
    
    MobilePaymentsSDK.shared.paymentManager.startPayment(
        paymentParams,
        promptParameters: paymentPromptParameters,
        from: viewController,
        delegate: vc
    )
}

func makePaymentParameters(amountMoney: Money) -> PaymentParameters {
    PaymentParameters(
        // Unique idempotency String for payment
        idempotencyKey: String(UUID().uuidString.prefix(8)),

        // Amount to transact and always in USD
        amountMoney: Money(amount: amountMoney.amount, currency: .USD),

        // Supports only online
        processingMode: .onlineOnly
    )
}

```

 ![square-screen](https://global.discourse-cdn.com/square/original/2X/e/e08bbac338a8e1c2891345ba900faf850969f0a7.jpeg)

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [June 3, 2025, 4:29pm UTC](https://developer.squareup.com/forums/t/ios-swift-mobilepaymentssdk-payments-screen-would-not-get-presented-for-card-reader-swipe/22625/2 "2025-06-03T16:29:08Z")

</div>

Are you getting an error when this code runs? If so what’s the error message. 🙂

---

<div class="post-metadata">

**Author:** ![iamchandra](https://avatars.discourse-cdn.com/v4/letter/i/46a35a/32.png) [@iamchandra](https://developer.squareup.com/forums/u/iamchandra)\
**Post date:** [June 3, 2025, 4:45pm UTC](https://developer.squareup.com/forums/t/ios-swift-mobilepaymentssdk-payments-screen-would-not-get-presented-for-card-reader-swipe/22625/3 "2025-06-03T16:45:52Z")

</div>

1. No, I don’t get any error.
2. I can’t enable SSL on this to monitor the traffic on Square production APIs to see if this calls any API and what could be the error.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [June 3, 2025, 4:54pm UTC](https://developer.squareup.com/forums/t/ios-swift-mobilepaymentssdk-payments-screen-would-not-get-presented-for-card-reader-swipe/22625/4 "2025-06-03T16:54:13Z")

</div>

### Common Reasons for Payment Screen Not Appearing

1. **SDK Initialization** First, verify the SDK is properly initialized. Add this before calling `makeSquareTransaction`:

```auto
// Add at app startup or before payments
func initializeSDK() {
    do {
        try MobilePaymentsSDK.shared.initialize(applicationLaunchOptions: nil)
        print("Square SDK initialized successfully")
    } catch {
        print("Failed to initialize Square SDK: \(error)")
    }
}

```

1. **Delegate Implementation** Ensure your view controller properly implements `PaymentManagerDelegate`:

```auto
class YourViewController: UIViewController, PaymentManagerDelegate {
    // Required delegate methods
    func paymentManager(_ paymentManager: PaymentManager, didCompletePayment result: PaymentResult) {
        // Handle successful payment
    }
    
    func paymentManager(_ paymentManager: PaymentManager, didFailPayment error: Error) {
        // Handle payment failure
    }
    
    func paymentManagerDidCancel(_ paymentManager: PaymentManager) {
        // Handle payment cancellation
    }
}

```

1. **Modified Payment Parameters** Here’s the complete `makePaymentParameters` function with all required fields:

```auto
func makePaymentParameters(amountMoney: Money) -> PaymentParameters {
    return PaymentParameters(
        idempotencyKey: UUID().uuidString,
        amountMoney: amountMoney,
        // Add these required parameters
        autocomplete: false,
        locationId: "YOUR_LOCATION_ID",
        customerId: nil, // Optional
        notes: notes, // Optional
        statementDescription: nil, // Optional
        metadata: nil // Optional
    )
}

```

1. **Updated Transaction Method** Here’s the corrected `makeSquareTransaction` method with error handling:

```auto
func makeSquareTransaction(
    centsAmount: Int,
    notes: String,
    from viewController: UIViewController
) {
    // Verify SDK initialization
    guard MobilePaymentsSDK.shared.isInitialized else {
        print("Square SDK not initialized")
        return
    }
    
    // Verify delegate
    guard let vc = viewController as? PaymentManagerDelegate else {
        print("PaymentManagerDelegate is required")
        return
    }
    
    // Create payment parameters
    let amountMoney = Money(amount: UInt(centsAmount), currency: .USD)
    let paymentParams = makePaymentParameters(amountMoney: amountMoney)
    
    // Create prompt parameters
    let paymentPromptParameters = PromptParameters(
        mode: .default,
        additionalMethods: .all
    )
    
    // Start payment with completion handler
    DispatchQueue.main.async {
        MobilePaymentsSDK.shared.paymentManager.startPayment(
            paymentParams,
            promptParameters: paymentPromptParameters,
            from: viewController,
            delegate: vc
        ) { result in
            switch result {
            case .success:
                print("Payment screen presented successfully")
            case .failure(let error):
                print("Failed to present payment screen: \(error)")
            }
        }
    }
}

```

### Implementation Checklist

1. **Verify Info.plist Settings**

```auto
<key>NSCameraUsageDescription</key>
<string>Required for card scanning</string>
<key>NSMicrophoneUsageDescription</key>
<string>Required for tap to pay</string>
<key>NSNFCReaderUsageDescription</key>
<string>Required for tap to pay</string>

```

1. **Add Required Capabilities** In Xcode:

- Enable “Near Field Communication Tag Reading” capability
- Enable “Payment Processing” capability

1. **Usage Example**

```auto
class YourViewController: UIViewController, PaymentManagerDelegate {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        initializeSDK()
    }
    
    @IBAction func onPayButtonTapped(_ sender: Any) {
        makeSquareTransaction(
            centsAmount: 1000, // $10.00
            notes: "Test payment",
            from: self
        )
    }
    
    // Delegate methods implementation
    func paymentManager(_ paymentManager: PaymentManager, didCompletePayment result: PaymentResult) {
        print("Payment completed: \(result)")
    }
    
    func paymentManager(_ paymentManager: PaymentManager, didFailPayment error: Error) {
        print("Payment failed: \(error)")
    }
    
    func paymentManagerDidCancel(_ paymentManager: PaymentManager) {
        print("Payment cancelled")
    }
}

```

### Debugging Steps

1. Add logging to track the flow:

```auto
print("SDK Initialized: \(MobilePaymentsSDK.shared.isInitialized)")
print("Payment Parameters: \(paymentParams)")
print("View Controller: \(viewController)")

```

1. Check for any console errors or warnings
2. Verify you’re calling this on the main thread

---

<div class="post-metadata">

**Author:** ![iamchandra](https://avatars.discourse-cdn.com/v4/letter/i/46a35a/32.png) [@iamchandra](https://developer.squareup.com/forums/u/iamchandra)\
**Post date:** [June 4, 2025, 6:53pm UTC](https://developer.squareup.com/forums/t/ios-swift-mobilepaymentssdk-payments-screen-would-not-get-presented-for-card-reader-swipe/22625/5 "2025-06-04T18:53:15Z")

</div>

Thank you for your reply @Bryan-Square

The suggested usage of the methods from SDK might have changed because I get the below errors. Could you please check?

* * *

### Compilation Error - 1

> [@Bryan-Square](#):
>
> ```auto
> // Verify SDK initialization
> guard MobilePaymentsSDK.shared.isInitialized else {
> print("Square SDK not initialized")
> return
> }
> 
> ```

![image](https://global.discourse-cdn.com/square/optimized/2X/7/769858036e8258056b07427c9feda9a2d5a900af_2_690x45.png)

* * *

### Compilation Error - 2

> [@Bryan-Square](#):
>
> ```auto
> do {
> try MobilePaymentsSDK.shared.initialize(applicationLaunchOptions: nil)
> print("Square SDK initialized successfully")
> } catch {
> print("Failed to initialize Square SDK: \(error)")
> }
> 
> ```

 ![image](https://global.discourse-cdn.com/square/original/2X/9/95ebeed08f8035ea74691dfe3c0f6fe7bc6dbb28.png)

[quote=“Bryan-Square, post:4, topic:22625”]

* * *

### Compilation Error - 3

This error occurs when I add the `block` to the `startPayment` method that has check for the `result`.

> [@](#):
>
> ```auto
> // Start payment with completion handler
> DispatchQueue.main.async {
> MobilePaymentsSDK.shared.paymentManager.startPayment(
> paymentParams,
> promptParameters: paymentPromptParameters,
> from: viewController,
> delegate: vc
> ) { result in
> switch result {
> case .success:
> print("Payment screen presented successfully")
> case .failure(let error):
> print("Failed to present payment screen: \(error)")
> }
> }
> }
> 
> ```

 ![image](https://global.discourse-cdn.com/square/original/2X/9/980db568bf8b9b024f62eb7923fd3f42326f5875.png)

* * *

I am able to add “Near Field Communication Tag Reading” capability. But not “Payment Processing” as such capability is not listed when I searched.

> [@Bryan-Square](#):
>
> 1. **Add Required Capabilities** In Xcode:
> 
> - Enable “Near Field Communication Tag Reading” capability
> - Enable “Payment Processing” capability

 ![image](https://global.discourse-cdn.com/square/original/2X/a/a356c0a0ab7b847f6a878176f067f535b73c9e80.png)

Thank you much

---

<div class="post-metadata">

**Author:** ![iamchandra](https://avatars.discourse-cdn.com/v4/letter/i/46a35a/32.png) [@iamchandra](https://developer.squareup.com/forums/u/iamchandra)\
**Post date:** [June 5, 2025, 7:24pm UTC](https://developer.squareup.com/forums/t/ios-swift-mobilepaymentssdk-payments-screen-would-not-get-presented-for-card-reader-swipe/22625/6 "2025-06-05T19:24:20Z")

</div>

Hi @Bryan-Square , I hope you had chance to check this. The code you suggested are having compilation errors. Could that be from older version of SDK? I am using `2.2.3` version of SquarePaymentsSDK

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [June 5, 2025, 7:31pm UTC](https://developer.squareup.com/forums/t/ios-swift-mobilepaymentssdk-payments-screen-would-not-get-presented-for-card-reader-swipe/22625/7 "2025-06-05T19:31:21Z")

</div>

What was the last version that you had working? 🙂

---

<div class="post-metadata">

**Author:** ![iamchandra](https://avatars.discourse-cdn.com/v4/letter/i/46a35a/32.png) [@iamchandra](https://developer.squareup.com/forums/u/iamchandra)\
**Post date:** [June 10, 2025, 5:12pm UTC](https://developer.squareup.com/forums/t/ios-swift-mobilepaymentssdk-payments-screen-would-not-get-presented-for-card-reader-swipe/22625/8 "2025-06-10T17:12:06Z")

</div>

Hi @Bryan-Square

Sorry for the late reply, I was out of station.  
We were migrating from SquareReaderSDK to SquarePaymentsSDK. This is the first time we are using `SquarePaymentsSDK` and the version is `2.2.3`.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [June 10, 2025, 7:05pm UTC](https://developer.squareup.com/forums/t/ios-swift-mobilepaymentssdk-payments-screen-would-not-get-presented-for-card-reader-swipe/22625/9 "2025-06-10T19:05:24Z")

</div>

So it’s just the payment that’s failing? are you able to connect a reader? 🙂

---

<div class="post-metadata">

**Author:** ![iamchandra](https://avatars.discourse-cdn.com/v4/letter/i/46a35a/32.png) [@iamchandra](https://developer.squareup.com/forums/u/iamchandra)\
**Post date:** [June 10, 2025, 7:40pm UTC](https://developer.squareup.com/forums/t/ios-swift-mobilepaymentssdk-payments-screen-would-not-get-presented-for-card-reader-swipe/22625/10 "2025-06-10T19:40:27Z")

</div>

Here are the series of events happened on this chat. 3rd point onwards.

1. I followed the SDK example and developed code.
2. With the code that I developed - I am unable to present the Payment Screen. I believe - similar to ReaderSDK, I will be able to connect my Reader once I present the Square payment screen attached to this comment. But, I am unable to present that Square screen.
3. So, I raised this ticket.
4. You suggested some code changes.
5. I incorporated those changes. And, I am having compilation errors with the code-changes that you mentioned [on this comment](https://developer.squareup.com/forums/t/ios-swift-mobilepaymentssdk-payments-screen-would-not-get-presented-for-card-reader-swipe/22625/4).
6. I mentioned those compilation errors in [this comment on this same thread.](https://developer.squareup.com/forums/t/ios-swift-mobilepaymentssdk-payments-screen-would-not-get-presented-for-card-reader-swipe/22625/5).

 ![image](https://global.discourse-cdn.com/square/original/2X/9/9946709d7dd3e5c565a6212aeedd2db51833b1a9.png)

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [June 10, 2025, 9:05pm UTC](https://developer.squareup.com/forums/t/ios-swift-mobilepaymentssdk-payments-screen-would-not-get-presented-for-card-reader-swipe/22625/11 "2025-06-10T21:05:28Z")

</div>

Connecting to a reader will be on a different screen then the payment screen. If you revert the changes back to when it was working are there any errors? 🙂
