> For the complete documentation index, see [llms.txt](https://developer.paywall.one/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.paywall.one/client-side-servisler/3.-tempcard.md).

# 3. TempCard

{% hint style="success" %}
[**Yetkilendirme**](/client-side-servisler/1.-yetkilendirme.md) metodundan alınan geçici token ile kullanılabilir
{% endhint %}

{% hint style="info" %}
Hem E-Ticaret hem de Sigortacılık kapsamında kart saklama işlemi yapılabilmektedir. Kapsamı istek içerisindeki Scope parametresiyle belirleyebilirsiniz.
{% endhint %}

## TempCard

<mark style="color:green;">`POST`</mark> `{{Base Adres}}/api/paywall/tempcard`&#x20;

{% hint style="info" %}
Önemli: **TempCard** servisini kullanabilmeniz için 'Header' alanında '**token**' parametresini göndermeniz gerekmektedir. Bu bilgiyi [**Yetkilendirme**](/client-side-servisler/1.-yetkilendirme.md) sayfasındaki şekilde alabilirsiniz\
\
[<mark style="color:green;">**PaymentAPI Adresi**</mark>](/ortam.md)
{% endhint %}

<table><thead><tr><th width="188">Parametre</th><th width="79">Tip</th><th width="107">Zorunlu</th><th width="403">Açıklama</th></tr></thead><tbody><tr><td>token</td><td>string</td><td>Evet</td><td><a href="/pages/Xlup3CR2JHsiLiySFjO5"><strong>Yetkilendirme</strong></a> servisinden Client-Side işlemler için alınan geçici token bilgisidir</td></tr></tbody></table>

#### Servise gönderilmesi gereken parametreler şu şekildedir:

<table><thead><tr><th width="202">Parametre</th><th width="136">Kapsam</th><th>Tip</th><th>Zorunlu</th><th width="336">Açıklama</th></tr></thead><tbody><tr><td><pre><code>CardType
</code></pre></td><td><mark style="color:blue;"><code>Normal</code></mark></td><td>int</td><td>Evet</td><td>Kart'ın kapsamını belirtmektedir<br><br>1. ECom<br>2. Insurance</td></tr><tr><td><pre><code>CardOwnerName
</code></pre></td><td><mark style="color:blue;"><code>Normal</code></mark></td><td>string</td><td>Evet</td><td>Kart sahibinin adı</td></tr><tr><td><pre><code>CardNumber
</code></pre></td><td><mark style="color:green;"><code>ECommerce</code></mark></td><td>string</td><td>Evet/Hayır</td><td>Kart numarası</td></tr><tr><td><pre><code>CardCvv
</code></pre></td><td><mark style="color:green;"><code>ECommerce</code></mark></td><td>string</td><td>Evet/Hayır</td><td>Kart CVV bilgisi</td></tr><tr><td><pre><code>CardExpiryMonth
</code></pre></td><td><mark style="color:green;"><code>ECommerce</code></mark></td><td>string</td><td>Evet/Hayır</td><td>Kart son kullanma ay</td></tr><tr><td><pre><code>CardExpiryYear
</code></pre></td><td><mark style="color:green;"><code>ECommerce</code></mark></td><td>string</td><td>Evet/Hayır</td><td>Kart son kullanma yıl</td></tr><tr><td><pre><code>CardNoFirst
</code></pre></td><td><mark style="color:orange;"><code>Insurance</code></mark></td><td>string</td><td>Evet/Hayır</td><td>Kart ilk 8</td></tr><tr><td><pre><code>CardNoLast
</code></pre></td><td><mark style="color:orange;"><code>Insurance</code></mark></td><td>string</td><td>Evet/Hayır</td><td>Kart son 4</td></tr><tr><td><pre><code>IdentityNumber
</code></pre></td><td><mark style="color:orange;"><code>Insurance</code></mark></td><td>string</td><td>Evet/Hayır</td><td>Kart sahibinin kimlik bilgisi</td></tr><tr><td><pre><code>ExpiryMinutes
</code></pre></td><td><mark style="color:blue;"><code>Normal</code></mark></td><td>int</td><td>Evet</td><td>Token, kaç dakika geçerli olacak?<br><br><mark style="color:blue;"><strong>0 ile 30 arasında tanım yapılabilir</strong></mark></td></tr></tbody></table>

**Servise gönderilecek örnek&#x20;**<mark style="color:green;">**JSON**</mark>**&#x20;ve&#x20;**<mark style="color:green;">**örnek kodlar**</mark>**&#x20;aşağıdaki gibidir.**

{% tabs %}
{% tab title="JSON" %}
{% code lineNumbers="true" %}

```json5
{
    "CardType": 1, // 1: ECom | 2: Insurance
    "CardOwnerName": "Enes Selman Tütüncü",
    "CardNumber": "5528790000000008", // Scope: ECom
    "CardCvv": "123", // Scope: ECom
    "CardExpiryMonth": "12", // Scope: ECom
    "CardExpiryYear": "30", // Scope: ECom
    // "CardNoFirst": "48249048", // Scope: Insurance
    // "CardNoLast": "8012", // Scope: Insurance
    // "IdentityNumber": "21234567890" // Scope: Insurance
    "ExpiryMinutes": 30
}
```

{% endcode %}
{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

class Program
{
    static readonly HttpClient client = new HttpClient();

    static async Task Main()
    {
        var url = "{{BaseAddress}}/api/paywall/tempcard";
        var data = new
        {
            CardType = 1, // 1: ECom | 2: Insurance
            CardOwnerName = "Enes Selman Tütüncü",
            CardNumber = "5528790000000008", // Scope: ECom
            CardCvv = "123",                 // Scope: ECom
            CardExpiryMonth = "12",          // Scope: ECom
            CardExpiryYear = "30",           // Scope: ECom
            // CardNoFirst = "48249048",       // Scope: Insurance
            // CardNoLast = "8012",            // Scope: Insurance
            // IdentityNumber = "21234567890", // Scope: Insurance
            ExpiryMinutes = 30
        };

        var json = JsonConvert.SerializeObject(data);
        var content = new StringContent(json, Encoding.UTF8, "application/json");
        content.Headers.Add("apikeypublic", "%PUBLICKEY%");
        content.Headers.Add("apiclientpublic", "%PUBLICCLIENT%");

        var response = await client.PostAsync(url, content);
        var responseBody = await response.Content.ReadAsStringAsync();
        Console.WriteLine(responseBody);
    }
}
```

{% endtab %}

{% tab title="GO" %}

```go
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io/ioutil"
    "net/http"
)

type RequestData struct {
    CardType        int    `json:"CardType"`
    CardOwnerName   string `json:"CardOwnerName"`
    CardNumber      string `json:"CardNumber,omitempty"`
    CardCvv         string `json:"CardCvv,omitempty"`
    CardExpiryMonth string `json:"CardExpiryMonth,omitempty"`
    CardExpiryYear  string `json:"CardExpiryYear,omitempty"`
    IdentityNumber  string `json:"IdentityNumber,omitempty"`
    CardNoFirst     string `json:"CardNoFirst,omitempty"`
    CardNoLast      string `json:"CardNoLast,omitempty"`
    ExpiryMinutes   int    `json:"ExpiryMinutes"`
}

func main() {
    url := "{{BaseAddress}}/api/paywall/tempcard"
    data := RequestData{
        CardType:        1, // 1: ECom | 2: Insurance
        CardOwnerName:   "Enes Selman Tütüncü",
        CardNumber:      "5528790000000008", // Scope: ECom
        CardCvv:         "123",               // Scope: ECom
        CardExpiryMonth: "12",                // Scope: ECom
        CardExpiryYear:  "30",                // Scope: ECom
        // IdentityNumber: "21234567890", // Scope: Insurance
        // CardNoFirst:    "48249048",    // Scope: Insurance
        // CardNoLast:     "8012",        // Scope: Insurance
        ExpiryMinutes: 30,
    }

    requestBody, _ := json.Marshal(data)
    client := &http.Client{}
    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(requestBody))
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("apikeypublic", "%PUBLICKEY%")
    req.Header.Set("apiclientpublic", "%PUBLICCLIENT%")

    resp, _ := client.Do(req)
    defer resp.Body.Close()

    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))
}
```

{% endtab %}

{% tab title="Java" %}

```java
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;
import org.json.JSONObject;

public class Main {
    public static void main(String[] args) {
        try {
            URL url = new URL("{{BaseAddress}}/api/paywall/tempcard");

            JSONObject jsonObject = new JSONObject();
            jsonObject.put("CardType", 1); // 1: ECom | 2: Insurance
            jsonObject.put("CardOwnerName", "Enes Selman Tütüncü");
            jsonObject.put("CardNumber", "5528790000000008"); // Scope: ECom
            jsonObject.put("CardCvv", "123");                 // Scope: ECom
            jsonObject.put("CardExpiryMonth", "12");          // Scope: ECom
            jsonObject.put("CardExpiryYear", "30");           // Scope: ECom
            // jsonObject.put("CardNoFirst", "48249048");        // Scope: Insurance
            // jsonObject.put("CardNoLast", "8012");             // Scope: Insurance
            // jsonObject.put("IdentityNumber", "21234567890");  // Scope: Insurance
            jsonObject.put("ExpiryMinutes", 30);

            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setDoOutput(true);
            conn.setRequestMethod("POST");
            conn.setRequestProperty("Content-Type", "application/json");
            conn.setRequestProperty("apikeypublic", "%PUBLICKEY%");
            conn.setRequestProperty("apiclientpublic", "%PUBLICCLIENT%");

            OutputStream os = conn.getOutputStream();
            os.write(jsonObject.toString().getBytes());
            os.flush();

            Scanner scan = new Scanner(conn.getInputStream());
            String entireResponse = "";
            while (scan.hasNext())
                entireResponse += scan.nextLine();
            System.out.println("Response : " + entireResponse);
            scan.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$url = '{{BaseAddress}}/api/paywall/tempcard';
$header = array(
    'Content-Type: application/json',
    'apikeypublic: %%',
    'apiclientpublic: %%'
);
$data = array(
    'CardType' => 1, // 1: ECom | 2: Insurance
    'CardOwnerName' => 'Enes Selman Tütüncü',
    'CardNumber' => '5528790000000008', // Scope: ECom
    'CardCvv' => '123',                 // Scope: ECom
    'CardExpiryMonth' => '12',          // Scope: ECom
    'CardExpiryYear' => '30',           // Scope: ECom
    // 'CardNoFirst' => '48249048',        // Scope: Insurance
    // 'CardNoLast' => '8012',             // Scope: Insurance
    // 'IdentityNumber' => '21234567890',  // Scope: Insurance
    'ExpiryMinutes' => 30
);
$context = stream_context_create(array(
    'http' => array(
        'method' => 'POST',
        'header' => $header,
        'content' => json_encode($data),
    )
));
$result = file_get_contents($url, false, $context);
echo $result;
?>
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = '{{BaseAddress}}/api/paywall/tempcard'
headers = {
    'Content-Type': 'application/json',
    'apikeypublic': '%%',
    'apiclientpublic': '%%'
}
data = {
    'CardType': 1,  # 1: ECom | 2: Insurance
    'CardOwnerName': 'Enes Selman Tütüncü',
    'CardNumber': '5528790000000008',  # Scope: ECom
    'CardCvv': '123',                  # Scope: ECom
    'CardExpiryMonth': '12',           # Scope: ECom
    'CardExpiryYear': '30',            # Scope: ECom
    # 'CardNoFirst': '48249048',        # Scope: Insurance
    # 'CardNoLast': '8012',             # Scope: Insurance
    # 'IdentityNumber': '21234567890',  # Scope: Insurance
    'ExpiryMinutes': 30
}

response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'uri'
require 'net/http'
require 'json'

url = URI("{{BaseAddress}}/api/paywall/tempcard")
http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["apikeypublic"] = '%%'
request["apiclientpublic"] = '%%'
request.body = JSON.dump({
  "CardType" => 1, # 1: ECom | 2: Insurance
  "CardOwnerName" => "Enes Selman Tütüncü",
  "CardNumber" => "5528790000000008", # Scope: ECom
  "CardCvv" => "123",                 # Scope: ECom
  "CardExpiryMonth" => "12",          # Scope: ECom
  "CardExpiryYear" => "30",           # Scope: ECom
  # "CardNoFirst" => "48249048",        # Scope: Insurance
  # "CardNoLast" => "8012",             # Scope: Insurance
  # "IdentityNumber" => "21234567890",  # Scope: Insurance
  "ExpiryMinutes" => 30
})

response = http.request(request)
puts response.read_body
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
import axios from 'axios';

const url = '{{BaseAddress}}/api/paywall/tempcard';
const headers = {
  'Content-Type': 'application/json',
  'apikeypublic': '%%',
  'apiclientpublic': '%%'
};
const data = {
  CardType: 1, // 1: ECom | 2: Insurance
  CardOwnerName: 'Enes Selman Tütüncü',
  CardNumber: '5528790000000008', // Scope: ECom
  CardCvv: '123',                 // Scope: ECom
  CardExpiryMonth: '12',          // Scope: ECom
  CardExpiryYear: '30',           // Scope: ECom
  // CardNoFirst: '48249048',        // Scope: Insurance
  // CardNoLast: '8012',             // Scope: Insurance
  // IdentityNumber: '21234567890',  // Scope: Insurance
  ExpiryMinutes: 30
};

axios.post(url, data, { headers })
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.error(error);
  });
```

{% endtab %}

{% tab title="Curl" %}

```sh
# CardType: 1 = ECom (CardNumber/CardCvv/CardExpiryMonth/CardExpiryYear), 2 = Insurance (CardNoFirst/CardNoLast/IdentityNumber)
curl --location --request POST '{{BaseAddress}}/api/paywall/tempcard' \
--header 'Content-Type: application/json' \
--header 'apikeypublic: %%' \
--header 'apiclientpublic: %%' \
--data-raw '{
    "CardType": 1,
    "CardOwnerName": "Enes Selman Tütüncü",
    "CardNumber": "5528790000000008",
    "CardCvv": "123",
    "CardExpiryMonth": "12",
    "CardExpiryYear": "30",
    "ExpiryMinutes": 30
}'
```

{% endtab %}
{% endtabs %}

Servisten dönen parametreler şu şekildedir:

<table><thead><tr><th width="189">Parametre</th><th width="100.33333333333331">Tip</th><th>Açıklama</th></tr></thead><tbody><tr><td>ErrorCode</td><td>int</td><td>Hata kodu. İşlem başarılı ise '0' değerini döner.</td></tr><tr><td>Result</td><td>bool</td><td>True ya da false değeri döner. İşlem başarılı iste 'true' değerini döner.</td></tr><tr><td>Message</td><td>string</td><td>İşlem hatalıysa, bu hataya dair belirtilen mesajdır, locale parametresine göre dil desteği sunar.</td></tr><tr><td>Body</td><td>nesne</td><td>İşlem detay bilgileri</td></tr></tbody></table>

{% tabs %}
{% tab title="JSON" %}
{% code lineNumbers="true" %}

```json
{
    "ErrorCodeType": 1,
    "ErrorMessage": null,
    "ErrorCode": 0,
    "Result": true,
    "Message": "",
    "Body": {
        "TempCardId": 2211290,
        "CardToken": "701b5df5-a50a-461d-9763-6107bea48184",
        "ExpiryDateTime": "2024-07-11T23:09:29.4294449+03:00"
    }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}
