Project

rm_vendor

0.01
No commit activity in last 3 years
No release in over 3 years
A RubyMotion StoreKit Wrapper that allows you to buy, restore and get product info on your in app purchases and subscriptions
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

 Project Readme

Vendor

Installation

Add this line to your application's Gemfile:

gem 'rm_vendor'

And then execute:

$ bundle

Require in your rakefile:

require 'vendor'

Install pod dependencies:

$ rake pod:install

USAGE

Initialize.

Initialize your products with your In App Purchase ID. Vendor will check if the product exists and return it's attributes:

@products = Vendor::Products.new([{:name => "first_item", :id => "com.your.first_item.id"}, {:name => "second_item", :id => "com.your.second_item.id"}]) do |products|
  products.map{ |product| NSLog "Product exists?: #{product.success}" }
  products.map{ |product| NSLog "Product error: #{product.error}" }
  products.map{ |product| NSLog "Product response: #{product.response}" }
end

You don't need to pass along a block though. If you're sure your product exists, then you can just do this:

@products = Vendor::Products.new([{:name => "first_item", :id => "com.your.first_item.id"}, {:name => "second_item", :id => "com.your.second_item.id"}])

If you want to initialize your product with data such as price and description, you can do that as well:

@products = Vendor::Products.new([{:name => "first_item", :id => "com.your.first_item.id", :price => "0.99", :title ="Title of my first item", :description => "My first items description"}])

Get product info.

After you've initialized your product, you get its information:

@product[:first_item].price
@product[:first_item].title
@product[:first_item].description
@product[:first_item].bought?

Purchase product.

To purchase a product, simply do:

@product[:first_item].purchase do |product|
  p "Purchase successful: #{product.success}"
  p "Purchase transaction: #{product.transaction}"
end

And to restore it:

@product[:first_item].restore do |product|
  p "Restore successful: #{product.success}"
  p "Restore transaction: #{product.transaction}"
end

Subscriptions.

Vendor also works with subscriptions. To initialize a subscription:

@subscription_products = Vendor::Products.new([{:name => "subscription", :id => "com.your.subscription.id", :secret => "abcdefg12345", :subscription => true}]) do |subscriptions|
  subscriptions.map{ |subscription| NSLog "Subscription exists?: #{subscription.success}" }
  subscriptions.map{ |subscription| NSLog "Subscription error: #{subscription.error}" }
  subscriptions.map{ |subscription| NSLog "Subscription response: #{subscription.response}" }
end

To purchase a subscription:

@subscription_products[:subscription].purchase do |subscription|
  p "Subscription successful: #{subscription.success}"
  p "Subscription transaction: #{subscription.transaction}"
end

To see wether product is registered as a subscription and if user is currently subscribed:

@subscription_products[:subscription].subscribed?
@subscription_products[:subscription].subscription?

Example App.

You can find an example app inside this gem (inside the app folder).