module Spaceship::Tunes::IAPType

Defines the different in-app purchase product types

As specified by Apple: developer.apple.com/library/content/documentation/LanguagesUtilities/Conceptual/iTunesConnectInAppPurchase_Guide/Chapters/CreatingInAppPurchaseProducts.html

Constants

CONSUMABLE
NON_CONSUMABLE
NON_RENEW_SUBSCRIPTION
READABLE_AUTO_RENEWABLE_SUBSCRIPTION

A product that allows users to purchase dynamic content for a set period (auto-rene).

READABLE_CONSUMABLE

A product that is used once

READABLE_NON_CONSUMABLE

A product that is purchased once and does not expire or decrease with use.

READABLE_NON_RENEWING_SUBSCRIPTION

A product that allows users to purchase a service with a limited duration.

RECURRING

Public Class Methods

get_from_string(text) click to toggle source

Get the iap type matching based on a string (given by App Store Connect)

# File spaceship/lib/spaceship/tunes/iap_type.rb, line 25
def self.get_from_string(text)
  mapping = {
    'ITC.addons.type.consumable' => READABLE_CONSUMABLE,
    'ITC.addons.type.nonConsumable' => READABLE_NON_CONSUMABLE,
    'ITC.addons.type.recurring' => READABLE_AUTO_RENEWABLE_SUBSCRIPTION,
    'ITC.addons.type.subscription' => READABLE_NON_RENEWING_SUBSCRIPTION,
    'consumable' => READABLE_CONSUMABLE,
    'nonConsumable' => READABLE_NON_CONSUMABLE,
    'recurring' => READABLE_AUTO_RENEWABLE_SUBSCRIPTION,
    'subscription' => READABLE_NON_RENEWING_SUBSCRIPTION
  }

  mapping.each do |itc_type, readable_type|
    return readable_type if itc_type == text
  end

  return nil
end