4. In-App Purchase
Apple In-App Purchase
FID offers server-side verification for orders, which is user-friendly and straightforward. FID also supports order verification retries in the event of errors such as crashes or internet connectivity issues.
4.1 Get Available Products
FID retrieves all products from Funzy's CMS and subsequently updates the prices of these products from AppStore.
[[FTSDKPurchase instance] getListPackagesOnSuccess:^(FTSDKListPackageData * _Nonnull listProducts) {
} onFailure:^(FTSDKError * _Nonnull error) {
}];
4.2 Make a Purchase
Before make Purchase, you must implement FTSDKPurchaseDelegate
to handle result
// MARK: FTSDKPurchaseDelegate
- (void)didPurchaseSuccessWithTransacion:(FTSDKTransaction *)transacion {
// Purchase success, add item for user
}
- (void)didPurchaseFailedWithError:(FTSDKError *)error {
// Purchase failed
}
// Rember to assign delegate
[FTSDKPurchase instance].delegate = self;
To make a Purchase, you need:
FTSDKListPackageData
fetch from4.1
FTSDKFunzyOrderInfo
with randomcooOrderSerial
// package get from getListPackagesOnSuccess
FTSDKPackageData *package;
// Create random order ID to tracking
FTSDKFunzyOrderInfo *funzyOrderInfo = [[FTSDKFunzyOrderInfo alloc] initWithCooOrderSerial:@"RANDOM_ID"];
[[FTSDKPurchase instance] paymentWithoutUISDKWith:package funzyOrderInfo:funzyOrderInfo];
FID provides a sample UI for testing purposes. To access it, you can make a call to:
[[FTSDKPurchase instance] paymentWithUISDKWithFunzyOrderInfo:funzyOrderInfo];
4.3 Retry Verify Pending Transactions
To verify pending or failed transactions, it is advisable to make a call each time the user accesses the app/game, following a successful initialization of FID.
[[FTSDKPurchase instance] reVerifyPendingTransacionsWithCompleted:^(NSArray<FTSDKTransaction *> * _Nonnull listTrans) {
}];
Last updated