logo

Trade Credit

Credit limits are the values assigned to each customer. Thanks to the credit limit, the customer can place orders with the option of paying for the order later. After each posting process in the external system, the customer's credit limit changes, which is sent to the ONE system and updated on the client's card.
⚠️
It is possible using the API to add trade credit to client, get information about trade credit and delete trade credit in external system.
⚠️
Trade credit can only be assigned to Organization type Customers. Trade credit cannot be assigned to individual customers.

Table of contents

Glossary

Name
Explanation
availableCreditValue
the available amount of credit that is left to the customer
creditValue
the amount of credit granted to the customer
creditValueUsed
the amount of credit used by the customer

GET trade credits for synchronization

As previously mentioned, There is possible to add trade credit to client in ONe.
The diagram below shows the dependence of communicating with the API when credit assigned to client in ONe platform:
Image without caption
In this case first of all you have to use GET /api/v1/account/integrations/auth-required/trade-credits/synchronization to find the specified client created (or edited) in ONe.
Use the following query parameters to find the events of the trade credit:
  • contexts (list of the event context, default: APPLICATION, BACKOFFICE, INTERNAL, INTEGRATIONS)
  • startId (first index of the result rows) - integer($int64)
Example request
json
curl -X GET "https://api-preprod.one.unity.pl/api/v1/account/integrations/auth-required/trade-credits/synchronization?contexts=INTEGRATIONS&startId=59" -H "accept: */*" -H "one-tenant: {tenant}" -H "ApiAuth: {apiKey}"
In response you will receive a information about next step ID along client ID and type.
Example request
json
{ "nextId": 60, "events": [ { "clientId": "org:8872d4f8-cf33-456e-8084-41bacbc0fb2a", "type": "UPDATE" -- Create or update } ] }
When we see that the trade credit has changed, we can use Client ID to check the current data. Here's how to do it.

GET trade credit by organization ID

Now as you have clientId you can use GET /api/v1/account/integrations/auth-required/trade-credits/{organizationId} to receive information about trade credtit assigned to specific client using his ID.
The diagram below shows the dependency of communicating with the API:
Image without caption
To create segment you need in request to put required the following data:
  • clientId (path)
Example request
json
curl -X GET "https://api-preprod.one.unity.pl/api/v1/account/integrations/auth-required/trade-credits/org%3A8872d4f8-cf33-456e-8084-41bacbc0fb2a" -H "accept: */*" -H "one-tenant: {tenant}" -H "ApiAuth: {apiKey}"
In response you will receive a information about details of trade credit.
Example request
json
{ "clientId": "org:8872d4f8-cf33-456e-8084-41bacbc0fb2a", "creditValue": 10000, "creditValueUsed": 1000, "availableCreditValue": 9000 }

PUT - add trade credit to organization

Trade credit can be add both in the external system and in ONe. In ONe platfrom create client is possible in backoffice ( Customer β†’ Customers β†’ choose Client β†’ edit β†’ financial data β†’ limit allocated). Below we will explain how to do it with the API.
Use PUT /api/v1/account/integrations/auth-required/trade-credits/{organizationId} to add trade credit to the Client. Trade credit can only be assigned to Organization type Customers. Trade credit cannot be assigned to individual customers.
The diagram below shows the dependency of communicating with the API:
Image without caption
To add trade credit to client you need in request to put required the following data:
  • clientId (path)
  • availableCreditValue (body)
  • creditValue (body)
  • creditValueUsed (body)
Example request
json
curl -X PUT "https://api-preprod.one.unity.pl/api/v1/account/integrations/auth-required/trade-credits/org%3A8872d4f8-cf33-456e-8084-41bacbc0fb2a" -H "accept: */*" -H "one-tenant: {tenant}" -H "ApiAuth: {apiKey}" -H "Content-Type: application/json" -d "{ "availableCreditValue": 9000, -- the available amount of credit that is left to the customer "creditValue": 10000, -- the amount of credit granted to the customer "creditValueUsed": 1000 -- the amount of credit used by the customer }"

DELETE trade credit from organization

At the end you have the option to delete the trade credit. Use DELETE /api/v1/account/integrations/auth-required/trade-credits/{organizationId}
The diagram below shows the dependency of communicating with the API:
Image without caption
To create segment you need in request to put required the following data:
  • clientId (path)
Example request
json
curl -X DELETE "https://api-preprod.one.unity.pl/api/v1/account/integrations/auth-required/trade-credits/org%3A8872d4f8-cf33-456e-8084-41bacbc0fb2a" -H "accept: */*" -H "one-tenant: {tenant}" -H "ApiAuth: {apiKey}"

Powered by Notaku