# 5. Verify OTP

## Verify OTP

<mark style="color:green;">`POST`</mark> `{{Base Address}}/api/paywall/masterpass/otp/verify`

It will be sufficient to send a request to the address provided above. You can use the 'Base Address' for both the Test environment and the Production environment as you wish.

{% hint style="info" %}
Important: To use the Masterpass - Verify OTP service, you must include the parameters **'apikeyprivate'** and **'apiclientprivate'** in the 'Header' field.\
\
[<mark style="color:green;">**PaymentAPI Address**</mark>](https://developer.paywall.one/payment-orchestration-integration-document/environment)
{% endhint %}

<table><thead><tr><th width="182">Parameter</th><th width="106.33333333333331">Type</th><th width="133.04296875">Mondatory</th><th>Description</th></tr></thead><tbody><tr><td>apikeyprivate</td><td>string</td><td>Yes</td><td>The Private Key obtained from the merchant panel.</td></tr><tr><td>apiclientprivate</td><td>string</td><td>Yes</td><td>The Private Client obtained from the merchant panel.</td></tr></tbody></table>

**The parameters that need to be sent to the service are as follows:**

<table><thead><tr><th width="228">Parameter</th><th width="106">Type</th><th width="142.30859375">Mondotory</th><th>Description</th></tr></thead><tbody><tr><td>OtpToken</td><td>string</td><td>Yes</td><td>It is included in the API response parameters at the time of the transaction requiring OTP.<br><br><code>Masterpass > Result > Token</code></td></tr><tr><td>OtpCode</td><td>string</td><td>Yes</td><td>The OTP code received from the user on the screen.</td></tr><tr><td>ForLinkToMerchant</td><td>bool</td><td>No</td><td>If OTP verification is performed to establish the connection between the user and the merchant company, this parameter must be sent as <code>true.</code></td></tr><tr><td>SessionId</td><td>Guid</td><td>Yes</td><td><a href="broken-reference">Session ID</a> information</td></tr></tbody></table>

{% tabs %}
{% tab title="JSON" %}

```json5
{
    "OtpToken": "88599362e05441458c1efa588a711c8f",
    "OtpCode": "123456",
    "ForLinkToMerchant": false,
    "SessionId": "5095433e-f36b-1410-825e-001264113a90"
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
// Soon
```

{% endtab %}

{% tab title="GO" %}

```go
// Soon
```

{% endtab %}

{% tab title="Java" %}

```java
// Soon
```

{% endtab %}

{% tab title="PHP" %}

```php
// Soon
```

{% endtab %}

{% tab title="Python" %}

```python
// Soon
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
// Soon
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
// Soon
```

{% endtab %}

{% tab title="Curl" %}

```sh
// Soon
```

{% endtab %}
{% endtabs %}

**Response returned from the service:**

<table><thead><tr><th width="156">Parameter</th><th width="83.33333333333331">Type</th><th>Desciption</th></tr></thead><tbody><tr><td>Body</td><td>object</td><td>JSON containing payment details (optional)</td></tr><tr><td>ErrorCode</td><td>int</td><td>Error code. Returns '0' if the transaction is successful.</td></tr><tr><td>Result</td><td>bool</td><td>Returns either true or false. If the transaction is successful, it returns true.</td></tr><tr><td>Message</td><td>string</td><td>If the transaction fails, this is the error message provided, with language support according to the locale parameter.</td></tr></tbody></table>

{% hint style="info" %}
**`Body > Masterpass > Result > StatusCode` ve `Body > Masterpass > Result > ResponseCode`** The flow must be established by checking the parameter under the directory.

* [**Masterpass ResponseCode List**](https://developer.paywall.one/payment-orchestration-integration-document/masterpass-integration/broken-reference)
  {% endhint %}

{% tabs %}
{% tab title="Successful  ✅" %}

```json5
{
    "ErrorCodeType": 1,
    "ErrorMessage": null,
    "ErrorCode": 0,
    "Result": true,
    "Message": "",
    "Body": {
        "Session": {
            "SessionRenewed": false,
            "SessionId": "a527433e-f36b-1410-80e5-004205aa382d"
        },
        "Masterpass": {
            "Result": {
                "RetrievalReferenceNumber": "100005844112",
                "IsVerified": true,
                "Url3d": null,
                "Url3dSuccess": null,
                "Url3dFail": null,
                "CardUniqueNumber": "382C4D4AA6AA93C7CF2D613BB144AA6305A46FDCD40B795C40B97A486D8E2BE2",
                "Token": "057227d485424da0a3394056b8c21bdc",
                "ResponseCode": "0000",
                "Description": "OTP verified successfully."
            },
            "BuildId": "78",
            "CorrelationId": "6ba60890-6f0e-479d-8987-c1cfd4cf4abc",
            "Exception": null,
            "Message": "OK",
            "RequestId": null,
            "StatusCode": 200,
            "Version": null
        }
    }
}
```

{% endtab %}

{% tab title="Failed  ❌" %}

```json
{
    "ErrorCodeType": 1,
    "ErrorMessage": null,
    "ErrorCode": 1,
    "Result": false,
    "Message": "",
    "Body": {
        "Session": {
            "SessionRenewed": true,
            "SessionId": "a527433e-f36b-1410-80e5-004205aa382d"
        },
        "Masterpass": {
            "Result": null,
            "BuildId": "78",
            "CorrelationId": null,
            "Exception": {
                "Level": "Unauthorized",
                "Code": "TOKEN_HAS_EXPIRED",
                "Message": "Tokenın süresi doldu."
            },
            "Message": "Unauthorized",
            "RequestId": null,
            "StatusCode": 401,
            "Version": null
        }
    }
}
```

{% endtab %}
{% endtabs %}
