Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8315833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:13:16+00:00 2026-06-08T21:13:16+00:00

I was learning about In-App purchase task in blackberry using Payment SDk version 1.8.

  • 0

I was learning about In-App purchase task in blackberry using Payment SDk version 1.8.
Currently I am using the below code:

package com.purchasedemo;

///import net.rimlib.blackberry.api.payment.*;
import net.rimlib.blackberry.api.paymentsdk.PaymentEngine;
import net.rimlib.blackberry.api.paymentsdk.PaymentException;
import net.rimlib.blackberry.api.paymentsdk.Purchase;
import net.rimlib.blackberry.api.paymentsdk.PurchaseArgumentsBuilder;
import net.rimlib.blackberry.api.paymentsdk.PurchaseResult;
import net.rimlib.blackberry.api.paymentsdk.purchaseHistory.PurchaseHistory;
import net.rimlib.blackberry.api.paymentsdk.purchaseHistory.PurchaseHistoryListingListener;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;

public class PurchaseDemo extends UiApplication
{
    public static void main(String[] args) 
    {
        PurchaseDemo theApp = new PurchaseDemo();
        theApp.enterEventDispatcher();  
    }
    public PurchaseDemo() 
    {   
        pushScreen(new PurchaseDemoScreen());
    }


      private static class PurchaseDemoScreen extends MainScreen implements FieldChangeListener {
            private BasicEditField parentSku;
            private ButtonField buyButton;
            private ButtonField displayButton;
            private BasicEditField digitalGoodName;
            private BasicEditField digitalGoodSku;
            private PurchaseHistoryListingListener purchaseHistoryListener;
            private PaymentEngine **engine** = PaymentEngine.getInstance();

            public PurchaseDemoScreen() {
                setTitle( "Payment Service SDK Demo" );

                if( **engine** != null ) {
                    parentSku = new BasicEditField( "Parent SKU: ", "abc123" );
                    add( parentSku );
                    digitalGoodName = new BasicEditField( "Digital Good Name: ", "Sample Good" );
                    add( digitalGoodName );
                    digitalGoodSku = new BasicEditField( "Digital Good SKU: ", "abc123" );
                    add( digitalGoodSku );
                    HorizontalFieldManager hfm = new HorizontalFieldManager();
                    add( hfm );
                    buyButton = new ButtonField( "Buy" );
                    buyButton.setChangeListener( this );
                    hfm.add( buyButton );
                    displayButton = new ButtonField( "Display Purchases" );
                    displayButton.setChangeListener( this );
                    hfm.add( displayButton );
                } else {
                    RichTextField errorMessage = new RichTextField( "Sorry, in-app purchases are unavailable" );
                    add( errorMessage );
                }
            }

            public void fieldChanged( Field field, int context ) {
                if( field == buyButton ) {
                    String name = digitalGoodName.getText();
                    String sku = digitalGoodSku.getText();
                    PurchaseArgumentsBuilder arguments = new PurchaseArgumentsBuilder().withDigitalGoodSku( sku )
                            .withDigitalGoodName( name ).withMetadata( name ).withPurchasingAppName( "Payment Service SDK Demo" );
                    try {
                        PurchaseResult purchase = engine.purchase( arguments.build() );
                        Dialog.inform( "Purchase of " + purchase.getMetadata() + " is successful." );
                    } catch( IllegalArgumentException e ) {
                        Dialog.inform( e.getMessage() );
                    } catch( PaymentException e ) {
                        Dialog.inform( e.getMessage() );
                    }
                } else if( field == displayButton ) {
                    purchaseHistoryListener = new PurchaseHistoryListingListener() {

                        public void error( String message, int errorCode ) {
                            Dialog.inform( message );
                        }

                        public void success( Purchase[] purchases ) {
                            if( purchases.length != 0 ) {
                                if( getFieldCount() > 3 ) {
                                    deleteRange( 3, ( getFieldCount() - 3 ) );
                                }
                                for( int i = 0; i < purchases.length; i++ ) {
                                    RichTextField purchaseRecord = new RichTextField( "Name: " + purchases[ i ].getMetadata()
                                            + " SKU: " + purchases[ i ].getDigitalGoodSku() );
                                    add( purchaseRecord );
                                }
                            } else {
                                Dialog.inform( "No existing purchases" );
                            }
                        }
                    };

                    PurchaseHistory.get(purchaseHistoryListener);
                }
            }
        }
}

By using this code, I was just trying to learn how this process actually work.
But the PROBLEM IS, i am getting null in the engine object of PaymentEngine.
Please let me know how can i solve this problem.
And also what are the actual requirements of this service. Currently I am working on 5.0 OS and in device 6.0 OS

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:13:17+00:00Added an answer on June 8, 2026 at 9:13 pm

    The first thing you want to do, before making the call to PaymentEngine.getInstance() you should first be calling PaymentEngine.isAppWorldInstalledAndAtCorrectVersion(). This call checks to see what version of App World is installed to the device and if it needs to be upgraded. The Payment SDK requires a minimum version of App World that changes with SDK versions, so the above call will help keep you safe. If this throws an exception you can call PaymentEngine.upDateAppWorld() to initiate the update.

    If the version of App World is at the correct version then please include some information on the version of App World on the device and the exact device models and software versions used to repro the issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Google App Engine and Objectify 3.1 and slowly learning about denormalization and
I'm interested in learning about all ways in which publishing an app on Google
I am learning about raw sockets. I heard that ping utility is using raw
I just started learning about servers, and I am messing around with Google's App
I am learning iOS and I have written a simple iPhone app using iOS
I'm learning about UINavigationController and UIViewController s. Here is the simple app I build.
I'm learning about Qt Model/View with Ruby and I'm trying run the following code
I recently started learning about ASP.Net MVC and its various features MVC_3_MUSIC_STORE + CODE
As a part of learning process, I am writing simple IM app, using Remoting
I am just learning about app.config in respect of creating custom sections. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.