pay
Native store purchasing and web payment
Install
npm install vigour-pay
Updates via upstream remote
git remote add skeleton git@github.com:vigour-io/plugin.git
git pull skeleton develop
Usage
See tests
Building native apps
See wrapper
Specs
Config
configuration for pay
should go in the app's package.json
Use of the Module
new Pay(settings)
var Pay = var pay =
when using templating for region specific product id's: set region
configregion
pay.buy(label, callback(err, response))
pay.buy(label, callback)
Will attempt to buy whatever product is configured as label
for the current platform. label
being single
, monthly
or yearly
when using the above config.
button
pay.products (Observable property)
pay.products
is a list of available products,
- based on the
config
+ platform - validated and completed by the native Plugin
e.g.
payproductsval = single: val: 'NL_single_purchase' owned: val: true receipt: hash: 'garblegarble' price: 099 monthly: val: 'NL_monthly_subscription' owned: true price: 499 yearly: val: 'NL_yearly_subscription' price: 1999
pay.products[label].owned
owned
is
- if owned
true
- could have
receipt
property when available
- if not owned
false
undefined
(property doesn't exist).
pay.products[label].price
Price is the number of pay.currency
one has to pay in order to buy product
.
pay.currency
The type of moneys the store wants to use.
paycurrencyval = val: '€' name: 'Euro'
Native Plugins
Methods
buy(productId, callback(error, response))
- buy the product with
productId
- when done, call callback passing
error
response
getProducts(callback(err, response))
Used to
- get products available for this app on this platform
In order to
- ensure products in
package.json
are actually available in the store - get
product.price
- get
product.owned
response
response should look like:
var response = productId1: price: 99901 owned: // check if the device's store account owns the product val: true receipt: 'RECEIPTFORPRODUCT' // platform specific info may go here productId2: price: 099