Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8843641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:16:47+00:00 2026-06-14T11:16:47+00:00

Pretty long question but easy to understand so please take a minute :) A

  • 0

Pretty long question but easy to understand so please take a minute 🙂

A few weeks ago I created a shop page for my app. I was new to the in-app purchases and got some code of the net. This was made for 1 object so I decided to edit the code to my own needs. one purchase for the pro version of the app and 3 purchases for 3 different amount of coins.

When I buy coins it works fine the only problem is that the second time I buy it will add 2x the amount of coins I bought, the third time it will add 3x the amount of coins I bought etc. I hope someone can take a look at my code and tell me whats wrong. For this topic I’ve made the code a little smaller and will not show all purchases.

//the 100 coins button
-(IBAction)savedata100:(id)sender {
        askToPurchase100Munten = [[UIAlertView alloc] 
                         initWithTitle:@"100 Munten" 
                         message:@"Ga verder om 100 Munten te kopen."
                         delegate:self 
                         cancelButtonTitle:nil
                         otherButtonTitles:@"Verder", @"Cancel", nil]; 
        askToPurchase100Munten.delegate = self;
        [askToPurchase100Munten show];
        [askToPurchase100Munten release];

//the next step

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

else if (alertView==askToPurchase100Munten) {
    if (buttonIndex==0) {
        // user tapped YES, but we need to check if IAP is enabled or not.
        if ([SKPaymentQueue canMakePayments]) { 

            SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:@"100Munten"]];  

            Temp = 2;
            request.delegate = self;  
            [request start];  

        } else {
            UIAlertView *tmp = [[UIAlertView alloc] 
                                initWithTitle:@"Prohibited" 
                                message:@"Parental Control is enabled, cannot make a purchase!"
                                delegate:self 
                                cancelButtonTitle:nil 
                                otherButtonTitles:@"Ok", nil]; 
            [tmp show];
            [tmp release];
        }
    }
}

//the next step

-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:    (SKProductsResponse *)response  
{ 
statusLabel.text = @"";
int count = [response.products count];
}
if (Temp == 2){
    if (count>0) {

        SKProduct *selectedProduct = [response.products objectAtIndex:0];
        SKPayment *payment = [SKPayment paymentWithProduct:selectedProduct];
        [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
        [[SKPaymentQueue defaultQueue] addPayment:payment];


    } else {
        UIAlertView *tmp = [[UIAlertView alloc] 
                            initWithTitle:@"Not Available" 
                            message:@"No products to purchase"
                            delegate:self 
                            cancelButtonTitle:nil 
                            otherButtonTitles:@"Ok", nil]; 
        [tmp show];
        [tmp release];
    }
}

//the last step this is what is being called more and more times every time I do it (the uiView also pops up more times)

-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
    switch (transaction.transactionState) {
        case SKPaymentTransactionStatePurchasing:

            // show wait view here
            statusLabel.text = @"Verwerken...";
            break;

        case SKPaymentTransactionStatePurchased:

            [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
            // remove wait view and unlock feature 2

            statusLabel.text = @"Klaar!";

            if (Temp == 2){
                //ADD COINS WHEN PURCHASES IS COMPLETE
                int coinsToAdd = 100;
                 int currentCoins = [[NSUserDefaults standardUserDefaults] integerForKey:@"savedstring"];
                 int savestring =
                 currentCoins + coinsToAdd;
                 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setInteger:savestring forKey:@"savedstring"]; [defaults synchronize];
                 [label111 setText:[NSString stringWithFormat:@"Munten: %i",[self getCoins]]];

                //ALERTVIEW TO SHOW YOU PURCHASED COINS
                UIAlertView *tmp2 = [[UIAlertView alloc]
                                    initWithTitle:@"Voltooid" 
                                    message:@"Je hebt 100 Munten Gekocht"
                                    delegate:self 
                                    cancelButtonTitle:nil 
                                    otherButtonTitles:@"Ok", nil]; 
                [tmp2 show];
                [tmp2 release];

Thanks for reading hope someone can help me out 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:16:48+00:00Added an answer on June 14, 2026 at 11:16 am

    Once you made a transaction you should set transaction.transactionState to SKPaymentTransactionStatePurchased, otherwise you will repeat the transaction the next time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question seems subjective but it's really pretty simple. As a long
Hey guys sorry this is a pretty long question but I cannot call printPASSInfo()
I have a text file that is pretty long. Any easy way to undo
The title is a bit long, but it should be pretty straightforward for someone
Not sure how you'll take this question but... Whenever I try to make my
My question's pretty basic, but it's been a while. I'm reading in a text
This is going to be a pretty long question, so bear with me. I'm
This is a pretty simple question but I can't seem to find an answer.
i am pretty sure this is a simple question for a long time c++
This may sound like a SuperUser issue, but I wrote the page in question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.