> For the complete documentation index, see [llms.txt](https://docs.payments.thalescloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payments.thalescloud.io/nfc-wallet-sdk-ios/implement-nfc-wallet/make-payments/other-payment-methods/implement-dsrp-remote-payment.md).

# Implement DSRP remote payment

## Overview

Use Mastercard DSRP remote payment to generate payment data for remote acceptance (for example, e-commerce).

In this flow, your digital wallet application generates payment data. You then pass that data to your merchant system or payment gateway for authorization.

Before you implement DSRP remote payments, complete **Tokenization**. See [Tokenize a card](/nfc-wallet-sdk-ios/implement-nfc-wallet/tokenize-a-card.md).

{% hint style="warning" %}
The NFC Wallet SDK supports DSRP remote payment for **Mastercard** digital cards with the **MCBP 2.x profile** only.

If you need DSRP remote payment for a different profile or payment network, contact your Thales delivery team.
{% endhint %}

## SDK integration

### Check prerequisites

Confirm the digital card supports DSRP remote payment using `DigitalCard.Details.isPaymentTypeSupported()` with `PaymentType.dsrp`.

```swift
func checkCardSupportForDSRP(card: DigitalCard) async throws -> Bool {
    return try await card.details.isPaymentTypeSupported(.dsrp)
}
```

### Create the DSRP payment input data

Before generating DSRP payment data, you must provide the input data in `RemotePaymentInputData`.

```swift
func buildRemoteInputData() -> RemotePaymentSession.RemotePaymentInputData  {
    let amount = "000000500030"  // 5000.30 EUR in minor units
    let currencyCode = "978"     // ISO 4217 numeric
    let countryCode = "840"      // ISO 3166-1 numeric (example: US)
    let unpredictableNumber = "12345"
    
    return RemotePaymentSession.RemotePaymentInputData(
        amount: amount,
        currencyCode: currencyCode,
        transactionType: .purchase,
        unpredictableNumber: unpredictableNumber,
        countryCode: countryCode,
        cryptogramType: .de55
    )
}
```

`RemotePaymentSession.RemotePaymentInputData` has the following fields:

<table><thead><tr><th width="196">Input data</th><th width="120">Type</th><th width="150">Format</th><th>Description</th></tr></thead><tbody><tr><td><code>amount</code></td><td>String</td><td>Numeric, minor units</td><td><strong>Required</strong><br>Transaction amount in minor units (no decimal separator). For example, 119.00 USD is <code>11900</code> (then left-pad if your integration requires fixed length).</td></tr><tr><td><code>currencyCode</code></td><td>String</td><td>3-digit ISO 4217 numeric</td><td><strong>Required</strong><br>Transaction currency code. For example, USD is <code>840</code>.</td></tr><tr><td><code>countryCode</code></td><td>String</td><td>3-digit ISO 3166-1 numeric</td><td><strong>Required</strong><br>Merchant country code. For example, United States is <code>840</code>.</td></tr><tr><td><code>transactionType</code></td><td>Enum</td><td><code>.purchase</code></td><td><strong>Required</strong><br>Financial transaction type. For DSRP payments, use <code>.purchase</code>.</td></tr><tr><td><code>cryptogramType</code></td><td>Enum</td><td><code>.ucaf</code> or <code>.de55</code></td><td><strong>Required</strong><br>Cryptogram data format returned by the SDK.</td></tr><tr><td><code>unpredictableNumber</code></td><td>String</td><td>Numeric</td><td><strong>Required</strong><br>Random number generated by the merchant or payment gateway.</td></tr></tbody></table>

### Generate DSRP payment data

In your digital wallet application, call `RemotePaymentSession.generateRemotePayment()`.

This API can throw an error. See [Handle errors](#handle-errors).

On success, the API returns `RemotePaymentOutputData` with the following fields:

<table><thead><tr><th width="217">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>cryptogramData</code></td><td>Byte array containing the formatted response. This is either UCAF or TLV data for the merchant to populate DE-55.</td></tr><tr><td><code>pan</code></td><td>PAN with any <code>F</code> padding removed (if present).</td></tr><tr><td><code>panSequenceNumber</code></td><td>PAN sequence number (PSN) of the card used.</td></tr><tr><td><code>track2EquivalentData</code></td><td>Track 2 data elements per ISO/IEC 7813 (excluding start sentinel, end sentinel, and LRC): PAN, field separator (<code>D</code>), expiration date (YYMM), service code, discretionary data, and optional <code>F</code> padding.</td></tr><tr><td><code>par</code></td><td>Payment account reference (PAR), if provided by the payment network.</td></tr><tr><td><code>expirationDate</code></td><td>Card expiration date.</td></tr><tr><td><code>cryptogramDataType</code></td><td>Cryptogram format returned (UCAF or DE55).</td></tr></tbody></table>

### Handle errors

If `generateRemotePayment()` throws an error, treat the payment as failed. Reset your UI state. Guide the end user to the next best action.

<table><thead><tr><th width="260">Error</th><th>Description</th></tr></thead><tbody><tr><td><code>deviceEnvironmentUnsafe</code></td><td>The device does not meet the security requirements.</td></tr><tr><td><code>sessionInProgress</code></td><td>Another payment session is still running.</td></tr><tr><td><code>invalidInputData</code></td><td>One or more fields in <code>RemotePaymentInputData</code> are missing or malformed.</td></tr><tr><td><code>noPaymentKeys</code></td><td>No payment keys are available for the transaction.</td></tr><tr><td><code>cardNotSupported</code></td><td>The digital card does not support DSRP remote payment.</td></tr><tr><td><code>cardNotActive</code></td><td>The digital card is not active.</td></tr><tr><td><code>noDefaultCard</code></td><td>No default card is set.</td></tr><tr><td><code>clientError</code></td><td>The remote payment flow failed due to a client-side error (for example, a network issue).</td></tr><tr><td><code>authenticationKeyInvalidated</code></td><td>The device passcode was disabled and secure storage was wiped.</td></tr><tr><td><code>biometricNotEnrolled</code></td><td>Biometrics are unavailable or not enrolled.</td></tr></tbody></table>

{% hint style="info" %}
Each error can include a message that explains the failure. Use it for troubleshooting and support diagnostics.
{% endhint %}

{% hint style="warning" %}
NFC Wallet SDK automatically wipes stored credentials when `authenticationKeyInvalidated` occurs (for example, after a passcode reset or security change).

Your application should guide the end user through re-enrollment.
{% endhint %}

### Full implementation example

Use this code sample to understand how the previous steps fit together.

{% code expandable="true" %}

```swift
func generateDSRP(digitalCard: DigitalCard?) async {
    do {
        let remotePaymentSession = RemotePaymentSession()

        let amount = "000000500030"      // 5000.30 in minor units, left-padded to 12
        let currencyCode = "978"         // ISO 4217 numeric (EUR)
        let countryCode = "840"          // ISO 3166-1 numeric (US example)
        let unpredictableNumber = "12345"

        let input = RemotePaymentSession.RemotePaymentInputData(
            amount: amount,
            currencyCode: currencyCode,
            transactionType: .purchase,
            unpredictableNumber: unpredictableNumber,
            countryCode: countryCode,
            cryptogramType: .de55
        )

        if let digitalCard {
            _ = try await remotePaymentSession.generateRemotePayment(
                withDigitalCardID: digitalCard.digitalCardID,
                remotePaymentInputData: input,
                userPrompt: "Authenticate"
            )
        } else {
            // Use the default digital card.
            _ = try await remotePaymentSession.generateRemotePayment(
                withDigitalCardID: nil,
                remotePaymentInputData: input,
                userPrompt: "Authenticate"
            )
        }
    } catch {
        guard let err = error as? RemotePaymentSession.Error else {
            return
        }

        switch err {
        case .deviceEnvironmentUnsafe:
            break
        case .sessionInProgress:
            break
        case .invalidInputData:
            break
        case .authenticationKeyInvalidated:
            break
        case .biometricNotEnrolled:
            break
        default:
            break
        }
    }
}
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.payments.thalescloud.io/nfc-wallet-sdk-ios/implement-nfc-wallet/make-payments/other-payment-methods/implement-dsrp-remote-payment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
