v2支付优化
This commit is contained in:
@@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// 充值成功二次验证
|
||||
/// @param orderId 订单编号
|
||||
/// @param transcationId 商品id
|
||||
- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId;
|
||||
- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId errorToast:(BOOL)errorToast;
|
||||
|
||||
/// 批量验证内购掉单
|
||||
/// @param transcations 凭据的数组
|
||||
|
@@ -61,14 +61,14 @@
|
||||
/// 充值成功二次验证
|
||||
/// @param orderId 订单编号
|
||||
/// @param transcationId 商品id
|
||||
- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId {
|
||||
- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId errorToast:(BOOL)errorToast{
|
||||
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]checkReceiptFailWithCode:code transcationId:transcationId];
|
||||
} showLoading:NO errorToast:NO] chooseEnv:@"true" chargeRecordId:orderId transcationId:transcationId uid:uid ticket:ticket];
|
||||
} showLoading:NO errorToast:errorToast] chooseEnv:@"true" chargeRecordId:orderId transcationId:transcationId uid:uid ticket:ticket];
|
||||
}
|
||||
|
||||
|
||||
|
@@ -27,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// 充值成功二次验证
|
||||
/// @param orderId 订单编号
|
||||
/// @param transcationId 商品id
|
||||
- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId;
|
||||
- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId errorToast:(BOOL)errorToast;
|
||||
|
||||
/// 批量验证内购掉单
|
||||
/// @param transcations 凭据的数组
|
||||
|
@@ -69,14 +69,14 @@
|
||||
|
||||
/// @param orderId 订单编号
|
||||
/// @param transcationId 商品id
|
||||
- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId {
|
||||
- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId errorToast:(BOOL)errorToast{
|
||||
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] chooseEnv:@"true" chargeRecordId:orderId transcationId:transcationId uid:uid ticket:ticket];
|
||||
} showLoading:YES errorToast:errorToast] chooseEnv:@"true" chargeRecordId:orderId transcationId:transcationId uid:uid ticket:ticket];
|
||||
}
|
||||
|
||||
/// 批量验证内购掉单
|
||||
|
@@ -242,7 +242,7 @@
|
||||
NSString *orderId = transcation[@"orderId"];
|
||||
NSString *transcationId = transcation[@"transcationId"];
|
||||
///二次验证
|
||||
[self.presenter checkReceiptWithOrderId:orderId transcationId:transcationId];
|
||||
[self.presenter checkReceiptWithOrderId:orderId transcationId:transcationId errorToast:NO];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,6 +340,12 @@
|
||||
///二次校验成功
|
||||
- (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.orderId = nil;
|
||||
//5秒之后如果没有收到开通成功的云信消息,则请求一次用户信息
|
||||
@@ -353,6 +359,12 @@
|
||||
- (void)checkReceiptFailWithCode:(NSInteger)code transcationId:(NSString *)transcationId{
|
||||
[self hideHUD];
|
||||
if(code == 1444){
|
||||
if (@available(iOS 15.0, *)) {
|
||||
PIIAPPayment *iap = [PIIAPPayment shared];
|
||||
[iap transactionFinishWithTransaction:[NSString stringWithFormat:@"%@",transcationId] completionHandler:^{
|
||||
|
||||
}];
|
||||
}
|
||||
[self deleteRechageReciptWithTransactionIdentifier:transcationId];
|
||||
}
|
||||
}
|
||||
@@ -394,7 +406,7 @@
|
||||
[self saveRechageReciptWithTransactionIdentifier:transactionIdentifier];
|
||||
[self showLoading];
|
||||
///二次验证
|
||||
[self.presenter checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier];
|
||||
[self.presenter checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier errorToast:YES];
|
||||
}
|
||||
|
||||
///充值成功之后保存订单到钥匙串
|
||||
|
@@ -224,7 +224,7 @@
|
||||
NSString *orderId = transcation[@"orderId"];
|
||||
NSString *transcationId = transcation[@"transcationId"];
|
||||
///二次验证
|
||||
[self.presenter checkReceiptWithOrderId:orderId transcationId:transcationId];
|
||||
[self.presenter checkReceiptWithOrderId:orderId transcationId:transcationId errorToast:NO];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -279,7 +279,7 @@
|
||||
[self saveRechageReciptWithTransactionIdentifier:transactionIdentifier];
|
||||
[self showLoading];
|
||||
///二次验证
|
||||
[self.presenter checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier];
|
||||
[self.presenter checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier errorToast:YES];
|
||||
|
||||
}
|
||||
|
||||
@@ -364,6 +364,12 @@
|
||||
-(void)checkReceiptFailWithCode:(NSInteger)code transcationId:(NSString *)transcationId{
|
||||
[self hideHUD];
|
||||
if(code == 1444){
|
||||
if (@available(iOS 15.0, *)) {
|
||||
PIIAPPayment *iap = [PIIAPPayment shared];
|
||||
[iap transactionFinishWithTransaction:[NSString stringWithFormat:@"%@",transcationId] completionHandler:^{
|
||||
|
||||
}];
|
||||
}
|
||||
[self deleteRechageReciptWithTransactionIdentifier:transcationId];
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,8 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPRoomAnimationView : XPRoomAnimationHitView <RoomGuestDelegate>
|
||||
|
||||
-(void)resumeTimer;
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate;
|
||||
@end
|
||||
|
||||
|
@@ -153,6 +153,9 @@
|
||||
- (void)dealloc {
|
||||
[NSObject cancelPreviousPerformRequestsWithTarget:self];
|
||||
[[NIMSDK sharedSDK].broadcastManager removeDelegate:self];
|
||||
|
||||
}
|
||||
-(void)resumeTimer{
|
||||
if(self.giftEffectTimer != nil){
|
||||
dispatch_resume(self.giftEffectTimer);
|
||||
self.giftEffectTimer = nil;
|
||||
@@ -163,7 +166,6 @@
|
||||
self.giftTimer = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
|
@@ -346,7 +346,7 @@
|
||||
///保存唯一凭证
|
||||
[self saveRechageReciptWithTransactionIdentifier:transactionIdentifier];
|
||||
///二次验证
|
||||
[self checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier];
|
||||
[self checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier errorToast:YES];
|
||||
}
|
||||
|
||||
///充值成功之后保存订单到钥匙串
|
||||
@@ -400,11 +400,11 @@
|
||||
NSString *orderId = transcation[@"orderId"];
|
||||
NSString *transcationId = transcation[@"transcationId"];
|
||||
///二次验证
|
||||
[self checkReceiptWithOrderId:orderId transcationId:transcationId];
|
||||
[self checkReceiptWithOrderId:orderId transcationId:transcationId errorToast:NO] ;
|
||||
}
|
||||
|
||||
}
|
||||
- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId {
|
||||
- (void)checkReceiptWithOrderId:(NSString *)orderId transcationId:(NSString *)transcationId errorToast:(BOOL)errorToast{
|
||||
NSString * uid = [AccountInfoStorage instance].getUid;
|
||||
NSString * ticket = [AccountInfoStorage instance].getTicket;
|
||||
|
||||
@@ -414,9 +414,18 @@
|
||||
[self checkReceiptSuccess:transcationId];
|
||||
} else {
|
||||
if(code == 1444){
|
||||
if (@available(iOS 15.0, *)) {
|
||||
PIIAPPayment *iap = [PIIAPPayment shared];
|
||||
[iap transactionFinishWithTransaction:[NSString stringWithFormat:@"%@",transcationId] completionHandler:^{
|
||||
|
||||
}];
|
||||
}
|
||||
[self deleteRechageReciptWithTransactionIdentifier:transcationId];
|
||||
}
|
||||
[XNDJTDDLoadingTool showErrorWithMessage:msg];
|
||||
if(errorToast == YES){
|
||||
[XNDJTDDLoadingTool showErrorWithMessage:msg];
|
||||
}
|
||||
|
||||
}
|
||||
[XNDJTDDLoadingTool hideHUD];
|
||||
} chooseEnv:@"true" chargeRecordId:orderId transcationId:transcationId uid:uid ticket:ticket];
|
||||
@@ -425,7 +434,12 @@
|
||||
|
||||
///二次验证成功
|
||||
- (void)checkReceiptSuccess:(NSString *)transcationId {
|
||||
|
||||
if (@available(iOS 15.0, *)) {
|
||||
PIIAPPayment *iap = [PIIAPPayment shared];
|
||||
[iap transactionFinishWithTransaction:[NSString stringWithFormat:@"%@",transcationId] completionHandler:^{
|
||||
|
||||
}];
|
||||
}
|
||||
[self deleteRechageReciptWithTransactionIdentifier:transcationId];
|
||||
self.orderId = nil;
|
||||
}
|
||||
|
@@ -1433,6 +1433,7 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出
|
||||
|
||||
- (void)exitRoom {
|
||||
[self.menuContainerView menuResignFirstResponder];
|
||||
[self.animationView resumeTimer];
|
||||
if (self.roomInfo.roomModeType == RoomModeType_Open_Micro_Mode || self.roomInfo.roomModeType == RoomModeType_Open_Blind) {
|
||||
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid];
|
||||
NSString * uid = [AccountInfoStorage instance].getUid;
|
||||
|
@@ -79,11 +79,9 @@ static NSString * kUpdateVersionNum = @"kUpdateVersionNum";
|
||||
[Api checkReceipt:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
if (code == 200) {
|
||||
NSString * uid = [AccountInfoStorage instance].getUid;
|
||||
[RechargeStorage delegateAllTranscationIdsWithUid:uid];
|
||||
} else {
|
||||
[XNDJTDDLoadingTool showErrorWithMessage:msg];
|
||||
[RechargeStorage delegateTranscationId:transcationId uid:uid];
|
||||
}
|
||||
[XNDJTDDLoadingTool hideHUD];
|
||||
|
||||
} chooseEnv:@"true" chargeRecordId:orderId transcationId:transcationId uid:uid ticket:ticket];
|
||||
}
|
||||
|
||||
|
@@ -78,39 +78,8 @@ public class PIIAPPayment: NSObject {
|
||||
print("iap error")
|
||||
}
|
||||
}
|
||||
/*All transactions:全部的购买交易订单
|
||||
Latest transactions:最新的购买交易订单。(分为订阅品项和除订阅品项外的所有类型二种)
|
||||
Current entitlements:当前用户有购买的权限。(全部的订阅品项、和非消耗品项)
|
||||
*/
|
||||
@objc public func allTransaction(list:[NSString]) async {
|
||||
// var getList:[String] = [];
|
||||
// for i in 0..<list.count{
|
||||
// let str = list[i];
|
||||
// getList.append(String(str))
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// for await result in Transaction.all {
|
||||
// do {
|
||||
// let transactionId = try result.payloadValue.id
|
||||
// let tran = try checkVerified(result)
|
||||
// if !getList.contains(String(transactionId)){
|
||||
// await tran.finish()
|
||||
// }
|
||||
//
|
||||
//
|
||||
// } catch let error {
|
||||
//
|
||||
// print("error:----\(error)")
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
//Transaction.latest(for: "pid")
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 购买某个产品
|
||||
@objc public func requestBuyProduct(productId:String, uuid: String) async throws {
|
||||
if(stateBlock != nil ){
|
||||
@@ -120,6 +89,9 @@ public class PIIAPPayment: NSObject {
|
||||
let list:[String] = [productId]
|
||||
let storeProducts = try await Product.products(for: Set.init(list))
|
||||
|
||||
|
||||
|
||||
|
||||
if storeProducts.count > 0 {
|
||||
try await purchase(storeProducts[0],uuid)
|
||||
}else {
|
||||
@@ -143,7 +115,7 @@ public class PIIAPPayment: NSObject {
|
||||
if(stateBlock != nil ){
|
||||
stateBlock(StoreState.pay,nil)
|
||||
}
|
||||
|
||||
|
||||
guard let curUUID = UUID.init(uuidString: uuid) else{
|
||||
|
||||
if(stateBlock != nil ){
|
||||
@@ -207,11 +179,37 @@ public class PIIAPPayment: NSObject {
|
||||
await uploadServer(for: transactionId)
|
||||
|
||||
// 这里不触发完成,等服务器验证再触发完成逻辑
|
||||
// await transaction.finish()
|
||||
await transaction.finish()
|
||||
|
||||
print("iap: finish")
|
||||
return transaction
|
||||
}
|
||||
|
||||
/*All transactions:全部的购买交易订单
|
||||
Latest transactions:最新的购买交易订单。(分为订阅品项和除订阅品项外的所有类型二种)
|
||||
Current entitlements:当前用户有购买的权限。(全部的订阅品项、和非消耗品项)
|
||||
*/
|
||||
func allTransaction(transactionId:String) async {
|
||||
|
||||
let transactionIntId = UInt64(transactionId)
|
||||
for await result in Transaction.all {
|
||||
do {
|
||||
let tran = try checkVerified(result)
|
||||
let resultId = try result.payloadValue.id
|
||||
if transactionIntId == resultId {
|
||||
await tran.finish()
|
||||
break
|
||||
}
|
||||
} catch let error {
|
||||
|
||||
print("error:----\(error)")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Transaction.latest(for: "pid")
|
||||
|
||||
}
|
||||
// 事件完成处理
|
||||
|
||||
@objc public func transactionFinish(transaction:String) async{
|
||||
@@ -220,7 +218,7 @@ public class PIIAPPayment: NSObject {
|
||||
transactionMap.removeValue(forKey: transaction)
|
||||
print("transactionFinish end")
|
||||
}else {
|
||||
print("transaction不存在,参数不正确,Id=\(transaction)")
|
||||
await allTransaction(transactionId: transaction)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user