# 3. Complete Payment

## Complete Payment

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

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 - Complete Payment 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="137.78515625">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="150.41796875">Mondatory</th><th>Description</th></tr></thead><tbody><tr><td>SessionId</td><td>Guid</td><td>Yes</td><td><a href="broken-reference">Session ID</a>information</td></tr><tr><td>MasterpassPaymentId</td><td>Guid</td><td>Yes</td><td>It is included in the response returned from the Paywall services at the time of initiating the payment.</td></tr></tbody></table>

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

```json5
{
    "SessionId": "5895433e-f36b-1410-825e-001264113a90",
    "MasterpassPaymentId": "ce55004d-888c-416f-84d7-ed2873531fe7"
}
```

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

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

```json5
{
    "ErrorCodeType": 1,
    "ErrorMessage": null,
    "ErrorCode": 0,
    "Result": true,
    "Message": "Commit successful",
    "Body": {
        "Session": {
            "SessionRenewed": false,
            "SessionId": "55555555-4444-3333-222222-11111111"
        },
        "Masterpass": {
            "Result": true,
            "Detail": {
                "PaymentId": 203948888,
                "PaymentActivityId": 4413674,
                "UniqueCode": "aaaaaaa-33333-32222-0000-11111111111",
                "MerchantUniqueCode": "0000000-2664-4d3c-ae6e-000000000000",
                "TrackingCode": "0-0-0-0-0-0-0-0-0-0-0-0-0-0-0"
            },
            "Error": {
                "ProviderErrorCode": null,
                "ProviderErrorMessage": null
            }
        }
    }
}
```

{% endtab %}

{% tab title="Failed ❌" %}

1. **Payment Not Found**

```json5
{
    "ErrorCodeType": 1,
    "ErrorMessage": null,
    "ErrorCode": 56,
    "Result": false,
    "Message": "Masterpass payment not found",
    "Body": {
        "Session": {
            "SessionRenewed": false,
            "SessionId": "dc27433e-f36b-1410-80e5-004205aa382d"
        },
        "Masterpass": null
    }
}
```

2. **AutoCommit Payments Cannot Be Completed Again**

```json5
{
    "ErrorCodeType": 1,
    "ErrorMessage": null,
    "ErrorCode": 92,
    "Result": false,
    "Message": "Auto commit payment cannot commit again",
    "Body": {
        "Session": {
            "SessionRenewed": false,
            "SessionId": "dc27433e-f36b-1410-80e5-004205aa382d"
        },
        "Masterpass": null
    }
}
```

{% endtab %}
{% endtabs %}
