iOS Development Buy-in Process

Posted by unbreakable9 on Tue, 04 Jun 2019 21:59:28 +0200

I. Submit information to appStore


First step

The second step

The third step


Finish Step 3 and remember to save


The fourth step

The fifth step

First click SetUp of Contact Info


The sixth step

The seventh step

Fill it out, save it, and go back to the previous page.


The eighth step

The ninth step

The tenth step

The eleventh step

The twelfth step


In the twelve steps, some banks may not be able to find it through Apple, so they need to use Baidu. They must check it accurately, otherwise they will have problems. I recommend an address here.
https://e.czbank.com/CORPORBANK/query_unionBank_index.jsp


Thirteenth Step


This step should be noted that the currency type may be ambiguous, depending on whether you want to accept the US dollar or RMB, they all say that the US dollar is appropriate. Nevertheless, in order to avoid things, I chose CNY to support domestic production. Also, if the bank account is a public account, you need to fill in the company's English name, if not, on the Pinyin! Then Click to save the bank information, and then go back to the original page.


The fourteenth step

The fifteenth step

The sixteenth step

The seventeenth step

The eighteenth step

The nineteenth step


It should be noted here that although this page seems to have a lot of information to fill in, in fact, many of them are useless. They are for what laws in the United States need to cooperate with. Generally, we don't need to do so. We just need to select the place to check out and submit it it.


The twentieth step

Step 20

Step 22

II. Creating a Buy-in Project


First step

The second step


Choose the type according to the needs of your app, write in detail, let's not say much.


The third step

The fourth step

The fifth step

The sixth step

3. Adding in-project purchase test account


First step

The second step

Fourth, do not talk too much nonsense, on the code

The first step is to import the StoreKit.framework Library
Then look at the. h file first.

#import <StoreKit/StoreKit.h>
enum{IAP0p20=20,
IAP1p100,
IAP4p600,
IAP9p1000,
IAP24p6000,}
buyCoinsTag;

//Agent@interface RechargeVC: UIViewController < SKPayment Transaction Observer, SKProduct Request Delegate >
{
int buyType;
}

- (void) requestProUpgradeProductData;

-(void)RequestProductData;

-(void)buy:(int)type;

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions;

-(void) PurchasedTransaction: (SKPaymentTransaction *)transaction;

- (void) completeTransaction: (SKPaymentTransaction *)transaction;

- (void) failedTransaction: (SKPaymentTransaction *)transaction;

-(void) paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentTransaction *)transaction;

-(void) paymentQueue:(SKPaymentQueue *) paymentQueue restoreCompletedTransactionsFailedWithError:(NSError *)error;

- (void) restoreTransaction: (SKPaymentTransaction *)transaction;-(void)provideContent:(NSString *)product;

-(void)recordTransaction:(NSString *)product;

@end

Then look at the. m file.

#import "RechargeVC.h"

//Merchandise List Number Created in Internal Purchase Project
#define ProductID_IAP0p20 @"Nada.JPYF01"//20
#define ProductID_IAP1p100 @"Nada.JPYF02" //100
#define ProductID_IAP4p600 @"Nada.JPYF03" //600
#define ProductID_IAP9p1000 @"Nada.JPYF04" //1000
#define ProductID_IAP24p6000 @"Nada.JPYF05" //6000

@interface RechargeVC ()

@end

@implementation RechargeVC

- (void)viewDidLoad { 

 [super viewDidLoad];
 [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
 [self buy:IAP0p20];

}

-(void)buy:(int)type{ 
  buyType = type; 
  if ([SKPaymentQueue canMakePayments]) {
   [self RequestProductData]; NSLog(@"Allow in-process payment for purchase");
  }else{ 
  NSLog(@"No in-process purchase allowed"); 
  UIAlertView *alerView = [[UIAlertView alloc] initWithTitle:@"Tips" message:@"Your mobile phone has not been opened for in-app payment" 
delegate:nil cancelButtonTitle:NSLocalizedString(@"Close",nil) otherButtonTitles:nil];
   [alerView show]; }
}

-(void)RequestProductData{

 NSLog(@"---------Request corresponding product information------------"); 
NSArray *product = nil; 
switch (buyType) 
{
   case IAP0p20: product=[[NSArray alloc] initWithObjects:ProductID_IAP0p20,nil];
   break;

   case IAP1p100: product=[[NSArray alloc] initWithObjects:ProductID_IAP1p100,nil];
   break; 

  case IAP4p600: product=[[NSArray alloc] initWithObjects:ProductID_IAP4p600,nil];
   break;

   case IAP9p1000: product=[[NSArray alloc] initWithObjects:ProductID_IAP9p1000,nil]; 
  break;

   case IAP24p6000: product=[[NSArray alloc] initWithObjects:ProductID_IAP24p6000,nil]; 
  break;

 default:
 break;
} 

NSSet *nsset = [NSSet setWithArray:product];
 SKProductsRequest *request=[[SKProductsRequest alloc] initWithProductIdentifiers: nsset];
 request.delegate=self; 

[request start];}

//<SKProduct Request Delegate> Request Protocol//Received Product Information
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{

  NSLog(@"-----------Receiving product feedback--------------"); 
  NSArray *myProduct = response.products;
  NSLog(@"product Product ID:%@",response.invalidProductIdentifiers);  
  NSLog(@"Product Payment Quantity: %d", (int)[myProduct count]); 

  // populate UI 
  for(SKProduct *product in myProduct){
  NSLog(@"product info"); 
  NSLog(@"SKProduct Descriptive information%@", [product description]); 
  NSLog(@"Product title %@" , product.localizedTitle);
  NSLog(@"Product Description Information: %@" , product.localizedDescription); 
  NSLog(@"Price: %@" , product.price);
  NSLog(@"Product id: %@" , product.productIdentifier);

}

 SKPayment *payment = nil; 
switch (buyType) {

 case IAP0p20: payment = [SKPayment paymentWithProductIdentifier:ProductID_IAP0p20]; //Payment 25 break; case 
IAP1p100: payment = [SKPayment paymentWithProductIdentifier:ProductID_IAP1p100]; //Payment 108 break; case 

IAP4p600: payment = [SKPayment paymentWithProductIdentifier:ProductID_IAP4p600]; //Payment 618 break; case 

IAP9p1000: payment = [SKPayment paymentWithProductIdentifier:ProductID_IAP9p1000]; //Payment 1048 break; 

case IAP24p6000: payment = [SKPayment 
paymentWithProductIdentifier:ProductID_IAP24p6000]; //Pay 5898 break; default: 
break;
} 
NSLog(@"---------Send Purchase Request------------");

 [[SKPaymentQueue defaultQueue] addPayment:payment];
}

- (void)requestProUpgradeProductData{

 NSLog(@"------Request upgrade data---------"); 

NSSet *productIdentifiers = [NSSet setWithObject:@"com.productid"];
 SKProductsRequest* productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers]; 
productsRequest.delegate = self; 
[productsRequest start];}

//Pop-up error message
- (void)request:(SKRequest *)request didFailWithError:(NSError *)error{ 

    NSLog(@"-------Pop-up error message----------"); 
    UIAlertView *alerView = [[UIAlertView alloc]initWithTitle:NSLocalizedString(@"Alert",NULL) message:[error localizedDescription] delegate:nil cancelButtonTitle:NSLocalizedString(@"Close",nil) otherButtonTitles:nil]; 
[alerView show];
}

-(void) requestDidFinish:(SKRequest *)request{

   NSLog(@"----------End of Feedback Information--------------");

}

-(void) PurchasedTransaction: (SKPaymentTransaction *)transaction{ 

  NSLog(@"-----PurchasedTransaction----");

   NSArray *transactions =[[NSArray alloc] initWithObjects:transaction, nil]; 
  [ self paymentQueue:[SKPaymentQueue defaultQueue] updatedTransactions:transactions];

}

//Don't forget to bind < SKPayment Transaction Observer > The code is as follows:
//Monitor purchase results
//[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions//Transaction results{

 NSLog(@"-----paymentQueue--------"); 

  for (SKPaymentTransaction *transaction in transactions) { 
  switch (transaction.transactionState) { 
  case SKPaymentTransactionStatePurchased:{
//Self Complete Transaction: transaction; 

  NSLog(@"-----Transaction completed --------");

 UIAlertView *alerView = [[UIAlertView alloc] initWithTitle:@"" message:@"Purchase success" delegate:nil cancelButtonTitle:NSLocalizedString(@"Close",nil) otherButtonTitles:nil];
   [alerView show]; 
} break;
 case SKPaymentTransactionStateFailed://Transaction failure 

{
 [self failedTransaction:transaction]; 
  NSLog(@"-----Transaction failure --------"); 
  UIAlertView *alerView2 = [[UIAlertView alloc] initWithTitle:@"Tips" message:@"Buying failed, please try again" delegate:nil cancelButtonTitle:NSLocalizedString(@"Close",nil) otherButtonTitles:nil]; 
  [alerView2 show]; 
}break;

case SKPaymentTransactionStateRestored://The product has been purchased [self restore Transaction: transaction];
   NSLog(@"-----It has been purchased. --------");
   case SKPaymentTransactionStatePurchasing: 
//Goods added to the list
 NSLog(@"-----Goods added to the list --------");
 break
; default: 
break;
       } 
    }
}

- (void) completeTransaction: (SKPaymentTransaction *)transaction{ 
  NSLog(@"-----completeTransaction--------"); 
  // Your application should implement these two methods. NSString *product = transaction.payment.productIdentifier; 
  if ([product length] > 0) { 
    NSArray *tt = [product componentsSeparatedByString:@"."]; 
    NSString *bookid = [tt lastObject];
 if ([bookid length] > 0) { 
  [self recordTransaction:bookid]; [self provideContent:bookid];}
} 
  // Remove the transaction from the payment queue. [[SKPaymentQueue   defaultQueue] finishTransaction: transaction];
}

//Record transactions
-(void)recordTransaction:(NSString *)product{
   NSLog(@"-----Record transactions--------");

}

//Processing Downloads
-(void)provideContent:(NSString *)product{ 
  NSLog(@"-----download--------");
}

- (void) failedTransaction: (SKPaymentTransaction *)transaction{ 
  NSLog(@"fail"); 
  if (transaction.error.code != SKErrorPaymentCancelled) { } 
  [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}

-(void) paymentQueueRestoreCompletedTransactionsFinished: (SKPaymentTransaction *)transaction{}- (void) restoreTransaction: (SKPaymentTransaction *)transaction{ 
  NSLog(@" Transaction Recovery Processing");
}

-(void) paymentQueue:(SKPaymentQueue *) paymentQueue restoreCompletedTransactionsFailedWithError:(NSError *)error{ 
  NSLog(@"-------paymentQueue----");
}

#pragma mark connection delegate
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{ 
  NSLog(@"%@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection{}- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{ switch([(NSHTTPURLResponse *)response statusCode]) {
  case 200:
  case 206: 
  break; 
  case 304: 
  break; 
  case 400: 
  break; 
  case 404:
  break; 
  case 416: 
  break; 
  case 403: 
  break; 
  case 401:
  case 500:
  break; 

default: 
break; 
}
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
   NSLog(@"test");
}

-(void)dealloc{ 
  [[SKPaymentQueue defaultQueue] removeTransactionObserver:self];
  //Release monitoring

}

@end

Epilogue

There are still many problems with Apple's internal purchase, or need to cooperate with the background more, for example, when purchasing, the default is the current logged-in Apple id payment, if you want to switch to other ids, there will be problems. There was no refund process, but now it can be refunded.

Brief Book Link: http://www.jianshu.com/p/d9d742e82188

Topics: JSP Mobile encoding