Syncing Commission Data via API and Callbacks
Once your users start generating sales, you'll want your system to sync the associated data so that you can show these sales to your users, send push notifications, etc. There are two ways to get this commission data: pull them from our API or receive callbacks from our system. In most cases, you'll want to receive callbacks to keep your system in sync as closely as possible, but you'll also want to hit the API to pull batches of commission in case a callback wasn't successful. At this time, we do not re-attempt failed callbacks.
To see the API docs for how to fetch commission data en masse see the API reference.
Features of commission API:
- Fetch up to 2000 records at a time
- Cursor-based requests to page through all results
- Request commissions between a date_modified range to capture all changes
Notes:
- Commission API should only be called up to 1 time per 5 seconds (more frequent requests will be rejected).
- Whereas callbacks provide low-latency commission data, the batch API provides a guarantee of not missing any records (as callbacks are not retried).
- Requests to the commission API can timeout for a number of reasons (network connectivity, unplanned maintenance windows, etc.). The HTTP response code and payload should be evaluated to ensure you received an expected response. If an unexpected response was received, consider retrying with an exponential backoff pattern.
Callbacks offer nearly realtime updates as commission records are created or changed in the Wildfire platform. Lower latency means showing a user their cashback sooner and giving them confidence that their purchase was tracked.
To set up your callback URL, in your partner admin tool, select the application you want to configure and then select the gear icon. Here you can enter a callback URL (please ensure it's an HTTPS endpoint) and a callback key. The callback key can be any value. The purpose of the callback key is to ensure that the callback is valid (and that a rogue entity is not invoking your callback URL with false data).
The content of the body is different depending on what version of the APIs your application is configured to use. By default, we subscribe an application when it is created to the most recent version of our APIs. Wildfire will not auto-update your application to a new version of the APIs but you may request to have your application(s) upgraded. Please contact your Client Success Manager to determine your application's current API version and/or to request an upgrade.
A V3 callback request will have a body similar to this:
A V4 callback request will have a body similar to this:
Note: *Both of the above examples include whitespace/indentation for readability, but when generating the HMAC check to verify this callback came from Wildfire, the callback body must be evaluated without modification (i.e. it should contain no indentation/whitespace/formatting).
Example v3 body without whitespace:
Example v4 body without whitespace:
ID: The callback ID. Note that this is different from the commission ID. Every callback request will have a unique callback ID, but it may have the same commission ID (i.e. in the case of an update). There is a button in Partner Admin that allows a user to resend a callback to your callback receiver URL. Every time that resend callback button is selected, a new callback will fire with a unique callback ID but the same commission ID.
Type: "Commission"
Action: "create", "update"
CommissionID: Unique ID for this commission, when updates are sent this ID will be the same.
ApplicationID: The ID of the application with which the purchase was made.
DeviceID: The ID for the user’s device that made the purchase.
MerchantID: The ID for a merchant. This value can be used to match to a merchant in the JSON feed.
SaleAmount
- Amount: Reported sale amount from merchant. Note: Some merchants don't report sale amount, this can be 0.
- Currency: The original currency in which the purchase was made. This value is not converted to the application default currency.
Amounts: This is an array with up to two maps with data for the user’s earnings and the application’s earnings. If you pay your end user you will only see a map for the application SplitPart. If Wildfire pays your end users you will see two maps, one containing the user’s earnings and the other containing the application’s earnings.
- Amount: The commission amount, this can be a negative number in the case of a canceled or returned order to offset the original commission (this will have a new ID).
- Currency: Commissions are always converted to your application's default currency (e.g. if your default currency is CAD, this value will be sent via API and callback in CAD).
- SplitPart: A split part is the amount of money allocated to one or two entities depending on the configuration of your application(s). In instances where you pay your end users directly, you will only ever see an Application split part. If Wildfire pays your end users on your behalf, this response will include both the Application SplitPart and the Device (end user) SplitPart. Note: SplitPart was added in v4 of commission records.
- Application: Represents your portion of a commission.
- Device: Represents the end user's portion of a commission. Only present in cases where Wildfire is paying your end user.
TrackingCode: This is the value referred to Tracking Code (TC) Parameter
EventDate: Timestamp for when the order was placed.
CreatedDate: Timestamp for when the commission was entered into our database.
ModifiedDate: Timestamp for the last time this commission was modified in our database.
LockingDate: The period of time that the merchants give themselves to reverse or adjust a commission.
MerchantOrderID: Order ID provided by the merchant for this commission. Note:This value may be blank, not every merchant reports an order ID.
MerchantSKU: SKU number for item purchased. Note: This value may be blank, not every merchant reports SKU values.
The headers for a callback will look like this:
Note the "X-WF-Signature" value is the HMAC encoded value of the POST body using a sha256 encoding type and using the Callback Key value that you set. A PHP example for how to generate this signature (to compare it to the one in the headers to verify that the request is authentic) looks like this:
Note: Altering the body of the callback sent by Wildfire will result in a mismatched signature.
At the time of the writing of this article, Wildfire does not support retrying failed callbacks. We do intend to add this feature in the future, but in the meantime we recommend using the API calls (see get all commissions) on a regular basis (i.e. daily) to compensate for the possibility of incomplete callbacks.
If you would like to set up commission callbacks, you may do so via the Partner Admin under a given application's settings screen:
- Navigate to https://platform.wildlink.me/
- Select the application you'd like to configure callbacks for.
- Select the three dots overflow menu in the top right. (See Fig 1)
- Select "Settings" from the menu.
- Input the callback URL (this needs to be a full URL available to the public) and callback key (this can be any value you choose) you'd like to use. (See Fig 2)
- Select the callback version you'd like to use (the newest version is usually preferred as it includes more details about each commission record).
- Save. Note: It can take a few minutes before the changes take effect.
Once you set up your callback settings, you'll be able to resend callbacks from the commission history to test your receiving script (See Fig 3).