Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #14 from clearsightstudio/bugfix/13
Browse files Browse the repository at this point in the history
shut down IAP when completed, canceled, or failed. Closes #13
  • Loading branch information
jamonholmgren committed Jul 22, 2015
2 parents eb16304 + c946f87 commit a4c3651
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/ProMotion/iap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ def transaction_product_id(transaction)
transaction.respond_to?(:payment) ? transaction.payment.productIdentifier : "all"
end

def transaction_complete?(transactions)
states = transactions.map(&:transactionState)
return true unless states.include?(SKPaymentTransactionStatePurchasing)
false
end

public

# SKProductsRequestDelegate methods
Expand Down Expand Up @@ -160,6 +166,7 @@ def paymentQueue(_, updatedTransactions:transactions)
end
end
end
iap_shutdown if transaction_complete?(transactions)
end

def paymentQueue(_, restoreCompletedTransactionsFailedWithError:error)
Expand Down

0 comments on commit a4c3651

Please sign in to comment.