/** * Notifies that the transaction has been received by the App Store/ * Google Play. * Platform: Android and iOS. * @param purchase The object that sent the event. */ void Test1::requestInProgress(const Purchase& purchase) { if ( mPurchase->getHandle() == purchase.getHandle() ) { MAUtil::String info = "Product " + MAUtil::integerToString(purchase.getHandle()) + " failed, product is in progress"; mApplicationController.log(info); this->setFailedReason(info); mApplicationController.testFailed(*this); } }
/** * 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 Test1::requestCompleted(const Purchase& purchase) { if ( mPurchase->getHandle() == purchase.getHandle() ) { MAUtil::String info = "Product " + MAUtil::integerToString(purchase.getHandle()) + "was purchased without public key"; mApplicationController.log(info); this->setFailedReason(info); mApplicationController.testFailed(*this); } }
/** * Notifies that the product has been validated by the App Store. * NOTE: On Android there is no validation done at this step, if the * product results to be unavailable, then the application will be later * notified via a requestFailed() callback. The errorCode will equal * #MA_PURCHASE_ERROR_INVALID_PRODUCT. * Platform: iOS and Android. * @param purchase The object that sent the event. */ void Test1::productValid(const Purchase& purchase) { if ( purchase.getHandle() == mPurchase->getHandle() && getPlatform() == ANDROID) { mPurchase->requestPurchase(); } }
/** * Notifies that the transaction has been validated by the App Store / * Google Play. * Platform: Android and iOS. * @param purchase The object that sent the event. * @param receipt Transaction receipt. */ void ApplicationController::receiptValid( const Purchase& purchase, Receipt& receipt) { if ( purchase.getHandle() == mPurchases[mCurrentPurchase]->getHandle() ) { // Display the dialog containing the receipt information. mMainScreen->fillReceiptDialog(receipt.getAppID(), receipt.getProductID(), receipt.getTransactionDate(), receipt.getTransactionID(), receipt.getBID(), receipt.getPrice(), receipt.getTitle()); } }
/** * 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 Test1::requestFailed(const Purchase& purchase, const int errorCode) { if ( mPurchase->getHandle() == purchase.getHandle() && getPlatform() == ANDROID && errorCode == MA_PURCHASE_ERROR_PUBLIC_KEY_NOT_SET ) { mApplicationController.testSucceeded(*this); } else { MAUtil::String info = "Purchase failed for different reason"; mApplicationController.log(info); this->setFailedReason(info); mApplicationController.testFailed(*this); } }