Process flow: Purchasing digital goods
The process for purchasing digital goods is designed to be consistent for each payment type and for all BlackBerry device users.
- A user clicks a purchase
option for digital goods in your application.

- The application creates a
PurchaseArguments object which contains information
about the digital goods.
PurchaseArgumentsBuilder arguments = new PurchaseArgumentsBuilder() .withDigitalGoodSku( "abc123" ) .withDigitalGoodName( "Adventures of a BlackBerry Java Developer" ) .withPurchasingAppName( "My eBooks" ) .withMetadata ( "ISBN 34560202010" ); - The application invokes
PaymentEngine.purchase(PurchaseArguments) to initiate
the purchase request and send information about the digital goods to the
Payment
Service server.
try { PurchaseResult purchaseResult = engine.purchase(arguments.build()); } catch (PaymentException e) { Dialog.inform(e.getMessage()); } - If the user isn't
logged in using a BlackBerry
ID account, the
application prompts the user to provide login information without requiring that the user leave the application.

- The
application prompts the user to confirm the purchase using the default payment
type. The user can change the payment type or set up a new payment type.

- The Payment Service server verifies that the digital goods are valid and processes the purchase through the payment provider.
- Depending on the results of
the purchase attempt, one of the following events occurs:
- If the purchase request is successful, the Payment Service server returns a PurchaseResult object to the application that contains details about the successful purchase. If the application utilizes a content server, the Payment Service server can send information about the successful purchase to the content server as well.
- If the purchase request is unsuccessful, the application throws an exception. For information about handling exceptions, view the API reference for the Payment Service SDK.
- If the purchase attempt is successful, the application provides the digital goods to the user in the manner that you designed.
Previous topic: Retrieving available goods