Skip to content
Knowledge Base

Salesforce Billing Integration

To have the balance synchronization between Salesforce and Topsort, the following steps are required:

  1. When the balance is updated in Salesforce, the client needs to implement an automated workflow that triggers every time the budget is changed and make a request to Topsort endpoint to top up balance of the specific vendor.
  2. To update the vendor balance in salesforce, the client needs to configure a webhook in Topsort that will be executed every day and will report the new balance to the selected endpoint generated by the client.

Top up balance of a vendor

To top up the balance of a vendor, in Topsort we have the following endpoint.

Before showing the example is important to say that we will truncate the input to its minimum denomination, e.g. USD 1,000.234 is USD 1,000.23 , as there is no fraction of a cent.

The curl example of the endpoint look like:

curl --request POST \
--url https://api.topsort.com/public/v1/billing-service/vendors/{external-vendor-id}/balance \
--header 'Content-Type: application/json' \
--data '{
"balance": 1,
"description": "Free credits added to the account"
}'

Where are two required inputs:

  1. Balance: the new balance of the vendor

  2. The description of this change.

    Webhook report vendor balance

To create the webhook in Topsort, we offer and endpoint, if all the required parameters are give correctly, the webhook will be executed every day.

A curl example of how to implement a budget update webhook:

curl --request POST \
--url https://api.topsort.com/public/v1/webhooks/webhooks \
--header 'Content-Type: application/json' \
--data '{
"channel": "vendor:budget_update",
"url": "<string>" //url of the client where the new budget will be reported}'

Where the required parameters are:

  1. Channel: the type of the webhook, in this case vendor:budget_update
  2. Url: the url where the budget change will be reported

This will generate a daily POST request to the url provided by the client, with the following payload.

{
"channel": "vendor:budget_update",
"timestamp": "2024-10-31T14:42:55.759185Z",
"id": "gUo",
"payload": {
"name": "<Vendor name>",
"external_vendor_id": "<Vendor id>"
"budget": 1000
}
}

In the payload we can see:

  1. Name: Name of the vendor
  2. External vendor id: The id of the vendor that the marketplace uses.
  3. Budget: The current budget of the vendor