# POST /invoice/recordpayment/{{invoice_id}} — Record Payment Invoice

> Product: **Pabbly Subscription Billing** (v1)
> Base URL: `https://payments.pabbly.com/api/v1`
> Auth: Basic via `Authorization` header
> Canonical: `/subscription-billing/invoice/record-payment-invoice`

POST request API. Used to record the payment of any customer. invoice_id will be added in the Request URL. In response you will get the ‘Success’ status and the status of invoice will be updated.

**Path parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| invoice_id | string | Yes |  |

**Body parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| payment_mode | string | Yes | Name the source in which you have collected the payment like cash, bank transfer etc. |
| payment_note | string | No | Add a note in for future reference. |
| transaction | string | No | Add transaction details if any. |

**Example request body:**

```json
{
	"payment_mode":"cash",
	"payment_note":"The custmer has made a cash payout", 
	"transaction":"Transaction data if any"
}
```

**Response (200)** — Record Payment Invoice:

```json
{
    "status": "success",
    "message": "Your payment is successful.",
    "data": {
        "user": {
            "currency": "USD",
            "process": "done",
            "lockout_count": 0,
            "status": "active",
            "createdAt": "2018-09-10T07:22:45.819Z",
            "updatedAt": "2020-03-04T05:09:30.807Z",
            "id": "5b961bc55dfff7797d9cd897",
            "parent": "5a1cfb08e5866110121ebbf5",
            "first_name": "Tamara",
            "last_name": "Ethridge",
            "email": "mayank.dhiman03@gmail.com",
            "address_line1": "",
            "address_line2": "",
            "city": "Southfield",
            "state": "Michigan",
            "country": "United States",
            "zip_code": "48075",
            "phone": "8105286395",
            "mobile": "",
            "facebook_url": "",
            "twitter_url": "",
            "time_zone": "Asia/Kolkata",
            "date_format": "DD/MM/YYYY hh:mm A",
            "ip_address": "::ffff:127.0.0.1",
            "currency_symbol": "$"
        },
        "customer": {
            "company_name": "",
            "is_affiliate": false,
            "website": "",
            "phone": "9895651332",
            "billing_address": {
                "street1": "",
                "street2": "",
                "city": "",
                "state": "",
                "state_code": "",
                "zip_code": "",
                "country": "US"
            },
            "shipping_address": {
                "attention": "",
                "street1": "",
                "street2": "",
                "city": "",
                "state": "",
                "state_code": "",
                "zip_code": "",
                "country": "US"
            },
            "portal_status": true,
            "copy_billing_address": false,
            "createdAt": "2020-03-03T10:04:58.241Z",
            "updatedAt": "2020-03-03T10:04:58.254Z",
            "id": "5e5e2bca815f5442a4208dfe",
            "first_name": "Tamara",
            "last_name": "Ethridge",
            "email_id": "ethridgertamara@gmail.com"
        },
        "product": {
            "createdAt": "2020-02-05T10:12:36.805Z",
            "updatedAt": "2020-02-05T10:12:36.805Z",
            "id": "5e3a95143c92e44b424b6d47",
            "product_name": "Product 1",
            "description": null,
            "notification_email": null,
            "redirect_url": "#"
        },
        "subscription": {
            "plan": {
                "plan_active": "true",
                "bump_offer": {},
                "createdAt": "2020-02-06T11:30:00.807Z",
                "updatedAt": "2020-02-06T11:30:00.807Z",
                "id": "5e3bf8b8db85462760295d2f",
                "product_id": "5e3a95143c92e44b424b6d47",
                "user_id": "5b961bc55dfff7797d9cd897",
                "plan_name": "New recurring plan",
                "plan_code": "new-recurring-plan",
                "price": 200,
                "billing_period": "m",
                "billing_period_num": "1",
                "billing_cycle": "lifetime",
                "billing_cycle_num": null,
                "trial_period": 0,
                "setup_fee": 0,
                "plan_description": "<p>zdf</p>"
            },
            "setup_fee": 0,
            "payment_terms": "",
            "currency_symbol": "$",
            "addons": [
                {
                    "id": "5e3aac363c92e44b424b6dfc",
                    "user_id": "5b961bc55dfff7797d9cd897",
                    "name": "Add on 1 one time",
                    "product_id": "5e3a95143c92e44b424b6d47",
                    "code": "add-on-1-one-time",
                    "price": 100,
                    "quantity": 1,
                    "billing_cycle": "onetime",
                    "billing_period": "",
                    "associate_plans": "all_plans",
                    "plans_array": null,
                    "category_array": [
                        "5e3aac1924b63d4b28410d4d"
                    ],
                    "adjusted_amount": 100
                }
            ],
            "payment_method": "test",
            "taxable": true,
            "gateway_type": "test",
            "gateway_id": "5e3a950824b63d4b28410c8d",
            "custom_fields": [],
            "cron_process": "done",
            "createdAt": "2020-03-03T10:07:30.453Z",
            "updatedAt": "2020-03-03T10:14:22.586Z",
            "id": "5e5e2c62815f5442a4208e01",
            "customer_id": "5e5e2bca815f5442a4208dfe",
            "product_id": "5e3a95143c92e44b424b6d47",
            "plan_id": "5e3bf8b8db85462760295d2f",
            "amount": 200,
            "email_id": "ethridgertamara@gmail.com",
            "status": "live",
            "quantity": 1,
            "starts_at": "2020-03-03T10:07:30.303Z",
            "activation_date": "2020-03-04T05:49:04.044Z",
            "expiry_date": "2120-03-03T10:07:30.303Z",
            "trial_days": 0,
            "trial_expiry_date": "",
            "next_billing_date": "2020-04-04T05:49:04.044Z",
            "last_billing_date": "2020-03-04T05:49:04.044Z",
            "canceled_date": null
        },
        "invoice": {
            "invoice_id": "INV-50",
            "quantity": 1,
            "product_id": "5e3a95143c92e44b424b6d47",
            "setup_fee": 0,
            "currency_symbol": "$",
            "credit_note": {
                "total_tax": "0.00",
                "status": "success",
                "new_plan_total": 300,
                "credit_applied": []
            },
            "tax_apply": "not_exist",
            "cron_process": "done",
            "retry": false,
            "retry_count": 0,
            "createdAt": "2020-03-03T10:07:30.466Z",
            "updatedAt": "2020-03-03T10:07:30.468Z",
            "id": "5e5e2c62815f5442a4208e02",
            "customer_id": "5e5e2bca815f5442a4208dfe",
            "subscription_id": "5e5e2c62815f5442a4208e01",
            "status": "paid",
            "payment_term": "",
            "amount": 300,
            "due_amount": 0,
            "due_date": "2020-03-03T10:07:30.303Z",
            "plan_id": [
                "5e3bf8b8db85462760295d2f"
            ]
        }
    }
}
```

**Code examples:**

_cURL_

```curl
curl -X POST https://payments.pabbly.com/api/v1/invoice/recordpayment/{{invoice_id}} \
  -u {{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}} \
  -H "Content-Type: application/json" \
  -d '{
    "payment_mode": "cash",
    "payment_note": "The custmer has made a cash payout",
    "transaction": "Transaction data if any"
  }'
```

_Ruby_

```ruby
require 'net/http'
require 'json'

uri = URI('https://payments.pabbly.com/api/v1/invoice/recordpayment/{{invoice_id}}')
request = Net::HTTP::Post.new(uri)
request.basic_auth '{{YOUR_API_KEY}}', '{{YOUR_SECRET_KEY}}'
request['Content-Type'] = 'application/json'
request.body = "{\"payment_mode\":\"cash\",\"payment_note\":\"The custmer has made a cash payout\",\"transaction\":\"Transaction data if any\"}"

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
  http.request(request)
end

data = JSON.parse(response.body)
```

_Python_

```python
import requests
from requests.auth import HTTPBasicAuth

response = requests.post(
    'https://payments.pabbly.com/api/v1/invoice/recordpayment/{{invoice_id}}',
    auth=HTTPBasicAuth('{{YOUR_API_KEY}}', '{{YOUR_SECRET_KEY}}'),
    json={
    'payment_mode': 'cash',
    'payment_note': 'The custmer has made a cash payout',
    'transaction': 'Transaction data if any'
},
)

data = response.json()
```

_PHP_

```php
<?php
$ch = curl_init('https://payments.pabbly.com/api/v1/invoice/recordpayment/{{invoice_id}}');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_USERPWD, '{{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}}');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"payment_mode":"cash","payment_note":"The custmer has made a cash payout","transaction":"Transaction data if any"}');

$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
```

_Java_

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Base64;

String credentials = Base64.getEncoder().encodeToString("{{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}}".getBytes());

HttpClient client = HttpClient.newHttpClient();
HttpRequest.Builder builder = HttpRequest.newBuilder()
    .uri(URI.create("https://payments.pabbly.com/api/v1/invoice/recordpayment/{{invoice_id}}"))
    .header("Authorization", "Basic " + credentials)
    .header("Content-Type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("{\"payment_mode\":\"cash\",\"payment_note\":\"The custmer has made a cash payout\",\"transaction\":\"Transaction data if any\"}"));

HttpRequest request = builder.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

_Node.js_

```node
const credentials = Buffer.from('{{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}}').toString('base64');

const response = await fetch('https://payments.pabbly.com/api/v1/invoice/recordpayment/{{invoice_id}}', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${credentials}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "payment_mode": "cash",
    "payment_note": "The custmer has made a cash payout",
    "transaction": "Transaction data if any"
  }),
});

const data = await response.json();
```

_Go_

```go
package main

import (
    "fmt"
    "io"
    "net/http"
    "strings"
)

func main() {
    payload := strings.NewReader("{\"payment_mode\":\"cash\",\"payment_note\":\"The custmer has made a cash payout\",\"transaction\":\"Transaction data if any\"}")
    req, _ := http.NewRequest("POST", "https://payments.pabbly.com/api/v1/invoice/recordpayment/{{invoice_id}}", payload)
    req.Header.Set("Content-Type", "application/json")
    req.SetBasicAuth("{{YOUR_API_KEY}}", "{{YOUR_SECRET_KEY}}")

    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)
    fmt.Println(string(body))
}
```

_.NET_

```dotnet
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

var credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes("{{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}}"));

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://payments.pabbly.com/api/v1/invoice/recordpayment/{{invoice_id}}");
request.Headers.TryAddWithoutValidation("Authorization", $"Basic {credentials}");
request.Content = new StringContent("{\"payment_mode\":\"cash\",\"payment_note\":\"The custmer has made a cash payout\",\"transaction\":\"Transaction data if any\"}");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

var response = await client.SendAsync(request);
var data = await response.Content.ReadAsStringAsync();
Console.WriteLine(data);
```

---

**Other endpoints in Invoice:**

- [GET /invoice/{{invoice_id}} — Get Single Invoice](/subscription-billing/invoice/get-single-invoice)
- [GET /invoices/transactions/{{invoice_id}} — List All Transactions By Invoice Id](/subscription-billing/invoice/list-all-transactions-by-invoice-id)
- [GET /invoices/{{customer_id}} — List All Invoices By Customer Id](/subscription-billing/invoice/list-all-invoices-by-customer-id)
- [GET /invoices — List All Invoices](/subscription-billing/invoice/list-all-invoices)
- [POST /invoice/failedpayment/{{invoice_id}} — Record Failed Payment Invoice](/subscription-billing/invoice/record-failed-payment-invoice)
- [DELETE /invoices/{{invoice_id}} — Delete Invoice](/subscription-billing/invoice/delete-invoice)
- [POST /invoices/create-metered/{{subscription_id}} — Create Metered Invoice](/subscription-billing/invoice/create-metered-invoice)

