-
Notifications
You must be signed in to change notification settings - Fork 82
Credit System
This sdk documentation is deprecated and will not be updated. Check out our new docs at https://sdk.buildfire.com/docs/credit-system/
API accessible via the Buildfire plugin SDK that allows plugin developers to add and manage user credits. Credits can be managed and consumed via the API’s for in-app purchases.
The credit-system is scoped to each individual instance of a Buildfire app in which the user is currently logged into.
-
The user must be logged in and authenticated for credit-system API calls to succeed.
-
Bundles are configured through the Control Panel side of a Buildfire app and are not accessible through the SDK API.
-
The following link is an example of how to create a plugin with the Buildfire credit-system API.
Examples included in demo plugin:
- Integration with the credit-system on the control panel side to add bundles.
- A complete example of UI integrated with the credit-system API.
On the widget page or control page you need to include scripts/buildfire/services/creditSystem/credits.js:
<script src="../../../scripts/buildfire/services/credits/credits.js"></script>
This method will return all bundles available.
-
callback(err, data)
: required- function will be invoked after all bundles have been retrieved.
Example:
var callback = function(err, result){
console.log("callback" + JSON.stringify(result));
}
buildfire.services.credits.getBundles(null, callback);
This method will facilitate the purchase of a bundle. When you call it your chosen payment provider will be called and credits will be deducted from the users balance within the credit system.
-
options
: object-
bundleId
: string, required- This property is the id of the bundle the user is purchasing.
memo
xRef1
xRef2
xRef3
-
-
callback(err, data)
: required- function will be invoked after purchasing for bundle has been completed.
Example:
var options = {
'bundleId': ''
};
var callback = function(err, result){
console.log("callback" + JSON.stringify(result));
}
buildfire.services.credits.purchaseBundle(options, callback);
Calling this method will subtract credits from the balance of a user.
-
options
: object-
creditAmount
: decimal, required- This property is the amount of credit you would like to add to a users account.
memo
xRef1
xRef2
xRef3
-
-
callback(err, data)
: required- function will be invoked after subtraction has been completed.
Example:
var options = {
‘amount’: 3.12
};
var callback = function(err, result){
console.log("callback" + JSON.stringify(result));
}
buildfire.services.credits.consumeCredits(options, callback);
This method will retrieve the details of a users account.
-
callback(err, data)
: required- function will be invoked after user info is available.
Example:
var callback = function(err, result){
console.log("callback" + JSON.stringify(result));
}
buildfire.services.credits.getUser(callback);
This method returns the history of transactions for the currently logged in user.
-
options
: object-
pageSize
: int, required- Indicates the amount of results to return per call.
-
pageIndex
: int, required- Indicates the partition of the pagination to return.
-
-
callback(err, data)
: required- function will be returned all transactions for current user.
Example:
var callback = function(err, result){
console.log("callback" + JSON.stringify(result));
}
var options = {
'pageSize': 2,
'pageIndex': 3
}
buildfire.services.credits.getUserTransactions(options, callback);
This method transfer credits from current loggedIn user to another user.
-
options
: object-
receiverUserToken
: string, required if (receiverUserEmail) not specified- The user Id for the receiver user.
-
receiverUserEmail
: string, required if (receiverUserToken) not specified- The user Email for the receiver user.
-
creditAmount
: int, required- The amount that the current loggedIn user wants to transfer.
-
-
callback(err, data)
: required- function will be invoked after transfer credits has been updated.
Example:
var callback = function(err, result){
console.log("callback" + JSON.stringify(result));
}
var options = {
'receiverUserToken': 'userToken',
'creditAmount': 32
}
buildfire.services.credits.transferCredits(options, callback);
This method works only on Control Panel, this method will show the transactions popup for all users
Example:
buildfire.services.credits.showTransactions();