chore: Initial clean commit
- Removed YuMi/Library/ (138 MB, not tracked) - Removed YuMi/Resources/ (23 MB, not tracked) - Removed old version assets (566 files, not tracked) - Excluded Pods/, xcuserdata/ and other build artifacts - Clean repository optimized for company server deployment
This commit is contained in:
30
YuMi/Tools/IAPHelper/RechargeStorage.h
Normal file
30
YuMi/Tools/IAPHelper/RechargeStorage.h
Normal file
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// RechargeStorage.h
|
||||
// YUMI
|
||||
//
|
||||
// Created by YUMI on 2021/9/26.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface RechargeStorage : NSObject
|
||||
|
||||
/// 根据商品id保存凭证
|
||||
+ (BOOL)saveTransactionId:(NSString *)transactionId
|
||||
receipt:(NSString *)receipt
|
||||
uid:(NSString *)uid;
|
||||
|
||||
/// 获取所有凭证
|
||||
+ (NSArray *)getAllReceiptsWithUid:(NSString *)uid;
|
||||
|
||||
/// 根据订单删除凭证
|
||||
+ (BOOL)delegateTransactionId:(NSString *)transactionId
|
||||
uid:(NSString *)uid;
|
||||
|
||||
/// 删除所有凭证
|
||||
+ (void)delegateAllTransactionIdsWithUid:(NSString *)uid;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
67
YuMi/Tools/IAPHelper/RechargeStorage.m
Normal file
67
YuMi/Tools/IAPHelper/RechargeStorage.m
Normal file
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// RechargeStorage.m
|
||||
// YUMI
|
||||
//
|
||||
// Created by YUMI on 2021/9/26.
|
||||
//
|
||||
|
||||
#import "RechargeStorage.h"
|
||||
#import <SSKeychain/SSKeychain.h>
|
||||
|
||||
#define kAppStoreKey @"kAppStoreKey"
|
||||
static
|
||||
|
||||
@implementation RechargeStorage
|
||||
|
||||
/// 根据商品id保存凭证
|
||||
+ (BOOL)saveTransactionId:(NSString *)transactionId
|
||||
receipt:(NSString *)receipt
|
||||
uid:(NSString *)uid {
|
||||
NSString * key = [NSString stringWithFormat:@"%@_%@", kAppStoreKey, uid];
|
||||
return [SSKeychain setPassword:receipt
|
||||
forService:key
|
||||
account:transactionId
|
||||
error:nil];
|
||||
}
|
||||
|
||||
|
||||
/// 获取所有凭证
|
||||
+ (NSArray *)getAllReceiptsWithUid:(NSString *)uid {
|
||||
NSArray *transactionIds = [SSKeychain allAccounts];
|
||||
NSMutableArray *teamArray = [NSMutableArray array];
|
||||
[transactionIds enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
if ([obj[kSSKeychainWhereKey] isKindOfClass:[NSString class]]) {
|
||||
NSString * key = [NSString stringWithFormat:@"%@_%@", kAppStoreKey, uid];
|
||||
if ([obj[kSSKeychainWhereKey] isEqualToString:key]) {
|
||||
NSString *receipt = [SSKeychain passwordForService:key
|
||||
account:obj[kSSKeychainAccountKey]
|
||||
error:nil];
|
||||
NSData *data = [receipt dataUsingEncoding:NSUTF8StringEncoding];
|
||||
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
|
||||
[teamArray addObject:json];
|
||||
}
|
||||
}
|
||||
}];
|
||||
return teamArray;
|
||||
}
|
||||
|
||||
/// 根据订单删除凭证
|
||||
+ (BOOL)delegateTransactionId:(NSString *)transactionId uid:(NSString *)uid {
|
||||
NSString * key = [NSString stringWithFormat:@"%@_%@", kAppStoreKey, uid];
|
||||
return [SSKeychain deletePasswordForService:key account:transactionId error:nil];
|
||||
}
|
||||
|
||||
/// 删除所有凭证
|
||||
+ (void)delegateAllTransactionIdsWithUid:(NSString *)uid {
|
||||
NSArray *transactionIds = [SSKeychain allAccounts];
|
||||
[transactionIds enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
if ([obj[kSSKeychainWhereKey] isKindOfClass:[NSString class]]) {
|
||||
NSString * key = [NSString stringWithFormat:@"%@_%@", kAppStoreKey, uid];
|
||||
if ([obj[kSSKeychainWhereKey] isEqualToString:key]) {
|
||||
[SSKeychain deletePasswordForService:key account:obj[@"acct"]];
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
Reference in New Issue
Block a user