Accessing Billing API from JavaScript (deprecated)
To use Billing service from your Red App you need to do the following:
-
Add authorization tag to your redapp.xml - for complete information, see Authorization to Access or Use Services in "Building a redapp.xml File."
<Authorization name=__"com.sabre.edge.cf.billing.BillingService"__ threshold=__"10"__ metric=__"tpm"__ />
-
Use Billing Web API as described:
function doBilling(){
var rsp = SrwApi.storeBillingTxn('transactionId', 'eventName', 'component');
rsp = eval ("(" rsp ")");
if(rsp.response.success == false){
alert(rsp.response.errors.error[0].code);
}
}
The JavaScript function SrwApi.storeBillingTxn requires list of parameters in given order:
-
transactionId
-
eventName
-
component
The optional fields:
-
description
-
unit
-
currency
-
gross
-
fee
-
netAmount
-
quantity
-
refAppRefCode
-
sabreRLoc
Note
|
The index of the argument is important, which means that javascript function requires a empty argument to be given. For example: storeBillingTxn('id','event','cmp','','unit'); where the description is not set, but has to be specified if argument after it has any value. |
Note
|
To use the simplified API, you must use (or inherit from) DefaultWebkitEditor or WebkitView class from the com.sabre.edge.platform.optional.webkit plug-in. |