blob: 526364020ad3cc3dfb19c7eafd1eb85b216a06ef [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "FIAPReceiptManager.h"
#import <Flutter/Flutter.h>
@implementation FIAPReceiptManager
- (NSString *)retrieveReceiptWithError:(FlutterError **)error {
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receipt = [self getReceiptData:receiptURL];
if (!receipt) {
*error = [FlutterError errorWithCode:@"storekit_no_receipt"
message:@"Cannot find receipt for the current main bundle."
details:nil];
return nil;
}
return [receipt base64EncodedStringWithOptions:kNilOptions];
}
- (NSData *)getReceiptData:(NSURL *)url {
return [NSData dataWithContentsOfURL:url];
}
@end