From 4489f2fbc0777b15ffd1d7aa3658ec7023c2eea5 Mon Sep 17 00:00:00 2001 From: Marco Borromeo Date: Wed, 8 Jul 2015 00:41:11 +0200 Subject: [PATCH] Getting the product in case of Hash Not sure if this will fix issue #5, but surely does for me. If clicking "Cancel" while restoring purchases, products variable in the block is not an array but an Hash, so the .find won't work. Sorry for not very elegant solution, i was running for a quick win. --- lib/ProMotion/product.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ProMotion/product.rb b/lib/ProMotion/product.rb index 32536fa..cc615e3 100644 --- a/lib/ProMotion/product.rb +++ b/lib/ProMotion/product.rb @@ -20,8 +20,9 @@ def purchase(&callback) def restore(&callback) restore_iaps(product_id) do |status, products| - callback.call status, products.find{|p| p[:product_id] == product_id } + product = products.is_a?(Hash) ? products : products.find{|p| p[:product_id] == product_id } + callback.call status, product end end end -end \ No newline at end of file +end