
- 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
68 lines
2.3 KiB
Objective-C
68 lines
2.3 KiB
Objective-C
//
|
|
// 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
|