# 9. Ödeme Başlat

## Ödeme Başlat

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

Yukarıda verilmiş olan adrese istek atmanız yeterli olacaktır. Test ortamı ve Gerçek ortam için 'Base Address' istediğiniz gibi kullanabilirsiniz.

{% hint style="info" %}
Önemli: **Masterpass - Ödeme Başlat** servisini kullanabilmeniz için 'Header' alanında '**apikeyprivate**' ve '**apiclientprivate**' parametrelerini göndermeniz gerekmektedir.\
\
[<mark style="color:green;">**PaymentAPI Adresi**</mark>](/ortam.md)
{% endhint %}

<table><thead><tr><th width="182">Parametre</th><th width="106.33333333333331">Tip</th><th width="97">Zorunlu</th><th>Açıklama</th></tr></thead><tbody><tr><td>apikeyprivate</td><td>string</td><td>Evet</td><td>Üye işyeri panelinden temin etmiş olduğunuz Private Key.</td></tr><tr><td>apiclientprivate</td><td>string</td><td>Evet</td><td>Üye işyeri panelinden temin etmiş olduğunuz Private Client.</td></tr></tbody></table>

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

<table><thead><tr><th width="228">Parametre</th><th width="106">Tip</th><th width="123">Zorunlu</th><th>Açıklama</th></tr></thead><tbody><tr><td>SessionId</td><td>Guid</td><td>Evet</td><td><a href="/pages/xpRDdgZPoDKXW4msT7aK">Oturum Kimliği</a> bilgisi</td></tr></tbody></table>

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

```json5
{
    "SessionId": "8496433e-f36b-1410-825e-001264113a90",
    "Force3D": false,
    "AutoCommit": true,
    "PaymentDetail": { 
        "Amount": 50,
        "MerchantUniqueCode": "{{$guid}}",
        "TrackingCode": "test1132412341412341234--1243-14-23-41-324-123-4",
        "CurrencyId": 1,
        "MerchantSuccessBackUrl": "https://webhook.site/2132fe83-9f0d-461d-ae18-85e9d4a8b0ec",
        "MerchantFailBackUrl": "https://webhook.site/2132fe83-9f0d-461d-ae18-85e9d4a8b0ec",
        "ClientIP": "34.123.2.45",
        "Installment": 1,
        "ChannelId": 0,
        "TagId": 0,
        "PayWatch": null,
        "PayWatchMultipleSupport": false,
        "PayWatchMultiple": null
    },
    "Card": {
        "IsSavedCard": true,
        
        // For SavedCard
        "CardBin": "552879",
        "CardMasked": "552879********08",

        // For not SavedCard
        "OwnerName": "test",
        "Number": "5528790000000008",
        "ExpireMonth": "12",
        "ExpireYear": "2030",
        "Cvv": "123",
        
        // Common Params
        "SaveCard": false,
        "CardAlias": "55daa93d-4a99-45de-9431-bb93d0bbf92e" // For saved and saving card
    },
    "Customer": {
        "IdentityNumber": "11111111110"
    },
    "Products": [
        {
            "MemberId": 994,
            "MemberEarningCalculated": false,
            "MemberEarning": 138,
            "MemberCustomCommission": false,
            "MemberCommission": 5,
            "ProductId": "1-1-1-1234342342------1--7-8-9",
            "ProductName": "Nakliye Hizmeti",
            "ProductCategory": "123",
            "ProductDescription": "Nakliye 123",
            "ProductAmount": 50,
            "DiscountOwnerType": 0,
            "DiscountType": 0,
            "DiscountValue": 0,
            "CargoType": 0,
            "CargoCurrencyId": 0,
            "CargoCost": 0
        }
    ]
}
```

{% 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 %}

**Servisten dönen cevap:**

<table><thead><tr><th width="156">Parametre</th><th width="83.33333333333331">Tip</th><th>Açılama</th></tr></thead><tbody><tr><td>Body</td><td>object</td><td>Ödemeye ilişkin detay içeren JSON (opsiyonel)</td></tr><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></tbody></table>

{% tabs %}
{% tab title="Başarılı ✅" %}

```json5
{
    "ErrorCodeType": 1,
    "ErrorMessage": null,
    "ErrorCode": 0,
    "Result": true,
    "Message": "Success",
    "Body": {
        "Session": {
            "SessionRenewed": false,
            "SessionId": "dc27433e-f36b-1410-80e5-004205aa382d"
        },
        "Masterpass": {
            "Paywall": {
                "MasterpassPaymentId": "e9b18fc1-1915-4876-8ad8-c1aafada747f",
                "PaymentId": 6618969,
                "ActivityId": 14597573,
                "UniqueCode": "9ee137ed-8dba-414e-9115-ee2cc774acf5",
                "MerchantUniqueKey": "ecae9baa-ba88-441e-b99e-42dd79aef4b5",
                "PaymentGatewayId": 4142,
                "PaymentGatewayName": "Masterpass",
                "PaymentGatewayProviderName": "Masterpass",
                "Products": [
                    {
                        "Id": 6962735,
                        "MemberId": 0,
                        "MemberEarningCalculated": false,
                        "MemberEarning": 0.0,
                        "ProductId": "1-1-1-1234342342------1--7-8-9",
                        "ProductName": "Nakliye Hizmeti",
                        "ProductCategory": "123",
                        "ProductDescription": "Nakliye 123",
                        "ProductAmount": 50.0
                    }
                ]
            },
            "Provider": {
                "IsOtp": false,
                "IsThreeD": true,
                "ThreeDAddress": "https://dev-payment-agent.itspaywall.com/paywall/callbackmasterpass?UniqueNumber=e9b18fc1-1915-4876-8ad8-c1aafada747f",
                "Detail": {
                    "Result": {
                        "ResponseCode": "5010",
                        "Description": "Telefonunuza gelen tek kullanımlık şifreyi girerek işleminizi tamamlayınız",
                        "Token": "e85525f1077640ba8ba2423f2c1ffc41",
                        "RetrievalReferenceNumber": "200007817889",
                        "MaskedNumber": "************0008",
                        "TerminalGroupId": "78516638760698041272198"
                    },
                    "BuildId": "105",
                    "CorrelationId": "e3aa50c2-d749-4513-8a9b-22e151ad6da6",
                    "Exception": null,
                    "Message": "Accepted",
                    "RequestId": null,
                    "StatusCode": 202,
                    "Version": null
                }
            },
            "Error": {
                "ProviderErrorCode": null,
                "ProviderErrorMessage": null
            }
        }
    }
}
```

{% endtab %}

{% tab title="Başarısız ❌" %}

```json
{
    "ErrorCodeType": 1,
    "ErrorMessage": null,
    "ErrorCode": 78,
    "Result": false,
    "Message": "Masterpass payment request failed",
    "Body": {
        "Session": {
            "SessionRenewed": false,
            "SessionId": "ca27433e-f36b-1410-80e5-004205aa382d"
        },
        "Masterpass": {
            "Paywall": {
                "MasterpassPaymentId": null,
                "PaymentId": 0,
                "ActivityId": 0,
                "UniqueCode": "",
                "MerchantUniqueKey": "",
                "PaymentGatewayId": 0,
                "PaymentGatewayName": "",
                "PaymentGatewayProviderName": "",
                "Products": null
            },
            "Provider": {
                "IsOtp": false,
                "IsThreeD": false,
                "ThreeDAddress": "",
                "Detail": {
                    "Result": null,
                    "BuildId": "105",
                    "CorrelationId": null,
                    "Exception": {
                        "Level": "NotFound",
                        "Code": "CARD_NOT_FOUND",
                        "Message": "Kart bulunamadı."
                    },
                    "Message": "NotFound",
                    "RequestId": null,
                    "StatusCode": 404,
                    "Version": null
                }
            },
            "Error": {
                "ProviderErrorCode": null,
                "ProviderErrorMessage": 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/masterpass-entegrasyonu/9.-odeme-baslat.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.
