ios - Consumable In App Purchase Already Purchased -


i have added consumable in app purchase app. able purchase when try purchase again says have purchased download again. type consumable. going wrong? thanks

func purchasepoints(sender:anyobject) {     //purchase     buyconsumable()   }  func buyconsumable(){     print("about fetch products");     // check allow make purchase.     if (skpaymentqueue.canmakepayments())     {         var productid:nsset = nsset(object: "com.companyname.appname.coins");         var productsrequest:skproductsrequest = skproductsrequest(productidentifiers: productid as! set<string>);         productsrequest.delegate = self;         productsrequest.start();         print("fething products");     }else{         print("can not make purchases");     } }   func productsrequest (request: skproductsrequest, didreceiveresponse response: skproductsresponse) {     print("got request apple")     var count : int = response.products.count     if (count>0) {         var validproducts = response.products         var validproduct: skproduct = response.products[0] skproduct         if (validproduct.productidentifier == "com.companyname.appname.coins") {             print(validproduct.localizedtitle)             print(validproduct.localizeddescription)             print(validproduct.price)             buyproduct(validproduct);         } else {             print(validproduct.productidentifier)         }     } else {         print("nothing")     } }  func buyproduct(product: skproduct){     print("sending payment request apple");     var payment = skpayment(product: product)     skpaymentqueue.defaultqueue().addpayment(payment); }   func paymentqueue(queue: skpaymentqueue!, updatedtransactions transactions: [skpaymenttransaction]) {     print("received payment transaction response apple");      transaction:anyobject in transactions {          if let trans:skpaymenttransaction = transaction as? skpaymenttransaction{             switch trans.transactionstate {             case .purchased:                 print("product purchased");                 skpaymentqueue.defaultqueue().finishtransaction(transaction as! skpaymenttransaction)                 break;             case .failed:                 print("purchased failed");                 skpaymentqueue.defaultqueue().finishtransaction(transaction as! skpaymenttransaction)                 break;                 // case .restored:                 //[self restoretransaction:transaction];             default:                 break;             }         }     } } 

did see messages in console log:

print("received payment transaction response apple"); 

and

print("product purchased"); 

or

print("purchased failed"); 

?

if not, seems did not add

skpaymentqueue.defaultqueue().addtransactionobserver(self) 

somewhere before adding payment queue. try add in buyconsumable method.

in according https://developer.apple.com/library/ios/documentation/networkinginternet/conceptual/storekitguide/chapters/deliverproduct.html

try existing transaction, sure consumable.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -