Skip to main content

Accessing Billing API from JavaScript

To use Billing service from your Red App you need to do the following:

  1. 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" />

  1. 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:

  1. transactionId

  2. eventName

  3. component

The optional fields:

  1. description

  2. unit

  3. currency

  4. gross

  5. fee

  6. netAmount

  7. quantity

  8. refAppRefCode

  9. 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.

Additional Resources for Billing Service

The Sabre Red 360 Developer Toolkit includes the sample plug-in com.sabre.redapp.example.cf.billing, showing how to access Billing service with a JavaScript function.