Errors

The MPError enum and delegate-callback reference for Scan to PayKit.

Scan to PayKit reports failures in two layers: the delegate callback that fired (e.g. scanToPayError(_:) vs scanToPayPaymentFailed(...)) and, for the error callback specifically, the MPError enum value passed in.


Delegate callbacks vs MPError

LayerWhere it shows upHow to read it
Delegate methodWhich MPScanToPayDelegate method the SDK calledTells you what kind of outcome occurred
MPError enumThe argument passed to scanToPayError(_:)Tells you the specific cause

If scanToPayError(_:) fires, you'll have an MPError to inspect. For the other callbacks (success, failure, cancel, invalid code, registered, wallet completed), no MPError is involved.


MPScanToPayDelegate callbacks

CallbackWhen you'll see it
scanToPayPaymentSucceeded(withTransactionReference:)Customer completed payment (verify server-side)
scanToPayPaymentFailed(withTransactionReference:)Payment was attempted but failed (bank declined, etc.)
scanToPayUserDidCancel()Customer aborted before completing
scanToPayInvalidCode()code parameter was malformed, expired, or already used
scanToPayError(_:)An error occurred — see MPError below
scanToPayUserRegistered()Pre-registration completed
scanToPayUserCompletedWallet()Manage-card flow completed

MPError enum

typedef NS_ENUM(NSInteger, MPError) {
    MPErrorNetworkError,
    MPErrorExceptionOccurred,
    MPErrorPaymentError,
    MPErrorOTPError,
    MPErrorInvalidCodeParameter,
    MPErrorInvalidApiKeyParameter,
    MPErrorSecureCodeNotSupported
};
CaseDescriptionWhat to do
MPErrorNetworkErrorThe SDK couldn't reach the platformShow a "no network" message; let the customer retry
MPErrorExceptionOccurredAn unexpected internal exceptionRaise a support ticket with details (capture timestamp)
MPErrorPaymentErrorPayment-time error not surfaced as scanToPayPaymentFailedTreat like scanToPayPaymentFailed; let the customer retry
MPErrorOTPErrorOTP retrieval / validation failed during card registrationCustomer can re-request the OTP
MPErrorInvalidCodeParametercode parameter was missing or emptyFix the calling code — code is mandatory
MPErrorInvalidApiKeyParameterapiKey parameter was missing or invalidGenerate a fresh key in the Portal; verify the system (.live vs .test)
MPErrorSecureCodeNotSupportedThe card's BIN requires 3D Secure but isn't enabled for itCustomer needs a different card, or the BIN config needs platform support

Triage cheat sheet

delegate callback?
├── scanToPayPaymentSucceeded(...)   → verify on backend, fulfil order
├── scanToPayPaymentFailed(...)      → log reference, retry option
├── scanToPayUserDidCancel()         → noop or analytics
├── scanToPayInvalidCode()           → bug in your code-creation flow
├── scanToPayUserRegistered()        → onboarding complete
├── scanToPayUserCompletedWallet()   → manage flow done
└── scanToPayError(MPError)
                    ├── .networkError              → retry, friendly message
                    ├── .exceptionOccurred         → support ticket
                    ├── .paymentError              → retry payment
                    ├── .otpError                  → retry OTP
                    ├── .invalidCodeParameter      → integration bug
                    ├── .invalidApiKeyParameter    → integration bug
                    └── .secureCodeNotSupported    → unsupported card

What's next