PDL_PurchaseItem

Purchase the item with the sent-in itemID. This launches a system-level confirmation dialog before the purchase goes through. If the user has not yet configured a payment option, a UI for doing that appears first.

A successful purchase returns a "Charged" status and a receipt. If a payment takes time, a "Pending" status is returned. In this case, your app can later call "PDL_GetPendingPurchaseInfo" to check if the payment experienced further user action. Note that a pending status can also transit to failure.

For perishable items, 3rd-party apps should not charge the user twice. Your UI should diplay the item as "pending" and not allow the user to re-purchase it. Users should be able to check if it is done (via user tap) or, alternatively, your app can poll state periodically.

This call is a wrapper for a purchaseItem com.palm.service.payment call and returns the same response.

Note

PDL_ItemReceipt is an opaque type that your code cannot directly access. You need to call PDL_GetItemReceiptJSON to turn the response into a JSON-formatted string.

Syntax

PDL_ItemReceipt *PDL_PurchaseItem(const char *itemID, int qty, const char *usr);

Parameters

Parameter
Required Type Description
itemId Yes pointer Pointer to string containing item ID, i.e. "gamelevel101". 64 characters maximum.
qty Yes int Number of items to buy. At present, it must be set to 1. Any other value returns an error. In the future, this restriction will be lifted.
usr Yes pointer Pointer to string returned with purchase receipts. 255 bytes maximum. Developers can use this to keep track of purchases. NULL is allowed.

Returns

Pointer to PDL_ItemReceipt struct.