# 2. Authorization / SDK

## TempToken/Sdk

{% hint style="info" %}
The **TempToken/Sdk** service, unlike the TempToken service, has customized request and response parameters designed specifically for use in Paywall SDKs. For operations to be performed within the SDKs,
{% endhint %}

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

{% hint style="info" %}
**Important:** To use the TempToken/Sdk service, you must include the **'apikeypublic'** and **'apiclientpublic'** parameters in the **Header**.\
\
[<mark style="color:green;">**PaymentAPI Address**</mark>](/payment-orchestration-integration-document/environment.md)
{% endhint %}

<table><thead><tr><th width="188">Parameter</th><th width="121">Type</th><th width="153">Compulsory</th><th width="403">Description</th></tr></thead><tbody><tr><td>apikeypublic</td><td>string</td><td>Yes</td><td>The Public Key you obtained from the merchant panel.</td></tr><tr><td>apiclientpublic</td><td>string</td><td>Yes</td><td>The Public Client you obtained from the merchant panel.</td></tr></tbody></table>

&#x20;**The parameters to be sent to the service are as follows:**

<table><thead><tr><th width="251.5078125">Parameter</th><th width="164.6875">Scope</th><th width="135.15234375">Compulsory</th><th width="336">Description</th></tr></thead><tbody><tr><td><pre><code>ClientCardSave
</code></pre></td><td>boolean</td><td>Yes</td><td>Will the token be used on the client side for card storage?</td></tr><tr><td><pre><code>ThreeDSession
</code></pre></td><td>boolean</td><td>Yes</td><td>Will the token be used on the client side to perform 3D transactions?</td></tr><tr><td><pre><code>ClientSdk
</code></pre></td><td>boolean</td><td>Yes</td><td>Will the token be used for Paywall’s client-side library?</td></tr><tr><td><pre><code>ScopeBased
</code></pre></td><td>boolean</td><td>Yes</td><td>You should use the <strong>Scope</strong> parameter to define the token’s permissions.</td></tr><tr><td><pre><code>Scope
</code></pre></td><td>int</td><td>Yes/No</td><td><p><strong>Token Permissions</strong></p><p></p><p>0 = None<br>1 = ClientCardSave<br>2 = ThreeDSession<br>3 = ClientSdk</p></td></tr><tr><td><pre><code>ExpiryMin
</code></pre></td><td>int</td><td>Yes</td><td><p>How long will the token be valid?</p><p></p><p><mark style="color:blue;">A value can be defined between <strong>0 and 1440</strong> minutes.</mark></p></td></tr><tr><td><pre><code>IncludeMasterpassSession
</code></pre></td><td>Bool</td><td>No</td><td>If you want the Masterpass session information to be returned in the response object of the temp token creation request, this parameter must be set to <strong>true</strong>.</td></tr><tr><td><pre><code>MasterpassSession
</code></pre></td><td><sup><mark style="color:$warning;">MasterpassSession</mark></sup></td><td>Yes/No</td><td>When the <strong>IncludeMasterpassSession</strong> parameter is sent as <strong>true</strong>, it becomes mandatory and must include the required information for the Masterpass session.</td></tr></tbody></table>

**The sample&#x20;**<mark style="color:green;">**JSON**</mark>**&#x20;and&#x20;**<mark style="color:green;">**code snippets**</mark>**&#x20;to be sent to the service are as follows:**

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

```json5
{
    "ClientCardSave": true,
    "ThreeDSession": false,
    "ClientSdk": true,
    "ScopeBased": false,
    "Scope": 0,
    "ExpiryMin": 1440,
    "IncludeMasterpassSession": true,
    "MasterpassSession": {
        "ReferenceCode": "{{$guid}}",
        "UserId": "%UserId%", // Kullanıcının sisteminizdeki tekil kimlik bilgisi
        "UserPhone": "%UserPhone%", // Kullanıcının sisteminizdeki doğrulanmış telefon numarası
        "Force3D": false, // Kullanıcı tüm ödeme akışında 3D'ye zorlansın mı?
        "PhoneVerifiedByMerchant": true // Telefon doğrulaması yapıldı mı?
    }
}
```

{% 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 = "{{MemberBaseAddress}}/api/paywall/member";
        var data = new
        {
            IsSubMerchant = true,
            MemberType = 1,
            MemberExternalId = "111aa11135552244413",
            MemberName = "Intranet Technology",
            MemberTitle = "Intranet Technology Yazılım A.S",
            MemberTaxOffice = "Besiktas",
            MemberTaxNumber = "4651176935",
            MemberIdentityNumber = "11111111110",
            MemberEmail = "member@paywall.one",
            MemberPhone = "5554443322",
            MemberAddress = "test adresi",
            ContactName = "Member Name",
            ContactLastname = "Lastname",
            BankAccounts = new[]
            {
                new {
                    CurrencyId = 1,
                    Title = "Ünvan",
                    Iban = "TR370006400012345678987654"
                }
            },
            ValueDate = new
            {
                CalculationType = 1,
                CalculationValue = 10,
                Commission = 10   
            }
        };

        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);

        if (response.IsSuccessStatusCode)
        {
            var responseBody = await response.Content.ReadAsStringAsync();
            dynamic result = JsonConvert.DeserializeObject(responseBody);

            Console.WriteLine($"ErrorCode: {result.ErrorCode}");
            Console.WriteLine($"Result: {result.Result}");
            Console.WriteLine($"Message: {result.Message}");

            if (result.Body != null)
            {
                dynamic body = result.Body;
                Console.WriteLine($"Id: {body.Id}");
                Console.WriteLine($"IsSubMerchant: {body.IsSubMerchant}");
                Console.WriteLine($"MemberType: {body.MemberType}");
                Console.WriteLine($"MemberExternalId: {body.MemberExternalId}");
                Console.WriteLine($"MemberName: {body.MemberName}");
                Console.WriteLine($"MemberTitle: {body.MemberTitle}");
                Console.WriteLine($"MemberTaxOffice: {body.MemberTaxOffice}");
                Console.WriteLine($"MemberTaxNumber: {body.MemberTaxNumber}");
                Console.WriteLine($"MemberEmail: {body.MemberEmail}");
                Console.WriteLine($"MemberPhone: {body.MemberPhone}");
                Console.WriteLine($"MemberAddress: {body.MemberAddress}");
                Console.WriteLine($"ContactName: {body.ContactName}");
                Console.WriteLine($"ContactLastname: {body.ContactLastname}");
                Console.WriteLine($"InsertDateTime: {body.InsertDateTime}");
            }
        }
    }
}
```

{% endtab %}

{% tab title="GO" %}

```go
package main

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

type RequestData struct {
	IsSubMerchant      bool   `json:"IsSubMerchant"`
	MemberType         int    `json:"MemberType"`
	MemberExternalId   string `json:"MemberExternalId"`
	MemberName         string `json:"MemberName"`
	MemberTitle        string `json:"MemberTitle"`
	MemberTaxOffice    string `json:"MemberTaxOffice"`
	MemberTaxNumber    string `json:"MemberTaxNumber"`
	MemberIdentityNumber string `json:"MemberIdentityNumber"`
	MemberEmail        string `json:"MemberEmail"`
	MemberPhone        string `json:"MemberPhone"`
	MemberAddress      string `json:"MemberAddress"`
	ContactName        string `json:"ContactName"`
	ContactLastname    string `json:"ContactLastname"`
	BankAccounts       []BankAccount `json:"BankAccounts"`
	ValueDate          ValueDate `json:"ValueDate"`
}

type BankAccount struct {
	CurrencyId int    `json:"CurrencyId"`
	Title      string `json:"Title"`
	Iban       string `json:"Iban"`
}

type ValueDate struct {
	CalculationType  int `json:"CalculationType"`
	CalculationValue int `json:"CalculationValue"`
	Commission       int `json:"Commission"`
}

type ResponseData struct {
	ErrorCode int    `json:"ErrorCode"`
	Result    bool   `json:"Result"`
	Message   string `json:"Message"`
	Body      BodyData `json:"Body"`
}

type BodyData struct {
	Id                 int    `json:"Id"`
	IsSubMerchant      bool   `json:"IsSubMerchant"`
	MemberType         int    `json:"MemberType"`
	MemberExternalId   string `json:"MemberExternalId"`
	MemberName         string `json:"MemberName"`
	MemberTitle        string `json:"MemberTitle"`
	MemberTaxOffice    string `json:"MemberTaxOffice"`
	MemberTaxNumber    string `json:"MemberTaxNumber"`
	MemberIdentityNumber string `json:"MemberIdentityNumber"`
	MemberEmail        string `json:"MemberEmail"`
	MemberPhone        string `json:"MemberPhone"`
	MemberAddress      string `json:"MemberAddress"`
	ContactName        string `json:"ContactName"`
	ContactLastname    string `json:"ContactLastname"`
	InsertDateTime     string `json:"InsertDateTime"`
}

func main() {
	url := "{{MemberBaseAddress}}/api/paywall/member"
	data := RequestData{
		IsSubMerchant:      true,
		MemberType:         1,
		MemberExternalId:   "111aa11135552244413",
		MemberName:         "Intranet Technology",
		MemberTitle:        "Intranet Technology Yazılım A.S",
		MemberTaxOffice:    "Besiktas",
		MemberTaxNumber:    "4651176935",
		MemberIdentityNumber: "11111111110",
		MemberEmail:        "member@paywall.one",
		MemberPhone:        "5554443322",
		MemberAddress:      "test adresi",
		ContactName:        "Member Name",
		ContactLastname:    "Lastname",
		BankAccounts:       []BankAccount{
			{
				CurrencyId: 1,
				Title:      "Ünvan",
				Iban:       "TR370006400012345678987654",
			},
		},
		ValueDate: ValueDate{
			CalculationType:  1,
			CalculationValue: 10,
			Commission:       10,
		},
	}

	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)

	var responseData ResponseData
	json.Unmarshal(body, &responseData)

	fmt.Println("ErrorCode:", responseData.ErrorCode)
	fmt.Println("Result:", responseData.Result)
	fmt.Println("Message:", responseData.Message)
	fmt.Println("Body.Id:", responseData.Body.Id)
	fmt.Println("Body.IsSubMerchant:", responseData.Body.IsSubMerchant)
	fmt.Println("Body.MemberType:", responseData.Body.MemberType)
	fmt.Println("Body.MemberExternalId:", responseData.Body.MemberExternalId)
	fmt.Println("Body.MemberName:", responseData.Body.MemberName)
	fmt.Println("Body.MemberTitle:", responseData.Body.MemberTitle)
	fmt.Println("Body.MemberTaxOffice:", responseData.Body.MemberTaxOffice)
	fmt.Println("Body.MemberTaxNumber:", responseData.Body.MemberTaxNumber)
	fmt.Println("Body.MemberIdentityNumber:", responseData.Body.MemberIdentityNumber)
	fmt.Println("Body.MemberEmail:", responseData.Body.MemberEmail)
	fmt.Println("Body.MemberPhone:", responseData.Body.MemberPhone)
	fmt.Println("Body.MemberAddress:", responseData.Body.MemberAddress)
	fmt.Println("Body.ContactName:", responseData.Body.ContactName)
	fmt.Println("Body.ContactLastname:", responseData.Body.ContactLastname)
	fmt.Println("Body.InsertDateTime:", responseData.Body.InsertDateTime)
}
```

{% endtab %}

{% tab title="Java" %}

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

import org.json.JSONArray;
import org.json.JSONObject;

public class Main {

    public static void main(String[] args) {
        try {
            URL url = new URL("{{MemberBaseAddress}}/api/paywall/member");

            JSONObject jsonObject = new JSONObject();
            jsonObject.put("IsSubMerchant", true);
            jsonObject.put("MemberType", 1);
            jsonObject.put("MemberExternalId", "111aa11135552244413");
            jsonObject.put("MemberName", "Intranet Technology");
            jsonObject.put("MemberTitle", "Intranet Technology Yazılım A.S");
            jsonObject.put("MemberTaxOffice", "Besiktas");
            jsonObject.put("MemberTaxNumber", "4651176935");
            jsonObject.put("MemberIdentityNumber", "11111111110");
            jsonObject.put("MemberEmail", "member@paywall.one");
            jsonObject.put("MemberPhone", "5554443322");
            jsonObject.put("MemberAddress", "test adresi");
            jsonObject.put("ContactName", "Member Name");
            jsonObject.put("ContactLastname", "Lastname");

            JSONArray bankAccounts = new JSONArray();
            JSONObject bankAccount = new JSONObject();
            bankAccount.put("CurrencyId", 1);
            bankAccount.put("Title", "Ünvan");
            bankAccount.put("Iban", "TR370006400012345678987654");
            bankAccounts.put(bankAccount);

            jsonObject.put("BankAccounts", bankAccounts);

            JSONObject valueDate = new JSONObject();
            valueDate.put("CalculationType", 1);
            valueDate.put("CalculationValue", 10);
            valueDate.put("Commission", 10);

            jsonObject.put("ValueDate", valueDate);

            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setDoOutput(true);
            conn.setRequestMethod("POST");
            conn.setRequestProperty("apikeypublic", "%PUBLICKEY%")
            conn.setRequestProperty("apiclientpublic", "%PUBLICCLIENT%")

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

            if (conn.getResponseCode() != HttpURLConnection.HTTP_CREATED) {
                throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
            }

            Scanner scan = new Scanner(url.openStream());
            String entireResponse = new String();
            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 = '{{MemberBaseAddress}}/api/paywall/member';

$header = array(
    'Content-Type: application/json',
    'apikeypublic: %%',
    'apiclientpublic: %%'
);

$data = array(
    'IsSubMerchant' => true,
    'MemberType' => 1,
    'MemberExternalId' => '111aa11135552244413',
    'MemberName' => 'Intranet Technology',
    'MemberTitle' => 'Intranet Technology Yazılım A.S',
    'MemberTaxOffice' => 'Besiktas',
    'MemberTaxNumber' => '4651176935',
    'MemberIdentityNumber' => '11111111110',
    'MemberEmail' => 'member@paywall.one',
    'MemberPhone' => '5554443322',
    'MemberAddress' => 'test adresi',
    'ContactName' => 'Member Name',
    'ContactLastname' => 'Lastname',
    'BankAccounts' => array(
        array(
            'CurrencyId' => 1,
            'Title' => 'Ünvan',
            'Iban' => 'TR370006400012345678987654'
        )
    ),
    'ValueDate' => array(
        'CalculationType' => 1,
        'CalculationValue' => 10,
        'Commission' => 10
    )
);

$context = stream_context_create(array(
    'http' => array(
        'method' => 'POST',
        'header' => $header,
        'content' => json_encode($data),
    )
));

$result = file_get_contents($url, false, $context);
?>
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = '{{MemberBaseAddress}}/api/paywall/member'
headers = {
    'Content-Type': 'application/json',
    'apikeypublic': '%%',
    'apiclientpublic': '%%'
}

data = {
    'IsSubMerchant': True,
    'MemberType': 1,
    'MemberExternalId': '111aa11135552244413',
    'MemberName': 'Intranet Technology',
    'MemberTitle': 'Intranet Technology Yazılım A.S',
    'MemberTaxOffice': 'Besiktas',
    'MemberTaxNumber': '4651176935',
    'MemberIdentityNumber': '11111111110',
    'MemberEmail': 'member@paywall.one',
    'MemberPhone': '5554443322',
    'MemberAddress': 'test adresi',
    'ContactName': 'Member Name',
    'ContactLastname': 'Lastname',
    'BankAccounts': [
        {
            'CurrencyId': 1,
            'Title': 'Ünvan',
            'Iban': 'TR370006400012345678987654'
        }
    ],
    'ValueDate': {
        'CalculationType': 1,
        'CalculationValue': 10,
        'Commission': 10   
    }
}

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("{{MemberBaseAddress}}/api/paywall/member")

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({
  "IsSubMerchant" => true,
  "MemberType" => 1,
  "MemberExternalId" => '111aa11135552244413',
  "MemberName" => 'Intranet Technology',
  "MemberTitle" => 'Intranet Technology Yazılım A.S',
  "MemberTaxOffice" => 'Besiktas',
  "MemberTaxNumber" => '4651176935',
  "MemberIdentityNumber" => '11111111110',
  "MemberEmail" => 'member@paywall.one',
  "MemberPhone" => '5554443322',
  "MemberAddress" => 'test adresi',
  "ContactName" => 'Member Name',
  "ContactLastname" => 'Lastname',
  "BankAccounts" => [
    {
      "CurrencyId" => 1,
      "Title" => 'Ünvan',
      "Iban" => 'TR370006400012345678987654'
    }
  ],
  "ValueDate" => {
    "CalculationType" => 1,
    "CalculationValue" => 10,
    "Commission" => 10
  }
})

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

{% endtab %}

{% tab title="TypeScript" %}

```typescript
import axios from 'axios';

const url = '{{MemberBaseAddress}}/api/paywall/member';
const headers = {
  'Content-Type': 'application/json',
  'apikeypublic': '%%',
  'apiclientpublic': '%%'
};

const data = {
  'IsSubMerchant': true,
  'MemberType': 1,
  'MemberExternalId': '111aa11135552244413',
  'MemberName': 'Intranet Technology',
  'MemberTitle': 'Intranet Technology Yazılım A.S',
  'MemberTaxOffice': 'Besiktas',
  'MemberTaxNumber': '4651176935',
  'MemberIdentityNumber': '11111111110',
  'MemberEmail': 'member@paywall.one',
  'MemberPhone': '5554443322',
  'MemberAddress': 'test adresi',
  'ContactName': 'Member Name',
  'ContactLastname': 'Lastname',
  'BankAccounts': [
    {
      'CurrencyId': 1,
      'Title': 'Ünvan',
      'Iban': 'TR370006400012345678987654'
    }
  ],
  'ValueDate': {
    'CalculationType': 1,
    'CalculationValue': 10,
    'Commission': 10
  }
};

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

{% endtab %}

{% tab title="Curl" %}

```sh
curl --location --request POST '{{MemberBaseAddress}}/api/paywall/member' \
--header 'Content-Type: application/json' \
--header 'apikeypublic: %%' \
--header 'apiclientpublic: %%' \
--data-raw '{
    "IsSubMerchant": true,
    "MemberType": 1,
    "MemberExternalId": "111aa11135552244413",
    "MemberName": "Intranet Technology",
    "MemberTitle": "Intranet Technology Yazılım A.S",
    "MemberTaxOffice": "Besiktas",
    "MemberTaxNumber": "4651176935",
    "MemberIdentityNumber": "11111111110",
    "MemberEmail": "member@paywall.one",
    "MemberPhone": "5554443322",
    "MemberAddress": "test adresi",
    "ContactName": "Member Name",
    "ContactLastname": "Lastname",
    "BankAccounts": [
        {
            "CurrencyId": 1,
            "Title": "Ünvan",
            "Iban": "TR370006400012345678987654"
        }
    ],
    "ValueDate": {
        "CalculationType": 1,
        "CalculationValue": 10,
        "Commission": 10
    }
}'
```

{% endtab %}
{% endtabs %}

**The parameters returned from the service are as follows:**

<table><thead><tr><th width="189">Parameter</th><th width="100.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>ErrorCode</td><td>int</td><td>Error code. Returns '0' if the operation is successful.</td></tr><tr><td>Result</td><td>bool</td><td>Returns either a <strong>true</strong> or <strong>false</strong> value. If the operation is successful, it returns <strong>true</strong>.</td></tr><tr><td>Message</td><td>string</td><td>If the operation fails, this is the error message describing the issue. It provides language support based on the locale parameter.</td></tr><tr><td>Body</td><td>object</td><td>Transaction detail information.</td></tr></tbody></table>

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

```json
{
    "ErrorCodeType": 1,
    "ErrorMessage": null,
    "ErrorCode": 0,
    "Result": true,
    "Message": "",
    "Body": {
        "TempTokenId": 504,
        "Token": "ee166e14-5670-410a-901c-db6b817c3cfa",
        "ExpiryDateTime": "2026-01-31T15:57:33.537137+03:00",
        "Scope": {
            "ClientCardSave": true,
            "ThreeDSession": false,
            "ClientSdk": true,
            "ScopeBased": false,
            "Scope": 0
        },
        // IncludeMasterpassSession parametresinin false ise, null döner
        // Nullable
        "Masterpass": {
            "SessionId": "c8f3663e-f36b-1410-80e8-004205aa382d",
            "SessionExpiryDate": "2026-01-30T16:12:34",
            "MasterpassToken": "%%JWT_TOKEN%%",
            "MasterpassMerchantId": "%%MERCHANT_MASTERPASS_MERCHANT_ID%%",
            "MasterpassTerminalGroupId": "%%MERCHANT_MASTERPASS_TERMINAL_GROUP_ID%%",
            "IsProd": false,
            "IsTest": true,
            "IsUat": false
        }
    }
}
```

{% endcode %}
{% 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/client-side-services/2.-authorization-sdk.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.
