This commit is contained in:
2025-12-05 20:18:18 +08:00
parent ad18a47d21
commit fa999f502f
4 changed files with 14 additions and 15 deletions

View File

@@ -40,6 +40,10 @@
#define API_CHARACTER_DEL_USER_CHARACTER @"/character/delUserCharacter" // 删除用户人设 #define API_CHARACTER_DEL_USER_CHARACTER @"/character/delUserCharacter" // 删除用户人设
#define API_CHARACTER_ADD_USER_CHARACTER @"/character/addUserCharacter" // 添加用户人设(假定路径,如有不同请按后端实际修改) #define API_CHARACTER_ADD_USER_CHARACTER @"/character/addUserCharacter" // 添加用户人设(假定路径,如有不同请按后端实际修改)
/// pay
#define API_VALIDATE_RECEIPT @"/api/apple/validate-receipt" // 排行榜标签列表
@@ -48,8 +52,5 @@
#define KB_API_APP_CONFIG @"app/config" // 获取 App 配置 #define KB_API_APP_CONFIG @"app/config" // 获取 App 配置
#endif #endif
#ifndef KB_API_IAP_VERIFY
#define KB_API_IAP_VERIFY @"/payment/apple/verify" // Apple IAP 验签(示例路径,请按后端实际修改)
#endif
#endif /* KBAPI_h */ #endif /* KBAPI_h */

View File

@@ -37,8 +37,8 @@
type = 1; type = 1;
#endif #endif
NSDictionary *params = @{ @"payment": @{ @"receipt": receipt ?: @"", @"type": @(type) } }; // , @"type": @(type)
NSDictionary *params = @{ @"receipt": receipt ?: @""};
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
[self.payVM applePayReqWithParams:params needShow:NO completion:^(NSInteger sta, NSString * _Nullable msg) { [self.payVM applePayReqWithParams:params needShow:NO completion:^(NSInteger sta, NSString * _Nullable msg) {
[KBHUD dismiss]; [KBHUD dismiss];
@@ -56,13 +56,9 @@
#pragma mark - Helpers #pragma mark - Helpers
- (BOOL)checkLogin { - (BOOL)checkLogin {
BOOL loggedIn = [[KBAuthManager shared] isLoggedIn]; BOOL loggedIn = [[KBUserSessionManager shared] isLoggedIn];
if (!loggedIn) { if (!loggedIn) {
dispatch_async(dispatch_get_main_queue(), ^{ [[KBUserSessionManager shared] goLoginVC];
UIViewController *top = [UIViewController kb_topMostViewController];
if (top) { [KBLoginSheetViewController presentIfNeededFrom:top]; }
});
return NO;
} }
return YES; return YES;
} }

View File

@@ -243,19 +243,21 @@ static NSString * const kKBJfPayCellId = @"kKBJfPayCellId";
// NSString *msg = [NSString stringWithFormat:@"购买:%@ Coins %@", item[@"coins"], item[@"price"]]; // NSString *msg = [NSString stringWithFormat:@"购买:%@ Coins %@", item[@"coins"], item[@"price"]];
// [KBHUD showInfo:msg]; // [KBHUD showInfo:msg];
// } // }
NSString *productId = @"com.yolo.vip.1month"; NSString *productId = @"com.loveKey.nyx.1day";
/// 2. /// 2.
[KBHUD show]; [KBHUD show];
[self.filter requestProductsWith:[NSSet setWithObject:productId] completion:^(NSArray<SKProduct *> * _Nonnull products) { [self.filter requestProductsWith:[NSSet setWithObject:productId] completion:^(NSArray<SKProduct *> * _Nonnull products) {
NSLog(@"====="); // NSLog(@"=====");
// if (products.count > 0) { // if (products.count > 0) {
// SKProduct *pro = productsp[0]; // SKProduct *pro = productsp[0];
// } // }
// [[FGIAPManager shared].iap buyProduct:product onCompletion:^(NSString * _Nonnull message, FGIAPManagerPurchaseRusult result) { }]; // [[FGIAPManager shared].iap buyProduct:product onCompletion:^(NSString * _Nonnull message, FGIAPManagerPurchaseRusult result) { }];
/// 3. /// 3.
SKProduct *product = products.firstObject;
[[FGIAPManager shared].iap buyProduct:products.firstObject onCompletion:^(NSString * _Nonnull message, FGIAPManagerPurchaseRusult result) { [[FGIAPManager shared].iap buyProduct:products.firstObject onCompletion:^(NSString * _Nonnull message, FGIAPManagerPurchaseRusult result) {
// [self.view makeToast:message]; // [self.view makeToast:message];
[KBHUD dismiss];
}]; }];
}]; }];
} }

View File

@@ -14,7 +14,7 @@
completion:(KBPayCompletion)completion { completion:(KBPayCompletion)completion {
if (needShow) { [KBHUD show]; } if (needShow) { [KBHUD show]; }
[[KBNetworkManager shared] POST:KB_API_IAP_VERIFY jsonBody:params headers:nil completion:^(NSDictionary * _Nullable json, NSURLResponse * _Nullable response, NSError * _Nullable error) { [[KBNetworkManager shared] POST:API_VALIDATE_RECEIPT jsonBody:params headers:nil completion:^(NSDictionary * _Nullable json, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if (needShow) { [KBHUD dismiss]; } if (needShow) { [KBHUD dismiss]; }
if (error) { if (error) {