diff --git a/.gitignore b/.gitignore
index a32d29f..b9c960c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,5 @@ Thumbs.db
*.pyc
.project
.cproject
-builtins
\ No newline at end of file
+builtins
+_site
diff --git a/README.md b/README.md
index d5c9d85..1f94cd0 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,11 @@
-# extension-iap
-In-app purchase extension for Defold
+# In-app purchase extension for Defold
+
+This is a Defold [native extension](https://www.defold.com/manuals/extensions/) which provides access to In-app purchase functionality on iOS, Android (Google Play and Amazon) and Facebook Canvas platforms.
+
+To learn more please visit the [documentation page](https://defold.github.io/extension-iap/) for this extension.
+
+[The manual](https://defold.com/manuals/iap/) is available on the official Defold site.
+
+---
+
+If you have any issues, questions or suggestions please [create an issue](https://github.com/defold/extension-iap/issues).
diff --git a/docs/Gemfile b/docs/Gemfile
new file mode 100644
index 0000000..37f5eaa
--- /dev/null
+++ b/docs/Gemfile
@@ -0,0 +1,2 @@
+source 'https://rubygems.org'
+gem 'github-pages', group: :jekyll_plugins
diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock
new file mode 100644
index 0000000..8351a0e
--- /dev/null
+++ b/docs/Gemfile.lock
@@ -0,0 +1,248 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ activesupport (4.2.11.1)
+ i18n (~> 0.7)
+ minitest (~> 5.1)
+ thread_safe (~> 0.3, >= 0.3.4)
+ tzinfo (~> 1.1)
+ addressable (2.6.0)
+ public_suffix (>= 2.0.2, < 4.0)
+ coffee-script (2.4.1)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.11.1)
+ colorator (1.1.0)
+ commonmarker (0.17.13)
+ ruby-enum (~> 0.5)
+ concurrent-ruby (1.1.5)
+ dnsruby (1.61.2)
+ addressable (~> 2.5)
+ em-websocket (0.5.1)
+ eventmachine (>= 0.12.9)
+ http_parser.rb (~> 0.6.0)
+ ethon (0.12.0)
+ ffi (>= 1.3.0)
+ eventmachine (1.2.7)
+ execjs (2.7.0)
+ faraday (0.15.4)
+ multipart-post (>= 1.2, < 3)
+ ffi (1.11.1)
+ forwardable-extended (2.6.0)
+ gemoji (3.0.1)
+ github-pages (198)
+ activesupport (= 4.2.11.1)
+ github-pages-health-check (= 1.16.1)
+ jekyll (= 3.8.5)
+ jekyll-avatar (= 0.6.0)
+ jekyll-coffeescript (= 1.1.1)
+ jekyll-commonmark-ghpages (= 0.1.5)
+ jekyll-default-layout (= 0.1.4)
+ jekyll-feed (= 0.11.0)
+ jekyll-gist (= 1.5.0)
+ jekyll-github-metadata (= 2.12.1)
+ jekyll-mentions (= 1.4.1)
+ jekyll-optional-front-matter (= 0.3.0)
+ jekyll-paginate (= 1.1.0)
+ jekyll-readme-index (= 0.2.0)
+ jekyll-redirect-from (= 0.14.0)
+ jekyll-relative-links (= 0.6.0)
+ jekyll-remote-theme (= 0.3.1)
+ jekyll-sass-converter (= 1.5.2)
+ jekyll-seo-tag (= 2.5.0)
+ jekyll-sitemap (= 1.2.0)
+ jekyll-swiss (= 0.4.0)
+ jekyll-theme-architect (= 0.1.1)
+ jekyll-theme-cayman (= 0.1.1)
+ jekyll-theme-dinky (= 0.1.1)
+ jekyll-theme-hacker (= 0.1.1)
+ jekyll-theme-leap-day (= 0.1.1)
+ jekyll-theme-merlot (= 0.1.1)
+ jekyll-theme-midnight (= 0.1.1)
+ jekyll-theme-minimal (= 0.1.1)
+ jekyll-theme-modernist (= 0.1.1)
+ jekyll-theme-primer (= 0.5.3)
+ jekyll-theme-slate (= 0.1.1)
+ jekyll-theme-tactile (= 0.1.1)
+ jekyll-theme-time-machine (= 0.1.1)
+ jekyll-titles-from-headings (= 0.5.1)
+ jemoji (= 0.10.2)
+ kramdown (= 1.17.0)
+ liquid (= 4.0.0)
+ listen (= 3.1.5)
+ mercenary (~> 0.3)
+ minima (= 2.5.0)
+ nokogiri (>= 1.8.5, < 2.0)
+ rouge (= 2.2.1)
+ terminal-table (~> 1.4)
+ github-pages-health-check (1.16.1)
+ addressable (~> 2.3)
+ dnsruby (~> 1.60)
+ octokit (~> 4.0)
+ public_suffix (~> 3.0)
+ typhoeus (~> 1.3)
+ html-pipeline (2.11.1)
+ activesupport (>= 2)
+ nokogiri (>= 1.4)
+ http_parser.rb (0.6.0)
+ i18n (0.9.5)
+ concurrent-ruby (~> 1.0)
+ jekyll (3.8.5)
+ addressable (~> 2.4)
+ colorator (~> 1.0)
+ em-websocket (~> 0.5)
+ i18n (~> 0.7)
+ jekyll-sass-converter (~> 1.0)
+ jekyll-watch (~> 2.0)
+ kramdown (~> 1.14)
+ liquid (~> 4.0)
+ mercenary (~> 0.3.3)
+ pathutil (~> 0.9)
+ rouge (>= 1.7, < 4)
+ safe_yaml (~> 1.0)
+ jekyll-avatar (0.6.0)
+ jekyll (~> 3.0)
+ jekyll-coffeescript (1.1.1)
+ coffee-script (~> 2.2)
+ coffee-script-source (~> 1.11.1)
+ jekyll-commonmark (1.3.1)
+ commonmarker (~> 0.14)
+ jekyll (>= 3.7, < 5.0)
+ jekyll-commonmark-ghpages (0.1.5)
+ commonmarker (~> 0.17.6)
+ jekyll-commonmark (~> 1)
+ rouge (~> 2)
+ jekyll-default-layout (0.1.4)
+ jekyll (~> 3.0)
+ jekyll-feed (0.11.0)
+ jekyll (~> 3.3)
+ jekyll-gist (1.5.0)
+ octokit (~> 4.2)
+ jekyll-github-metadata (2.12.1)
+ jekyll (~> 3.4)
+ octokit (~> 4.0, != 4.4.0)
+ jekyll-mentions (1.4.1)
+ html-pipeline (~> 2.3)
+ jekyll (~> 3.0)
+ jekyll-optional-front-matter (0.3.0)
+ jekyll (~> 3.0)
+ jekyll-paginate (1.1.0)
+ jekyll-readme-index (0.2.0)
+ jekyll (~> 3.0)
+ jekyll-redirect-from (0.14.0)
+ jekyll (~> 3.3)
+ jekyll-relative-links (0.6.0)
+ jekyll (~> 3.3)
+ jekyll-remote-theme (0.3.1)
+ jekyll (~> 3.5)
+ rubyzip (>= 1.2.1, < 3.0)
+ jekyll-sass-converter (1.5.2)
+ sass (~> 3.4)
+ jekyll-seo-tag (2.5.0)
+ jekyll (~> 3.3)
+ jekyll-sitemap (1.2.0)
+ jekyll (~> 3.3)
+ jekyll-swiss (0.4.0)
+ jekyll-theme-architect (0.1.1)
+ jekyll (~> 3.5)
+ jekyll-seo-tag (~> 2.0)
+ jekyll-theme-cayman (0.1.1)
+ jekyll (~> 3.5)
+ jekyll-seo-tag (~> 2.0)
+ jekyll-theme-dinky (0.1.1)
+ jekyll (~> 3.5)
+ jekyll-seo-tag (~> 2.0)
+ jekyll-theme-hacker (0.1.1)
+ jekyll (~> 3.5)
+ jekyll-seo-tag (~> 2.0)
+ jekyll-theme-leap-day (0.1.1)
+ jekyll (~> 3.5)
+ jekyll-seo-tag (~> 2.0)
+ jekyll-theme-merlot (0.1.1)
+ jekyll (~> 3.5)
+ jekyll-seo-tag (~> 2.0)
+ jekyll-theme-midnight (0.1.1)
+ jekyll (~> 3.5)
+ jekyll-seo-tag (~> 2.0)
+ jekyll-theme-minimal (0.1.1)
+ jekyll (~> 3.5)
+ jekyll-seo-tag (~> 2.0)
+ jekyll-theme-modernist (0.1.1)
+ jekyll (~> 3.5)
+ jekyll-seo-tag (~> 2.0)
+ jekyll-theme-primer (0.5.3)
+ jekyll (~> 3.5)
+ jekyll-github-metadata (~> 2.9)
+ jekyll-seo-tag (~> 2.0)
+ jekyll-theme-slate (0.1.1)
+ jekyll (~> 3.5)
+ jekyll-seo-tag (~> 2.0)
+ jekyll-theme-tactile (0.1.1)
+ jekyll (~> 3.5)
+ jekyll-seo-tag (~> 2.0)
+ jekyll-theme-time-machine (0.1.1)
+ jekyll (~> 3.5)
+ jekyll-seo-tag (~> 2.0)
+ jekyll-titles-from-headings (0.5.1)
+ jekyll (~> 3.3)
+ jekyll-watch (2.2.1)
+ listen (~> 3.0)
+ jemoji (0.10.2)
+ gemoji (~> 3.0)
+ html-pipeline (~> 2.2)
+ jekyll (~> 3.0)
+ kramdown (1.17.0)
+ liquid (4.0.0)
+ listen (3.1.5)
+ rb-fsevent (~> 0.9, >= 0.9.4)
+ rb-inotify (~> 0.9, >= 0.9.7)
+ ruby_dep (~> 1.2)
+ mercenary (0.3.6)
+ mini_portile2 (2.4.0)
+ minima (2.5.0)
+ jekyll (~> 3.5)
+ jekyll-feed (~> 0.9)
+ jekyll-seo-tag (~> 2.1)
+ minitest (5.11.3)
+ multipart-post (2.1.1)
+ nokogiri (1.10.3)
+ mini_portile2 (~> 2.4.0)
+ octokit (4.14.0)
+ sawyer (~> 0.8.0, >= 0.5.3)
+ pathutil (0.16.2)
+ forwardable-extended (~> 2.6)
+ public_suffix (3.1.1)
+ rb-fsevent (0.10.3)
+ rb-inotify (0.10.0)
+ ffi (~> 1.0)
+ rouge (2.2.1)
+ ruby-enum (0.7.2)
+ i18n
+ ruby_dep (1.5.0)
+ rubyzip (1.2.3)
+ safe_yaml (1.0.5)
+ sass (3.7.4)
+ sass-listen (~> 4.0.0)
+ sass-listen (4.0.0)
+ rb-fsevent (~> 0.9, >= 0.9.4)
+ rb-inotify (~> 0.9, >= 0.9.7)
+ sawyer (0.8.2)
+ addressable (>= 2.3.5)
+ faraday (> 0.8, < 2.0)
+ terminal-table (1.8.0)
+ unicode-display_width (~> 1.1, >= 1.1.1)
+ thread_safe (0.3.6)
+ typhoeus (1.3.1)
+ ethon (>= 0.9.0)
+ tzinfo (1.2.5)
+ thread_safe (~> 0.1)
+ unicode-display_width (1.6.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ github-pages
+
+BUNDLED WITH
+ 2.0.2
diff --git a/docs/_config.yml b/docs/_config.yml
new file mode 100644
index 0000000..2ca3fd3
--- /dev/null
+++ b/docs/_config.yml
@@ -0,0 +1 @@
+title: "extension-iap"
diff --git a/docs/_data/api.yml b/docs/_data/api.yml
new file mode 100644
index 0000000..1a02b47
--- /dev/null
+++ b/docs/_data/api.yml
@@ -0,0 +1,299 @@
+- name: iap
+ type: table
+ desc: Functions and constants for doing in-app purchases. Supported on iOS, Android (Google Play and Amazon)
+ and Facebook Canvas platforms.
+ [icon:ios] [icon:googleplay] [icon:amazon] [icon:facebook]
+ members:
+
+#*****************************************************************************************************
+
+ - name: buy
+ type: function
+ desc: Sets the listener function for inter-app communication events.
+ parameters:
+ - name: id
+ type: string
+ desc: product to buy
+
+ - name: options
+ type: table
+ desc: optional parameters as properties. The following parameters can be set
+ members:
+ - name: request_id
+ type: string
+ desc: Facebook only. [icon:facebook] Optional custom unique request id to
+ set for this transaction. The id becomes attached to the payment within the Graph API.
+
+ examples:
+ - desc: |-
+ ```lua
+ local function iap_listener(self, transaction, error)
+ if error == nil then
+ -- purchase is successful.
+ print(transaction.date)
+ -- required if auto finish transactions is disabled in project settings
+ if (transaction.state == iap.TRANS_STATE_PURCHASED) then
+ -- do server-side verification of purchase here..
+ iap.finish(transaction)
+ end
+ else
+ print(error.error, error.reason)
+ end
+ end
+
+ function init(self)
+ iap.set_listener(iap_listener)
+ iap.buy("my_iap")
+ end
+ ```
+
+#*****************************************************************************************************
+
+ - name: finish
+ type: function
+ desc: Explicitly finish a product transaction.
+ [icon:attention] Calling iap.finish is required on a successful transaction
+ if `auto_finish_transactions` is disabled in project settings. Calling this function
+ with `auto_finish_transactions` set will be ignored and a warning is printed.
+ The `transaction.state` field must equal `iap.TRANS_STATE_PURCHASED`.
+ parameters:
+ - name: transaction
+ type: table
+ desc: transaction table parameter as supplied in listener callback
+
+#*****************************************************************************************************
+
+ - name: get_provider_id
+ type: function
+ desc: Get current iap provider
+ returns:
+ - name: provider_id
+ type: constant
+ desc: one of the following values
+
+ - `iap.PROVIDER_ID_GOOGLE`
+
+ - `iap.PROVIDER_ID_AMAZON`
+
+ - `iap.PROVIDER_ID_APPLE`
+
+ - `iap.PROVIDER_ID_FACEBOOK`
+
+#*****************************************************************************************************
+
+ - name: list
+ type: function
+ desc: Get a list of all avaliable iap products.
+ parameters:
+ - name: ids
+ type: table
+ desc: table (array) of identifiers to get products from
+
+ - name: callback
+ type: function
+ desc: result callback taking the following parameters
+ parameters:
+ - name: self
+ type: object
+ desc: The current object.
+
+ - name: products
+ type: table
+ desc: a table describing the available iap products.
+ members:
+ - name: ident
+ type: string
+ desc: The product identifier.
+
+ - name: title
+ type: string
+ desc: The product title.
+
+ - name: description
+ type: string
+ desc: The product description.
+
+ - name: price
+ type: number
+ desc: The price of the product.
+
+ - name: price_string
+ type: string
+ desc: The price of the product, as a formatted string (amount and currency symbol).
+
+ - name: currency_code
+ type: string
+ desc: The currency code. On Google Play, this reflects the merchant's locale, instead of the user's.
+ [icon:ios] [icon:googleplay] [icon:facebook]
+
+ - name: error
+ type: table
+ desc: a table containing error information. `nil` if there is no error. - `error` (the error message)
+
+ examples:
+ - desc: |-
+ ```lua
+ local function iap_callback(self, products, error)
+ if error == nil then
+ for k,p in pairs(products) do
+ -- present the product
+ print(p.title)
+ print(p.description)
+ end
+ else
+ print(error.error)
+ end
+ end
+
+ function init(self)
+ iap.list({"my_iap"}, iap_callback)
+ end
+ ```
+
+#*****************************************************************************************************
+
+ - name: restore
+ type: function
+ desc: Restore previously purchased products.
+ returns:
+ - name: success
+ type: boolean
+ desc: value is `true` if current store supports handling
+ restored transactions, otherwise `false`.
+
+#*****************************************************************************************************
+
+ - name: set_listener
+ type: function
+ desc: Set the callback function to receive purchase transaction events.
+ parameters:
+ - name: listener
+ type: function
+ desc: listener callback function. Pass an empty function if you no longer wish to receive callbacks.
+ parameters:
+ - name: self
+ type: object
+ desc: The current object.
+
+ - name: transaction
+ type: table
+ desc: a table describing the transaction.
+ members:
+ - name: ident
+ type: string
+ desc: The product identifier.
+
+ - name: state
+ type: string
+ desc: The transaction state. One of the following
+
+ - `iap.TRANS_STATE_FAILED`
+
+ - `iap.TRANS_STATE_PURCHASED`
+
+ - `iap.TRANS_STATE_PURCHASING`
+
+ - `iap.TRANS_STATE_RESTORED`
+
+ - `iap.TRANS_STATE_UNVERIFIED`
+
+ - name: date
+ type: string
+ desc: The date and time for the transaction.
+
+ - name: trans_ident
+ type: string
+ desc: The transaction identifier. This field is only set when `state` is
+ `TRANS_STATE_RESTORED`, `TRANS_STATE_UNVERIFIED` or `TRANS_STATE_PURCHASED`.
+
+ - name: receipt
+ type: string
+ desc: The transaction receipt. This field is only set when `state` is `TRANS_STATE_PURCHASED` or `TRANS_STATE_UNVERIFIED`.
+
+ - name: original_trans
+ type: string
+ desc: Apple only[icon:apple]. The original transaction. This field is only set when `state` is `TRANS_STATE_RESTORED`.
+
+ - name: signature
+ type: string
+ desc: Google Play only[icon:googleplay]. A string containing the signature of the purchase data that was signed with the private key of the developer.
+
+ - name: request_id
+ type: string
+ desc: Facebook only[icon:facebook]. This field is set to the optional custom unique request id `request_id` if set in the `iap.buy()` call parameters.
+
+ - name: user_id
+ type: string
+ desc: Amazon Pay only[icon:amazon]. The user ID.
+
+ - name: is_sandbox_mode
+ type: boolean
+ desc: Amazon Pay only[icon:amazon]. If `true`, the SDK is running in Sandbox mode.
+ This only allows interactions with the Amazon AppTester. Use this mode only for testing locally.
+
+ - name: cancel_date
+ type: string
+ desc: Amazon Pay only[icon:amazon]. The cancel date for the purchase. This field is only set if the purchase is canceled.
+
+ - name: canceled
+ type: string
+ desc: Amazon Pay only[icon:amazon]. Is set to `true` if the receipt was canceled or has expired; otherwise `false`.
+
+ - name: error
+ type: table
+ desc: a table containing error information. `nil` if there is no error. `error` - the error message.
+ `reason` - the reason for the error, value can be one of the following constants
+
+ - `iap.REASON_UNSPECIFIED`
+
+ - `iap.REASON_USER_CANCELED`
+
+#*****************************************************************************************************
+
+ - name: PROVIDER_ID_AMAZON
+ type: number
+ desc: provider id for Amazon
+
+ - name: PROVIDER_ID_APPLE
+ type: number
+ desc: provider id for Apple
+
+ - name: PROVIDER_ID_FACEBOOK
+ type: number
+ desc: provider id for Facebook
+
+ - name: PROVIDER_ID_GOOGLE
+ type: number
+ desc: iap provider id for Google
+
+ - name: REASON_UNSPECIFIED
+ type: number
+ desc: unspecified error reason
+
+ - name: REASON_USER_CANCELED
+ type: number
+ desc: user canceled reason
+
+ - name: TRANS_STATE_FAILED
+ type: number
+ desc: transaction failed state
+
+ - name: TRANS_STATE_PURCHASED
+ type: number
+ desc: transaction purchased state
+
+ - name: TRANS_STATE_PURCHASING
+ type: number
+ desc: transaction purchasing state
+ This is an intermediate mode followed by TRANS_STATE_PURCHASED. Store provider support dependent.
+
+ - name: TRANS_STATE_RESTORED
+ type: number
+ desc: transaction restored state
+ This is only available on store providers supporting restoring purchases.
+
+ - name: TRANS_STATE_UNVERIFIED
+ type: number
+ desc: transaction unverified state, requires verification of purchase
+
+
\ No newline at end of file
diff --git a/docs/_includes/description.md b/docs/_includes/description.md
new file mode 100644
index 0000000..bf81741
--- /dev/null
+++ b/docs/_includes/description.md
@@ -0,0 +1,38 @@
+{% assign truncate = 10000 %}
+{% if include.truncate %}
+ {% assign truncate = include.truncate %}
+{% endif %}
+{{ include.desc
+ | truncate: truncate
+ | replace: "[type:string]","string
"
+ | replace: "[type:number]","number
"
+ | replace: "[type:table]","table
"
+ | replace: "[icon:attention]","
"
+ | replace: "[icon:android]", ""
+ | replace: "[icon:gameroom]", ""
+ | replace: "[icon:apple]", ""
+ | replace: "[icon:clipboard]", ""
+ | replace: "[icon:king]", ""
+ | replace: "[icon:defold]", ""
+ | replace: "[icon:search]", ""
+ | replace: "[icon:link-ext]", ""
+ | replace: "[icon:link]", ""
+ | replace: "[icon:amazon]", ""
+ | replace: "[icon:html5]", ""
+ | replace: "[icon:ios]", ""
+ | replace: "[icon:linux]", ""
+ | replace: "[icon:windows]", ""
+ | replace: "[icon:macos]", ""
+ | replace: "[icon:clock]", ""
+ | replace: "[icon:star]", ""
+ | replace: "[icon:googleplay]", ""
+ | replace: "[icon:dropbox]", ""
+ | replace: "[icon:twitter]", ""
+ | replace: "[icon:slack]", ""
+ | replace: "[icon:instagram]", ""
+ | replace: "[icon:steam]", ""
+ | replace: "[icon:github]", ""
+ | replace: "[icon:facebook]", ""
+
+ | markdownify
+}}
\ No newline at end of file
diff --git a/docs/_includes/type-function.md b/docs/_includes/type-function.md
new file mode 100644
index 0000000..afc51be
--- /dev/null
+++ b/docs/_includes/type-function.md
@@ -0,0 +1,23 @@
+
Parameter | +Type | +Description | +
---|---|---|
{{ param.name }} | +{{ param.type }} |
+ {% include description.md desc=param.desc %} + + {% if param.type == "table" %} + {% include type-table.md fields=param.members %} + {% endif %} + | +
{{ field.type }}
- {% include description.md desc=field.desc %}
+Functions and constants for doing in-app purchase. Supported on iOS, Android (Google Play and Amazon) and Facebook Canvas.
+ +To use this library in your Defold project, add the following URL to your game.project
dependencies:
+
https://github.com/defold/extension-iap/archive/master.zip+ + +
We recommend using a link to a zip
file of a specific release.
The source code can be viewed at: https://github.com/defold/extension-iap
+ +{{ item.name }}
+{% include description.md desc=item.desc %}
+{% endfor %}
+
+{{ module.name }}.{{ item.name }} | +{{ item.desc | markdownify | replace: "[icon:attention]"," ⚠️"}} |
+
{{ module.name }}.{{ item.name }}() | +{% include description.md desc=item.desc %} | +
{{ module.name }}.{{ function.name }}({% for param in function.parameters %}{{param.name}}{% unless forloop.last %}, {% endunless %}{% endfor %})
Parameter | +Type | +Description | +
---|---|---|
+ {{ param.name }} + {% if param.optional %} + (optional) + {% endif %} + | +{{ param.type }} |
+ {% include description.md desc=param.desc %} + {% if param.type == "function" %} + {% include type-function.md params=param.parameters %} + {% endif %} + {% if param.type == "table" %} + {% include type-table.md fields=param.members %} + {% endif %} + | +
Return value | +Type | +Description | +
---|---|---|
{{ return.name }} | +{{ return.type }} |
+ {% include description.md desc=return.desc %} + {% if return.type == "table" %} + {% include type-table.md fields=return.members %} + {% endif %} + | +