Handling errors

See C++

You can use the PaymentReply::isError() function to check whether a PaymentManager request succeeds or fails. If a request fails, use errorCode() and errorText() to identify why the request failed.

You can see how errors are handled in the following code sample:

// This differentiates between successful responses 
// and error responses and emits appropriate signal 
// for each.

void PaymentServiceControl::purchaseResponse()
    bb::platform::PurchaseReply *reply = 

    // Emit an error signal if there were errors.
    if (reply->isError()) {

		emit infoResponseError(reply->errorCode(), 

    // Emit a success signal if the request succeeded.
    } else {
        const QString displayString = 

        emit purchaseResponseSuccess(displayString);


10.2 You can use the errorCode() function to identify why a payment transaction failed. The errorCode() function returns a PaymentErrorCode, with one of the following values:


This error code is returned when the PaymentReply is unfinished or the payment finished successfully.


This error is returned when a user cancels the request.


This error is returned when a user tries to purchase more than one item at a time.


This error is returned when a payment transaction fails. More information is provided in errorText and errorInfo.


This error is returned when the device is not connected to a network. The request cannot be completed until the device connects to a network.

After you check the PaymentErrorCode and identify the type of error, you can find out more specific information about the error by using errorText() and errorInfo().

void MyApp::handleError(PaymentReply *reply) {
  log_fail("ErrorCode: " + QString::number(reply->errorCode()));
  log_fail("ErrorText: " + reply->errorText());
  log_fail("ErrorInfo: " + reply->errorInfo());

The errorCode() function returns one of the PaymentErrorCode values, indicating a success or failure status. The errorText() contains a localized message describing the problem. The errorInfo() is attached to the errorText() message along with a series of tags (for example, AW30242PWAT) that help to identify the context of an error. The information provided in errorInfo() helps to diagnose errors. For a list of errorInfo() values, see Payment Service error messages.

Last modified: 2014-09-30

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

comments powered by Disqus