getPrice

Synopsis:

void blackberry.payment.getPrice(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.

id {String}

ID of the digital good.

sku

SKU of the digital good

onSuccess {Function}

Function to be called on success.

data {Object}

The data object of the success callback.

price {String}

The cost of the digital good.

initialPeriod {String}

The number of days in the subscriptions initial period. This will only be present if the digital good represents a subscription item.

renewalPrice {String}

The subscription renewal price. This will only be present if the digital good represents a subscription item.

renewalPeriod {String}

The number of days in the subscription renewal period. This will only be present if the digital good represents a subscription item.

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 getPrice() {
        try {
            blackberry.payment.getPrice({
                "id:" "123"
            }, onSuccess, onFailure);
        } catch (e) {
            alert ("Error" + e);
        }
    }

    function onSuccess(data) {
        var price = data.price;

        alert("Digital good price: " + price);

        if (data.initialPeriod) {
            var initialPeriod = data.initialPeriod;
            var renewalPrice = data.renewalPrice;
            var renewalPeriod = data.renewalPeriod;
            alert("Subscription Info: " + initialPeriod + "," + renewalPrice + "," + renewalPeriod);
        }
    }


    function onFailure(err) {
        alert("Error occurred: " + err.errorText + ", " + err.errorID);
    }

</script>
            

Last modified: 2014-03-10



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus