purchase

Synopsis:

void blackberry.payment.purchase(args, onSuccess, onFailure)

Parameters:

args {Object}

Contains information that describes the digital good. One of ID or SKU needs to be specified, and if both are specified, the ID takes precedence and SKU will be ignored.

digitalGoodID {String}

ID of the digital good being purchased

digitalGoodSKU {String}

SKU of the digital good being purchased.

digitalGoodName {String}

Name of the digital good being purchased

metaData {Object}

Metadata associated with the digital good. Metadata offers the application developer a way to store information about each purchase on the Payment Service server.

purchaseAppName {String}

Name of the application requesting the purchase.

purchaseAppIcon {String}

Icon of the application requesting the purchase.

extraParameters {Object}

Set of extra parameters, in the form of key/value pairs, to associate with the purchase.

onSuccess {function}

Function to be invoked on successful call

data {Boolean}

A Purchase object containing the details of the successful purchase.

onFailure {function}

Function to be invoked when an error occurs

error {PaymentError}

A PaymentError object containing details about the error

Example:

<script type="text/javascript">
function purchase() {
    try {
        blackberry.payment.purchase({
		    "digitalGoodID":"123",
		    "digitalGoodSKU":"someSKU",
		    "digitalGoodName":"SomeName",
		    "metaData":"metadata",
		    "purchaseAppName":"WebWorks APP",
		    "purchaseAppIcon":null,
		    "extraParameters": {
			    "key1": "value1",
			    "key2": "value2"
		    }
		},
		onSuccess, onFailure);
	} catch (e) {
		alert ("Error" + e);
	}
}

function onSuccess(purchasedItem) {
    var transId = purchasedItem.transactionID;
	var sku = purchasedItem.digitalGoodSKU;
	var dgId = purchasedItem.digitalGoodID;
	alert("Purchased Item: " + transId + "," + sku +  "," + dgId);
}

function onFailure(error) {
    alert("Error occurred: " + error.errorText + ", " + error.errorID);
}
</script>
            

Last modified: 2014-03-10