You have to wrap InAppPurchase functions to monkey for that
Here is something i worked on but didn't complete it
You have "just" to forward those values and variables and make it monkey ready
If you have success it would be very nice if you would share it with the community!
// inapppurchase.cpp
#import <Foundation/Foundation.h>
//In App Purchase Functions
void InitStore()
{
//Your application should add the observer when your application launches.
MyStoreObserver *observer = [[MyStoreObserver alloc] init];
[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];
}
void requestProductData()
{
SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObject: kMyFeatureIdentifier]];
request.delegate = self;
[request start];
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
NSArray *myProduct = response.products;
// populate UI
[request autorelease];
}
BOOL isInAppPurchaseAvailable() {
if ([SKPaymentQueue canMakePayments])
{
return true;
}
else
{
return false;
}
}
void completeTransaction(SKPaymentTransaction *transaction)
{
// Your application should implement these two methods.
[self recordTransaction: transaction];
[self provideContent: transaction.payment.productIdentifier];
// Remove the transaction from the payment queue.
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}
void restoreTransaction(SKPaymentTransaction *transaction)
{
[self recordTransaction: transaction];
[self provideContent: transaction.originalTransaction.payment.productIdentifier];
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}
void failedTransaction(SKPaymentTransaction *transaction)
{
if (transaction.error.code != SKErrorPaymentCancelled)
{
// Optionally, display an error here.
}
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}
void BuyItem()
{
SKPayment *payment = [SKPayment paymentWithProductIdentifier:kMyFeatureIdentifier];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
void BuyAmount(int quantity)
{
//If your store offers the ability to purchase more than one of a product,
//you can create a single payment and set the quantity property.
SKMutablePayment *payment = [SKMutablePayment paymentWithProductIdentifier:kMyFeatureIdentifier];
payment.quantity = quantity;
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction *transaction in transactions)
{
switch (transaction.transactionState)
{
case SKPaymentTransactionStatePurchased:
[self completeTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
[self failedTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
[self restoreTransaction:transaction];
default:
break;
}
}
}
|