> For the complete documentation index, see [llms.txt](https://ofn-user-guide.gitbook.io/ofn-api-handbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ofn-user-guide.gitbook.io/ofn-api-handbook/ofn-api-v1/customer-account-transaction-customer-credit.md).

# Customer Account Transaction (Customer Credit)

The customer account transaction endpoint enables the crediting of customer accounts. Credits granted via this endpoint are automatically applied to future orders by the customer (e.g. reducing the order total to pay by the amount of credit on the customer's account).&#x20;

#### Background

This endpoint was funded by a project in the UK aimed at improving digital inclusion, which also involved the building of an integration linking POS payments with OFN customers. Customers made in-person payments via a POS device. The integration matched the email address entered on the POS device with an OFN customer record, and this endpoint was used to credit the customer's account with the amount paid.

Alternative uses for this endpoint include setting up a CSA payments system, i.e. customers pay X amount at the beginning of the season upfront, with subsequent orders deducted from their balance.

The UI can also be used to credit an account with the 'credit customer' button that displays when an order is in the 'credit owed' state, for instance by removing an item or creating a negative adjustment - see user guide.

## POST /api/v1/customer\_account\_transaction

> Create customer transaction

```json
{"openapi":"3.0.1","info":{"title":"API V1","version":"v1"},"servers":[{"url":"/"}],"paths":{"/api/v1/customer_account_transaction":{"post":{"summary":"Create customer transaction","tags":["Customer account transaction"],"parameters":[],"responses":{"201":{"description":"Customer transaction created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/customer_account_transaction"}}}},"401":{"description":"Unauthorized"},"404":{"description":"Invalid customer ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/error_response"}}}},"422":{"description":"Missing required parameter","content":{"application/json":{"schema":{"$ref":"#/components/schemas/error_response"}}}}},"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"customer_id":{"type":"integer"},"amount":{"type":"decimal"},"description":{"type":"string","nullable":true}},"required":["customer_id","amount"]}}}}}}},"components":{"schemas":{"customer_account_transaction":{"type":"object","properties":{"data":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"attributes":{"type":"object","properties":{"id":{"type":"integer"},"customer_id":{"type":"integer"},"amount":{"type":"decimal"},"currency":{"type":"string"},"description":{"type":"string","nullable":true},"balance":{"type":"decimal"}},"required":["id","customer_id","amount","currency","description","balance"]},"relationships":{"type":"object","properties":{"customer":{"type":"object","properties":{"data":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"}}},"links":{"type":"object","properties":{"related":{"type":"string"}}}}}}}}},"meta":{"type":"object"},"links":{"type":"object"}},"required":["data"]},"error_response":{"type":"object","properties":{"errors":{"type":"array","items":{"type":"object","properties":{"title":{"type":"string"},"detail":{"type":"string"},"source":{"type":"object"}},"required":["detail"]}}},"required":["errors"]}}}}
```

{% hint style="info" %}
Only managers or owners of an enterprise can credit customers
{% endhint %}

{% hint style="info" %}
Customer ID can be obtained from the 'id' column in the Customers screen
{% endhint %}
