Class: RubyNative::Generators::IapGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/ruby_native/iap_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



11
12
13
# File 'lib/generators/ruby_native/iap_generator.rb', line 11

def self.next_migration_number(dirname)
  Time.now.utc.strftime("%Y%m%d%H%M%S")
end

Instance Method Details

#copy_migrationObject



15
16
17
18
# File 'lib/generators/ruby_native/iap_generator.rb', line 15

def copy_migration
  migration_template "create_ruby_native_purchase_intents.rb",
    "db/migrate/create_ruby_native_purchase_intents.rb"
end


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/generators/ruby_native/iap_generator.rb', line 20

def print_next_steps
  say ""
  say "Ruby Native IAP installed!", :green
  say ""
  say "  1. Run migrations: bin/rails db:migrate"
  say "  2. Add your callback in config/initializers/ruby_native.rb:"
  say ""
  say '     RubyNative.on_subscription_change do |event|'
  say '       user = User.find_by(id: event.owner_token)'
  say '       user&.update!(subscribed: event.active?)'
  say '     end'
  say ""
  say "  3. Set your App Store Server Notification URL to:"
  say "     https://yourapp.com/native/webhooks/apple"
  say ""
end