Giter Site home page Giter Site logo

vendor's Introduction

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).

vendor's People

Contributors

holgersindbaek avatar hayesmp avatar

Stargazers

Agusti Fernandez avatar Angus H. avatar Tay avatar Will Jessop avatar Pooyan Khosravi avatar Julias Shaw avatar Gerard Niemira avatar Chris Edwards avatar Evgeny Erohin avatar Ivan Lisovyi avatar Rob Worley avatar  avatar  avatar Bill Gloff avatar Satoshi Namai avatar Mark Rickert avatar Libin Pan avatar

Watchers

Mark Rickert avatar James Cloos avatar

vendor's Issues

After complete the buy

Objective-C stub for message verifyTransactionReceipt:password:success:failure:' type v@:@@@?@?' not precompiled. Make sure you properly link with the framework or library that defines this message.
Process 1200 exited with status = 0 (0x00000000) Terminated due to signal 6

EXC_BAD_ACCESS on device

So I'm trying to get this up and running on a device and I'm running into an EXC_BAD_ACCESS error when running in debug mode (it just stops with no error message when not in debug mode). Any idea about what's going on here?

$ rake device debug=1

  packet: QSetEnableAsyncProfiling;enable:1;interval_usec:1000000;scan_type:0xfffffeff;
response: OK
Process 0 connected
Executing commands in '/var/folders/v7/vrn4z9cs6ml0q2817kx3vrnh0000gn/T/_deploylldbcmds'.
(lldb)  command script import /var/folders/v7/vrn4z9cs6ml0q2817kx3vrnh0000gn/T/_deploylldbcmds.py
Process 194 stopped
* thread #1: tid = 0x14c7, 0x2bea9028 dyld`_dyld_start, stop reason = signal SIGSTOP
    frame #0: 0x2bea9028 dyld`_dyld_start
dyld`_dyld_start:
-> 0x2bea9028:  mov    r8, sp
   0x2bea902c:  sub    sp, sp, #0x10
   0x2bea9030:  bic    sp, sp, #0x7
   0x2bea9034:  ldr    r3, [pc, #112]            ; _dyld_start + 132
(lldb) c
Process 194 resuming
"Starting IAP"
2014-06-30 21:25:05.292 MYApp[194:60b] Starting purchase process.
Process 194 stopped
* thread #1: tid = 0x14c7, 0x3a2b5622 libobjc.A.dylib`objc_msgSend + 2, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x4)
    frame #0: 0x3a2b5622 libobjc.A.dylib`objc_msgSend + 2
libobjc.A.dylib`objc_msgSend + 2:
-> 0x3a2b5622:  ldr.w  r9, [r0]
   0x3a2b5626:  ldrh.w r12, [r9, #12]
   0x3a2b562a:  ldr.w  r9, [r9, #8]
   0x3a2b562e:  and.w  r12, r12, r1

Can't get the gem to be recognized in the project

application_settings_controller.rb:53:in `viewDidLoad': uninitialized constant ApplicationSettingsController::Vendor (NameError)`
source 'https://rubygems.org'
gem 'bubble-wrap'
gem 'motion-testflight'
gem 'cocoapods'
gem 'motion-cocoapods'
gem 'rm_vendor'
class ApplicationSettingsController < UIViewController

    def viewDidLoad
        super
        @month_sync = Vendor::Product.new(:name => "month_sync", :id => "com.kanban2go.sync.month")
        @year_sync = Vendor::Product.new(:name => "year_sync", :id => "com.kanban2go.sync.year")

        return self
      end
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.