# Create payment resource

Creates a payment resource to represent that an invoice was paid outside of the Moov platform. If a payment link was created for the invoice, the corresponding payment link is canceled, but a receipt is still sent.

To access this endpoint using an [access token](https://docs.moov.io/api/authentication/access-tokens/) you'll need to specify the `/accounts/{accountID}/invoices.write` scope.

## POST

/accounts/{accountID}/invoices/{invoiceID}/payments

### Ask

```shell
curl -X POST "https://api.moov.io/accounts/{accountID}/invoices/{invoiceID}/payments" \
  -H "Authorization: Bearer {token}" \
  -H "X-Moov-Version: v2026.07.00" \
  -d '{\n  "amount": {\n    "currency": "USD",\n    "valueDecimal": "12.987654321"\n  }\n}'
```

### Ask

```go
mc, _ := moov.NewClient()

accountID := "241bf524-e777-4941-a5e4-d7f3f34d7a00"
invoiceID := "3dfff852-927d-47e8-822c-2fffc57ff6b9"

mc.CreateInvoicePayment(ctx, accountID, invoiceID, moov.CreateInvoicePayment{
  ForeignID:   moov.PtrOf("EXT-PAY-12345"),
  Description: moov.PtrOf("Payment received via wire transfer"),
  Amount:      moov.AmountDecimal{
    Currency: "USD",
    ValueDecimal: "500.00",
  },
})
```

### Ask

```typescript
import { Moov } from "@moovio/sdk";

const moov = new Moov({
  security: {
    username: "",
    password: "",
  },
});

async function run() {
  const result = await moov.invoices.createInvoicePayment({
    accountID: "e02333e4-a835-46d1-8d02-9af7a405e65f",
    invoiceID: "99e7ebb0-9996-49b2-98f0-304c7332ece6",
    createInvoicePayment: {
      foreignID: "EXT-PAY-12345",
      amount: {
        currency: "USD",
        valueDecimal: "500.00",
      },
      description: "Payment received via wire transfer",
      paymentDate: new Date("2026-01-20T14:45:00Z"),
    },
  });

console.log(result);
}

run();
```

### Ask

```php
declare(strict_types=1);

require 'vendor/autoload.php';

use Moov\MoovPhp;
use Moov\MoovPhp\Models\Components;
use Moov\MoovPhp\Utils;

$sdk = MoovPhp\Moov::builder()
    ->setSecurity(
        new Components\Security(
            username: '',
            password: '',
        )
    )
    ->build();

$createInvoicePayment = new Components\CreateInvoicePayment(
    foreignID: 'EXT-PAY-12345',
    amount: new Components\AmountDecimal(
        currency: 'USD',
        valueDecimal: '500.00',
    ),
    description: 'Payment received via wire transfer',
    paymentDate: Utils\Utils::parseDateTime('2026-01-20T14:45:00Z'),
);

$response = $sdk->invoices->createInvoicePayment(
    accountID: 'e02333e4-a835-46d1-8d02-9af7a405e65f',
    invoiceID: '99e7ebb0-9996-49b2-98f0-304c7332ece6',
    createInvoicePayment: $createInvoicePayment
);

if ($response->invoicePayment !== null) {
    // handle response
}
```

### Ask

```java
package hello.world;

import io.moov.sdk.Moov;
import io.moov.sdk.models.components.*;
import io.moov.sdk.models.errors.CreateInvoicePaymentError;
import io.moov.sdk.models.errors.GenericError;
import io.moov.sdk.models.operations.CreateInvoicePaymentResponse;
import java.lang.Exception;
import java.time.OffsetDateTime;

public class Application {

public static void main(String[] args) throws GenericError, CreateInvoicePaymentError, Exception {

Moov sdk = Moov.builder()
                .security(Security.builder()
                    .username("")
                    .password("")
                    .build())
            .build();

CreateInvoicePaymentResponse res = sdk.invoices().createInvoicePayment()
                .accountID("e02333e4-a835-46d1-8d02-9af7a405e65f")
                .invoiceID("99e7ebb0-9996-49b2-98f0-304c7332ece6")
                .createInvoicePayment(CreateInvoicePayment.builder()
                    .amount(AmountDecimal.builder()
                        .currency("USD")
                        .valueDecimal("500.00")
                        .build())
                    .foreignID("EXT-PAY-12345")
                    .description("Payment received via wire transfer")
                    .paymentDate(OffsetDateTime.parse("2026-01-20T14:45:00Z"))
                    .build())
                .call();

if (res.invoicePayment().isPresent()) {
            System.out.println(res.invoicePayment().get());
        }
    }
}
```

### Ask

```python
from moovio_sdk import Moov
from moovio_sdk.models import components
from moovio_sdk.utils import parse_datetime

with Moov(
    security=components.Security(
        username="",
        password="",
    ),
) as moov:

res = moov.invoices.create_invoice_payment(account_id="e02333e4-a835-46d1-8d02-9af7a405e65f", invoice_id="99e7ebb0-9996-49b2-98f0-304c7332ece6", amount={
        "currency": "USD",
        "value_decimal": "500.00",
    }, foreign_id="EXT-PAY-12345", description="Payment received via wire transfer", payment_date=parse_datetime("2026-01-20T14:45:00Z"))

# Handle response
    print(res)
```

### Ask

```ruby
require 'moov_ruby'

Models = ::Moov::Models
s = ::Moov::Client.new(
  security: Models::Components::Security.new(
    username: '',
    password: ''
  )
)
res = s.invoices.create_invoice_payment(account_id: 'e02333e4-a835-46d1-8d02-9af7a405e65f', invoice_id: '99e7ebb0-9996-49b2-98f0-304c7332ece6', create_invoice_payment: Models::Components::CreateInvoicePayment.new(
  foreign_id: 'EXT-PAY-12345',
  amount: Models::Components::AmountDecimal.new(
    currency: 'USD',
    value_decimal: '500.00'
  ),
  description: 'Payment received via wire transfer',
  payment_date: DateTime.iso8601('2026-01-20T14:45:00Z')
))

unless res.invoice_payment.nil?
  # handle response
end
```

### Ask

```csharp
using Moov.Sdk;
using Moov.Sdk.Models.Components;
using System;

var sdk = new MoovClient(security: new Security() {
    Username = "",
    Password = "",
});

var res = await sdk.Invoices.CreateInvoicePaymentAsync(
    accountID: "e02333e4-a835-46d1-8d02-9af7a405e65f",
    invoiceID: "99e7ebb0-9996-49b2-98f0-304c7332ece6",
    body: new CreateInvoicePayment() {
        ForeignID = "EXT-PAY-12345",
        Amount = new AmountDecimal() {
            Currency = "USD",
            ValueDecimal = "500.00",
        },
        Description = "Payment received via wire transfer",
        PaymentDate = System.DateTime.Parse("2026-01-20T14:45:00Z").ToUniversalTime(),
    }
);

// handle response
```

### External payment

```json
{
  "amount": {
    "currency": "USD",
    "valueDecimal": "500.00"
  },
  "external": {
    "description": "Payment via external system",
    "foreignID": "EXT-PAY-12345",
    "paymentDate": "2026-01-20T14:45:00Z"
  },
  "invoicePaymentID": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "invoicePaymentType": "external"
}
```

### Response headers

A unique identifier used to trace requests.

---

The server could not understand the request due to invalid syntax.

---

The request contained missing or expired authentication.

---

The user is not authorized to make the request.

---

The requested resource was not found.

---

The request conflicted with the current state of the target resource.
