# 1. Generate Repeatedly

## Generate Recurring Payments

<mark style="color:green;">`POST`</mark> `{{Base Adres}}/api/paywall/recurring`

{% hint style="info" %}
**Important**: To use the Recurring Payment Creation service, you need to send the '**apikeypublic**' and '**apiclientpublic**' parameters 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="162">Parameter</th><th width="79">Type</th><th width="144">Compulsory</th><th width="403">Description</th></tr></thead><tbody><tr><td>apikeypublic</td><td>string</td><td>Yes</td><td>The Public Key obtained from the merchant panel.</td></tr><tr><td>apiclientpublic</td><td>string</td><td>Yes</td><td>The Public 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="268">Parameter</th><th width="112">Type</th><th width="143">Compulsory</th><th width="336">Description</th></tr></thead><tbody><tr><td><strong>Card</strong>:UniqueCode</td><td>string</td><td>Yes</td><td>The UniqueCode information of the stored card where payments will be received, returned from Paywall during saving and listing of registered cards.</td></tr><tr><td>SubscriptionType</td><td>int</td><td>Yes</td><td>Membership type. Currently, only one is supported.<br><br>See: <a href="broken-reference">Recurring Payment</a></td></tr><tr><td>SubscriptionMerchantCode</td><td>string</td><td>Yes</td><td>The unique tracking number provided by your side for the recurring payment.</td></tr><tr><td>CurrencyId</td><td>int</td><td>Yes</td><td>Currency</td></tr><tr><td>Amount</td><td>decimal</td><td>Yes</td><td>The recurring payment amount. The amount to be deducted from the card each time.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>No</td><td>The address where payment results will be POSTed. No callback will be sent if left empty<br><br>See. <a href="broken-reference"><strong>Post Body</strong></a></td></tr><tr><td>HasTrial</td><td>bool</td><td>Yes</td><td>Is there a trial period applied to the membership?</td></tr><tr><td>TrialDay</td><td>int</td><td>Yes</td><td>The number of days for the trial period applied to the membership. If the payment was created on 02/07 in a monthly period and there is a trial period of 10 days, the first payment will be charged on 12/08.</td></tr><tr><td>PaymentAtCreation</td><td>bool</td><td>Yes</td><td><p>If you send the parameter as TRUE, the first payment will be collected with the relevant information before the membership is created. Once the payment is successfully processed, the membership will be created with the corresponding card details. If FALSE is sent, the membership will be created along with the selected period, and a payment order will be generated. However, the first payment will not be collected when the membership is created.<br><br><mark style="color:blue;">Note: If a trial day is provided, the frist</mark>        </p><p><mark style="color:blue;">payment will be collected after today plus the trial day even if this parameter is</mark> </p><p><mark style="color:blue;">send as TRUE.</mark></p></td></tr><tr><td>FirstPaymentDate</td><td>DateTime</td><td>No</td><td><p>You can determine the initial date of the payment on your side. If the parameter is sent as 2024-04-04, the payment will be collected on the specified date, 2024-04-04, and will continue with the period you have set thereafter.</p><p><br><br>Note: In case of your trial implementation, days are added on top of the initial payment date, and the payment is processed accordingly. If you specify 2024-04-04 and there is a trial period of 10 days, the first payment will be collected on 2024-04-14.</p><p><br></p></td></tr><tr><td>RecurringPeriodType</td><td>int</td><td>Yes</td><td>The type of period in which the payment will be repeated.<br><br>See: <a href="broken-reference">Recurring Payment</a></td></tr><tr><td>RecurringPeriodCount</td><td>int</td><td>Yes (Conditional)</td><td>In case the membership type is 'Quantity-Based,' the desired quantity information to be deducted is entered.</td></tr><tr><td>FailAttempt</td><td>int</td><td>Yes</td><td>The number of retry attempts if the payment fails. <mark style="color:red;">Max: 5</mark></td></tr><tr><td>FailAttemptPendingHour</td><td>int</td><td>Yes</td><td>The time zone that Paywall will wait between retry attempts for failed payments. <mark style="color:red;">Max: 24</mark></td></tr><tr><td><strong>Customer</strong>:SubscriptionCustomerPoolId</td><td>int</td><td>No</td><td>If a membership is to be created with a record from the Customer/User pool, it is the ID (identifier) information of the relevant record.</td></tr><tr><td><strong>Customer</strong>:Name</td><td>string</td><td>Yes</td><td>The username/customer name associated with the payment in your system.</td></tr><tr><td><strong>Customer</strong>:Lastname</td><td>string</td><td>Yes</td><td>The surname associated with the payment in your system.</td></tr><tr><td><strong>Customer</strong>:Phone</td><td>string</td><td>Yes</td><td>The phone number associated with the user/customer in your payment system.</td></tr><tr><td><strong>Customer</strong>:Email</td><td>string</td><td>Yes</td><td>The email address associated with the user/customer in your payment system.</td></tr><tr><td><strong>Customer</strong>:Country</td><td>string</td><td>Yes</td><td>The country information associated with the user/customer in your payment system.</td></tr><tr><td><strong>Customer</strong>:City</td><td>string</td><td>Yes</td><td>The city information associated with the user/customer in your payment system.</td></tr><tr><td><strong>Customer</strong>:Address</td><td>string</td><td>Yes</td><td>The address information associated with the user/customer in your payment system.</td></tr><tr><td><strong>Customer</strong>:IdentityNumber</td><td>string</td><td>Yes</td><td>The identification information associated with the user/customer in your payment system.</td></tr><tr><td><strong>Items:</strong>SubscriptionItemPoolId</td><td>int</td><td>No</td><td>If a membership is to be created with a record from the Content Pool, it is the ID (identifier) information of the relevant record.</td></tr><tr><td><strong>Items</strong>:Type</td><td>int</td><td>Yes</td><td>The type of sale that the payment concerns.<br><br>See: <a href="broken-reference">Recurring Payment</a></td></tr><tr><td><strong>Items</strong>:Name</td><td>string</td><td>Yes</td><td>The name of the sale that the payment concerns.</td></tr><tr><td><strong>Items</strong>:Amount</td><td>decimal</td><td>Yes</td><td><p>The amount of the sale that the payment concerns.<br><br><mark style="color:red;">the items object is on array, and the entered items should be equal tı the total amount array'dir ve girilen item'lerin Amount</mark></p><p><br></p></td></tr></tbody></table>

**Sample to be sent for service&#x20;**<mark style="color:green;">**JSON**</mark>**&#x20;and&#x20;**<mark style="color:green;">**example codes**</mark>**&#x20;Sample to be sent for service**

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

```json5
{
    "Card": {
        "UniqueCode": "aQbAoMhiAeYSfailjc2UzF7S1E/6QC=="
    },
    "SubscriptionType": 1,
    "SubscriptionMerchantCode": "12asaaaaasssaasaass2ada3",
    "CurrencyId": 1,
    "Amount": 110,
    "CallbackUrl": "https://webhook.site/8d70cb8e-fe1b-478b-8ee3-823870549ef2",
    "HasTrial": false,
    "TrialDay": 10,
    "FirstPaymentDate": "2023-09-26T05:00", // Null can be provided
    "RecurringPeriodType": 1,
    "RecurringPeriodCount": 0, // RecurringPeriodType
        // When parameter 2 is sent, the API...
        // It is controlled by the API. It takes a value between 0 and 365!
    "FailAttempt": 1,
    "FailAttemptPendingHour": 1,
    "Customer": {
        "SubscriptionCustomerPoolId": null, // Customer/User
            // If a selection has been made from the pool and...
            // If a membership is being created, the record in the pool...
            // ID (identity) information
            // -Creating with pool data
            // No need for the following information instantly-
        "Name": "Jogni",
        "Lastname": "Kivi",
        "Phone": "5554433212",
        "Email": "kivijogni@paywall.one",
        "Country": "Turkey",
        "City": "Istanbul",
        "Address": "Heaven",
        "IdentityNumber": "11111111110"
    },
    "Items": [
        {
            "SubscriptionItemPoolId": null, // Membership content
            // If a selection has been made from the pool and...
            // If a membership is to be created, the record in the pool
            // ID (identity) information
            // -Creating with pool data
            // No need for the following information instantly-
            "Type": 1,
            "Name": "Gold Package",
            "Amount": 110
        }
    ]
}
```

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

**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>It returns a True or False value. If the operation is successful, it returns 'true'.</td></tr><tr><td>Message</td><td>string</td><td>If the operation fails, this is the specified error message.</td></tr><tr><td>Body</td><td>object</td><td><em>No details are returned.</em></td></tr></tbody></table>

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

```json
{
    "ErrorCode": 0,
    "Result": true,
    "Message": "",
    "Body": null
}
```

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