コード例 #1
0
/**
 * Notifies that a purchase has been refunded.
 * Platform: Android.
 * @param purchase The purchase that has been refunded.
 */
void ApplicationController::purchaseRefunded(Purchase& purchase)
{
	MAUtil::String refundString = "You received a refund for " + purchase.getProductId();
	maAlert("Product refunded", refundString.c_str(), "OK", NULL,NULL);
	Purchase* restoredItem = new Purchase(purchase.getProductId(), this);
	mPurchases.add(restoredItem);
	mCurrentPurchase = mPurchases.size()-1;

	// Notify The UI.
	mMainScreen->productRefunded(purchase.getProductId());
}
コード例 #2
0
/**
 * Notifies that the transaction has been successfully processed.
 * The user should receive the purchased product.
 * Platform: Android and iOS.
 * @param purchase The object that sent the event.
 */
void ApplicationController::requestCompleted(const Purchase& purchase)
{
	// Notify UI that a product was purchased.
	mMainScreen->productPurchased(purchase.getProductId());

	// Update DB.
	DatabaseProduct* dbProduct = new DatabaseProduct();
	dbProduct->setProductID(purchase.getProductId());
	int date = maLocalTime();
	dbProduct->setDate(date);
	mDatabase->addRow(*dbProduct);
	delete dbProduct;
	dbProduct = NULL;
}
コード例 #3
0
/**
 * Notifies that the product is not valid on the App Store.
 * Platform: iOS.
 * @param purchase The object that sent the event.
 */
void ApplicationController::productInvalid(const Purchase& purchase)
{
	MAUtil::String errorMessage = "Product " + purchase.getProductId()
			+ " is invalid!";
	mMainScreen->productError(errorMessage);
	mPurchases.remove( mCurrentPurchase );
	mCurrentPurchase = -1;
	//TODO remove, only for android.test.purchased
//	/mPurchases[mCurrentPurchase]->requestPurchase();
}
コード例 #4
0
/**
 * Notifies that a purchase has been restored.
 * Platform: iOS and Android.
 * @param purchase The purchase that has been restored.
 */
void ApplicationController::purchaseRestored(Purchase& purchase)
{
	Purchase* restoredItem = new Purchase(purchase.getProductId(), this);
	mPurchases.add(restoredItem);
	mCurrentPurchase = mPurchases.size()-1;
	//restoredItem->addPurchaseListener(this);
	restoredItem->verifyReceipt();
//	mCurrentPurchase = mPurchase

	// Store the product in the repository.
	DatabaseProduct* dbProduct = new DatabaseProduct();
	dbProduct->setProductID(purchase.getProductId());
	int date = maLocalTime();
	dbProduct->setDate(date);
	mDatabase->addRow(*dbProduct);
	delete dbProduct;
	dbProduct = NULL;
	delete restoredItem;
	restoredItem = NULL;

	// Notify The UI.
	mMainScreen->productRestored(purchase.getProductId());
}
コード例 #5
0
/**
 * Notifies that the transaction has failed.
 * Platform: Android and iOS.
 * @param purchase The object that sent the event.
 * @param errorCode The reason why it failed.
 * Note that even if the request fails because it was canceled
 * (errorCode = MA_PURCHASE_ERROR_CANCELLED), you will still be
 * able to get a receipt for your purchase.
 */
void ApplicationController::requestFailed(const Purchase& purchase,
	const int errorCode)
{
	mPurchases.remove( mCurrentPurchase );
	mCurrentPurchase = -1;
	MAUtil::String errorMessage = "Purchase failed for product " + purchase.getProductId();
	if ( errorCode == MA_PURCHASE_ERROR_PRODUCT_ALREADY_OWNED)
	{
		errorMessage += ". Item already owned!";
	}
	else
	{
		errorMessage += " with err code = "  + MAUtil::integerToString(errorCode);
	}
	mMainScreen->productError(errorMessage);
}
コード例 #6
0
/**
 * Notifies that an error occurred while verifying the receipt.
 * Platform: Android and iOS.
 * @param purchase The object that sent the event.
 * @param errorCode The reason why it failed.
 */
void ApplicationController::receiptError(const Purchase& purchase,
	const int errorCode)
{
	mMainScreen->productError("Product " + purchase.getProductId()
			+ " does not have a receipt!");
}
コード例 #7
0
/**
 * Notifies that the transaction is not valid on the App Store /
 * Google Play.
 * Platform: Android and iOS.
 * @param purchase The object that sent the event.
 */
void ApplicationController::receiptInvalid(const Purchase& purchase)
{
	mMainScreen->productError("Product " + purchase.getProductId()
			+ " does not have a receipt. It may be a managed item.");
}
コード例 #8
0
/**
 * Notifies that the transaction is not valid on the App Store /
 * Google Play.
 * Platform: Android and iOS.
 * @param purchase The object that sent the event.
 */
void ApplicationController::receiptInvalid(const Purchase& purchase)
{
	mMainScreen->productError("Product " + purchase.getProductId()
			+ " has an invalid receipt!");
}
コード例 #9
0
/**
 * Notifies that the transaction has failed.
 * Platform: Android and iOS.
 * @param purchase The object that sent the event.
 * @param errorCode The reason why it failed.
 * Note that even if the request fails because it was canceled
 * (errorCode = MA_PURCHASE_ERROR_CANCELLED), you will still be
 * able to get a receipt for your purchase.
 */
void ApplicationController::requestFailed(const Purchase& purchase,
	const int errorCode)
{
	mMainScreen->productError("Purchase failed for product "
			+ purchase.getProductId() );
}
コード例 #10
0
/**
 * Notifies that the transaction has been successfully processed.
 * The user should receive the purchased product.
 * Platform: Android and iOS.
 * @param purchase The object that sent the event.
 */
void ApplicationController::requestCompleted(const Purchase& purchase)
{
	// Notify UI that a product was purchased.
	mMainScreen->productPurchased(purchase.getProductId());
}
コード例 #11
0
/**
 * Notifies that the product is not valid on the App Store.
 * Platform: iOS.
 * @param purchase The object that sent the event.
 */
void ApplicationController::productInvalid(const Purchase& purchase)
{
	MAUtil::String errorMessage = "Product " + purchase.getProductId()
			+ " is invalid!";
	mMainScreen->productError(errorMessage);
}