Invoice Sales Integration
Our invoice sales process is robust and dynamic solution that will help external sales providers to easily integrate with our Unimicro platform.
How Invoice Sales works
We use Webhooks (event plans) and Approvals to handle invoice sales. Webhooks are asynchronous events trigged when some action done by user. We use webhooks to notify the external sales provider about the request and wait for external sales provider to send offers to our external-offer endpoint. 'Ones' system receives offer, will create approvals which can be used by end user to provide feedback by accepting or rejecting the offer. End user can only accept one offer if there are multiple offers from different sales provider. When user accept an offer other pending offers will be automatically rejected by the system.
If user Accept or Reject an offer it will trigger an event in webhook system to notify to external sales provider about the feedback.
When external sales provider receives an accepted offer notification, they should send the Bank Account Number, Invoice Text, and PaymentID for the invoice to the purchased offer endpoint in Unimicro platform
How to Integrate with Unimicro
External vendors who like to onboard to do invoice sales need to create a product in our developer portal. They need to create a server client to do communication with our endpoints.
Read How to create product in Dev Portal article for more details
User should select Invoice Sale
as the product category for the Application you create in dev portal and need to enter values for following properties
Property | Description |
---|---|
Request Offer Endpoint | This endpoint will be used to notify sales provider when user request for an invoice sale |
Accepted Offer Endpoint | This endpoint will be used to notify sales provider when user accepted an external sales offer |
Rejected Offer Endpoint | This endpoint will be used to notify sales provider when user rejected an external sales offer |
Credit Note Raised Endpoint | This endpoint will be used to notify sales provider when user raised a credit note for sold invoice |
Product Activation Endpoint | This endpoint will be used to notify sales provider when user activated invoice sales product |
SigningKey | This key will used to create a unique signature and include in webhook events request . Read more here. |
As mentioned above table, external sales providers should open 5 endpoints as event listeners for events that triggered when user initiated the invoice sale. When an event occurs Unimicro platform will send a notification to the event listener endpoints so external sales provider can act depend on the event.
There are 5 main events.
- Request Offer Event
- Accept Offer Event
- Reject Offer Event
- Credit Note Raised Event
- Product Activation Event
External Sales provider should actively listen to these events and response to those events by calling our Unimicro platform APIs for Invoice Sales
All the event listeners will use a single generic object type with entity
property. This entity
property will include the object that associated with each event. Object that comes in the entity property will differ depend on the event. You can read more below.
Following properties will be included in the generic object that will be sent by the event listener endpoints
Property | Type | Description |
---|---|---|
EventType | string | Type of the Event it can be Create, Update, or Delete |
EntityName | string | Type of the entity property |
Entity | object | Object of the event entity |
EntityID | int32 | id of the event entity |
MessageID | string | Unique message id |
SessionID | guid | Session Id |
TimeStamp | dateTime | Time stamp of the event |
CompanyKey | guid | Company key |
Reason | string | URL of the event has initiated |
Example :
{
"EventType": "Update",
"EntityName": "PurchaseEvent",
"Entity":
{
"PurchaseEventType": 1020,
"ProductId": 49,
"CompanyName": "Testserver selskap",
"OrganizationNumber": "959415900",
"Email": "",
"Platform": "unimicro",
"ApiBaseUrl": "https://test-api.unimicro.no/",
"ID": 2931
},
"EntityID": 2931,
"MessageID": "170987-1",
"SessionID": "bb8f7d6c-c900-4d01-aab0-ed786fcafe9f",
"TimeStamp": "2021-08-27T07:00:12.51414Z",
"CompanyKey": "eda508bc-cab4-4697-aeb8-8b5688389fe6",
"Reason": "/api/elsa/purchases"
}
API needed to communicate with Unimicro
Following 4 APIs can be used by external providers to do Invoice sales though Unimicro
1. Send Offer API
2. Offer Purchased API
3. Credit Note Success API
4. Product Status Update Endpoint
Event listener endpoint Specification
These event listener endpoints should follow bellow rules and specification.
1. All event listener endpoints should be HTTP POST
2. All endpoints should be able call without any Authorization or Authentication.
3. Request Offer event listener endpoint should accept CustomerInvoice
object in HTTP request body.
4. AcceptOffer, RejectOffer and CreditNoteRaised event listener endpoints should accept ExternalOffer
object in HTTP request body
5. Product Activation event listener endpoint should accept following model in HTTP request body
Property | Type | Decription |
---|---|---|
PurchaseEventType | integer -Event Types | Type of the Event. There can be four types. |
CompanyKey | GUID | Company Key that need to include in CompanyKey header in Unimicro API requests |
string | Email address of the compnay admin | |
CompanyName | string | Company Name |
OrganizationNumber | string | Organization Number of the company |
Platform | string | Platform code that product activated |
ApiBaseUrl | string | API base URL of the platform |
ProductId | int | Product Id for the product in platform |
How user Activate the product
User can activate the product through the marketplace. When a user activated an Invoice Sales product external sales provider will be notified about the activation and product activation status will be set to pending until external sales provider approved the customer. When product is in pending status external sales provider able to use our Unimicro API to get company details and accounting data to validate and verify the customer before onboarding. After external sales provider completed the verification and validation process, they should inform us the feedback through Product Status Update Endpoint. Using this endpoint external vendors can set the product purchase status to Active
, Reject
or Pending
. Only when purchase status set to Active
customers can start to sell invoices.
Product Status Update Endpoint
External vendors can use following endpoint to update the status of a purchase
- Method :
PUT
- Body :
null
{productId}
path parameter needs to replace with correct product Id for the external vendor. This will be available inMyApps
section in Dev Portal
✏ : Product Id can be different in production and test environments. Our product admin will be contact you with correct production values one's product is moved to production
Endpoint | Description |
---|---|
api/elsa/purchases/{productId}?action=set-as-active | Set the purchase status to Active |
api/elsa/purchases/{productId}?action=set-as-pending | Set the purchase status to Pending |
api/elsa/purchases/{productId}?action=set-as-canceled | Set the purchase status to Reject |
Get Company Details
CompnaySettings
entity api can provide all details about the company. External sales provider will get access to the company when user activated the product in marketplace.
- Entity :
CompanySettings
- Endpoint :
api/biz/companysettings
- More Details : Company Settings Swagger
Get Company Accounting Data
Following entity API's can be used to get different accounting related data for the company.
1. Account Receivables
2. Account Payable
3. Customer Invoice Reminders
4. General Ledger
Account Receivables
- Entity :
CustomerInvoice
- Endpoint :
api/biz/invoices
- More Details : Customer Invoice Swagger
Account Payable
- Entity :
SupplierInvoice
- Endpoint :
api/biz/supplierinvoices
- More Details : Supplier Invoice Swagger
Customer Invoice Reminders
- Entity :
CustomerInvoiceReminder
- Endpoint :
api/biz/invoicereminders
- More Details : Customer Invoice Reminder Swagger
General Ledger
- Entity :
JournalEntry
- Endpoint :
api/biz/journalentries
- More Details : Journal Entry Swagger
- Entity :
JournalEntryLine
- Endpoint :
api/biz/journalentrylines
- More Details : Journal Entry Line Swagger
- Entity :
Account
- Endpoint :
api/biz/accounts
- More Details : Account Swagger
Start to Sell Invoice
For a successful invoice sale there are 3 steps to be followed by user and external sales provider
- Request for Offer
- User will request for an Offer.
- External Sales Provider will receive an offer request.
- External Sales Provider will send an Offer.
- Accept/Reject Offer
- User Accept or Reject the Offer
- External Sales Provider receive the feedback.
- Complete the Offer (Only for Accepted Scenarios)
- External Sales Provider send the Bank Account Number, Invoice Text, and Payment ID (KID)
- Notify user and update the Invoice to
Sold
status.
Request Offer
This is the initial step for the invoice sales. User will request for an invoice sale for a draft invoice. It will update the invoice status to WaitingForOffer
. This will trigger an event in webhook system which has the responsibility of notifying the external sales provider about the request. If user has multiple invoice sales providers activated, then all providers will get the request simultaneously.
Webhook system will send a HTTP POST
request to the request offer event listener endpoint to notify about the request. Request will contain the invoice
object that offer has been requested. By looking at the invoice and other factors external sales providers can decide to send a Valid Offer or Rejected offer. It is recommended to always send a valid or rejected offer back to the customer. External sales providers can use Comment
property to provide reject reason when sending a rejecting offer. Then external sales providers can use Send Offer API to send a valid or rejected offer to customer.
Accept Offer or Reject Offer
User has option to accept or reject an offer depend on their preference. If use decide to accept the offer, then invoice will be updated to OfferAccepted
status. This will reject all other offers and system will reject all incoming offers after accepting an offer. If user choose to reject the offer system will not update the invoice.
Any of this action will trigger an event in webhook system to notify the external provider about the feedback using the endpoints added to the product properties by provider.
Complete the Offer
When user accepted an offer, external sales provider will receive the accepted exteralOffer
object to the accepted offer event listener endpoint. Then external sales provider should update the OfferStatus
, AccountNumber
, FreeText
and PaymentID
properties of the offer and re-send it to Offer Purchased API endpoint. This will complete the invoice sales process by creating all the required journal entries related to sales fee and update the status of the invoice to Sold
.
Credit Note for Sold Invoice
When user raised a credit note for a sold invoice system will undo the fee that been added to the invoice. Accepted ExternlOffer
status will be updated to CreditNoteRaised
. This will trigger the event that will notify the external vendor about the change using the credit note raised event listener endpoint with the credited externalOffer
object.
External sales provider should update the OfferStatus
and IsPaymentReleased
properties of the offer and re-send it to Credit Note Success API. Will send different notification messages to end user if IsPaymentReleased
flag is true
.
Invoice Sales APIs
Follwoing APIs can be used by external sales providers to send and update the external offers.
1. Send Offer API
This endpoint used to create new offers. Following are the properties need to set by vendors to create offers. To construct this object external vendors can use the invoice object they receive to their request offer event listener endpoint.
Following properties will be validated
Property | Type | Valiation Type | Expected Value |
---|---|---|---|
EntityType | string | Required | CustomerInvoice |
EntityID | int32 | Required | Id value of the invoice object |
EntityUpdatedAt | dateTime | Required | UpdatedAt value of the Invoice object |
OfferStatus | integer | Required | Offered (1000) or Rejected (1020) |
OfferID | string | Required | Unique Vendor Offer Id |
TotalAmount | decimal | Required | TaxInclusiveAmountCurrency value of the Invoice Object |
OfferAmount | decimal | Required | Vendor Offer Amount |
Fee | decimal | Required | Vendor Fee |
Comment | string | Optional | Reject reason if Offer Status is Rejected. Property becomes required if Offer Status is Rejected |
ExpiryDate | dateTime | Required | Offer Expiry Date |
CreditLimit | decimal | Required | Credit Limit for the customer |
CreditAvailable | decimal | Required | Available Credit Limit for the customer |
- Method :
POST
- Endpoint :
api/biz/external-offers
- Body :
ExternalOffer
object
Response :
- 200 - Success
- 400 - Bad Request
2. Offer Purchased API
External vendors should resend the ExteralOffer
object they receive to the Accept Offer Event listener endpoint back to this endpoint with following properties updated. Only accepted offer able to update these values.
Following properties will be validated
Property | Validation Type | Expected Value |
---|---|---|
PaymentID | Required | Vendor Payment ID |
BankAccountNumber | Required | Vendor Bank Account Number |
FreeText | Required | Text to Include in the Invoice document |
OfferStatus | Required | Purchased (1010) |
- Method:
PUT
- Endpoint :
api/biz/external-offers?action=purchase-offer
- Body :
ExternalOffer
object
Response :
- 200 - Success
- 400 - Bad Request
3. Credit Note Success API
When external vendors receive a notification to their credit note event listener with a external offer object which has StautsCode 2060
(CreditNoteRaised) they have to resend the same object back to this API with following field updated.
Property | Validation Type | Value Expected |
---|---|---|
OfferStatus | Required | Credited (1030) |
IsPaymentReleased | Required | True/False . true when Payment has released to the company, false otherwise |
- Method :
PUT
- Endpoint :
api/biz/external-offers?action=notify-credit-note-success
- Body :
ExternalOffer
object
Response :
- 200 - Success
- 400 - Bad Request
IsPaymentReleased
property will be used to show two different messages to user. If payment is released it should be set to true
otherwise it should be false
When payment is released message would be
Kreditnota er mottatt. Det opprinnelige fakturabeløpet ble utbetalt før mottak av kreditnota, så vi vil sende en faktura for tilbakebetaling av utbetalt beløp.
When payment is not released message would be
Kreditnota er mottatt, og utbetaling av fakturabeløp er stoppet. Tilgjengelig saldo er oppdatert.
Entity Model
External Offer Entity
Property | Type | Description |
---|---|---|
ID | integer | Id for the Offer |
StatusCode | integer -StatusCode | Status Code for the Offer |
EntityType | string | Type Of the Entity |
EntityID | integer | Entity Id |
EntityUpdatedAt | dateTime | Last Entity Updated DateTime |
OfferStatus | integer - OfferStatus | Vendor Offer Status |
OfferID | string | vendor Offer Id |
TotalAmount | decimal | Invoice Amount |
OfferAmount | decimal | Offer Amount |
Fee | decimal | Vendor Fee |
ExpiryDate | dateTime | Offer Expiry Date |
PaymentID | string | Vendor Payment ID (KID) |
BankAccountNumber | string | Vendor Bank Acc. Number |
FreeText | string | Invoice Text |
IsPaymentReleased | boolean | Flag to indicate payment is released |
Comment | string | Any Comment , Ex. Offer Reject Comment |
CreditLimit | decimal | Total credit limit for the customer |
CreditAvailable | decimal | Current avilable credit limit for the customer |
Offer Status for External Offer
This values need to set to OfferStatus
property by external vendor when sending or re-sending the offer
Enum Value | Integer Value | Description |
---|---|---|
Offered | 1000 | New Offer for an Invoice |
Purchased | 1010 | Invoice is Purchased by Vendor |
Rejected | 1020 | Offer request Rejected by Vendor |
Credited | 1030 | Offer is Credited by Vendor |
Status Code for External Offer
Unimicro API will set these values to the offer depend on different scenarios. External vendors no need to set StatusCode
for exteralOffer when sending offers
Enum Value | Integer Value | Description |
---|---|---|
Received | 2000 | Offer Received from Vendor |
Accepted | 2010 | Offer Accepted by User |
Rejected | 2020 | Offer Rejected by User |
SystemRejected | 2030 | System has Rejected the offer |
Sold | 2040 | Offer has been Sold |
Expired | 2050 | Offer has been Expired |
CreditNoteRaised | 2060 | Credit not has been raised |
Purchase Event Type
Enum Value | Integer Value | Description |
---|---|---|
OnPending | 1010 | Event has triggered when product purchase status is set to Pending |
OnActive | 1020 | Event has triggered when product purchase status is set to Accepted |
OnDeactivate | 1030 | Event has triggered when product purchase status is set to Rejected |
OnCancel | 1040 | Event has triggered when user deactivated the purchase |