Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Payment Service

Reply
Highlighted
Developer
Posts: 238
Registered: ‎12-26-2010
My Device: BlackBerry Z10
My Carrier: Telus
Accepted Solution

Payment Service Weird Problem

[ Edited ]

Hi all,

 

I have a freemium app that enable the users to unlock the Premium/Pro features. I have tried coding based on the tutorial on the cascades docs on Payment Service.

 

The problem is, I get long error code from the reply->errorCode();

the code was 141004048

 

IMG_00000065_edit.png

below is my code :

 

void PurchasePage::purchase()
{
	purchaseButton->setEnabled(false);

    paymentManager = new PaymentManager(this);

    // Get the window group ID and pass it to the PaymentManager instance.
    const QString windowGroupId =Application::instance()->mainWindow()->groupId();
    paymentManager->setWindowGroupId(windowGroupId);
//Request a purchase using the ID and SKU of the digital good. const PurchaseReply *purchaseReply = paymentManager->requestPurchase("244779xx", "ProVersion"); // Connect the finished() signal to a slot to handle the purchase. QObject::connect(purchaseReply, SIGNAL(finished()), SLOT(handlePurchase())); } void PurchasePage::handlePurchase() { PurchaseReply *reply = qobject_cast<PurchaseReply*>(sender()); Q_ASSERT(reply); // Check to see if the request finished. if (reply->isFinished()) { //if there were errors. if (reply->isError()) { showDialog("Purchase Error",QString::number(reply->errorCode())+"\n"+reply->errorText()); } else//if there were no errors. { QString successString="Pro version is now activated."; showDialog("Purchase Succeed",successString); //set statusLabel text to Activated statusLabel->setText("Activated"); purchaseButton->setEnabled(false); } } else { if (reply->isError()) { showDialog("Purchase Error",QString::number(reply->errorCode())+"\n"+reply->errorText()); } } reply->deleteLater(); }

 

 

 

www.jackdevora.com
Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: Payment Service Weird Problem

How was the app installed to the device (side-loaded, downloaded through BlackBerry World dev mode etc)?

Does the error code ever change? Or is it always 141004048?

 

Also, looking at your code it looks like the app instantiates a new PaymentManager every time a purchase is made, you should only have one instance of this, the purchase() call should only handle the purchase request logic.

Garett
@garettBeuk
--
Goodbye everybody!
Developer
Posts: 238
Registered: ‎12-26-2010
My Device: BlackBerry Z10
My Carrier: Telus

Re: Payment Service Weird Problem

it was installed via sandbox method.

The error code isnt suppose to be that.

It seems that I concat it in a wrong way..
QString::number(reply->errorCode())+"\n"+reply->errorText());

Everything is running well now.. thanks!!
www.jackdevora.com