v2内购
This commit is contained in:
@@ -4824,14 +4824,14 @@
|
||||
2331C1882A60F32D00E1D940 /* Model */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2331C1892A60F32D00E1D940 /* CandyTreeResultModel.m */,
|
||||
2331C18A2A60F32D00E1D940 /* CandyTreeRecordModel.m */,
|
||||
2331C18B2A60F32D00E1D940 /* XPCandyTreeAnimationModel.h */,
|
||||
2331C18C2A60F32D00E1D940 /* CandyTreeInfoModel.h */,
|
||||
2331C18D2A60F32D00E1D940 /* XPCandyTreeAnimationModel.m */,
|
||||
2331C18E2A60F32D00E1D940 /* CandyTreeRecordModel.h */,
|
||||
2331C18F2A60F32D00E1D940 /* CandyTreeResultModel.h */,
|
||||
2331C1902A60F32D00E1D940 /* CandyTreeInfoModel.m */,
|
||||
2331C18E2A60F32D00E1D940 /* CandyTreeRecordModel.h */,
|
||||
2331C18A2A60F32D00E1D940 /* CandyTreeRecordModel.m */,
|
||||
2331C18F2A60F32D00E1D940 /* CandyTreeResultModel.h */,
|
||||
2331C1892A60F32D00E1D940 /* CandyTreeResultModel.m */,
|
||||
2331C18B2A60F32D00E1D940 /* XPCandyTreeAnimationModel.h */,
|
||||
2331C18D2A60F32D00E1D940 /* XPCandyTreeAnimationModel.m */,
|
||||
);
|
||||
path = Model;
|
||||
sourceTree = "<group>";
|
||||
@@ -11202,7 +11202,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 10.13.1;
|
||||
MARKETING_VERSION = 10.13.2;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.peko.enterprise.ios;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
@@ -11236,7 +11236,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 10.13.1;
|
||||
MARKETING_VERSION = 10.13.2;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.peko.enterprise.ios;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
|
@@ -164,7 +164,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// @param uid 用户uid
|
||||
/// @param ticket ticket
|
||||
+ (void)checkReceipt:(HttpRequestHelperCompletion)complection
|
||||
receipt:(NSString *)receipt
|
||||
|
||||
chooseEnv:(NSString *)chooseEnv
|
||||
chargeRecordId:(NSString *)chargeRecordId
|
||||
transcationId:(NSString *)transcationId
|
||||
|
@@ -178,22 +178,21 @@
|
||||
/// @param deviceInfo uuid
|
||||
/// @param clientIp ip地址
|
||||
+ (void)requestIAPRecharge:(HttpRequestHelperCompletion)completion chargeProdId:(NSString *)chargeProdId uid:(NSString *)uid ticket:(NSString *)ticket deviceInfo:(NSString *)deviceInfo clientIp:(NSString *)clientIp {
|
||||
NSString * fang = [NSString stringFromBase64String:@"b3JkZXIvcGxhY2VWMg=="];///order/placeV2
|
||||
[self makeRequest:fang method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__,chargeProdId, uid, ticket, deviceInfo, clientIp, nil];
|
||||
|
||||
[self makeRequest:@"storeKitV2/placeOrder" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__,chargeProdId, uid, ticket, deviceInfo, clientIp, nil];
|
||||
}
|
||||
|
||||
|
||||
/// 验证凭据
|
||||
/// @param completion 完成
|
||||
/// @param receipt base 64 recepit
|
||||
/// @param chooseEnv @"true"
|
||||
/// @param chargeRecordId 服务端生成的订单编号
|
||||
/// @param transcationId 内购的唯一标识符
|
||||
/// @param uid 用户uid
|
||||
/// @param ticket ticket
|
||||
+ (void)checkReceipt:(HttpRequestHelperCompletion)completion receipt:(NSString *)receipt chooseEnv:(NSString *)chooseEnv chargeRecordId:(NSString *)chargeRecordId transcationId:(NSString *)transcationId uid:(NSString *)uid ticket:(NSString *)ticket {
|
||||
NSString * fang = [NSString stringFromBase64String:@"dmVyaWZ5L3NldGlhcA=="];///verify/setiap
|
||||
[self makeRequest:fang method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__,receipt, chooseEnv, chargeRecordId, transcationId, uid, ticket, nil];
|
||||
+ (void)checkReceipt:(HttpRequestHelperCompletion)completion chooseEnv:(NSString *)chooseEnv chargeRecordId:(NSString *)chargeRecordId transcationId:(NSString *)transcationId uid:(NSString *)uid ticket:(NSString *)ticket {
|
||||
|
||||
[self makeRequest:@"storeKitV2/verifyOrder" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, chooseEnv, chargeRecordId, transcationId, uid, ticket, nil];
|
||||
}
|
||||
|
||||
|
||||
|
@@ -32,7 +32,8 @@ typedef NS_ENUM(NSInteger, XPMineItemType) {
|
||||
XPMineItemType_FansTeam = 72,///粉丝团
|
||||
XPMineItemType_DressUp_Market = 73, ///装扮商场
|
||||
XPMineItemType_My_Dressup = 74,///我的装扮
|
||||
XPMineItemType_My_Set = 75///设置
|
||||
XPMineItemType_My_Set = 75,///设置
|
||||
XPMineItemType_My_Refund = 76///设置
|
||||
|
||||
};
|
||||
|
||||
|
@@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// @param receipt 凭据
|
||||
/// @param orderId 订单编号
|
||||
/// @param transcationId 商品id
|
||||
- (void)checkReceiptWithData:(NSString *)receipt orderId:(NSString *)orderId transcationId:(NSString *)transcationId;
|
||||
- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId;
|
||||
|
||||
/// 批量验证内购掉单
|
||||
/// @param transcations 凭据的数组
|
||||
|
@@ -50,7 +50,8 @@
|
||||
NSString * clientIp= [YYUtility ipAddress];
|
||||
[Api requestIAPRecharge:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||
NSString *orderId = (NSString *)data.data[@"recordId"];
|
||||
[[self getView] requestIAPRechargeOrderSuccess:orderId chargeProdId:chargeProdId];
|
||||
NSString *uuid = (NSString *)data.data[@"appAccountToken"];
|
||||
[[self getView] requestIAPRechargeOrderSuccess:orderId chargeProdId:chargeProdId uuid:uuid];
|
||||
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
||||
[[self getView] requestIAPRechargeOrderFail];
|
||||
}] chargeProdId:chargeProdId uid:uid ticket:ticket deviceInfo:deviceInfo clientIp:clientIp];
|
||||
@@ -58,17 +59,16 @@
|
||||
|
||||
|
||||
/// 充值成功二次验证
|
||||
/// @param receipt 凭据
|
||||
/// @param orderId 订单编号
|
||||
/// @param transcationId 商品id
|
||||
- (void)checkReceiptWithData:(NSString *)receipt orderId:(NSString *)orderId transcationId:(NSString *)transcationId {
|
||||
- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId {
|
||||
NSString * uid = [AccountInfoStorage instance].getUid;
|
||||
NSString * ticket = [AccountInfoStorage instance].getTicket;
|
||||
[Api checkReceipt:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||
[[self getView] checkReceiptSuccess:transcationId];
|
||||
}fail:^(NSInteger code, NSString * _Nullable msg) {
|
||||
[[self getView]hideHUD];
|
||||
} showLoading:YES] receipt:receipt chooseEnv:@"true" chargeRecordId:orderId transcationId:transcationId uid:uid ticket:ticket];
|
||||
} showLoading:YES] chooseEnv:@"true" chargeRecordId:orderId transcationId:transcationId uid:uid ticket:ticket];
|
||||
}
|
||||
|
||||
|
||||
|
@@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
///请求充值列表成功
|
||||
- (void)requestRechargeListSucccess:(NSArray *)list;
|
||||
///请求充值id的状态成功
|
||||
- (void)requestIAPRechargeOrderSuccess:(NSString *)orderId chargeProdId:(NSString *)chargeProdId;
|
||||
- (void)requestIAPRechargeOrderSuccess:(NSString *)orderId chargeProdId:(NSString *)chargeProdId uuid:(NSString *)uuid;
|
||||
///请求充值账单失败
|
||||
- (void)requestIAPRechargeOrderFail;
|
||||
///二次校验成功
|
||||
|
@@ -71,9 +71,9 @@
|
||||
- (void)checkReceiptWithData:(NSString *)receipt orderId:(NSString *)orderId transcationId:(NSString *)transcationId {
|
||||
NSString * uid = [AccountInfoStorage instance].getUid;
|
||||
NSString * ticket = [AccountInfoStorage instance].getTicket;
|
||||
[Api checkReceipt:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||
[[self getView] checkReceiptSuccess:transcationId];
|
||||
} showLoading:YES] receipt:receipt chooseEnv:@"true" chargeRecordId:orderId transcationId:transcationId uid:uid ticket:ticket];
|
||||
// [Api checkReceipt:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||
// [[self getView] checkReceiptSuccess:transcationId];
|
||||
// } showLoading:YES] receipt:receipt chooseEnv:@"true" chargeRecordId:orderId transcationId:transcationId uid:uid ticket:ticket];
|
||||
}
|
||||
|
||||
/// 批量验证内购掉单
|
||||
|
@@ -238,16 +238,15 @@
|
||||
|
||||
#pragma mark - XPIAPHelperDelegate
|
||||
///当前充值的状态
|
||||
- (void)rechargeProcessStatus:(PaymentStatus)status {
|
||||
- (void)rechargeNewProcessStatus:(StoreState)status {
|
||||
[self hideHUD];
|
||||
if (status == PaymentStatus_Purchased) {
|
||||
|
||||
if (status == StoreStatePay || status == StoreStateStart || status == StoreStateVerifiedServer) {
|
||||
[self showLoading];
|
||||
} else if (status == PaymentStatus_Purchasing) {
|
||||
[self showLoading];
|
||||
} else if (status == PaymentStatus_Failed) {
|
||||
[self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController0")];
|
||||
} else if (status == PaymentStatus_Deferred) {
|
||||
}else if (status == StoreStateUnowned) {
|
||||
[self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController1")];
|
||||
}else{
|
||||
[self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController0")];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +257,8 @@
|
||||
NSData *receiptData = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];
|
||||
NSString * receipt = [MF_Base64Codec base64StringFromData:receiptData];
|
||||
///二次验证
|
||||
[self.presenter checkReceiptWithData:receipt orderId:self.orderId transcationId:transactionIdentifier];
|
||||
[self.presenter checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier];
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - XPMineRechargeProtocol
|
||||
@@ -267,10 +267,48 @@
|
||||
[self.collectionView reloadData];
|
||||
}
|
||||
|
||||
- (void)requestIAPRechargeOrderSuccess:(NSString *)orderId chargeProdId:(NSString *)chargeProdId {
|
||||
- (void)requestIAPRechargeOrderSuccess:(NSString *)orderId chargeProdId:(NSString *)chargeProdId uuid:(nonnull NSString *)uuid{
|
||||
|
||||
if (orderId.length > 0) {
|
||||
|
||||
self.orderId = orderId;
|
||||
[[XPIAPHelper shareHelper] buyAppProductWithAppProductId:chargeProdId];
|
||||
if (@available(iOS 15.0, *)) {
|
||||
|
||||
PIIAPPayment *iap = [PIIAPPayment shared];
|
||||
[iap requestBuyProductWithProductId:chargeProdId uuid:uuid completionHandler:^(NSError * _Nullable error) {
|
||||
|
||||
}];
|
||||
@kWeakify(self);
|
||||
iap.stateBlock = ^(enum StoreState state, NSDictionary<NSString *,id> * _Nullable result) {
|
||||
@kStrongify(self);
|
||||
|
||||
[self rechargeNewProcessStatus:state];
|
||||
switch (state) {
|
||||
case StoreStateVerifiedServer:
|
||||
{
|
||||
NSString *transactionId = result[@"transactionId"];
|
||||
|
||||
[self rechargeSuccess:transactionId];
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
} else {
|
||||
[self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController8")];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,7 +319,15 @@
|
||||
|
||||
///二次验证成功
|
||||
- (void)checkReceiptSuccess:(NSString *)transcationId {
|
||||
[self hideHUD];
|
||||
if (@available(iOS 15.0, *)) {
|
||||
PIIAPPayment *iap = [PIIAPPayment shared];
|
||||
[iap transactionFinishWithTransaction:[NSString stringWithFormat:@"%@",transcationId] completionHandler:^{
|
||||
|
||||
}];
|
||||
}
|
||||
[self deleteRechageReciptWithTransactionIdentifier:transcationId];
|
||||
|
||||
///刷新一下用户的💎
|
||||
[self getUserWalletBalanceInfo];
|
||||
self.orderId = nil;
|
||||
|
@@ -208,7 +208,7 @@
|
||||
NSData *receiptData = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];
|
||||
NSString * receipt = [MF_Base64Codec base64StringFromData:receiptData];
|
||||
///二次验证
|
||||
[self.presenter checkReceiptWithData:receipt orderId:self.orderId transcationId:transactionIdentifier];
|
||||
// [self.presenter checkReceiptWithData:receipt orderId:self.orderId transcationId:transactionIdentifier];
|
||||
}
|
||||
|
||||
#pragma mark - XPMineRechargeProtocol
|
||||
|
@@ -58,6 +58,7 @@
|
||||
#import "XPIAPRechargeViewController.h"
|
||||
#import "XPIncomeRecordVC.h"
|
||||
#import "XPNobleCenterViewController.h"
|
||||
#import "YuMi-swift.h"
|
||||
UIKIT_EXTERN NSString *kRequestRicket;
|
||||
|
||||
@interface XPMineViewController ()<UITableViewDelegate, UITableViewDataSource, XPMineProtocol, XPMineHeadItemTableViewCellDelegate, XPMineHeadViewDelegate, XPHomeBannerTableViewCellDelegate>
|
||||
@@ -294,11 +295,96 @@ UIKIT_EXTERN NSString *kRequestRicket;
|
||||
|
||||
}
|
||||
break;
|
||||
case XPMineItemType_My_Refund:{
|
||||
#ifdef DEBUG
|
||||
|
||||
|
||||
UIView *bgView = [[UIView alloc]init];
|
||||
[kWindow addSubview:bgView];
|
||||
[bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.left.bottom.right.mas_equalTo(0);
|
||||
|
||||
}];
|
||||
|
||||
|
||||
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hiddenTextVeiw:)];
|
||||
[bgView addGestureRecognizer:tap];
|
||||
bgView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];
|
||||
|
||||
UIView *bgView1 = [UIView new];
|
||||
bgView1.layer.cornerRadius = 10;
|
||||
bgView1.layer.masksToBounds = YES;
|
||||
[bgView addSubview:bgView1];
|
||||
bgView1.backgroundColor = [UIColor whiteColor];
|
||||
CGFloat width = KScreenWidth - kGetScaleWidth(60);
|
||||
[bgView1 mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.center.equalTo(bgView);
|
||||
make.width.mas_equalTo(width);
|
||||
make.height.mas_equalTo(kGetScaleWidth(200));
|
||||
}];
|
||||
|
||||
|
||||
UITextField *textf = [[UITextField alloc]init];
|
||||
textf.backgroundColor = UIColorRGBAlpha(0xBBBCCF, 0.1);
|
||||
textf.layer.cornerRadius = kGetScaleWidth(40)/2;
|
||||
textf.layer.masksToBounds = YES;
|
||||
textf.attributedPlaceholder = [[NSMutableAttributedString alloc]initWithString:@" 请输入订单号" attributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0x2B2D33),NSFontAttributeName:kFontRegular(14)}];
|
||||
textf.textColor = UIColorFromRGB(0x222222);
|
||||
|
||||
textf.font = kFontRegular(14);
|
||||
[bgView1 addSubview:textf];
|
||||
[textf mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(bgView1);
|
||||
make.top.mas_equalTo(kGetScaleWidth(25));
|
||||
make.left.right.equalTo(bgView1).inset(kGetScaleWidth(30));
|
||||
make.height.mas_equalTo(kGetScaleWidth(40));
|
||||
}];
|
||||
textf.tag = 1001;
|
||||
|
||||
UIButton *bnt = [UIButton new];
|
||||
[bnt setBackgroundImage:[UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor], [DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(kGetScaleWidth(200), kGetScaleWidth(50))] forState:UIControlStateNormal];
|
||||
[bnt setTitle:@"确定" forState:UIControlStateNormal];
|
||||
[bnt setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
||||
[bnt addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[bgView1 addSubview:bnt];
|
||||
[bnt mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(bgView1);
|
||||
make.top.equalTo(textf.mas_bottom).mas_offset(kGetScaleWidth(40));
|
||||
make.width.mas_equalTo(kGetScaleWidth(250));
|
||||
make.height.mas_equalTo(kGetScaleWidth(50));
|
||||
}];
|
||||
bnt.layer.cornerRadius = kGetScaleWidth(50)/2;
|
||||
bnt.layer.masksToBounds = YES;
|
||||
#else
|
||||
|
||||
#endif
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
-(void)hiddenTextVeiw:(UITapGestureRecognizer *)sender{
|
||||
[sender.view removeFromSuperview];
|
||||
|
||||
}
|
||||
- (void)textFieldDidChange:(UIButton *)sender {
|
||||
|
||||
UITextField *textField = [sender.superview viewWithTag:1001];
|
||||
[textField.superview.superview removeFromSuperview];
|
||||
if (textField.text.length == 0) {
|
||||
[self showErrorToast:@"请输入订单号"];
|
||||
return;
|
||||
}
|
||||
if (@available(iOS 15.0, *)) {
|
||||
PIIAPPayment *iap = [PIIAPPayment shared];
|
||||
NSUInteger text = [textField.text integerValue];
|
||||
[iap refunRequestWithView:self.view transactionId:text completionHandler:^{
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)pushWebViewWIthUrl:(NSString *)url {
|
||||
XPWebViewController * webVC = [[XPWebViewController alloc] init];
|
||||
|
@@ -197,8 +197,8 @@
|
||||
/// 获取个播PK规则
|
||||
/// @param completion 完成
|
||||
+ (void)requestAnchorPkRule:(HttpRequestHelperCompletion)completion {
|
||||
NSString * fang = [NSString stringFromBase64String:@""];///
|
||||
[self makeRequest:fang method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, nil];
|
||||
|
||||
[self makeRequest:@"crossroompkround/getSingleRoomPkRule" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, nil];
|
||||
}
|
||||
|
||||
#pragma mark - 超管
|
||||
|
@@ -337,14 +337,14 @@
|
||||
- (void)checkReceiptWithData:(NSString *)receipt orderId:(NSString *)orderId transcationId:(NSString *)transcationId {
|
||||
NSString * uid = [AccountInfoStorage instance].getUid;
|
||||
NSString * ticket = [AccountInfoStorage instance].getTicket;
|
||||
[Api checkReceipt:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
if (code == 200) {
|
||||
[self checkReceiptSuccess:transcationId];
|
||||
} else {
|
||||
[XNDJTDDLoadingTool showErrorWithMessage:msg];
|
||||
}
|
||||
[XNDJTDDLoadingTool hideHUD];
|
||||
} receipt:receipt chooseEnv:@"true" chargeRecordId:orderId transcationId:transcationId uid:uid ticket:ticket];
|
||||
// [Api checkReceipt:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
// if (code == 200) {
|
||||
// [self checkReceiptSuccess:transcationId];
|
||||
// } else {
|
||||
// [XNDJTDDLoadingTool showErrorWithMessage:msg];
|
||||
// }
|
||||
// [XNDJTDDLoadingTool hideHUD];
|
||||
// } receipt:receipt chooseEnv:@"true" chargeRecordId:orderId transcationId:transcationId uid:uid ticket:ticket];
|
||||
}
|
||||
|
||||
///二次验证成功
|
||||
|
@@ -12,6 +12,14 @@
|
||||
|
||||
#define AppName ([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"])
|
||||
|
||||
#define isEnterprise \
|
||||
({BOOL isEnterprise = NO;\
|
||||
if (@available(iOS 11.0, *)) {\
|
||||
NSString *bundleID = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];\
|
||||
isEnterprise = [bundleID isEqualToString:@"com.hflighting.yumi"];\
|
||||
}\
|
||||
(isEnterprise);})
|
||||
|
||||
#ifdef DEBUG
|
||||
#define NSLog(fmt,...) NSLog((@"%s [Line %d]" fmt),__PRETTY_FUNCTION__,__LINE__,##__VA_ARGS__)
|
||||
#else
|
||||
|
@@ -17,12 +17,16 @@ typealias RenewalState = StoreKit.Product.SubscriptionInfo.RenewalState
|
||||
|
||||
|
||||
|
||||
public enum PIStoreError: Error { // 错误回调枚举
|
||||
enum PIStoreError: Error {
|
||||
|
||||
|
||||
// 错误回调枚举
|
||||
case failedVerification
|
||||
case noProduct
|
||||
|
||||
}
|
||||
|
||||
public enum StoreState: Int64 { // 支付状态
|
||||
@objc public enum StoreState: Int64 { // 支付状态
|
||||
case start // 开始
|
||||
case pay // 进行苹果支付
|
||||
case verifiedServer // 服务器校验
|
||||
@@ -37,15 +41,15 @@ public enum StoreState: Int64 { // 支付状态
|
||||
|
||||
@available(iOS 15.0, *)
|
||||
public class PIIAPPayment: NSObject {
|
||||
typealias KStateBlock = (_ state :StoreState,_ param:Dictionary<String,Any>?) ->()
|
||||
var stateBlock: KStateBlock! // 状态回调
|
||||
public typealias KStateBlock = (_ state :StoreState,_ param:Dictionary<String,Any>?) ->()
|
||||
@objc public var stateBlock: KStateBlock! // 状态回调
|
||||
|
||||
var updateListenerTask: Task<Void, Error>? = nil // 支付事件监听
|
||||
|
||||
var transactionMap :[String:Transaction] // 用于完成Id的缓存map
|
||||
|
||||
var name: String = "iosStore" // 单例的写法
|
||||
|
||||
|
||||
@objc public static let shared = {
|
||||
let instance = PIIAPPayment()
|
||||
return instance
|
||||
@@ -62,19 +66,44 @@ public class PIIAPPayment: NSObject {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 退订
|
||||
func refunRequest(for transactionId: UInt64, scene: UIWindowScene) async{
|
||||
@objc public func refunRequest(view: UIView,transactionId:UInt64) async{
|
||||
do {
|
||||
try await Transaction.beginRefundRequest(for: transactionId, in: scene)
|
||||
|
||||
if let scene = await view.window?.windowScene{
|
||||
try await Transaction.beginRefundRequest(for:transactionId , in: scene)
|
||||
}
|
||||
|
||||
}catch{
|
||||
print("iap error")
|
||||
}
|
||||
}
|
||||
/*All transactions:全部的购买交易订单
|
||||
Latest transactions:最新的购买交易订单。(分为订阅品项和除订阅品项外的所有类型二种)
|
||||
Current entitlements:当前用户有购买的权限。(全部的订阅品项、和非消耗品项)
|
||||
*/
|
||||
func allTransaction() async -> [UInt64] {
|
||||
var all = [UInt64]()
|
||||
|
||||
for await result in Transaction.all {
|
||||
do {
|
||||
let tran = try checkVerified(result)
|
||||
let transactionId = try result.payloadValue.id
|
||||
all.append(transactionId)
|
||||
|
||||
} catch let error {
|
||||
|
||||
print("error:----\(error)")
|
||||
}
|
||||
|
||||
}
|
||||
return all
|
||||
|
||||
//Transaction.latest(for: "pid")
|
||||
|
||||
}
|
||||
// 购买某个产品
|
||||
func requestBuyProduct(productId:String,_ uuid: String) async throws -> Transaction?{
|
||||
@objc public func requestBuyProduct(productId:String, uuid: String) async throws {
|
||||
if(stateBlock != nil ){
|
||||
stateBlock(StoreState.start,nil)
|
||||
}
|
||||
@@ -83,7 +112,7 @@ public class PIIAPPayment: NSObject {
|
||||
let storeProducts = try await Product.products(for: Set.init(list))
|
||||
|
||||
if storeProducts.count > 0 {
|
||||
return try await purchase(storeProducts[0],uuid)
|
||||
try await purchase(storeProducts[0],uuid)
|
||||
}else {
|
||||
print("iap: no found product")
|
||||
if(stateBlock != nil ){
|
||||
@@ -105,7 +134,15 @@ public class PIIAPPayment: NSObject {
|
||||
if(stateBlock != nil ){
|
||||
stateBlock(StoreState.pay,nil)
|
||||
}
|
||||
let getUUID = Product.PurchaseOption.appAccountToken(UUID.init(uuidString: uuid)!)
|
||||
|
||||
guard let curUUID = UUID.init(uuidString: uuid) else{
|
||||
|
||||
if(stateBlock != nil ){
|
||||
stateBlock(StoreState.failedVerification,nil)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
let getUUID = Product.PurchaseOption.appAccountToken(curUUID)
|
||||
let result = try await product.purchase(options: [getUUID])
|
||||
|
||||
switch result {
|
||||
@@ -162,16 +199,17 @@ public class PIIAPPayment: NSObject {
|
||||
await uploadServer(for: transactionId)
|
||||
|
||||
// 这里不触发完成,等服务器验证再触发完成逻辑
|
||||
// await transaction.finish()
|
||||
await transaction.finish()
|
||||
print("iap: finish")
|
||||
return transaction
|
||||
}
|
||||
|
||||
// 事件完成处理
|
||||
|
||||
func transactionFinish(transaction:String) async{
|
||||
@objc public func transactionFinish(transaction:String) async{
|
||||
if(transactionMap[transaction] != nil){
|
||||
await transactionMap[transaction]!.finish()
|
||||
transactionMap.removeValue(forKey: transaction)
|
||||
print("transactionFinish end")
|
||||
}else {
|
||||
print("transaction不存在,参数不正确,Id=\(transaction)")
|
||||
|
@@ -118,7 +118,11 @@ static NSString *_from = nil;
|
||||
&& ![from isEqualToString:@""]) {
|
||||
_from = from;
|
||||
} else {
|
||||
_from = @"appstore"; // App Store包
|
||||
if (isEnterprise == NO) {
|
||||
_from = @"piko_Enterprise"; // 企业包
|
||||
}else {
|
||||
_from = @"appstore"; // App Store包
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -513,6 +513,7 @@
|
||||
"XPIAPRechargeViewController5" = "如有任何问题请咨询客服,Piko号";
|
||||
"XPIAPRechargeViewController6" = "我的账户";
|
||||
"XPIAPRechargeViewController7" = "未成年禁止充值消费!请勿轻易相信各类刷单、 退款等信息,以免上当受骗";
|
||||
"XPIAPRechargeViewController8" = "储值失败。当前仅支持运行iOS15及以上系统的手机进行储值,请升级系统版本后重试。";
|
||||
|
||||
"XPMineRechargeViewController0" = "购买失败";
|
||||
"XPMineRechargeViewController1" = "出现未知错误,请重新尝试";
|
||||
|
@@ -521,6 +521,7 @@
|
||||
"XPIAPRechargeViewController5" = "如有任何問題請咨詢客服,Piko號";
|
||||
"XPIAPRechargeViewController6" = "我的賬戶";
|
||||
"XPIAPRechargeViewController7" = "未成年禁止充值消費!請勿輕易相信各類刷單、 退款等信息,以免上當受騙";
|
||||
"XPIAPRechargeViewController8" = "儲值失敗。當前僅支持運行iOS15及以上系統的手機進行儲值,請升級系統版本後重試。";
|
||||
|
||||
"XPMineRechargeViewController0" = "購買失敗";
|
||||
"XPMineRechargeViewController1" = "出現未知錯誤,請重新嘗試";
|
||||
|
Reference in New Issue
Block a user