{"_id":"gracenode-iap","_rev":"31-77966c7d3240024871ce1e123266d879","name":"gracenode-iap","description":"In-App-Purchase module for gracenode framework.","dist-tags":{"latest":"0.1.9"},"versions":{"0.1.0":{"name":"gracenode-iap","description":"In-App-Purchase module for gracenode framework.","version":"0.1.0","author":{"name":"Nobuyori Takahashi","email":"voltrue2@yahoo.com"},"repository":{"type":"git","url":"https://github.com/voltrue2/gracenode-iap.git"},"dependencies":{"request":"2.36.0"},"devDependencies":{"mocha":"1.18.2"},"engine":"node >= 0.10.20","contributors":[],"keywords":["gracenode","in-app-purchase","apple","google","android","ios","purchase","validate","app"],"license":"MIT","bugs":{"url":"https://github.com/voltrue2/gracenode-iap/issues"},"_id":"gracenode-iap@0.1.0","dist":{"shasum":"96f4d16fb6a52dbf9a07c4c3020a41a226ce32dc","tarball":"https://registry.npmjs.org/gracenode-iap/-/gracenode-iap-0.1.0.tgz","integrity":"sha512-bYUSzbHEKwUE9s9TbzUU7ypG5+QSHB97diJG+0jPfS4k3AVkOc4NbYj6RdLdEBM3agX0PyriVSFh1SSKzEB9tA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCrVvdZo96U2MiYtIYfe+1yqSldrSAq0myZNOYtxCur8AIhANCWKVIkDhmLdpy0EuV5yKPXaLl4AkzghZuW2ashg2E3"}]},"_from":"/var/www/npm-repo/node_modules/gracenode-iap/","_npmVersion":"1.3.11","_npmUser":{"name":"voltrue2","email":"voltrue2@yahoo.com"},"maintainers":[{"name":"voltrue2","email":"voltrue2@yahoo.com"}]},"0.1.1":{"name":"gracenode-iap","description":"In-App-Purchase module for gracenode framework.","version":"0.1.1","author":{"name":"Nobuyori Takahashi","email":"voltrue2@yahoo.com"},"repository":{"type":"git","url":"https://github.com/voltrue2/gracenode-iap.git"},"dependencies":{"request":"2.36.0"},"devDependencies":{"mocha":"1.18.2"},"engine":"node >= 0.10.20","contributors":[],"keywords":["gracenode","in-app-purchase","apple","google","android","ios","purchase","validate","app"],"license":"MIT","bugs":{"url":"https://github.com/voltrue2/gracenode-iap/issues"},"_id":"gracenode-iap@0.1.1","dist":{"shasum":"8486dc55ba13e15ba6ebd5a6db724925b56fd338","tarball":"https://registry.npmjs.org/gracenode-iap/-/gracenode-iap-0.1.1.tgz","integrity":"sha512-nf9rGd85Tb3S3PAPQ5boAidvZheb5DDUaiNP8wuZj0A/qWajUvYmFme7xStL3AA8f/uAUI4wgmk5X8VslwsXfA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBHrxv2bHt013gialDYinMLZaVmIwZRPHELg550r53IIAiAxZ/klnPdEgkwCV/jlmtBDh12Z4r3x+7at/1Z3ne3+5g=="}]},"_from":"/var/www/npm-repo/node_modules/gracenode-iap/","_npmVersion":"1.3.11","_npmUser":{"name":"voltrue2","email":"voltrue2@yahoo.com"},"maintainers":[{"name":"voltrue2","email":"voltrue2@yahoo.com"}]},"0.1.3":{"name":"gracenode-iap","description":"In-App-Purchase module for gracenode framework.","version":"0.1.3","author":{"name":"Nobuyori Takahashi","email":"voltrue2@yahoo.com"},"repository":{"type":"git","url":"https://github.com/voltrue2/gracenode-iap.git"},"dependencies":{"request":"2.36.0"},"devDependencies":{"mocha":"1.18.2"},"engine":"node >= 0.10.20","contributors":[],"keywords":["gracenode","in-app-purchase","apple","google","android","ios","purchase","validate","app"],"license":"MIT","bugs":{"url":"https://github.com/voltrue2/gracenode-iap/issues"},"_id":"gracenode-iap@0.1.3","dist":{"shasum":"ede16c0a14e5003f776dd760c0fa5f813c85056d","tarball":"https://registry.npmjs.org/gracenode-iap/-/gracenode-iap-0.1.3.tgz","integrity":"sha512-CbdBM5QUH8if7x+txUjswF5QbXjawPweWVQ0Y7S3VJ6ULv05v4B2S6ZQ9f9eiLAnM5yuD3MSVkx3TCR6ftYCCA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDIMpHWseWftEO8h9l9XKWQLZmjLMjBn3muesfNGrSPrAIhANvtfmdw2ps8LFtFH0fS/FFPEhQAZ2Z+Web2NuN5YjSg"}]},"_from":"/var/www/npm-repo/node_modules/gracenode-iap/","_npmVersion":"1.3.11","_npmUser":{"name":"voltrue2","email":"voltrue2@yahoo.com"},"maintainers":[{"name":"voltrue2","email":"voltrue2@yahoo.com"}]},"0.1.4":{"name":"gracenode-iap","description":"In-App-Purchase module for gracenode framework.","version":"0.1.4","author":{"name":"Nobuyori Takahashi","email":"voltrue2@yahoo.com"},"repository":{"type":"git","url":"https://github.com/voltrue2/gracenode-iap.git"},"dependencies":{"request":"2.36.0"},"devDependencies":{"mocha":"1.18.2"},"engine":"node >= 0.10.20","contributors":[],"keywords":["gracenode","in-app-purchase","apple","google","android","ios","purchase","validate","app"],"license":"MIT","bugs":{"url":"https://github.com/voltrue2/gracenode-iap/issues"},"_id":"gracenode-iap@0.1.4","dist":{"shasum":"d15421f20aaf943a52cef2535eaaa2504af78235","tarball":"https://registry.npmjs.org/gracenode-iap/-/gracenode-iap-0.1.4.tgz","integrity":"sha512-FGnwvjtU32BcRENfaHOYPWaLWt7pMAGjzBKEruSUB5d0xIwXCxQD3EDcT+MfoWPUdiIFb0xU2BSGSUwjO5VT4w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAn0SNPR6r6W/y+F413Wq9vzXV8c4L4/kaKALi6DLFoBAiA8FKGZppH9P4zRhhz3E5bpz7AXCcHOBbOZMgKUu7zaGQ=="}]},"_from":"/var/www/npm-repo/node_modules/gracenode-iap/","_npmVersion":"1.3.11","_npmUser":{"name":"voltrue2","email":"voltrue2@yahoo.com"},"maintainers":[{"name":"voltrue2","email":"voltrue2@yahoo.com"}]},"0.1.5":{"name":"gracenode-iap","description":"In-App-Purchase module for gracenode framework.","version":"0.1.5","author":{"name":"Nobuyori Takahashi","email":"voltrue2@yahoo.com"},"repository":{"type":"git","url":"https://github.com/voltrue2/gracenode-iap.git"},"dependencies":{"request":"2.36.0"},"devDependencies":{"mocha":"1.18.2"},"engine":"node >= 0.10.20","contributors":[],"keywords":["gracenode","in-app-purchase","apple","google","android","ios","purchase","validate","app"],"license":"MIT","bugs":{"url":"https://github.com/voltrue2/gracenode-iap/issues"},"_id":"gracenode-iap@0.1.5","dist":{"shasum":"b6affccd23b57b3bf4669a630c2355c00a59b8f1","tarball":"https://registry.npmjs.org/gracenode-iap/-/gracenode-iap-0.1.5.tgz","integrity":"sha512-vD1ox0W1ma2TzNfIawXqfT4Rakuo2xfGmIaPu1B+Ec+asTDqlbw/8Kql41UQUo/1K4SUcjhNU+maL31HCypWBQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCq0vvJO0gfmNERZZPiYR1wx6G6nmBz7fsYs5P4EaPtjAIgLwetORHRbkcuWjAXMC0z63Vhrfb4s91vEdlHqur87S8="}]},"_from":"/var/www/npm-repo/node_modules/gracenode-iap/","_npmVersion":"1.3.11","_npmUser":{"name":"voltrue2","email":"voltrue2@yahoo.com"},"maintainers":[{"name":"voltrue2","email":"voltrue2@yahoo.com"}]},"0.1.8":{"name":"gracenode-iap","description":"In-App-Purchase module for gracenode framework.","version":"0.1.8","author":{"name":"Nobuyori Takahashi","email":"voltrue2@yahoo.com"},"repository":{"type":"git","url":"https://github.com/voltrue2/gracenode-iap.git"},"dependencies":{"request":"2.36.0"},"devDependencies":{"mocha":"1.18.2"},"engine":"node >= 0.10.20","contributors":[],"keywords":["gracenode","in-app-purchase","apple","google","android","ios","purchase","validate","app"],"license":"MIT","bugs":{"url":"https://github.com/voltrue2/gracenode-iap/issues"},"_id":"gracenode-iap@0.1.8","dist":{"shasum":"ff3e097224d5669b70fe30c0368756e70a1341e7","tarball":"https://registry.npmjs.org/gracenode-iap/-/gracenode-iap-0.1.8.tgz","integrity":"sha512-V4HC1Z6ZmPaVjlpmZZARP0KDNqn86zQPlFdKGZ0tCExtinlfSDzXal4IHxS50W4BwsdFBLiy+IGirBMlNG2pQQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDJTcFDXBiNDgMYt+c7yxAfNRtYhRUqsk0FAZZnwofQ7QIhAIzDcsmyI8Y9CyHO0UZftQAVIJGWY0ntysdZ1+TPsjVJ"}]},"_from":"/var/www/npm-repo/node_modules/gracenode-iap/","_npmVersion":"1.3.11","_npmUser":{"name":"voltrue2","email":"voltrue2@yahoo.com"},"maintainers":[{"name":"voltrue2","email":"voltrue2@yahoo.com"}]},"0.1.9":{"name":"gracenode-iap","description":"In-App-Purchase module for gracenode framework.","version":"0.1.9","author":{"name":"Nobuyori Takahashi","email":"voltrue2@yahoo.com"},"repository":{"type":"git","url":"https://github.com/voltrue2/gracenode-iap.git"},"dependencies":{"async":"0.9.0","request":"2.36.0"},"devDependencies":{"mocha":"1.18.2"},"engine":"node >= 0.10.20","contributors":[],"keywords":["gracenode","in-app-purchase","apple","google","android","ios","purchase","validate","app"],"license":"MIT","bugs":{"url":"https://github.com/voltrue2/gracenode-iap/issues"},"_id":"gracenode-iap@0.1.9","dist":{"shasum":"5fcb455f5f272300f8c9084d3fcc9a618fbd40f4","tarball":"https://registry.npmjs.org/gracenode-iap/-/gracenode-iap-0.1.9.tgz","integrity":"sha512-aYZnd/fAku8e2X8xe3N6N+qgM9MsvS+8LkLh1vLSFSfCKT4369RjTwQt63qCx5XWPz+oTQrnFHENuAgM1zH/3g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDwYKX+9Zp82MHze6QwCYWjBZPg/s9a1984TbZfjQXFYQIgA3VvbNECfMWaB/lE9rSZi4VGeYCetO6xusPDGqnAb6M="}]},"_from":"/var/www/npm-repo/node_modules/gracenode-iap/","_npmVersion":"1.3.11","_npmUser":{"name":"voltrue2","email":"voltrue2@yahoo.com"},"maintainers":[{"name":"voltrue2","email":"voltrue2@yahoo.com"}]}},"readme":"# gracenode-iap Module (in-app-purchase)\n\nIn-App-Purchase module for gracenode framework.\n\nThis is designed to function within gracenode framework.\n\n### Requirements\n\nIn order for gracenode-iap module to work properly, you need to add gracenode-mysql module to your application.\n\n#### Before you start using gracenode-iap\n\ngracenode-iap module uses mysql database to store validation data, you will need to create the required table for the module.\n\nTo create the required mysql table, you will need to execute the following SQL queries:\n\n`gracenode-iap/schema.sql`\n\nIf you need to execute the queries from Node.js application, you may do:\n\n```\nvar gracenode = require('gracenode');\ngracenode.setConfigPath('path/to/your/config/dir/');\ngracenode.setConfigFiles(['yourConfig.json']);\ngracenode.use('gracenode-mysql');\ngracenode.use('gracenode-iap');\ngracenode.setup(function (error) {\n\tif (error) {\n\t\treturn console.error(error);\n\t}\n\tgracenode.getModuleSchema('gracenode-iap', function (error, sqlList) {\n\t\tif (error) {\n\t\t\t// hmm error\n\t\t}\n\t\t// execute the SQL queries in sqlList array here\n\t});\n});\n```\n\n## How to include it in my project\n\nTo add this package as your gracenode module, add the following to your package.json:\n\n```\n\"dependencies\": {\n\t\"gracenode\": \"\",\n\t\"gracenode-mysql\": \"\",\n\t\"gracenode-iap\": \"\"\n}\n```\n\nTo use this module in your application, add the following to your gracenode bootstrap code:\n\n```\nvar gracenode = require('gracenode');\n// this tells gracenode to load the module\n// make sure you load gracenode-mysql module BEFORE gracenode-iap module\ngracenode.use('gracenode-mysql');\ngracenode.use('gracenode-iap');\n```\n\nTo access the module:\n\n```\n// the prefix gracenode- will be removed automatically\ngracenode.iap\n```\n\n## Configurations\n```javascript\n\"modules\": {\n        \"gracenode-iap\": {\n                \"sql\": \"mysql module configuration name\",\n                \"googlePublicKeyPath\": \"path to google play public key files\" // the file names MUST be specific (for live: iap-live, for sandbox: iap-sandbox)\n        }\n}\n```\n\n## Production and Sandbox\n\n### Apple\n\ngracenode-iap module automatically detects the target environments and sends the validation requests to the right end point.\n\nInternally it sends validation to Apple in-app-purchase production server, and when it receives status `21007`, it will then retry sandbox.\n\n### Google\n\ngracenode-iap module automatically tries to validate each purchase with production key first and falls back to sandbox.\n\n###API: validateApplePurchase\n\n<pre>\nvoid validateApplePurchase(String receipt, Function cb)\n</pre>\n\nSends an HTTPS request to Apple to validate the given receipt and responds back an object { validateState: 'validated' or 'error', status: 'pending' or 'handled' or 'canceled' }\n\n###API: validateGooglePurchase\n\n<pre>\nvoid validateGooglePurchase(Object receipt, Function cb)\n</pre>\n\nValidates the receipt with public key using open SSL\n\n###API: isValidated\n\n<pre>\nbool isValidated(Object validationResponse)\n</pre>\n\nReturns true if the response of the purchase validation is validated.\n\n```javascript\ngracenode.iap.validateApplePurchase(receipt, function (error, response) {\n        if (error) {\n                // handle error here\n        }\n\n        // check the validated state\n        if (gracenode.iap.isValidated(response)) {\n\t\t// purchase has been validated\n\t}\n});\n```\n\n###API: updateStatus\n\n<pre>\nvoid updateStatus(Mixed receipt, String status, Function cb)\n</pre>\n> Updates the status of the given receipt. the valid status are: pending, handled, canceled.\n\nExample:\n```javascript\n// example code with iap module\ngracenode.iap.validateApplePurchase(receipt, function (error, response) {\n        if (error) {\n                // handle error here\n        }\n\n        // check the validated state\n        if (gracenode.iap.isValidated(response)) {\n                // Apple has validated the purchase\n\n                var hc = gracenode.wallet.create('hc');\n                hc.addPaid(receipt, userId, itemPrice, itemValue,\n\n                        // this callback will be called BEFORE the commit of \"addPaid\"\n                        function (continueCallback) {\n\n                                // update iap status to mark the receipt as \"handled\"\n                                gracenode.iap.updateStatus(receipt, 'handled', function (error) {\n                                        if (error) {\n                                                // error on updating the status to \"handled\"\n                                                return continueCallback(error); // this will make \"addPaid\" to auto-rollback\n                                        }\n\n                                        // iap receipt status updated to \"handled\" now commit\n                                        continueCallback();\n\n                                })\n\n                        },\n\n                        // this callback is to finalize \"addPaid\" transaction\n                        function (error) {\n                                if (error) {\n                                        // error on finalizing the transaction\n                                }\n\n                                // we are done!\n                        }\n\n                );\n\n        }\n\n});\n```\n","maintainers":[{"name":"voltrue2","email":"voltrue2@yahoo.com"}],"time":{"modified":"2022-06-18T13:46:01.814Z","created":"2014-05-22T05:31:31.011Z","0.1.0":"2014-05-22T05:31:32.275Z","0.1.1":"2014-05-23T00:45:50.832Z","0.1.3":"2014-05-26T04:53:33.589Z","0.1.4":"2014-05-30T02:02:48.398Z","0.1.5":"2014-05-31T02:36:58.054Z","0.1.8":"2014-07-04T18:38:46.649Z","0.1.9":"2014-07-06T09:42:22.840Z"},"readmeFilename":"README.md","keywords":["gracenode","in-app-purchase","apple","google","android","ios","purchase","validate","app"],"repository":{"type":"git","url":"https://github.com/voltrue2/gracenode-iap.git"},"contributors":[],"author":{"name":"Nobuyori Takahashi","email":"voltrue2@yahoo.com"},"bugs":{"url":"https://github.com/voltrue2/gracenode-iap/issues"},"license":"MIT"}