# 3. Add Card

## Add Card

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

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 - Add Card service, you must include the parameters **'apikeyprivate'** and **'apiclientprivate'** in the 'Header' field.

\
[<mark style="color:green;">**PaymentAPI Address**</mark>](/payment-orchestration-integration-document/environment.md)
{% endhint %}

<table><thead><tr><th width="182">Parameter</th><th width="106.33333333333331">Type</th><th width="140.84765625">Mandatory</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="175">Mondatory</th><th>Description</th></tr></thead><tbody><tr><td>CardAlias</td><td>string</td><td>Yes</td><td>The nickname given to the card by the user.</td></tr><tr><td>CardHolderName</td><td>string</td><td>Yes</td><td>The name of the cardholder.</td></tr><tr><td>CardNumber</td><td>string</td><td>Yes</td><td>Card number</td></tr><tr><td>ExpiryMonth</td><td>string</td><td>Yes</td><td>Card Expiry - Month</td></tr><tr><td>ExpiryYear</td><td>string</td><td>Yes</td><td>Card Expiry - Year</td></tr><tr><td>Cvv</td><td>string</td><td>Yes</td><td>Card CVV information</td></tr><tr><td>SessionId</td><td>Guid</td><td>Yes</td><td><a href="/pages/xpRDdgZPoDKXW4msT7aK">Session ID</a> information</td></tr></tbody></table>

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

```json5
{
    "CardAlias": "{{$guid}}",
    "CardHolderName": "Kart Sahibi Adı",
    "CardNumber": "5528790000000008",
    "ExpiryMonth": "12",
    "ExpiryYear": "2030",
    "Cvv": "123",
    "SessionId": "2193433e-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>Description</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**](broken://pages/N52fiKdyyLBEPHk2XAUK)
  {% endhint %}

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

```json5
{
    "ErrorCodeType": 1,
    "ErrorMessage": null,
    "ErrorCode": 0,
    "Result": true,
    "Message": "",
    "Body": {
        "Session": {
            "SessionRenewed": false,
            "SessionId": "a327433e-f36b-1410-80e5-004205aa382d"
        },
        "Masterpass": {
            "Result": {
                "RetrievalReferenceNumber": "100005844108",
                "ResponseCode": "5001",
                "Description": "Telefonunuza gelen tek kullanımlık şifreyi girerek kart doğrulama işlemini tamamlayınız",
                "Token": "7e6db5a88fe248ada3d20adc493035e4",
                "Url3d": null,
                "Url3dSuccess": null,
                "Url3dFail": null
            },
            "BuildId": "83",
            "CorrelationId": "7c18d334-2dc3-4ed6-931f-1ae16c4a2886",
            "Exception": null,
            "Message": "Accepted",
            "RequestId": null,
            "StatusCode": 202,
            "Version": null
        }
    }
}
```

{% endtab %}

{% tab title="Failed  ❌" %}

```json
{
    "ErrorCodeType": 1,
    "ErrorMessage": null,
    "ErrorCode": 0,
    "Result": true,
    "Message": "",
    "Body": {
        "Session": {
            "SessionRenewed": false,
            "SessionId": "a327433e-f36b-1410-80e5-004205aa382d"
        },
        "Masterpass": {
            "Result": null,
            "BuildId": "83",
            "CorrelationId": null,
            "Exception": {
                "Level": "Warning",
                "Code": "CARD_ALREADY_EXISTS",
                "Message": "Kart zaten mevcut."
            },
            "Message": "BadRequest",
            "RequestId": null,
            "StatusCode": 400,
            "Version": null
        }
    }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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://developer.paywall.one/payment-orchestration-integration-document/masterpass-integration/3.-add-card.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.
