Closed joshuapinter closed 8 years ago
that's just how apple designed their sdk. I don't know if we can do anything here.
@chirag04 Not really, though, right? Can't we just remove that cache you've created involving the products
variable and just call the purchase method with the specified product identifier?
Why do we need to load the products as a requirement for purchasing a product?
unless i'm mistaken there is no api for purchasing a product directly with a product identifier. you need to make a request to load it first.
loading product first can be useful in cases where you want to show the product price in local currency first.
Okay, I gotcha! Thanks again for all your help and creating this library. I'm well on my way now. :)
Just as a final thought, you could trigger a load of the products when somebody calls the purchaseProduct
and just use the product identifier that they supplied.
i would rather prefer that to be in the userland. if users want to load products automatically, they just write a wrapper function on top of purchase product that does it for them.
Fair enough man. Well, with the additional README hints, this should help clear things up for others. 👍
To @joshuapinter 's point, here's what we're doing:
export async function purchase(identifier) {
await loadProducts(identifier);
return purchaseProduct(identifier);
}
Be careful to check for loadProduct failures.
I have created a product with type being 'Non-consumable' and status 'Waiting for review'. I am trying to load the product, with the right indentifier, but the repsonse contains no products and just something like _invalidindentifers staff (get it from debugging windows). Does I mis-understanding some staff. I have been in this trap/trouble for one week.
You need to call
loadProducts
first and then callpurchaseProduct
either at a later time or in the callback forloadProducts
.At the very least the README should reflect this.
But, ideally,
purchaseProduct
should work without having to callloadProducts
first.Let me know your thoughts on this to make sure we're on the same page before I do a PR.