# Apply Payment

## **Introduction** <a href="#migrationtopaymentsapi-applypayment" id="migrationtopaymentsapi-applypayment"></a>

This endpoint is used to perform a one-time payment in Circulation Systems (NCS Circ, CircPro, and Matrix).

## Comparison <a href="#migrationtopaymentsapi-comparison" id="migrationtopaymentsapi-comparison"></a>

Compared to the older model, the new input model requires just a few parameters, as explained in detail below.

<table data-full-width="true"><thead><tr><th width="123"> </th><th width="441">Billing API (OLD)</th><th>Payments API (NEW)</th></tr></thead><tbody><tr><td><strong>URL</strong></td><td>/Billing/Payments/{subscriptionId}/ApplyPayment</td><td>/Payment</td></tr><tr><td><strong>Method</strong></td><td>POST</td><td>POST</td></tr><tr><td><strong>Input Example</strong></td><td><pre class="language-javascript" data-overflow="wrap"><code class="lang-javascript">{
   "ExternalPaymentMethodId":"10200849",
   "CustomerId":null,
   "GiveTip":false,
   "TipAmount":0.0,
   "TotalAmount":9.99,
   "PaymentSelectedAmount":9.99,
   "CurrencyCode":null,
   "PaymentMethodType":0,
   "NewPaymentMethod":null,
   "TypeOfPayment":null,
   "ParentEventId":0,
   "GiveDonation":false,
   "DonationAmount":0.0,
   "Last4Digits":null,
   "AuthToken":"10200849",
   "AuthTokenPaymentMethodType":2,
   "SignUpToEzPay":false,
   "IsTipAutoRenew":null,
   "IsDonationAutoRenew":null,
   "ApplyToCredit":false,
   "ValidateMaxAmount":false,
   "InvoiceId":null,
   "CreateMapOnTheFly":false,
   "Notes":null,
   "Token":null,
   "RenewalTerm":"Month",
   "RenewalLength":"1",
   "RateCode":null,
   "RestartDate":null,
   "IgnoreFee":true,
   "TransactionId":null,
   "AccountInfo":{
      "SubscriptionId":102830,
      "SubscriberId":102311,
      "RegistrationId":0
   }
}
</code></pre></td><td><pre class="language-javascript" data-overflow="wrap"><code class="lang-javascript">{
  "IgnoreFee": true,
  "DonationAmount": 0,
  "PaymentMethodId": 0,
  "SubscriptionId": 0,
  "TipAmount": 0,
  "TotalAmount": 0,
  "PaymentOptionAmount": 0,
  "TransactionId": "string",
  "ProcessingFeeAmount": 0,
  "ProcessingFeeTaxAmount": 0
}
</code></pre><p></p></td></tr></tbody></table>

***

## Apply Payment

<mark style="color:green;">`POST`</mark> `/Payment`

This endpoint is used to perform a one-time payment in Circulation Systems.

**Note:** *The parameters marked with an asterisk* (<mark style="color:red;">\*</mark>) *are mandatory and must be included in the input model.*

#### Headers

<table><thead><tr><th width="211">Name</th><th width="124">Type</th><th>Description</th></tr></thead><tbody><tr><td>Authorization<mark style="color:red;">*</mark></td><td>String</td><td>JSON Web Token used for security purposes</td></tr><tr><td>X-SourceSystem<mark style="color:red;">*</mark></td><td>String</td><td>To identify the consumer or the Source System</td></tr><tr><td>X-MediaGroupCode<mark style="color:red;">*</mark></td><td>String</td><td>Media Group Code of the Tenant</td></tr><tr><td>X-ClientCode<mark style="color:red;">*</mark></td><td>String</td><td>Client Code of the Tenant</td></tr><tr><td>X-PaperCode<mark style="color:red;">*</mark></td><td>String</td><td>Paper Code of the Tenant</td></tr></tbody></table>

#### Request Body

<table><thead><tr><th width="250">Name</th><th width="139">Type</th><th>Description</th></tr></thead><tbody><tr><td>SubscriptionId<mark style="color:red;">*</mark></td><td>Integer</td><td>Unique identifier of the Subscription in Naviga System</td></tr><tr><td>PaymentMethodId<mark style="color:red;">*</mark></td><td>Integer</td><td>Unique identifier of the payment method in Naviga System</td></tr><tr><td>DonationAmount</td><td>Decimal</td><td>Donation amount</td></tr><tr><td>TipAmount</td><td>Decimal</td><td>Tip amount</td></tr><tr><td>TotalAmount<mark style="color:red;">*</mark></td><td>Decimal</td><td><p>The total amount being paid (<em>PaymentOptionAmount</em> + <em>TipAmount</em> + <em>DonationAmount</em> + <em>ProcessingFeeAmount</em> + <em>ProcessingFeeTaxAmount</em>).</p><p></p><p>If the PaymentType is Credit Card for NCS clients, an Activation Fee is charged to the TotalAmount. </p><p><em>Total Amount</em> for NCS = <em>PaymentOptionAmount + TipAmount + DonationAmount + ProcessingFeeAmount + ProcessingFeeTaxAmount + ActivationFee</em></p></td></tr><tr><td>PaymentOptionAmount<mark style="color:red;">*</mark></td><td>Decimal</td><td>The Payment Option Amount being paid.</td></tr><tr><td>IgnoreFee</td><td>Boolean</td><td>Indicate whether the Activation Fee should be ignored. Applicable for NCS clients.</td></tr><tr><td>TransactionId</td><td>String</td><td>Transaction ID created by the Payment Gateway when creating a new Payment Method. Applicable for Matrix clients.</td></tr><tr><td>ProcessingFeeAmount</td><td>Decimal</td><td>The Fee amount being paid. Applicable for NCS clients.</td></tr><tr><td>ProcessingFeeTaxAmount</td><td>Decimal</td><td>The Fee tax amount being paid. Applicable for NCS clients.</td></tr></tbody></table>

{% tabs %}
{% tab title="200: OK Success Response" %}

```json
{
  "Code": 200,
  "Errors": [],
  "Result": {
    "EventId": 0
  },
  "SessionId": "string",
  "RequestId": "string"
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid Input" %}

```json
{
   "Code":400,
   "Errors":[
      {
         "Message":"Invalid Input.",
         "Code":"Payments_01",
         "Type":{
            "Id":0,
            "Code":"Validation"
         },
         "ErrorSource":null
      }
   ],
   "Result":null,
   "SessionId":"string",
   "RequestId":"string"
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid Total Amount" %}

```json
{
   "Code":400,
   "Errors":[
      {
         "Message":"The Total Amount is invalid.",
         "Code":"Payments_29",
         "Type":{
            "Id":0,
            "Code":"Validation"
         },
         "ErrorSource":null
      }
   ],
   "Result":null,
   "SessionId":"string",
   "RequestId":"string"
}
```

{% endtab %}

{% tab title="400: Bad Request Newspaper configuration settings error" %}
{% code overflow="wrap" %}

```json
{
   "Code":400,
   "Errors":[
      {
         "Message":"Error getting newspaper configuration settings",
         "Code":"Payments_18",
         "Type":{
            "Id":2,
            "Code":"Processing"
         },
         "ErrorSource":null
      }
   ],
   "Result":null,
   "SessionId":"string",
   "RequestId":"string"
}
```

{% endcode %}
{% endtab %}

{% tab title="400: Bad Request Subscription not found" %}
{% code overflow="wrap" fullWidth="false" %}

```json
{
   "Code":400,
   "Errors":[
      {
         "Message":"Subscription not found.",
         "Code":"Payments_03",
         "Type":{
            "Id":2,
            "Code":"Processing"
         },
         "ErrorSource":null
      }
   ],
   "Result":null,
   "SessionId":"string",
   "RequestId":"string"
}
```

{% endcode %}
{% endtab %}

{% tab title="400: Bad Request Subscriber Data not found" %}

```json
{
   "Code":400,
   "Errors":[
      {
         "Message":"SubscriberData not found.",
         "Code":"Payments_04",
         "Type":{
            "Id":2,
            "Code":"Processing"
         },
         "ErrorSource":null
      }
   ],
   "Result":null,
   "SessionId":"string",
   "RequestId":"string"
}
```

{% endtab %}

{% tab title="400: Bad Request Payment Method not found" %}
{% code overflow="wrap" %}

```json
{
   "Code":400,
   "Errors":[
      {
         "Message":"Payment Method not found.",
         "Code":"Payments_05",
         "Type":{
            "Id":2,
            "Code":"Processing"
         },
         "ErrorSource":null
      }
   ],
   "Result":null,
   "SessionId":"string",
   "RequestId":"string"
}
```

{% endcode %}
{% endtab %}

{% tab title="400: Bad Request Payment Method Type is not allowed" %}

```json
{
   "Code":400,
   "Errors":[
      {
         "Message":"Payment Method Type is not allowed.",
         "Code":"Payments_06",
         "Type":{
            "Id":1,
            "Code":"NotProcessingAllowed"
         },
         "ErrorSource":null
      }
   ],
   "Result":null,
   "SessionId":"string",
   "RequestId":"string"
}
```

{% endtab %}

{% tab title="400: Bad Request Comp Sub not allowed to make payments" %}

```json
{
   "Code":400,
   "Errors":[
      {
         "Message":"COMP subscription are not allowed to make payments",
         "Code":"Payments_27",
         "Type":{
            "Id":0,
            "Code":"Validation"
         },
         "ErrorSource":null
      }
   ],
   "Result":null,
   "SessionId":"string",
   "RequestId":"string"
}
```

{% endtab %}

{% tab title="400: Bad Request Currency empty in subscription" %}

```json
{
   "Code":400,
   "Errors":[
      {
         "Message":"The currency is empty in subscription.",
         "Code":"Payments_23",
         "Type":{
            "Id":0,
            "Code":"Validation"
         },
         "ErrorSource":null
      }
   ],
   "Result":null,
   "SessionId":"string",
   "RequestId":"string"
}
```

{% endtab %}

{% tab title="400: Bad Request Subscription already on EZPay " %}

```json
{
   "Code":400,
   "Errors":[
      {
         "Message":"The subscription is on EzPay already",
         "Code":"Payments_07",
         "Type":{
            "Id":0,
            "Code":"Validation"
         },
         "ErrorSource":null
      }
   ],
   "Result":null,
   "SessionId":"string",
   "RequestId":"string"
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid Subscription Status" %}

```json
{
   "Code":400,
   "Errors":[
      {
         "Message":"Invalid subscription status",
         "Code":"Payments_19",
         "Type":{
            "Id":1,
            "Code":"NotProcessingAllowed"
         },
         "ErrorSource":null
      }
   ],
   "Result":null,
   "SessionId":"string",
   "RequestId":"string"
}
```

{% endtab %}

{% tab title="400: Bad Request Payment was made in the last 24 hours" %}
{% code overflow="wrap" %}

```json
{
   "Code":400,
   "Errors":[
      {
         "Message":"The subscription already made a payment over the last 24 hours",
         "Code":"Payments_13",
         "Type":{
            "Id":1,
            "Code":"NotProcessingAllowed"
         },
         "ErrorSource":null
      }
   ],
   "Result":null,
   "SessionId":"string",
   "RequestId":"string"
}
```

{% endcode %}
{% endtab %}

{% tab title="400: Bad Request Failed to create Payment event" %}
{% code overflow="wrap" %}

```json
{
   "Code":400,
   "Errors":[
      {
         "Message":"Failed to create Payment event.",
         "Code":"Payments_02",
         "Type":{
            "Id":1,
            "Code":"Processing"
         },
         "ErrorSource":null
      }
   ],
   "Result":null,
   "SessionId":"string",
   "RequestId":"string"
}
```

{% endcode %}
{% endtab %}

{% tab title="400: Bad Request Authorized funds has failed" %}
{% code overflow="wrap" %}

```json
{
   "Code":400,
   "Errors":[
      {
         "Message":"Authorized funds has failed.",
         "Code":"Payments_09",
         "Type":{
            "Id":2,
            "Code":"Processing"
         },
         "ErrorSource":null
      }
   ],
   "Result":null,
   "SessionId":"string",
   "RequestId":"string"
}
```

{% endcode %}
{% endtab %}

{% tab title="400: Bad Request Failed when Processing Circ System" %}

```json
{
   "Code":400,
   "Errors":[
      {
         "Message":"Failed when Processing Circ System.",
         "Code":"Payments_10",
         "Type":{
            "Id":2,
            "Code":"Processing"
         },
         "ErrorSource":null
      }
   ],
   "Result":null,
   "SessionId":"string",
   "RequestId":"string"
}
```

{% endtab %}

{% tab title="400: Bad Request Update Subscription Data failed" %}

```json
{
   "Code":400,
   "Errors":[
      {
         "Message":"Update Subscription Data failed.",
         "Code":"Payments_20",
         "Type":{
            "Id":2,
            "Code":"Processing"
         },
         "ErrorSource":null
      }
   ],
   "Result":null,
   "SessionId":"string",
   "RequestId":"string"
}
```

{% endtab %}

{% tab title="400: Bad Request Update Subscription PaymentMethodId failed" %}

```json
{
   "Code":400,
   "Errors":[
      {
         "Message":"Update Subscription Payment Method Id failed.",
         "Code":"Payments_21",
         "Type":{
            "Id":2,
            "Code":"Processing"
         },
         "ErrorSource":null
      }
   ],
   "Result":null,
   "SessionId":"string",
   "RequestId":"string"
}
```

{% endtab %}

{% tab title="400: Bad Request Exceeded session validation attempts" %}
{% code overflow="wrap" %}

```json
{
   "Code":400,
   "Errors":[
      {
         "Message":"The amount of retries to validate your payment session reached the maximum allowed",
         "Code":"Payments_26",
         "Type":{
            "Id":1,
            "Code":"NotProcessingAllowed"
         },
         "ErrorSource":null
      }
   ],
   "Result":null,
   "SessionId":"string",
   "RequestId":"string"
}
```

{% endcode %}
{% endtab %}

{% tab title="400: Bad Request Surcharge for incorrect payment method" %}
{% code overflow="wrap" %}

```json
{
   "Code":400,
   "Errors":[
      {
         "Message":"The surcharge amounts only apply for Credit Card payment methods",
         "Code":"Payments_16",
         "Type":{
            "Id":0,
            "Code":"Validation"
         },
         "ErrorSource":null
      }
   ],
   "Result":null,
   "SessionId":"string",
   "RequestId":"string"
}
```

{% endcode %}
{% endtab %}

{% tab title="400: Bad Request Authorization is missing" %}

```json
{
    "error": "Authorization is missing."
}

```

{% endtab %}

{% tab title="400: Bad Request X-SourceSystem is missing" %}

```json
{
    "error": "X-SourceSystem is missing."
}
```

{% endtab %}

{% tab title="401: Unauthorized Invalid Source System" %}

```json
{
    "error": "Invalid Source System."
}
```

{% endtab %}

{% tab title="401: Unauthorized Invalid authorization" %}

```json
{
    "error": "Invalid authorization."
}
```

{% endtab %}

{% tab title="500: Internal Server Error Internal Server Error" %}

```json
{
    "error": "Something went wrong. Please try again later."
}
```

{% endtab %}
{% endtabs %}
