# 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:** 1\
**Showing post:** 4

<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

---

_[View the full topic](https://developer.squareup.com/forums/t/ios-swift-mobilepaymentssdk-payments-screen-would-not-get-presented-for-card-reader-swipe/22625)._
