In the App Purchase sandbox my login / pass is not requested

We are developing an application that (in turn) is used when purchasing applications (IAP). I did everything in the manual to enable iap, and everything works fine until I want to make a purchase.
Some of the code:

MainViewController.m

-(void)viewDidLoad { if ([SKPaymentQueue canMakePayments]) { MyStoreObserver *observer = [[MyStoreObserver alloc] init]; [[SKPaymentQueue defaultQueue] addTransactionObserver:observer]; SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObjects: @"com.company.app.product1", @"com.company.app.product1", nil]]; request.delegate = self; [request start]; } }; -(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response { for (SKProduct *prod in response.products) { NSLog(@"%@ (%@)", prod.localizedTitle, prod.price); } [request release]; }; -(IBAction)clickBuy:(UIButton *)__sender { SKPayment *payment = [SKPayment paymentWithProductIdentifier:@"com.company.app.product1"]; [[SKPaymentQueue defaultQueue] addPayment:payment]; }; 

MyStoreObserver.m

  - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions { for (SKPaymentTransaction *transaction in transactions) { switch (transaction.transactionState) { case SKPaymentTransactionStatePurchased: NSLog(@"SKPaymentTransactionStatePurchased"); break; case SKPaymentTransactionStateFailed: NSLog(@"SKPaymentTransactionStateFailed"); break; case SKPaymentTransactionStateRestored: NSLog(@"SKPaymentTransactionStateRestored"); break; case SKPaymentTransactionStatePurchasing: NSLog(@"SKPaymentTransactionStatePurchasing"); default: break; } } }; 

Delegate method productRequest: shows 2 products with their name / price. How I entered the iTunes connect site.

But as soon as I click the Buy button, a dialog box does not appear or does not ask for my credentials. Only "SKPaymentTransactionStatePurchasing" is recorded.

And I:
-... left in the settings panel / store
-... I use the right training profiles
-... desperately

Is anyone

+4
source share
5 answers

I ran into a similar problem, but my option was rather a shrill move on my part. I "reorganized" the finishTransaction call finishTransaction that it is called for each state in transactionState :

 - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions { for (SKPaymentTransaction *transaction in transactions) { switch (transaction.transactionState) { case SKPaymentTransactionStatePurchased: // do stuff break; case SKPaymentTransactionStateFailed: // do stuff break; case SKPaymentTransactionStateRestored: // do stuff break; default: break; } [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; } } 

Turns off ™, it will also cause finishTransaction on SKPaymentTransactionStatePurchasing , which will lead to failure. Moving finishTransaction back into each case of the switch statement is fixed.

+12
source

After I pulled out my hair with a disorder with a similar problem (instead of not asking for my credentials, it automatically filled in the email address without the ability to change it even after leaving the store in the settings application). I found that I had an unsuccessful transaction stuck in the queue from the development assembly on the same device, I had to clear all the transactions in the queue on the device, and then try to check again.

 NSArray *transactions = [[SKPaymentQueue defaultQueue] transactions]; for(id transaction in transactions){ [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; } 

I connected this code before IBOutlet and after launch it worked when my purchases in the application worked.

+4
source

IPhone may have limited access to the Apple App Store . For example, parents may limit their children's ability to purchase additional content.

Before you make a transaction, make sure you can buy it or not? Check it out like this:

  -(IBAction)clickBuy:(UIButton *)__sender { if ([SKPaymentQueue canMakePayments]) { SKPayment *payment = [SKPayment paymentWithProductIdentifier:@"Product_id"]; [[SKPaymentQueue defaultQueue] addPayment:payment]; } else { //show appropriate message } } 
+2
source

I also pulled a little hair. Turns off a simple reboot of the test device, and everything works fine.

+2
source

Are you testing iPhone / iPad Simulator 4.2 or something like that? This can be a problem. Testing on iPhone / iPad Simulator 5.0 or the device will work correctly with the storage.

0
source

Source: https://habr.com/ru/post/1391636/


All Articles