void Approve(const Purchase &item){ if(item.GetPrice()<10000000000.0){ cout<<"Item "<<item.GetItemNumber()<<" is apprived by "<<name_<<endl; } else{//CEOでも決済できないのでCommityに cout<<"Item "<<item.GetItemNumber()<<" will be apprived by commity"<<endl; } }
void Approve(const Purchase &item){ if(item.GetPrice()<10000000.0){ cout<<"Item "<<item.GetItemNumber()<<" is apprived by "<<name_<<endl; } else{//次の承認者に next_->Approve(item); } }
void Purchases::newPurchase(int prodId, double cantitaty, QDate date) { Purchase * pur = new Purchase(); pur->setIdProd(prodId); pur->setCantitaty(cantitaty); pur->setDate(date); addItem(pur); }
/** * 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()); }
/** * 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 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; }
void Purchases::deletePurchasesOfProduct(int productId) { for(int i=0; i<itemsCount(); i++){ Item *it = item(i); Purchase *purch = dynamic_cast<Purchase *>(it); if (!purch) continue; if (purch->id() == productId) { m_items.removeAll(it); delete it; } } }
/** * 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 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(); }
/** * 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 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()); }
/** * 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); }
/** * 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); } }
/** * 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() ); }
/** * 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!"); }
/** * 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!"); }
/** * 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()); }
/** * 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."); }
/** * 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); }